0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 18:41:52 +00:00

Add php.ini setting v8js.icudtl_dat_path

This commit is contained in:
Stefan Siegl 2017-04-21 18:20:12 +02:00
parent 73e1f3c9a2
commit 989f0ae82c
No known key found for this signature in database
GPG Key ID: 359A823ED8D6F17F
3 changed files with 35 additions and 9 deletions

View File

@ -156,6 +156,9 @@ struct _v8js_process_globals {
/* V8 command line flags */ /* V8 command line flags */
char *v8_flags; char *v8_flags;
/* Path to icudtl.dat file */
char *icudtl_dat_path;
v8::Platform *v8_platform; v8::Platform *v8_platform;
}; };

View File

@ -33,7 +33,7 @@ struct _v8js_process_globals v8js_process_globals;
/* {{{ INI Settings */ /* {{{ INI Settings */
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */ static bool v8js_ini_string(char **field, const zend_string *new_value)/* {{{ */
{ {
bool immutable = false; bool immutable = false;
@ -56,18 +56,33 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
} }
if (new_value) { if (new_value) {
if (v8js_process_globals.v8_flags) { if (*field) {
free(v8js_process_globals.v8_flags); free(*field);
v8js_process_globals.v8_flags = NULL; *field = NULL;
} }
if (!ZSTR_VAL(new_value)[0]) { if (!ZSTR_VAL(new_value)[0]) {
return FAILURE; return SUCCESS;
} }
v8js_process_globals.v8_flags = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
*field = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
} }
return SUCCESS; return SUCCESS;
} }
/* }}} */
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
{
return v8js_ini_string(&v8js_process_globals.v8_flags, new_value);
}
/* }}} */
static ZEND_INI_MH(v8js_OnUpdateIcudatPath) /* {{{ */
{
return v8js_ini_string(&v8js_process_globals.icudtl_dat_path, new_value);
}
/* }}} */
static bool v8js_ini_to_bool(const zend_string *new_value) /* {{{ */ static bool v8js_ini_to_bool(const zend_string *new_value) /* {{{ */
{ {
@ -106,6 +121,7 @@ static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
ZEND_INI_BEGIN() /* {{{ */ ZEND_INI_BEGIN() /* {{{ */
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags) ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
ZEND_INI_ENTRY("v8js.icudtl_dat_path", NULL, ZEND_INI_ALL, v8js_OnUpdateIcudatPath)
ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate) ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess) ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess)
ZEND_INI_ENTRY("v8js.compat_php_exceptions", "0", ZEND_INI_ALL, v8js_OnUpdateCompatExceptions) ZEND_INI_ENTRY("v8js.compat_php_exceptions", "0", ZEND_INI_ALL, v8js_OnUpdateCompatExceptions)

View File

@ -76,10 +76,17 @@ void v8js_v8_init() /* {{{ */
} }
} }
#if defined(PHP_V8_EXEC_PATH) && PHP_V8_API_VERSION >= 5003178 #if PHP_V8_API_VERSION >= 5003178
/* Initialize ICU, call introduced in V8 5.3.178 */ /* Initialize ICU, call introduced in V8 5.3.178 */
if (v8js_process_globals.icudtl_dat_path != NULL && v8js_process_globals.icudtl_dat_path[0] != 0) {
v8::V8::InitializeICUDefaultLocation(nullptr, v8js_process_globals.icudtl_dat_path);
}
#ifdef PHP_V8_EXEC_PATH
else {
v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr); v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
}
#endif #endif
#endif /* PHP_V8_API_VERSION >= 5003178 */
/* Initialize V8 */ /* Initialize V8 */
v8::V8::Initialize(); v8::V8::Initialize();