forked from OSchip/llvm-project
Locate VS InstallDir in the presence of newer runtime
This fixes getSystemRegistryString() in WindowsToolChain.cpp to make sure that the VS version that it picks has an InstallDir. Previously we would look for the highest version os VS and check for InstallDir afterwards. Patch by Yaron Keren! llvm-svn: 192374
This commit is contained in:
parent
896005804d
commit
d219231de5
|
@ -146,30 +146,29 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName,
|
|||
char numBuf[32];
|
||||
strncpy(numBuf, sp, sizeof(numBuf) - 1);
|
||||
numBuf[sizeof(numBuf) - 1] = '\0';
|
||||
double value = strtod(numBuf, NULL);
|
||||
if (value > bestValue) {
|
||||
bestIndex = (int)index;
|
||||
bestValue = value;
|
||||
double dvalue = strtod(numBuf, NULL);
|
||||
if (dvalue > bestValue) {
|
||||
// Test that InstallDir is indeed there before keeping this index.
|
||||
// Open the chosen key path remainder.
|
||||
strcpy(bestName, keyName);
|
||||
// Append rest of key.
|
||||
strncat(bestName, nextKey, sizeof(bestName) - 1);
|
||||
bestName[sizeof(bestName) - 1] = '\0';
|
||||
lResult = RegOpenKeyEx(hTopKey, bestName, 0,
|
||||
KEY_READ | KEY_WOW64_32KEY, &hKey);
|
||||
if (lResult == ERROR_SUCCESS) {
|
||||
lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
|
||||
(LPBYTE)value, &valueSize);
|
||||
if (lResult == ERROR_SUCCESS) {
|
||||
bestIndex = (int)index;
|
||||
bestValue = dvalue;
|
||||
returnValue = true;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
size = sizeof(keyName) - 1;
|
||||
}
|
||||
// If we found the highest versioned key, open the key and get the value.
|
||||
if (bestIndex != -1) {
|
||||
// Append rest of key.
|
||||
strncat(bestName, nextKey, sizeof(bestName) - 1);
|
||||
bestName[sizeof(bestName) - 1] = '\0';
|
||||
// Open the chosen key path remainder.
|
||||
lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ | KEY_WOW64_32KEY,
|
||||
&hKey);
|
||||
if (lResult == ERROR_SUCCESS) {
|
||||
lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,
|
||||
(LPBYTE)value, &valueSize);
|
||||
if (lResult == ERROR_SUCCESS)
|
||||
returnValue = true;
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
RegCloseKey(hTopKey);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue