From f63dab5a842df7349af73be23fb3acc37aa75703 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 25 Feb 2015 20:48:01 -0800 Subject: Back-out wcstok deprecation suppression and updates calls to use wcstok_s. --- Modules/main.c | 6 +++--- PC/getpathp.c | 7 ++++--- PCbuild/pythoncore.vcxproj | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Modules/main.c b/Modules/main.c index 83538c4..74e512b 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -520,16 +520,16 @@ Py_Main(int argc, wchar_t **argv) #ifdef MS_WINDOWS if (!Py_IgnoreEnvironmentFlag && (wp = _wgetenv(L"PYTHONWARNINGS")) && *wp != L'\0') { - wchar_t *buf, *warning; + wchar_t *buf, *warning, *context = NULL; buf = (wchar_t *)PyMem_RawMalloc((wcslen(wp) + 1) * sizeof(wchar_t)); if (buf == NULL) Py_FatalError( "not enough memory to copy PYTHONWARNINGS"); wcscpy(buf, wp); - for (warning = wcstok(buf, L","); + for (warning = wcstok_s(buf, L",", &context); warning != NULL; - warning = wcstok(NULL, L",")) { + warning = wcstok_s(NULL, L",", &context)) { PySys_AddWarnOption(warning); } PyMem_RawFree(buf); diff --git a/PC/getpathp.c b/PC/getpathp.c index deb40e7..d4f4574 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -451,11 +451,12 @@ find_env_config_value(FILE * env_file, const wchar_t * key, wchar_t * value) tmpbuffer, MAXPATHLEN * 2); Py_DECREF(decoded); if (k >= 0) { - wchar_t * tok = wcstok(tmpbuffer, L" \t\r\n"); + wchar_t * context = NULL; + wchar_t * tok = wcstok_s(tmpbuffer, L" \t\r\n", &context); if ((tok != NULL) && !wcscmp(tok, key)) { - tok = wcstok(NULL, L" \t"); + tok = wcstok_s(NULL, L" \t", &context); if ((tok != NULL) && !wcscmp(tok, L"=")) { - tok = wcstok(NULL, L"\r\n"); + tok = wcstok_s(NULL, L"\r\n", &context); if (tok != NULL) { wcsncpy(value, tok, MAXPATHLEN); result = 1; diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 430d835..479f68d 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -67,7 +67,7 @@ /Zm200 %(AdditionalOptions) $(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories) - _CRT_NON_CONFORMING_WCSTOK;_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions) + _USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions) ws2_32.lib;%(AdditionalDependencies) -- cgit v0.12