com php-src: basic fixes for ext/json: ext/json/JSON_parser .c ext/json/JSON_parser.h ext/json/json.c ext/jso n/php_json.h

From: Date: Fri, 29 Nov 2013 10:47:48 +0000
Subject: com php-src: basic fixes for ext/json: ext/json/JSON_parser .c ext/json/JSON_parser.h ext/json/json.c ext/jso n/php_json.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74163@lists.php.net to get a copy of this message
Commit: 3ffecac9163826f7160660996ee77d3dc54f8fa0 Author: Anatol Belski <ab@php.net> Fri, 29 Nov 2013 11:47:48 +0100 Parents: e6bf5ffebae2c219fc696a768ea0840d2d9c0733 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3ffecac9163826f7160660996ee77d3dc54f8fa0 Log: basic fixes for ext/json Changed paths: M ext/json/JSON_parser.c M ext/json/JSON_parser.h M ext/json/json.c M ext/json/php_json.h Diff: diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index dd832a7..b95629e 100644 --- a/ext/json/JSON_parser.c +++ b/ext/json/JSON_parser.c @@ -328,7 +328,7 @@ static void json_create_zval(zval **z, smart_str *buf, int type, int options) } } - ZVAL_LONG(*z, strtol(buf->c, NULL, 10)); + ZVAL_LONG(*z, ZEND_STRTOL(buf->c, NULL, 10)); } else if (type == IS_DOUBLE) { @@ -436,7 +436,7 @@ static void attach_zval(JSON_parser jp, int up, int cur, smart_str *key, int ass machine with a stack. */ int -parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int options TSRMLS_DC) +parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], zend_str_size_int length, int options TSRMLS_DC) { int next_char; /* the next character */ int next_class; /* the next character class */ diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 8671765..b3bcd8c 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -32,7 +32,7 @@ enum error_codes { }; extern JSON_parser new_JSON_parser(int depth); -extern int parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int options TSRMLS_DC); +extern int parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], zend_str_size_int length, int options TSRMLS_DC); extern int free_JSON_parser(JSON_parser jp); static inline int parse_JSON(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int assoc TSRMLS_DC) diff --git a/ext/json/json.c b/ext/json/json.c index d017753..f459df0 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -177,8 +177,8 @@ static int json_determine_array_type(zval **val TSRMLS_DC) /* {{{ */ i = myht ? zend_hash_num_elements(myht) : 0; if (i > 0) { char *key; - ulong index, idx; - uint key_len; + php_uint_t index, idx; + zend_str_size_uint key_len; HashPosition pos; zend_hash_internal_pointer_reset_ex(myht, &pos); @@ -262,8 +262,8 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) { char *key; zval **data; - ulong index; - uint key_len; + php_uint_t index; + zend_str_size_uint key_len; HashPosition pos; HashTable *tmp_ht; int need_comma = 0; @@ -326,7 +326,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) json_pretty_print_indent(buf, options TSRMLS_CC); smart_str_appendc(buf, '"'); - smart_str_append_long(buf, (long) index); + smart_str_append_long(buf, (php_int_t) index); smart_str_appendc(buf, '"'); smart_str_appendc(buf, ':'); @@ -358,10 +358,11 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) } /* }}} */ -static int json_utf8_to_utf16(unsigned short *utf16, char utf8[], int len) /* {{{ */ +static int json_utf8_to_utf16(unsigned short *utf16, char utf8[], zend_str_size_int len) /* {{{ */ { size_t pos = 0, us; - int j, status; + zend_str_size_int j; + int status; if (utf16) { /* really convert the utf8 string */ @@ -411,7 +412,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR if (options & PHP_JSON_NUMERIC_CHECK) { double d; int type; - long p; + php_int_t p; if ((type = is_numeric_string(s, len, &p, &d, 0)) != 0) { if (type == IS_LONG) { @@ -419,7 +420,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR } else if (type == IS_DOUBLE) { if (!zend_isinf(d) && !zend_isnan(d)) { char *tmp; - int l = spprintf(&tmp, 0, "%.*k", (int) EG(precision), d); + zend_str_size_int l = spprintf(&tmp, 0, "%.*k", (int) EG(precision), d); smart_str_appendl(buf, tmp, l); efree(tmp); } else { @@ -600,7 +601,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio } /* }}} */ -PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC) /* {{{ */ +PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, php_int_t options TSRMLS_DC) /* {{{ */ { switch (Z_TYPE_P(val)) { @@ -623,7 +624,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ case IS_DOUBLE: { char *d = NULL; - int len; + php_int_t len; double dbl = Z_DVAL_P(val); if (!zend_isinf(dbl) && !zend_isnan(dbl)) { @@ -638,7 +639,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ break; case IS_STRING: - json_escape_string(buf, Z_STRVAL_P(val), Z_STRLEN_P(val), options TSRMLS_CC); + json_escape_string(buf, Z_STRVAL_P(val), Z_STRSIZE_P(val), options TSRMLS_CC); break; case IS_OBJECT: @@ -661,7 +662,7 @@ PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_ } /* }}} */ -PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, long depth TSRMLS_DC) /* {{{ */ +PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, zend_str_size_int str_len, php_int_t options, php_int_t depth TSRMLS_DC) /* {{{ */ { int utf16_len; zval *z; @@ -694,9 +695,9 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, { double d; int type, overflow_info; - long p; + php_int_t p; char *trim = str; - int trim_len = str_len; + zend_str_size_int trim_len = str_len; /* Increment trimmed string pointer to strip leading whitespace */ /* JSON RFC says to consider as whitespace: space, tab, LF or CR */ @@ -776,10 +777,10 @@ static PHP_FUNCTION(json_encode) { zval *parameter; smart_str buf = {0}; - long options = 0; - long depth = JSON_PARSER_DEFAULT_DEPTH; + php_int_t options = 0; + php_int_t depth = JSON_PARSER_DEFAULT_DEPTH; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &parameter, &options, &depth) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ii", &parameter, &options, &depth) == FAILURE) { return; } @@ -804,12 +805,12 @@ static PHP_FUNCTION(json_encode) static PHP_FUNCTION(json_decode) { char *str; - int str_len; + zend_str_size_int str_len; zend_bool assoc = 0; /* return JS objects as PHP objects by default */ - long depth = JSON_PARSER_DEFAULT_DEPTH; - long options = 0; + php_int_t depth = JSON_PARSER_DEFAULT_DEPTH; + php_int_t options = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bll", &str, &str_len, &assoc, &depth, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|bii", &str, &str_len, &assoc, &depth, &options) == FAILURE) { return; } diff --git a/ext/json/php_json.h b/ext/json/php_json.h index ec707ce..861cd7d 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -49,8 +49,8 @@ ZEND_END_MODULE_GLOBALS(json) # define JSON_G(v) (json_globals.v) #endif -PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC); -PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len, int options, long depth TSRMLS_DC); +PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, php_int_t options TSRMLS_DC); +PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, zend_str_size_int str_len, php_int_t options, php_int_t depth TSRMLS_DC); extern zend_class_entry *php_json_serializable_ce; @@ -74,7 +74,7 @@ extern zend_class_entry *php_json_serializable_ce; #define PHP_JSON_OBJECT_AS_ARRAY (1<<0) #define PHP_JSON_BIGINT_AS_STRING (1<<1) -static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, long depth TSRMLS_DC) +static inline void php_json_decode(zval *return_value, char *str, zend_str_size_int str_len, zend_bool assoc, php_int_t depth TSRMLS_DC) { php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth TSRMLS_CC); }

« previous php.cvs (#74163) next »