Skip to content

Commit d4530f8

Browse files
committed
Use zend_string* & more legible API for php_get_display_errors_mode()
1 parent 021c988 commit d4530f8

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

main/main.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -401,32 +401,32 @@ static PHP_INI_MH(OnUpdateTimeout)
401401
/* }}} */
402402

403403
/* {{{ php_get_display_errors_mode() helper function */
404-
static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
404+
static zend_uchar php_get_display_errors_mode(zend_string *value)
405405
{
406406
zend_uchar mode;
407407

408408
if (!value) {
409409
return PHP_DISPLAY_ERRORS_STDOUT;
410410
}
411411

412-
if (value_length == 2 && !strcasecmp("on", value)) {
412+
if (zend_string_equals_literal_ci(value, "on")) {
413413
return PHP_DISPLAY_ERRORS_STDOUT;
414414
}
415-
if (value_length == 3 && !strcasecmp("yes", value)) {
415+
if (zend_string_equals_literal_ci(value, "yes")) {
416416
return PHP_DISPLAY_ERRORS_STDOUT;
417417
}
418418

419-
if (value_length == 4 && !strcasecmp("true", value)) {
419+
if (zend_string_equals_literal_ci(value, "true")) {
420420
return PHP_DISPLAY_ERRORS_STDOUT;
421421
}
422-
if (value_length == 6 && !strcasecmp(value, "stderr")) {
422+
if (zend_string_equals_literal_ci(value, "stderr")) {
423423
return PHP_DISPLAY_ERRORS_STDERR;
424424
}
425-
if (value_length == 6 && !strcasecmp(value, "stdout")) {
425+
if (zend_string_equals_literal_ci(value, "stdout")) {
426426
return PHP_DISPLAY_ERRORS_STDOUT;
427427
}
428428

429-
ZEND_ATOL(mode, value);
429+
ZEND_ATOL(mode, ZSTR_VAL(value));
430430
if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {
431431
return PHP_DISPLAY_ERRORS_STDOUT;
432432
}
@@ -438,7 +438,7 @@ static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
438438
/* {{{ PHP_INI_MH */
439439
static PHP_INI_MH(OnUpdateDisplayErrors)
440440
{
441-
PG(display_errors) = php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
441+
PG(display_errors) = php_get_display_errors_mode(new_value);
442442

443443
return SUCCESS;
444444
}
@@ -449,21 +449,17 @@ static PHP_INI_DISP(display_errors_mode)
449449
{
450450
zend_uchar mode;
451451
bool cgi_or_cli;
452-
size_t tmp_value_length;
453-
char *tmp_value;
452+
zend_string *temporary_value;
454453

455454
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
456-
tmp_value = (ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : NULL );
457-
tmp_value_length = (ini_entry->orig_value? ZSTR_LEN(ini_entry->orig_value) : 0);
455+
temporary_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
458456
} else if (ini_entry->value) {
459-
tmp_value = ZSTR_VAL(ini_entry->value);
460-
tmp_value_length = ZSTR_LEN(ini_entry->value);
457+
temporary_value = ini_entry->value;
461458
} else {
462-
tmp_value = NULL;
463-
tmp_value_length = 0;
459+
temporary_value = NULL;
464460
}
465461

466-
mode = php_get_display_errors_mode(tmp_value, tmp_value_length);
462+
mode = php_get_display_errors_mode(temporary_value);
467463

468464
/* Display 'On' for other SAPIs instead of STDOUT or STDERR */
469465
cgi_or_cli = (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg"));

0 commit comments

Comments
 (0)