mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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
This commit is contained in:
parent
4c70d9f79c
commit
8ebc6451f3
3 changed files with 13 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue