diff options
author | Minmin Gong <gongminmin@msn.com> | 2019-02-03 04:26:55 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2019-02-03 04:26:55 (GMT) |
commit | 8ebc6451f36fa213130c316199dbec5ad8a02163 (patch) | |
tree | 8462031060a85ff44ddb0e45d5550a3900f6a18f /Python/pathconfig.c | |
parent | 4c70d9f79c9b371990c8e054ccde53f7ff15946b (diff) | |
download | cpython-8ebc6451f36fa213130c316199dbec5ad8a02163.zip cpython-8ebc6451f36fa213130c316199dbec5ad8a02163.tar.gz cpython-8ebc6451f36fa213130c316199dbec5ad8a02163.tar.bz2 |
bpo-35890 : Fix some API calling consistency (GH-11742)
Unicode version of Windows APIs are used in places, but not for GetVersionEx in Python/sysmodule.c
The wcstok_s is called on Windows in Modules/main.c and PC/launcher.c, but not in Python/pathconfig.c
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r-- | Python/pathconfig.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 342a944..c9bddcf 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -675,6 +675,12 @@ _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv) } +#ifdef MS_WINDOWS +#define WCSTOK wcstok_s +#else +#define WCSTOK wcstok +#endif + /* Search for a prefix value in an environment file (pyvenv.cfg). If found, copy it into the provided buffer. */ int @@ -705,11 +711,11 @@ _Py_FindEnvConfigValue(FILE *env_file, const wchar_t *key, wchar_t *tmpbuffer = _Py_DecodeUTF8_surrogateescape(buffer, n); if (tmpbuffer) { wchar_t * state; - wchar_t * tok = wcstok(tmpbuffer, L" \t\r\n", &state); + wchar_t * tok = WCSTOK(tmpbuffer, L" \t\r\n", &state); if ((tok != NULL) && !wcscmp(tok, key)) { - tok = wcstok(NULL, L" \t", &state); + tok = WCSTOK(NULL, L" \t", &state); if ((tok != NULL) && !wcscmp(tok, L"=")) { - tok = wcstok(NULL, L"\r\n", &state); + tok = WCSTOK(NULL, L"\r\n", &state); if (tok != NULL) { wcsncpy(value, tok, MAXPATHLEN); result = 1; |