diff options
author | Antony Dovgal <tony2001@php.net> | 2005-06-22 12:02:47 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2005-06-22 12:02:47 +0000 |
commit | 1c68938c6000b07b4a37375dbd3d13b8497551a8 (patch) | |
tree | 56b2325436c33007549f5d8496b66ccf86c82da5 /Zend/zend_ini.c | |
parent | ce972676b568a520b061810790fecbe0b76adbce (diff) | |
download | php-git-1c68938c6000b07b4a37375dbd3d13b8497551a8.tar.gz |
- allow to use "yes" and "true" with ini_set() and in commandline (through -d flag)
- fix #15854 that was caused by wrong consideration that zend_ini_boolean_displayer_cb()
always recieves converted to "0"/"1" values.
Diffstat (limited to 'Zend/zend_ini.c')
-rw-r--r-- | Zend/zend_ini.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index aedc1e14ad..3de2f8de0c 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -371,15 +371,33 @@ static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) ZEND_INI_DISP(zend_ini_boolean_displayer_cb) { - int value; + int value, tmp_value_len; + char *tmp_value; if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { - value = (ini_entry->orig_value ? atoi(ini_entry->orig_value) : 0); + tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL ); + tmp_value_len = ini_entry->orig_value_length; } else if (ini_entry->value) { - value = atoi(ini_entry->value); + tmp_value = ini_entry->value; + tmp_value_len = ini_entry->value_length; } else { - value = 0; + tmp_value = NULL; + tmp_value_len = 0; } + + if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) { + value = 1; + } + else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) { + value = 1; + } + else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) { + value = 1; + } + else { + value = atoi(tmp_value); + } + if (value) { ZEND_PUTS("On"); } else { @@ -452,9 +470,16 @@ ZEND_API ZEND_INI_MH(OnUpdateBool) p = (zend_bool *) (base+(size_t) mh_arg1); - if (new_value_length==2 && strcasecmp("on", new_value)==0) { + if (new_value_length==2 && strcasecmp("on", new_value)==0) { *p = (zend_bool) 1; - } else { + } + else if (new_value_length==3 && strcasecmp("yes", new_value)==0) { + *p = (zend_bool) 1; + } + else if (new_value_length==4 && strcasecmp("true", new_value)==0) { + *p = (zend_bool) 1; + } + else { *p = (zend_bool) atoi(new_value); } return SUCCESS; |