mirror of
https://github.com/KDE/konsole.git
synced 2026-05-03 20:26:45 -04:00
Convert tabs to 4 spaces to match kdelibs conventions. Previously
there was a mix of tabs and spaces for indentation. CCMAIL:Stefan.Becker@nokia.com svn path=/trunk/KDE/kdebase/apps/konsole/; revision=863326
This commit is contained in:
@@ -124,53 +124,53 @@ QString ShellCommand::expand(const QString& text)
|
||||
*/
|
||||
static bool expandEnv( QString &text )
|
||||
{
|
||||
// Find all environment variables beginning with '$'
|
||||
//
|
||||
int pos = 0;
|
||||
// Find all environment variables beginning with '$'
|
||||
//
|
||||
int pos = 0;
|
||||
|
||||
bool expanded = false;
|
||||
bool expanded = false;
|
||||
|
||||
while ( (pos = text.indexOf(QLatin1Char('$'), pos)) != -1 ) {
|
||||
while ( (pos = text.indexOf(QLatin1Char('$'), pos)) != -1 ) {
|
||||
|
||||
// Skip escaped '$'
|
||||
//
|
||||
if ( pos > 0 && text.at(pos-1) == QLatin1Char('\\') ) {
|
||||
pos++;
|
||||
}
|
||||
// Variable found => expand
|
||||
//
|
||||
else {
|
||||
// Find the end of the variable = next '/' or ' '
|
||||
//
|
||||
int pos2 = text.indexOf( QLatin1Char(' '), pos+1 );
|
||||
int pos_tmp = text.indexOf( QLatin1Char('/'), pos+1 );
|
||||
// Skip escaped '$'
|
||||
//
|
||||
if ( pos > 0 && text.at(pos-1) == QLatin1Char('\\') ) {
|
||||
pos++;
|
||||
}
|
||||
// Variable found => expand
|
||||
//
|
||||
else {
|
||||
// Find the end of the variable = next '/' or ' '
|
||||
//
|
||||
int pos2 = text.indexOf( QLatin1Char(' '), pos+1 );
|
||||
int pos_tmp = text.indexOf( QLatin1Char('/'), pos+1 );
|
||||
|
||||
if ( pos2 == -1 || (pos_tmp != -1 && pos_tmp < pos2) )
|
||||
pos2 = pos_tmp;
|
||||
if ( pos2 == -1 || (pos_tmp != -1 && pos_tmp < pos2) )
|
||||
pos2 = pos_tmp;
|
||||
|
||||
if ( pos2 == -1 )
|
||||
pos2 = text.length();
|
||||
if ( pos2 == -1 )
|
||||
pos2 = text.length();
|
||||
|
||||
// Replace if the variable is terminated by '/' or ' '
|
||||
// and defined
|
||||
//
|
||||
if ( pos2 >= 0 ) {
|
||||
int len = pos2 - pos;
|
||||
QString key = text.mid( pos+1, len-1);
|
||||
QString value =
|
||||
QString::fromLocal8Bit( qgetenv(key.toLocal8Bit()) );
|
||||
// Replace if the variable is terminated by '/' or ' '
|
||||
// and defined
|
||||
//
|
||||
if ( pos2 >= 0 ) {
|
||||
int len = pos2 - pos;
|
||||
QString key = text.mid( pos+1, len-1);
|
||||
QString value =
|
||||
QString::fromLocal8Bit( qgetenv(key.toLocal8Bit()) );
|
||||
|
||||
if ( !value.isEmpty() ) {
|
||||
expanded = true;
|
||||
text.replace( pos, len, value );
|
||||
pos = pos + value.length();
|
||||
}
|
||||
else {
|
||||
pos = pos2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !value.isEmpty() ) {
|
||||
expanded = true;
|
||||
text.replace( pos, len, value );
|
||||
pos = pos + value.length();
|
||||
}
|
||||
else {
|
||||
pos = pos2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return expanded;
|
||||
return expanded;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user