summaryrefslogtreecommitdiff
path: root/ext/json/json.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@ohgaki.net>2015-08-05 14:36:37 +0900
committerJakub Zelenka <bukka@php.net>2016-06-26 13:26:43 +0100
commit3aa2aadcf0c39d7d22532c46d8921f443d27166f (patch)
treebc11f20aee95df13fb78072ddb85c53127e05121 /ext/json/json.c
parentf943daf2d7eeed98d3ead5c05637c2ea8a2ff0e6 (diff)
downloadphp-git-3aa2aadcf0c39d7d22532c46d8921f443d27166f.tar.gz
Add JSON_G(precision)
Diffstat (limited to 'ext/json/json.c')
-rw-r--r--ext/json/json.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/ext/json/json.c b/ext/json/json.c
index d3c6111d4d..0cfffe8b66 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -93,6 +93,31 @@ static const zend_function_entry json_serializable_interface[] = {
};
/* }}} */
+
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnSetJsonPrecision)
+{
+ zend_long i;
+
+ ZEND_ATOL(i, ZSTR_VAL(new_value));
+ if (i >= -1) {
+ JSON_G(precision) = i;
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
+}
+/* }}} */
+
+
+/* {{{ PHP_INI
+ */
+PHP_INI_BEGIN()
+STD_PHP_INI_ENTRY("json.precision", "-1", PHP_INI_ALL, OnSetJsonPrecision, precision, zend_json_globals, json_globals)
+PHP_INI_END()
+/* }}} */
+
/* Register constant for options and errors */
#define PHP_JSON_REGISTER_CONSTANT(_name, _value) \
REGISTER_LONG_CONSTANT(_name, _value, CONST_CS | CONST_PERSISTENT);
@@ -102,6 +127,8 @@ static PHP_MINIT_FUNCTION(json)
{
zend_class_entry ce;
+ REGISTER_INI_ENTRIES();
+
INIT_CLASS_ENTRY(ce, "JsonSerializable", json_serializable_interface);
php_json_serializable_ce = zend_register_internal_interface(&ce);
@@ -153,6 +180,16 @@ static PHP_GINIT_FUNCTION(json)
}
/* }}} */
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+*/
+static PHP_MSHUTDOWN_FUNCTION(json)
+{
+ UNREGISTER_INI_ENTRIES();
+
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ json_module_entry
*/
@@ -161,7 +198,7 @@ zend_module_entry json_module_entry = {
"json",
json_functions,
PHP_MINIT(json),
- NULL,
+ PHP_MSHUTDOWN(json),
NULL,
NULL,
PHP_MINFO(json),