]> granicus.if.org Git - php/commitdiff
ported ext/json
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 18:15:59 +0000 (20:15 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 18:15:59 +0000 (20:15 +0200)
ext/json/JSON_parser.c
ext/json/json.c
ext/json/php_json.h

index a4e34b07bc7498afcbf846375eef38dc562322e7..f2a1ee4dda77a3c52c715b67cdf40f09fb6043d0 100644 (file)
@@ -373,7 +373,7 @@ static void utf16_to_utf8(smart_str *buf, unsigned short utf16)
                 && ((unsigned char) buf->s->val[buf->s->len - 1] & 0xc0) == 0x80)
     {
         /* found surrogate pair */
-        unsigned long utf32;
+        php_uint_t utf32;
 
         utf32 = (((buf->s->val[buf->s->len - 2] & 0xf) << 16)
                     | ((buf->s->val[buf->s->len - 1] & 0x3f) << 10)
index 4e3692a543fd7b43a45d229e7a1fd180bf5e8341..60893fe1ea33202457cdefbc38cb764f9b7af44f 100644 (file)
@@ -177,7 +177,7 @@ static int json_determine_array_type(zval *val TSRMLS_DC) /* {{{ */
        i = myht ? zend_hash_num_elements(myht) : 0;
        if (i > 0) {
                zend_string *key;
-               ulong index, idx;
+               php_uint_t index, idx;
 
                idx = 0;
                ZEND_HASH_FOREACH_KEY(myht, index, key) {
@@ -252,7 +252,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options TSRMLS_DC)
        if (i > 0) {
                zend_string *key;
                zval *data;
-               ulong index;
+               php_uint_t index;
                HashTable *tmp_ht;
 
                ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) {
@@ -308,7 +308,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_int(buf, (long) index);
+                                       smart_str_append_int(buf, (php_int_t) index);
                                        smart_str_appendc(buf, '"');
                                        smart_str_appendc(buf, ':');
 
@@ -395,7 +395,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_INT) {
@@ -651,7 +651,7 @@ again:
 }
 /* }}} */
 
-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, int str_len, int options, php_int_t depth TSRMLS_DC) /* {{{ */
 {
        int utf16_len;
        unsigned short *utf16;
@@ -678,7 +678,7 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len,
        if (!parse_JSON_ex(jp, return_value, utf16, utf16_len, options TSRMLS_CC)) {
                double d;
                int type, overflow_info;
-               long p;
+               php_int_t p;
                char *trim = str;
                int trim_len = str_len;
 
@@ -758,10 +758,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;
        }
 
@@ -788,10 +788,10 @@ static PHP_FUNCTION(json_decode)
        char *str;
        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;
        }
 
index e00de6a27b8cde2c1a68e11de99f8bb7ffdc9910..b42aecba7d7ff72551cfdc8346ab40f58304c97f 100644 (file)
@@ -50,7 +50,7 @@ ZEND_END_MODULE_GLOBALS(json)
 #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_decode_ex(zval *return_value, char *str, int str_len, int options, php_int_t depth TSRMLS_DC);
 extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
 
 
@@ -74,7 +74,7 @@ extern PHP_JSON_API 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, 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);
 }