mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool() Closes GH-6844
This commit is contained in:
parent
f191e4f257
commit
09efad615b
20 changed files with 153 additions and 221 deletions
|
@ -587,18 +587,21 @@ PHP_FUNCTION(sapi_windows_cp_set)
|
|||
/* {{{ Get process codepage. */
|
||||
PHP_FUNCTION(sapi_windows_cp_get)
|
||||
{
|
||||
char *kind;
|
||||
size_t kind_len = 0;
|
||||
zend_string *kind = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &kind, &kind_len) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &kind) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (kind_len == sizeof("ansi")-1 && !strncasecmp(kind, "ansi", kind_len)) {
|
||||
if (!kind) {
|
||||
const struct php_win32_cp *cp = php_win32_cp_get_current();
|
||||
RETURN_LONG(cp->id);
|
||||
} else if (zend_string_equals_literal_ci(kind, "ansi")) {
|
||||
RETURN_LONG(GetACP());
|
||||
} else if (kind_len == sizeof("oem")-1 && !strncasecmp(kind, "oem", kind_len)) {
|
||||
} else if (zend_string_equals_literal_ci(kind, "oem")) {
|
||||
RETURN_LONG(GetOEMCP());
|
||||
} else {
|
||||
/* TODO Warn/ValueError for invalid kind? */
|
||||
const struct php_win32_cp *cp = php_win32_cp_get_current();
|
||||
RETURN_LONG(cp->id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue