Proliferate pathListSeparator()

Change-Id: I546107af6a88ad5901659a0a64485e4ebca3a164
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2023-04-06 18:31:47 +02:00
parent fe45294357
commit 1e1befd9eb
4 changed files with 7 additions and 16 deletions

View File

@@ -155,14 +155,13 @@ void Environment::prependOrSet(const QString &key, const QString &value, const Q
void Environment::prependOrSetLibrarySearchPath(const FilePath &value)
{
QTC_CHECK(value.osType() == osType());
const QChar sep = OsSpecificAspects::pathListSeparator(osType());
switch (osType()) {
case OsTypeWindows: {
const QChar sep = ';';
prependOrSet("PATH", value.nativePath(), sep);
break;
}
case OsTypeMac: {
const QChar sep = ':';
const QString nativeValue = value.nativePath();
prependOrSet("DYLD_LIBRARY_PATH", nativeValue, sep);
prependOrSet("DYLD_FRAMEWORK_PATH", nativeValue, sep);
@@ -170,7 +169,6 @@ void Environment::prependOrSetLibrarySearchPath(const FilePath &value)
}
case OsTypeLinux:
case OsTypeOtherUnix: {
const QChar sep = ':';
prependOrSet("LD_LIBRARY_PATH", value.nativePath(), sep);
break;
}

View File

@@ -118,14 +118,6 @@ static QString expand(const NameValueDictionary *dictionary, QString value)
return value;
}
enum : char {
#ifdef Q_OS_WIN
pathSepC = ';'
#else
pathSepC = ':'
#endif
};
void NameValueItem::apply(NameValueDictionary *dictionary, Operation op) const
{
switch (op) {
@@ -142,7 +134,7 @@ void NameValueItem::apply(NameValueDictionary *dictionary, Operation op) const
const NameValueDictionary::const_iterator it = dictionary->constFind(name);
if (it != dictionary->constEnd()) {
QString v = dictionary->value(it);
const QChar pathSep{QLatin1Char(pathSepC)};
const QChar pathSep = HostOsInfo::pathListSeparator();
int sepCount = 0;
if (v.startsWith(pathSep))
++sepCount;
@@ -162,7 +154,7 @@ void NameValueItem::apply(NameValueDictionary *dictionary, Operation op) const
const NameValueDictionary::const_iterator it = dictionary->constFind(name);
if (it != dictionary->constEnd()) {
QString v = dictionary->value(it);
const QChar pathSep{QLatin1Char(pathSepC)};
const QChar pathSep = HostOsInfo::pathListSeparator();
int sepCount = 0;
if (v.endsWith(pathSep))
++sepCount;

View File

@@ -421,10 +421,11 @@ void CdbEngine::setupEngine()
inferiorEnvironment.set(qtLoggingToConsoleKey, "0");
static const char cdbExtensionPathVariableC[] = "_NT_DEBUGGER_EXTENSION_PATH";
inferiorEnvironment.prependOrSet(cdbExtensionPathVariableC, extensionFi.absolutePath(), {";"});
const QString pSep = OsSpecificAspects::pathListSeparator(Utils::OsTypeWindows);
inferiorEnvironment.prependOrSet(cdbExtensionPathVariableC, extensionFi.absolutePath(), pSep);
const QString oldCdbExtensionPath = qtcEnvironmentVariable(cdbExtensionPathVariableC);
if (!oldCdbExtensionPath.isEmpty())
inferiorEnvironment.appendOrSet(cdbExtensionPathVariableC, oldCdbExtensionPath, {";"});
inferiorEnvironment.appendOrSet(cdbExtensionPathVariableC, oldCdbExtensionPath, pSep);
m_process.setEnvironment(inferiorEnvironment);
if (!sp.inferior.workingDirectory.isEmpty())

View File

@@ -363,7 +363,7 @@ void tst_Environment::pathChanges()
QFETCH(QString, value);
QFETCH(Environment, expected);
const QString sep = environment.osType() == OsTypeWindows ? ";" : ":";
const QString sep = HostOsInfo::pathListSeparator();
if (prepend)
environment.prependOrSet(variable, value, sep);