forked from qt-creator/qt-creator
Environment: Disable escaping when expanding variables
This breaks too much on windows. Reviewed-by: dt
This commit is contained in:
@@ -373,20 +373,15 @@ QString Environment::joinArgumentList(const QStringList &arguments)
|
||||
return result;
|
||||
}
|
||||
|
||||
enum State { BASE, VARIABLE, OPTIONALVARIABLEBRACE, STRING, STRING_ESCAPE, ESCAPE };
|
||||
enum State { BASE, VARIABLE, OPTIONALVARIABLEBRACE, STRING };
|
||||
|
||||
/** Expand environment variables in a string.
|
||||
*
|
||||
* Environment variables are accepted in the following forms:
|
||||
* $SOMEVAR, ${SOMEVAR} and %SOMEVAR%.
|
||||
*
|
||||
* The following escape sequences are supported:
|
||||
* "\$", "\\" and "\"" which will be replaced by '$', '\' and '%'
|
||||
* respectively.
|
||||
*
|
||||
* Strings enclosed in '"' characters do not get varaibles
|
||||
* substituted. Escape codes are processed though.
|
||||
*
|
||||
* substituted.
|
||||
*/
|
||||
QString Environment::expandVariables(const QString &input) const
|
||||
{
|
||||
@@ -399,9 +394,7 @@ QString Environment::expandVariables(const QString &input) const
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QChar c = input.at(i);
|
||||
if (state == BASE) {
|
||||
if (c == '\\') {
|
||||
state = ESCAPE;
|
||||
} else if (c == '$') {
|
||||
if (c == '$') {
|
||||
state = OPTIONALVARIABLEBRACE;
|
||||
variable.clear();
|
||||
endVariable = QChar(0);
|
||||
@@ -433,20 +426,12 @@ QString Environment::expandVariables(const QString &input) const
|
||||
variable = c;
|
||||
state = VARIABLE;
|
||||
} else if (state == STRING) {
|
||||
if (c == '\\') {
|
||||
state = STRING_ESCAPE;
|
||||
} else if (c == '\"') {
|
||||
if (c == '\"') {
|
||||
state = BASE;
|
||||
result += c;
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
} else if (state == STRING_ESCAPE) {
|
||||
result += c;
|
||||
state = STRING;
|
||||
} else if (state == ESCAPE){
|
||||
result += c;
|
||||
state = BASE;
|
||||
}
|
||||
}
|
||||
if (state == VARIABLE)
|
||||
|
||||
Reference in New Issue
Block a user