Bug 1150354: Make nsPluginDirServiceProvider build with MSVC 2015 CTP 6, r=jmathies

MSVC 2013 and earlier provided only a non-standard two-argument
variant of wcstok that is generally not thread-safe. For our
purposes here, it works fine, though, so we polyfill the
standard variant using the non-standard variant.

--HG--
extra : rebase_source : c54c07a4e1d1d6933cfe5899d84a7f11ae4f99fa
This commit is contained in:
Brian Smith 2015-04-01 07:48:39 -10:00
Родитель 17243ad410
Коммит b5f52f030e
1 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -116,10 +116,20 @@ TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion)
szJavaBuild[0] = '.'; szJavaBuild[0] = '.';
} }
szNum1 = wcstok(strVer, L"."); #if defined(_MSC_VER) && _MSC_VER < 1900
szNum2 = wcstok(nullptr, L"."); // MSVC 2013 and earlier provided only a non-standard two-argument variant of
szNum3 = wcstok(nullptr, L"."); // wcstok that is generally not thread-safe. For our purposes here, it works
szNum4 = wcstok(nullptr, L"."); // fine, though.
auto wcstok = [](wchar_t* strToken, const wchar_t* strDelimit,
wchar_t** /*ctx*/) {
return ::std::wcstok(strToken, strDelimit);
};
#endif
wchar_t* ctx = nullptr;
szNum1 = wcstok(strVer, L".", &ctx);
szNum2 = wcstok(nullptr, L".", &ctx);
szNum3 = wcstok(nullptr, L".", &ctx);
szNum4 = wcstok(nullptr, L".", &ctx);
vbVersion->wMajor = szNum1 ? (WORD) _wtoi(szNum1) : 0; vbVersion->wMajor = szNum1 ? (WORD) _wtoi(szNum1) : 0;
vbVersion->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0; vbVersion->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0;