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:
George Peter Banyard 2021-04-08 15:27:51 +01:00
parent f191e4f257
commit 09efad615b
No known key found for this signature in database
GPG key ID: D49A095D7329F6DC
20 changed files with 153 additions and 221 deletions

View file

@ -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);
}