Lines Matching refs:s
26 #define YYCURSOR s->cursor
27 #define YYLIMIT s->limit
28 #define YYMARKER s->marker
29 #define YYCTXMARKER s->ctxmarker
31 #define YYGETCONDITION() s->state
32 #define YYSETCONDITION(yystate) s->state = yystate
39 #define PHP_JSON_SCANNER_COPY_ESC() php_json_scanner_copy_string(s, 0)
40 #define PHP_JSON_SCANNER_COPY_UTF() php_json_scanner_copy_string(s, 5)
41 #define PHP_JSON_SCANNER_COPY_UTF_SP() php_json_scanner_copy_string(s, 11)
46 static void php_json_scanner_copy_string(php_json_scanner *s, int esc_size)
48 size_t len = s->cursor - s->str_start - esc_size - 1;
50 memcpy(s->pstr, s->str_start, len);
51 s->pstr += len;
69 static int php_json_ucs2_to_int_ex(php_json_scanner *s, int size, int start)
72 php_json_ctype *pc = s->cursor - start;
79 static int php_json_ucs2_to_int(php_json_scanner *s, int size)
81 return php_json_ucs2_to_int_ex(s, size, 1);
84 void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options)
86 s->cursor = (php_json_ctype *) str;
87 s->limit = (php_json_ctype *) str + str_len;
88 s->options = options;
92 int php_json_scan(php_json_scanner *s)
94 ZVAL_NULL(&s->value);
97 s->token = s->cursor;
149 ZVAL_NULL(&s->value);
153 ZVAL_TRUE(&s->value);
157 ZVAL_FALSE(&s->value);
161 zend_bool bigint = 0, negative = s->token[0] == '-';
162 size_t digits = (size_t) (s->cursor - s->token - negative);
165 int cmp = strncmp((char *) (s->token + negative), LONG_MIN_DIGITS, PHP_JSON_INT_MAX_LENGTH);
174 ZVAL_LONG(&s->value, ZEND_STRTOL((char *) s->token, NULL, 10));
176 } else if (s->options & PHP_JSON_BIGINT_AS_STRING) {
177 ZVAL_STRINGL(&s->value, (char *) s->token, s->cursor - s->token);
180 ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
185 ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
190 if (s->limit < s->cursor) {
193 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
198 s->str_start = s->cursor;
199 s->str_esc = 0;
204 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
208 s->errcode = PHP_JSON_ERROR_SYNTAX;
212 s->errcode = PHP_JSON_ERROR_UTF8;
217 s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
221 s->str_esc += 5;
225 s->str_esc += 4;
229 s->str_esc += 3;
233 s->str_esc += 8;
237 s->errcode = PHP_JSON_ERROR_UTF16;
241 s->str_esc++;
245 s->errcode = PHP_JSON_ERROR_SYNTAX;
250 size_t len = s->cursor - s->str_start - s->str_esc - 1;
253 ZVAL_EMPTY_STRING(&s->value);
258 ZVAL_STR(&s->value, str);
259 if (s->str_esc) {
260 s->pstr = (php_json_ctype *) Z_STRVAL(s->value);
261 s->cursor = s->str_start;
265 memcpy(Z_STRVAL(s->value), s->str_start, len);
272 s->errcode = PHP_JSON_ERROR_UTF8;
277 int utf16 = php_json_ucs2_to_int(s, 2);
279 *(s->pstr++) = (char) utf16;
280 s->str_start = s->cursor;
284 int utf16 = php_json_ucs2_to_int(s, 3);
286 *(s->pstr++) = (char) (0xc0 | (utf16 >> 6));
287 *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
288 s->str_start = s->cursor;
292 int utf16 = php_json_ucs2_to_int(s, 4);
294 *(s->pstr++) = (char) (0xe0 | (utf16 >> 12));
295 *(s->pstr++) = (char) (0x80 | ((utf16 >> 6) & 0x3f));
296 *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
297 s->str_start = s->cursor;
302 utf16_hi = php_json_ucs2_to_int(s, 4);
303 utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
306 *(s->pstr++) = (char) (0xf0 | (utf32 >> 18));
307 *(s->pstr++) = (char) (0x80 | ((utf32 >> 12) & 0x3f));
308 *(s->pstr++) = (char) (0x80 | ((utf32 >> 6) & 0x3f));
309 *(s->pstr++) = (char) (0x80 | (utf32 & 0x3f));
310 s->str_start = s->cursor;
316 switch (*s->cursor) {
335 esc = *s->cursor;
338 s->errcode = PHP_JSON_ERROR_SYNTAX;
341 *(s->pstr++) = esc;
343 s->str_start = s->cursor;
353 s->errcode = PHP_JSON_ERROR_SYNTAX;