Fix IP addresses being truncated in tab titles when using 'short host' format.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=670841
This commit is contained in:
Robert Knight
2007-06-02 17:03:02 +00:00
parent 5cf10be66f
commit a712ccb7b4

View File

@@ -20,6 +20,11 @@
// Own
#include "ProcessInfo.h"
// Unix
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
// Qt
#include <QtCore/QDebug>
#include <QtCore/QFile>
@@ -468,16 +473,30 @@ QString SSHProcessInfo::command() const
QString SSHProcessInfo::format(const QString& input) const
{
QString output(input);
// test whether host is an ip address
// in which case 'short host' and 'full host'
// markers in the input string are replaced with
// the full address
bool isIpAddress = false;
struct in_addr address;
if ( inet_aton(_host.toLocal8Bit().constData(),&address) != 0 )
isIpAddress = true;
else
isIpAddress = false;
// search for and replace known markers
output.replace("%u",_user);
output.replace("%h",_host.left(_host.indexOf('.')));
if ( isIpAddress )
output.replace("%h",_host);
else
output.replace("%h",_host.left(_host.indexOf('.')));
output.replace("%H",_host);
output.replace("%c",_command);
// remove any remaining %[LETTER] character sequences
// output.replace(QRegExp("%\\w"),QString::null);
return output;
}