diff options
author | Anatol Belski <ab@php.net> | 2017-01-08 23:54:58 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-01-08 23:54:58 +0100 |
commit | d4547304074096a9163488e7504c5ae5728605a2 (patch) | |
tree | fa90f5f4a2adb6e01e52344ba7d3eda6f409fd99 /win32/codepage.c | |
parent | c846daef28bd1dfbf10cdf905aad40a5fd3be62f (diff) | |
download | php-git-d4547304074096a9163488e7504c5ae5728605a2.tar.gz |
improve and generalize the recognition of a cli sapi
Diffstat (limited to 'win32/codepage.c')
-rw-r--r-- | win32/codepage.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/win32/codepage.c b/win32/codepage.c index 416fa28342..aa57892bf9 100644 --- a/win32/codepage.c +++ b/win32/codepage.c @@ -252,6 +252,11 @@ __forceinline static char *php_win32_cp_get_enc(void) return enc; }/*}}}*/ +__forceinline static BOOL php_win32_cp_is_cli_sapi() +{/*{{{*/ + return strlen(sapi_module.name) >= sizeof("cli") - 1 && !strncmp(sapi_module.name, "cli", sizeof("cli") - 1); +}/*}}}*/ + PW32CP const struct php_win32_cp *php_win32_cp_get_current(void) {/*{{{*/ return cur_cp; @@ -432,7 +437,7 @@ PW32CP const struct php_win32_cp *php_win32_cp_do_setup(const char *enc) if (!orig_cp) { orig_cp = php_win32_cp_get_by_id(GetACP()); } - if (!strcmp(sapi_module.name, "cli")) { + if (php_win32_cp_is_cli_sapi()) { if (!orig_in_cp) { orig_in_cp = php_win32_cp_get_by_id(GetConsoleCP()); if (!orig_in_cp) { @@ -458,7 +463,7 @@ PW32CP const struct php_win32_cp *php_win32_cp_do_update(const char *enc) } cur_cp = php_win32_cp_get_by_enc(enc); - if (!strcmp(sapi_module.name, "cli")) { + if (php_win32_cp_is_cli_sapi()) { php_win32_cp_cli_do_setup(cur_cp->id); } @@ -533,7 +538,7 @@ PHP_FUNCTION(sapi_windows_cp_set) RETURN_FALSE; } - if (!strcmp(sapi_module.name, "cli")) { + if (php_win32_cp_is_cli_sapi()) { cp = php_win32_cp_cli_do_setup((DWORD)id); } else { cp = php_win32_cp_set_by_id((DWORD)id); |