Changeset View
Changeset View
Standalone View
Standalone View
src/core/kconfig.cpp
Show All 22 Lines | |||||
23 | #include "kconfig.h" | 23 | #include "kconfig.h" | ||
24 | #include "kconfig_p.h" | 24 | #include "kconfig_p.h" | ||
25 | 25 | | |||
26 | #include "config-kconfig.h" | 26 | #include "config-kconfig.h" | ||
27 | 27 | | |||
28 | #include <cstdlib> | 28 | #include <cstdlib> | ||
29 | #include <fcntl.h> | 29 | #include <fcntl.h> | ||
30 | 30 | | |||
31 | #ifdef _MSC_VER | | |||
32 | static inline FILE *popen(const char *cmd, const char *mode) | | |||
33 | { | | |||
34 | return _popen(cmd, mode); | | |||
35 | } | | |||
36 | static inline int pclose(FILE *stream) | | |||
37 | { | | |||
38 | return _pclose(stream); | | |||
39 | } | | |||
40 | #else | | |||
41 | #include <unistd.h> | | |||
42 | #endif | | |||
43 | | ||||
44 | #include "kconfigbackend_p.h" | 31 | #include "kconfigbackend_p.h" | ||
45 | #include "kconfiggroup.h" | 32 | #include "kconfiggroup.h" | ||
46 | 33 | | |||
47 | #include <qcoreapplication.h> | 34 | #include <qcoreapplication.h> | ||
48 | #include <qprocess.h> | 35 | #include <qprocess.h> | ||
49 | #include <qstandardpaths.h> | 36 | #include <qstandardpaths.h> | ||
50 | #include <qbytearray.h> | 37 | #include <qbytearray.h> | ||
51 | #include <qfile.h> | 38 | #include <qfile.h> | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | |||||
178 | QString KConfigPrivate::expandString(const QString &value) | 165 | QString KConfigPrivate::expandString(const QString &value) | ||
179 | { | 166 | { | ||
180 | QString aValue = value; | 167 | QString aValue = value; | ||
181 | 168 | | |||
182 | // check for environment variables and make necessary translations | 169 | // check for environment variables and make necessary translations | ||
183 | int nDollarPos = aValue.indexOf(QLatin1Char('$')); | 170 | int nDollarPos = aValue.indexOf(QLatin1Char('$')); | ||
184 | while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) { | 171 | while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) { | ||
185 | // there is at least one $ | 172 | // there is at least one $ | ||
186 | if (aValue[nDollarPos + 1] == QLatin1Char('(')) { | 173 | if (aValue[nDollarPos + 1] != QLatin1Char('$')) { | ||
187 | int nEndPos = nDollarPos + 1; | | |||
188 | // the next character is not $ | | |||
189 | while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char(')'))) { | | |||
190 | nEndPos++; | | |||
191 | } | | |||
192 | nEndPos++; | | |||
193 | QString cmd = aValue.mid(nDollarPos + 2, nEndPos - nDollarPos - 3); | | |||
194 | | ||||
195 | QString result; | | |||
196 | | ||||
197 | // FIXME: wince does not have pipes | | |||
198 | #ifndef _WIN32_WCE | | |||
199 | FILE *fs = popen(QFile::encodeName(cmd).data(), "r"); | | |||
200 | if (fs) { | | |||
201 | QTextStream ts(fs, QIODevice::ReadOnly); | | |||
202 | result = ts.readAll().trimmed(); | | |||
203 | pclose(fs); | | |||
204 | } | | |||
205 | #endif | | |||
206 | aValue.replace(nDollarPos, nEndPos - nDollarPos, result); | | |||
207 | nDollarPos += result.length(); | | |||
208 | } else if (aValue[nDollarPos + 1] != QLatin1Char('$')) { | | |||
209 | int nEndPos = nDollarPos + 1; | 174 | int nEndPos = nDollarPos + 1; | ||
210 | // the next character is not $ | 175 | // the next character is not $ | ||
211 | QStringRef aVarName; | 176 | QStringRef aVarName; | ||
212 | if (aValue[nEndPos] == QLatin1Char('{')) { | 177 | if (aValue[nEndPos] == QLatin1Char('{')) { | ||
213 | while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { | 178 | while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { | ||
214 | nEndPos++; | 179 | nEndPos++; | ||
215 | } | 180 | } | ||
216 | nEndPos++; | 181 | nEndPos++; | ||
▲ Show 20 Lines • Show All 839 Lines • Show Last 20 Lines |