diff options
Diffstat (limited to 'ext/json/json.c')
-rw-r--r-- | ext/json/json.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/ext/json/json.c b/ext/json/json.c index 61445ee114..2acfb5e79f 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -33,14 +33,6 @@ #include "php_json_parser.h" #include <zend_exceptions.h> -#include <float.h> -#if defined(DBL_MANT_DIG) && defined(DBL_MIN_EXP) -#define NUM_BUF_SIZE (3 + DBL_MANT_DIG - DBL_MIN_EXP) -#else -#define NUM_BUF_SIZE 1080 -#endif - - static PHP_MINFO_FUNCTION(json); static PHP_FUNCTION(json_encode); static PHP_FUNCTION(json_decode); @@ -117,6 +109,7 @@ static PHP_MINIT_FUNCTION(json) PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE); PHP_JSON_REGISTER_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR); PHP_JSON_REGISTER_CONSTANT("JSON_PRESERVE_ZERO_FRACTION", PHP_JSON_PRESERVE_ZERO_FRACTION); + PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_LINE_TERMINATORS", PHP_JSON_UNESCAPED_LINE_TERMINATORS); /* options for json_decode */ PHP_JSON_REGISTER_CONSTANT("JSON_OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY); @@ -191,13 +184,15 @@ static PHP_MINFO_FUNCTION(json) } /* }}} */ -PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options) /* {{{ */ +PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options) /* {{{ */ { php_json_encode_zval(buf, val, options); + + return JSON_G(error_code) > 0 ? FAILURE : SUCCESS; } /* }}} */ -PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */ +PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */ { php_json_parser parser; @@ -205,8 +200,11 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_l if (php_json_yyparse(&parser)) { JSON_G(error_code) = php_json_parser_error_code(&parser); - RETURN_NULL(); + RETVAL_NULL(); + return FAILURE; } + + return SUCCESS; } /* }}} */ |