com php-src: improve and generalize the recognition of a cli sapi: win32/codepage.c

From: Date: Sun, 08 Jan 2017 22:54:58 +0000
Subject: com php-src: improve and generalize the recognition of a cli sapi: win32/codepage.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96633@lists.php.net to get a copy of this message
Commit: d4547304074096a9163488e7504c5ae5728605a2 Author: Anatol Belski <ab@php.net> Sun, 8 Jan 2017 23:54:58 +0100 Parents: c846daef28bd1dfbf10cdf905aad40a5fd3be62f Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d4547304074096a9163488e7504c5ae5728605a2 Log: improve and generalize the recognition of a cli sapi Changed paths: M win32/codepage.c Diff: diff --git a/win32/codepage.c b/win32/codepage.c index 416fa28..aa57892 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);

« previous php.cvs (#96633) next »