From b5f52f030ed7e345ace5ce576a5fabb0a1df363f Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Wed, 1 Apr 2015 07:48:39 -1000 Subject: [PATCH] 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 --- .../base/nsPluginDirServiceProvider.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dom/plugins/base/nsPluginDirServiceProvider.cpp b/dom/plugins/base/nsPluginDirServiceProvider.cpp index 1d30034cecab..f59ae29d9084 100644 --- a/dom/plugins/base/nsPluginDirServiceProvider.cpp +++ b/dom/plugins/base/nsPluginDirServiceProvider.cpp @@ -116,10 +116,20 @@ TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion) szJavaBuild[0] = '.'; } - szNum1 = wcstok(strVer, L"."); - szNum2 = wcstok(nullptr, L"."); - szNum3 = wcstok(nullptr, L"."); - szNum4 = wcstok(nullptr, L"."); +#if defined(_MSC_VER) && _MSC_VER < 1900 + // 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. + 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->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0;