summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2021-03-14 15:05:54 +0000
committerGeorge Peter Banyard <girgias@php.net>2021-03-14 15:06:15 +0000
commitd4530f807a78d50c2f5fd66114632480e7651d31 (patch)
treedfd81beec615c213bf9bbe8aacb7c754a123249b /main
parent021c988a6fbd9659b9c4dade5fa171263b8d8c98 (diff)
downloadphp-git-d4530f807a78d50c2f5fd66114632480e7651d31.tar.gz
Use zend_string* & more legible API for php_get_display_errors_mode()
Diffstat (limited to 'main')
-rw-r--r--main/main.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/main/main.c b/main/main.c
index 144586e372..1aa41da672 100644
--- a/main/main.c
+++ b/main/main.c
@@ -401,7 +401,7 @@ static PHP_INI_MH(OnUpdateTimeout)
/* }}} */
/* {{{ php_get_display_errors_mode() helper function */
-static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
+static zend_uchar php_get_display_errors_mode(zend_string *value)
{
zend_uchar mode;
@@ -409,24 +409,24 @@ static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
return PHP_DISPLAY_ERRORS_STDOUT;
}
- if (value_length == 2 && !strcasecmp("on", value)) {
+ if (zend_string_equals_literal_ci(value, "on")) {
return PHP_DISPLAY_ERRORS_STDOUT;
}
- if (value_length == 3 && !strcasecmp("yes", value)) {
+ if (zend_string_equals_literal_ci(value, "yes")) {
return PHP_DISPLAY_ERRORS_STDOUT;
}
- if (value_length == 4 && !strcasecmp("true", value)) {
+ if (zend_string_equals_literal_ci(value, "true")) {
return PHP_DISPLAY_ERRORS_STDOUT;
}
- if (value_length == 6 && !strcasecmp(value, "stderr")) {
+ if (zend_string_equals_literal_ci(value, "stderr")) {
return PHP_DISPLAY_ERRORS_STDERR;
}
- if (value_length == 6 && !strcasecmp(value, "stdout")) {
+ if (zend_string_equals_literal_ci(value, "stdout")) {
return PHP_DISPLAY_ERRORS_STDOUT;
}
- ZEND_ATOL(mode, value);
+ ZEND_ATOL(mode, ZSTR_VAL(value));
if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {
return PHP_DISPLAY_ERRORS_STDOUT;
}
@@ -438,7 +438,7 @@ static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateDisplayErrors)
{
- PG(display_errors) = php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
+ PG(display_errors) = php_get_display_errors_mode(new_value);
return SUCCESS;
}
@@ -449,21 +449,17 @@ static PHP_INI_DISP(display_errors_mode)
{
zend_uchar mode;
bool cgi_or_cli;
- size_t tmp_value_length;
- char *tmp_value;
+ zend_string *temporary_value;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- tmp_value = (ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : NULL );
- tmp_value_length = (ini_entry->orig_value? ZSTR_LEN(ini_entry->orig_value) : 0);
+ temporary_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
} else if (ini_entry->value) {
- tmp_value = ZSTR_VAL(ini_entry->value);
- tmp_value_length = ZSTR_LEN(ini_entry->value);
+ temporary_value = ini_entry->value;
} else {
- tmp_value = NULL;
- tmp_value_length = 0;
+ temporary_value = NULL;
}
- mode = php_get_display_errors_mode(tmp_value, tmp_value_length);
+ mode = php_get_display_errors_mode(temporary_value);
/* Display 'On' for other SAPIs instead of STDOUT or STDERR */
cgi_or_cli = (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg"));