Skip to content

Commit 8304e46

Browse files
committed
Replace encoder functions json prefix with php_json
1 parent 1e49e96 commit 8304e46

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

ext/json/json_encoder.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ ZEND_DECLARE_MODULE_GLOBALS(json)
3434

3535
static const char digits[] = "0123456789abcdef";
3636

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);
3838

39-
static int json_determine_array_type(zval *val) /* {{{ */
39+
static int php_json_determine_array_type(zval *val) /* {{{ */
4040
{
4141
int i;
4242
HashTable *myht = HASH_OF(val);
@@ -65,15 +65,15 @@ static int json_determine_array_type(zval *val) /* {{{ */
6565

6666
/* {{{ Pretty printing support functions */
6767

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) /* {{{ */
6969
{
7070
if (options & PHP_JSON_PRETTY_PRINT) {
7171
smart_str_appendc(buf, c);
7272
}
7373
}
7474
/* }}} */
7575

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) /* {{{ */
7777
{
7878
int i;
7979

@@ -87,14 +87,14 @@ static inline void json_pretty_print_indent(smart_str *buf, int options) /* {{{
8787

8888
/* }}} */
8989

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) /* {{{ */
9191
{
9292
int i, r, need_comma = 0;
9393
HashTable *myht;
9494

9595
if (Z_TYPE_P(val) == IS_ARRAY) {
9696
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);
9898
} else {
9999
myht = Z_OBJPROP_P(val);
100100
r = PHP_JSON_OUTPUT_OBJECT;
@@ -136,8 +136,8 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
136136
need_comma = 1;
137137
}
138138

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);
141141
php_json_encode(buf, data, options);
142142
} else if (r == PHP_JSON_OUTPUT_OBJECT) {
143143
if (key) {
@@ -155,13 +155,13 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
155155
need_comma = 1;
156156
}
157157

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);
160160

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);
162162
smart_str_appendc(buf, ':');
163163

164-
json_pretty_print_char(buf, options, ' ');
164+
php_json_pretty_print_char(buf, options, ' ');
165165

166166
php_json_encode(buf, data, options);
167167
} else {
@@ -171,15 +171,15 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
171171
need_comma = 1;
172172
}
173173

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);
176176

177177
smart_str_appendc(buf, '"');
178178
smart_str_append_long(buf, (zend_long) index);
179179
smart_str_appendc(buf, '"');
180180
smart_str_appendc(buf, ':');
181181

182-
json_pretty_print_char(buf, options, ' ');
182+
php_json_pretty_print_char(buf, options, ' ');
183183

184184
php_json_encode(buf, data, options);
185185
}
@@ -198,8 +198,8 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
198198

199199
/* Only keep closing bracket on same line for empty arrays/objects */
200200
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);
203203
}
204204

205205
if (r == PHP_JSON_OUTPUT_ARRAY) {
@@ -210,7 +210,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options) /* {{{ */
210210
}
211211
/* }}} */
212212

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) /* {{{ */
214214
{
215215
size_t pos = 0, us;
216216
int j, status;
@@ -247,7 +247,7 @@ static int json_utf8_to_utf16(unsigned short *utf16, char utf8[], int len) /* {{
247247
}
248248
/* }}} */
249249

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) /* {{{ */
251251
{
252252
int status;
253253
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)
284284

285285
if (options & PHP_JSON_UNESCAPED_UNICODE) {
286286
/* 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) {
288288
JSON_G(error_code) = PHP_JSON_ERROR_UTF8;
289289
smart_str_appendl(buf, "null", 4);
290290
return;
@@ -417,7 +417,7 @@ static void json_escape_string(smart_str *buf, char *s, size_t len, int options)
417417
}
418418
/* }}} */
419419

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) /* {{{ */
421421
{
422422
zend_class_entry *ce = Z_OBJCE_P(val);
423423
zval retval, fname;
@@ -455,7 +455,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio
455455
if ((Z_TYPE(retval) == IS_OBJECT) &&
456456
(Z_OBJ_HANDLE(retval) == Z_OBJ_HANDLE_P(val))) {
457457
/* 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);
459459
} else {
460460
/* All other types, encode as normal */
461461
php_json_encode(buf, &retval, options);
@@ -504,17 +504,17 @@ void php_json_encode_zval(smart_str *buf, zval *val, int options) /* {{{ */
504504
break;
505505

506506
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);
508508
break;
509509

510510
case IS_OBJECT:
511511
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);
513513
break;
514514
}
515515
/* fallthrough -- Non-serializable object */
516516
case IS_ARRAY:
517-
json_encode_array(buf, val, options);
517+
php_json_encode_array(buf, val, options);
518518
break;
519519

520520
case IS_REFERENCE:

0 commit comments

Comments
 (0)