mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-08 17:48:41 +00:00
Refactor php.ini bool option parsing
This commit is contained in:
parent
f22ce7046d
commit
9275600ac9
50
v8js.cc
50
v8js.cc
@ -48,53 +48,37 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool v8js_ini_to_bool(const char *new_value, uint new_value_length) /* {{{ */
|
||||||
|
{
|
||||||
|
if (new_value_length == 2 && strcasecmp("on", new_value) == 0) {
|
||||||
|
return true;
|
||||||
|
} else if (new_value_length == 3 && strcasecmp("yes", new_value) == 0) {
|
||||||
|
return true;
|
||||||
|
} else if (new_value_length == 4 && strcasecmp("true", new_value) == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return (bool) atoi(new_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
static ZEND_INI_MH(v8js_OnUpdateUseDate) /* {{{ */
|
static ZEND_INI_MH(v8js_OnUpdateUseDate) /* {{{ */
|
||||||
{
|
{
|
||||||
bool value;
|
V8JSG(use_date) = v8js_ini_to_bool(new_value, new_value_length);
|
||||||
if (new_value_length==2 && strcasecmp("on", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else {
|
|
||||||
value = (bool) atoi(new_value);
|
|
||||||
}
|
|
||||||
V8JSG(use_date) = value;
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
static ZEND_INI_MH(v8js_OnUpdateUseArrayAccess) /* {{{ */
|
static ZEND_INI_MH(v8js_OnUpdateUseArrayAccess) /* {{{ */
|
||||||
{
|
{
|
||||||
bool value;
|
V8JSG(use_array_access) = v8js_ini_to_bool(new_value, new_value_length);
|
||||||
if (new_value_length==2 && strcasecmp("on", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else {
|
|
||||||
value = (bool) atoi(new_value);
|
|
||||||
}
|
|
||||||
V8JSG(use_array_access) = value;
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
|
static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
|
||||||
{
|
{
|
||||||
bool value;
|
V8JSG(compat_php_exceptions) = v8js_ini_to_bool(new_value, new_value_length);
|
||||||
if (new_value_length==2 && strcasecmp("on", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
|
|
||||||
value = (bool) 1;
|
|
||||||
} else {
|
|
||||||
value = (bool) atoi(new_value);
|
|
||||||
}
|
|
||||||
V8JSG(compat_php_exceptions) = value;
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
Loading…
Reference in New Issue
Block a user