@@ -34,9 +34,9 @@ ZEND_DECLARE_MODULE_GLOBALS(json)
34
34
35
35
static const char digits [] = "0123456789abcdef" ;
36
36
37
- static void json_escape_string (smart_str * buf , char * s , size_t len , int options );
37
+ static void php_json_escape_string (smart_str * buf , char * s , size_t len , int options );
38
38
39
- static int json_determine_array_type (zval * val ) /* {{{ */
39
+ static int php_json_determine_array_type (zval * val ) /* {{{ */
40
40
{
41
41
int i ;
42
42
HashTable * myht = HASH_OF (val );
@@ -65,15 +65,15 @@ static int json_determine_array_type(zval *val) /* {{{ */
65
65
66
66
/* {{{ Pretty printing support functions */
67
67
68
- static inline void json_pretty_print_char (smart_str * buf , int options , char c ) /* {{{ */
68
+ static inline void php_json_pretty_print_char (smart_str * buf , int options , char c ) /* {{{ */
69
69
{
70
70
if (options & PHP_JSON_PRETTY_PRINT ) {
71
71
smart_str_appendc (buf , c );
72
72
}
73
73
}
74
74
/* }}} */
75
75
76
- static inline void json_pretty_print_indent (smart_str * buf , int options ) /* {{{ */
76
+ static inline void php_json_pretty_print_indent (smart_str * buf , int options ) /* {{{ */
77
77
{
78
78
int i ;
79
79
@@ -87,14 +87,14 @@ static inline void json_pretty_print_indent(smart_str *buf, int options) /* {{{
87
87
88
88
/* }}} */
89
89
90
- static void json_encode_array (smart_str * buf , zval * val , int options ) /* {{{ */
90
+ static void php_json_encode_array (smart_str * buf , zval * val , int options ) /* {{{ */
91
91
{
92
92
int i , r , need_comma = 0 ;
93
93
HashTable * myht ;
94
94
95
95
if (Z_TYPE_P (val ) == IS_ARRAY ) {
96
96
myht = HASH_OF (val );
97
- r = (options & PHP_JSON_FORCE_OBJECT ) ? PHP_JSON_OUTPUT_OBJECT : json_determine_array_type (val );
97
+ r = (options & PHP_JSON_FORCE_OBJECT ) ? PHP_JSON_OUTPUT_OBJECT : php_json_determine_array_type (val );
98
98
} else {
99
99
myht = Z_OBJPROP_P (val );
100
100
r = PHP_JSON_OUTPUT_OBJECT ;
@@ -136,8 +136,8 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
136
136
need_comma = 1 ;
137
137
}
138
138
139
- json_pretty_print_char (buf , options , '\n' );
140
- json_pretty_print_indent (buf , options );
139
+ php_json_pretty_print_char (buf , options , '\n' );
140
+ php_json_pretty_print_indent (buf , options );
141
141
php_json_encode (buf , data , options );
142
142
} else if (r == PHP_JSON_OUTPUT_OBJECT ) {
143
143
if (key ) {
@@ -155,13 +155,13 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
155
155
need_comma = 1 ;
156
156
}
157
157
158
- json_pretty_print_char (buf , options , '\n' );
159
- json_pretty_print_indent (buf , options );
158
+ php_json_pretty_print_char (buf , options , '\n' );
159
+ php_json_pretty_print_indent (buf , options );
160
160
161
- json_escape_string (buf , key -> val , key -> len , options & ~PHP_JSON_NUMERIC_CHECK );
161
+ php_json_escape_string (buf , key -> val , key -> len , options & ~PHP_JSON_NUMERIC_CHECK );
162
162
smart_str_appendc (buf , ':' );
163
163
164
- json_pretty_print_char (buf , options , ' ' );
164
+ php_json_pretty_print_char (buf , options , ' ' );
165
165
166
166
php_json_encode (buf , data , options );
167
167
} else {
@@ -171,15 +171,15 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
171
171
need_comma = 1 ;
172
172
}
173
173
174
- json_pretty_print_char (buf , options , '\n' );
175
- json_pretty_print_indent (buf , options );
174
+ php_json_pretty_print_char (buf , options , '\n' );
175
+ php_json_pretty_print_indent (buf , options );
176
176
177
177
smart_str_appendc (buf , '"' );
178
178
smart_str_append_long (buf , (zend_long ) index );
179
179
smart_str_appendc (buf , '"' );
180
180
smart_str_appendc (buf , ':' );
181
181
182
- json_pretty_print_char (buf , options , ' ' );
182
+ php_json_pretty_print_char (buf , options , ' ' );
183
183
184
184
php_json_encode (buf , data , options );
185
185
}
@@ -198,8 +198,8 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
198
198
199
199
/* Only keep closing bracket on same line for empty arrays/objects */
200
200
if (need_comma ) {
201
- json_pretty_print_char (buf , options , '\n' );
202
- json_pretty_print_indent (buf , options );
201
+ php_json_pretty_print_char (buf , options , '\n' );
202
+ php_json_pretty_print_indent (buf , options );
203
203
}
204
204
205
205
if (r == PHP_JSON_OUTPUT_ARRAY ) {
@@ -210,7 +210,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
210
210
}
211
211
/* }}} */
212
212
213
- static int json_utf8_to_utf16 (unsigned short * utf16 , char utf8 [], int len ) /* {{{ */
213
+ static int php_json_utf8_to_utf16 (unsigned short * utf16 , char utf8 [], int len ) /* {{{ */
214
214
{
215
215
size_t pos = 0 , us ;
216
216
int j , status ;
@@ -247,7 +247,7 @@ static int json_utf8_to_utf16(unsigned short *utf16, char utf8[], int len) /* {{
247
247
}
248
248
/* }}} */
249
249
250
- static void json_escape_string (smart_str * buf , char * s , size_t len , int options ) /* {{{ */
250
+ static void php_json_escape_string (smart_str * buf , char * s , size_t len , int options ) /* {{{ */
251
251
{
252
252
int status ;
253
253
unsigned int us , next_us = 0 ;
@@ -284,7 +284,7 @@ static void json_escape_string(smart_str *buf, char *s, size_t len, int options)
284
284
285
285
if (options & PHP_JSON_UNESCAPED_UNICODE ) {
286
286
/* validate UTF-8 string first */
287
- if (json_utf8_to_utf16 (NULL , s , len ) < 0 ) {
287
+ if (php_json_utf8_to_utf16 (NULL , s , len ) < 0 ) {
288
288
JSON_G (error_code ) = PHP_JSON_ERROR_UTF8 ;
289
289
smart_str_appendl (buf , "null" , 4 );
290
290
return ;
@@ -417,7 +417,7 @@ static void json_escape_string(smart_str *buf, char *s, size_t len, int options)
417
417
}
418
418
/* }}} */
419
419
420
- static void json_encode_serializable_object (smart_str * buf , zval * val , int options ) /* {{{ */
420
+ static void php_json_encode_serializable_object (smart_str * buf , zval * val , int options ) /* {{{ */
421
421
{
422
422
zend_class_entry * ce = Z_OBJCE_P (val );
423
423
zval retval , fname ;
@@ -455,7 +455,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio
455
455
if ((Z_TYPE (retval ) == IS_OBJECT ) &&
456
456
(Z_OBJ_HANDLE (retval ) == Z_OBJ_HANDLE_P (val ))) {
457
457
/* Handle the case where jsonSerialize does: return $this; by going straight to encode array */
458
- json_encode_array (buf , & retval , options );
458
+ php_json_encode_array (buf , & retval , options );
459
459
} else {
460
460
/* All other types, encode as normal */
461
461
php_json_encode (buf , & retval , options );
@@ -504,17 +504,17 @@ void php_json_encode_zval(smart_str *buf, zval *val, int options) /* {{{ */
504
504
break ;
505
505
506
506
case IS_STRING :
507
- json_escape_string (buf , Z_STRVAL_P (val ), Z_STRLEN_P (val ), options );
507
+ php_json_escape_string (buf , Z_STRVAL_P (val ), Z_STRLEN_P (val ), options );
508
508
break ;
509
509
510
510
case IS_OBJECT :
511
511
if (instanceof_function (Z_OBJCE_P (val ), php_json_serializable_ce )) {
512
- json_encode_serializable_object (buf , val , options );
512
+ php_json_encode_serializable_object (buf , val , options );
513
513
break ;
514
514
}
515
515
/* fallthrough -- Non-serializable object */
516
516
case IS_ARRAY :
517
- json_encode_array (buf , val , options );
517
+ php_json_encode_array (buf , val , options );
518
518
break ;
519
519
520
520
case IS_REFERENCE :
0 commit comments