Changeset View
Changeset View
Standalone View
Standalone View
kdecore/config/kconfig.cpp
Context not available. | |||||
160 | int nDollarPos = aValue.indexOf( QLatin1Char('$') ); | 160 | int nDollarPos = aValue.indexOf( QLatin1Char('$') ); | ||
---|---|---|---|---|---|
161 | while( nDollarPos != -1 && nDollarPos+1 < aValue.length()) { | 161 | while( nDollarPos != -1 && nDollarPos+1 < aValue.length()) { | ||
162 | // there is at least one $ | 162 | // there is at least one $ | ||
163 | if( aValue[nDollarPos+1] == QLatin1Char('(') ) { | 163 | if( aValue[nDollarPos+1] != QLatin1Char('$') ) { | ||
164 | int nEndPos = nDollarPos+1; | | |||
165 | // the next character is not $ | | |||
166 | while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=QLatin1Char(')')) ) | | |||
167 | nEndPos++; | | |||
168 | nEndPos++; | | |||
169 | QString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); | | |||
170 | | ||||
171 | QString result; | | |||
172 | QByteArray oldpath = qgetenv( "PATH" ); | | |||
173 | QByteArray newpath; | | |||
174 | if (KGlobal::hasMainComponent()) { | | |||
175 | newpath = QFile::encodeName(KGlobal::dirs()->resourceDirs("exe").join(QChar::fromLatin1(KPATH_SEPARATOR))); | | |||
176 | if (!newpath.isEmpty() && !oldpath.isEmpty()) | | |||
177 | newpath += KPATH_SEPARATOR; | | |||
178 | } | | |||
179 | newpath += oldpath; | | |||
180 | setenv( "PATH", newpath, 1/*overwrite*/ ); | | |||
181 | // FIXME: wince does not have pipes | | |||
182 | #ifndef _WIN32_WCE | | |||
183 | FILE *fs = popen(QFile::encodeName(cmd).data(), "r"); | | |||
184 | if (fs) { | | |||
185 | QTextStream ts(fs, QIODevice::ReadOnly); | | |||
186 | result = ts.readAll().trimmed(); | | |||
187 | pclose(fs); | | |||
188 | } | | |||
189 | #endif | | |||
190 | setenv( "PATH", oldpath, 1/*overwrite*/ ); | | |||
191 | aValue.replace( nDollarPos, nEndPos-nDollarPos, result ); | | |||
192 | nDollarPos += result.length(); | | |||
193 | } else if( aValue[nDollarPos+1] != QLatin1Char('$') ) { | | |||
194 | int nEndPos = nDollarPos+1; | 164 | int nEndPos = nDollarPos+1; | ||
195 | // the next character is not $ | 165 | // the next character is not $ | ||
196 | QString aVarName; | 166 | QString aVarName; | ||
Context not available. |