com php-src: Add return code from json API functions: ext/json/json.c ext/json/php_json.h
| From: | Jakub Zelenka | Date: | Tue, 28 Jun 2016 19:49:38 +0000 |
| Subject: | com php-src: Add return code from json API functions: ext/json/json.c ext/json/php_json.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92717@lists.php.net to get a copy of this message | ||
Commit: bea131f0bcbf4d61dd5f8d814b865183f8f1b657
Author: Jakub Zelenka <bukka@php.net> Tue, 28 Jun 2016 20:49:38 +0100
Parents: 0a4f89bc292c3c82ff719cd79e66ef96c2079526
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bea131f0bcbf4d61dd5f8d814b865183f8f1b657
Log:
Add return code from json API functions
It will allow fix few json bugs in a better way
Changed paths:
M ext/json/json.c
M ext/json/php_json.h
Diff:
diff --git a/ext/json/json.c b/ext/json/json.c
index 8bb5e51..e8b111b 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -184,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;
@@ -198,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;
}
/* }}} */
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
index d1fabd1..045ca02 100644
--- a/ext/json/php_json.h
+++ b/ext/json/php_json.h
@@ -93,12 +93,12 @@ PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS(json)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
-PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options);
-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_encode(smart_str *buf, zval *val, int options);
+PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long
options, zend_long depth);
-static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc,
zend_long depth)
+static inline int php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc,
zend_long depth)
{
- php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth);
+ return php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0,
depth);
}