diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-07-15 14:17:54 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-07-15 13:58:26 +0000 |
commit | 375e4dee2b549acae1cdf53db5e3495d0eed218e (patch) | |
tree | 448ae34cbc800c98ed05912a8d1248d94a0e80b6 /src/libs/utils/namevaluedictionary.cpp | |
parent | 4077bc869c415e061dac28e1fdbd5403c40c798f (diff) | |
download | qt-creator-375e4dee2b549acae1cdf53db5e3495d0eed218e.tar.gz |
Utils: Remove NameValueDictionary::expandVariables()
These functions were inadvertently copied from the Environment class in
4bae5de36b.
Change-Id: Iede8d4b43bd97e8d6d3a0641bd3224e5829fe4b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/utils/namevaluedictionary.cpp')
-rw-r--r-- | src/libs/utils/namevaluedictionary.cpp | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/libs/utils/namevaluedictionary.cpp b/src/libs/utils/namevaluedictionary.cpp index 30e3c18448..84402eaa1f 100644 --- a/src/libs/utils/namevaluedictionary.cpp +++ b/src/libs/utils/namevaluedictionary.cpp @@ -198,85 +198,4 @@ QString NameValueDictionary::userName() const return value(QString::fromLatin1(m_osType == OsTypeWindows ? "USERNAME" : "USER")); } -/** Expand environment variables in a string. - * - * KeyValueDictionary variables are accepted in the following forms: - * $SOMEVAR, ${SOMEVAR} on Unix and %SOMEVAR% on Windows. - * No escapes and quoting are supported. - * If a variable is not found, it is not substituted. - */ -QString NameValueDictionary::expandVariables(const QString &input) const -{ - QString result = input; - - if (m_osType == OsTypeWindows) { - for (int vStart = -1, i = 0; i < result.length();) { - if (result.at(i++) == '%') { - if (vStart > 0) { - const_iterator it = findKey(m_values, m_osType, result.mid(vStart, i - vStart - 1)); - if (it != m_values.constEnd()) { - result.replace(vStart - 1, i - vStart + 1, *it); - i = vStart - 1 + it->length(); - vStart = -1; - } else { - vStart = i; - } - } else { - vStart = i; - } - } - } - } else { - enum { BASE, OPTIONALVARIABLEBRACE, VARIABLE, BRACEDVARIABLE } state = BASE; - int vStart = -1; - - for (int i = 0; i < result.length();) { - QChar c = result.at(i++); - if (state == BASE) { - if (c == '$') - state = OPTIONALVARIABLEBRACE; - } else if (state == OPTIONALVARIABLEBRACE) { - if (c == '{') { - state = BRACEDVARIABLE; - vStart = i; - } else if (c.isLetterOrNumber() || c == '_') { - state = VARIABLE; - vStart = i - 1; - } else { - state = BASE; - } - } else if (state == BRACEDVARIABLE) { - if (c == '}') { - const_iterator it = m_values.constFind(result.mid(vStart, i - 1 - vStart)); - if (it != constEnd()) { - result.replace(vStart - 2, i - vStart + 2, *it); - i = vStart - 2 + it->length(); - } - state = BASE; - } - } else if (state == VARIABLE) { - if (!c.isLetterOrNumber() && c != '_') { - const_iterator it = m_values.constFind(result.mid(vStart, i - vStart - 1)); - if (it != constEnd()) { - result.replace(vStart - 1, i - vStart, *it); - i = vStart - 1 + it->length(); - } - state = BASE; - } - } - } - if (state == VARIABLE) { - const_iterator it = m_values.constFind(result.mid(vStart)); - if (it != constEnd()) - result.replace(vStart - 1, result.length() - vStart + 1, *it); - } - } - return result; -} - -QStringList NameValueDictionary::expandVariables(const QStringList &variables) const -{ - return Utils::transform(variables, [this](const QString &i) { return expandVariables(i); }); -} - } // namespace Utils |