yajl-ruby 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yajl-ruby might be problematic. Click here for more details.
- data/CHANGELOG.md +8 -1
- data/MIT-LICENSE +3 -3
- data/README.rdoc +8 -8
- data/VERSION.yml +1 -1
- data/benchmark/subjects/ohai.yml +171 -171
- data/ext/api/yajl_common.h +9 -9
- data/ext/api/yajl_gen.h +10 -10
- data/ext/api/yajl_parse.h +15 -15
- data/ext/yajl.c +8 -8
- data/ext/yajl_alloc.c +6 -6
- data/ext/yajl_alloc.h +6 -6
- data/ext/yajl_buf.c +7 -7
- data/ext/yajl_buf.h +7 -7
- data/ext/yajl_bytestack.h +10 -10
- data/ext/yajl_encode.c +12 -12
- data/ext/yajl_encode.h +6 -6
- data/ext/yajl_ext.c +67 -80
- data/ext/yajl_ext.h +4 -4
- data/ext/yajl_gen.c +16 -16
- data/ext/yajl_lex.c +79 -76
- data/ext/yajl_lex.h +14 -14
- data/ext/yajl_parser.c +34 -34
- data/ext/yajl_parser.h +7 -7
- data/lib/yajl.rb +7 -7
- data/lib/yajl/bzip2/stream_reader.rb +1 -11
- data/lib/yajl/bzip2/stream_writer.rb +1 -1
- data/lib/yajl/deflate/stream_reader.rb +6 -7
- data/lib/yajl/deflate/stream_writer.rb +2 -2
- data/lib/yajl/gzip/stream_reader.rb +0 -10
- data/lib/yajl/http_stream.rb +12 -12
- data/lib/yajl/json_gem/encoding.rb +4 -4
- data/lib/yajl/json_gem/parsing.rb +3 -3
- data/spec/encoding/encoding_spec.rb +23 -23
- data/spec/global/global_spec.rb +8 -8
- data/spec/http/http_delete_spec.rb +13 -13
- data/spec/http/http_error_spec.rb +2 -2
- data/spec/http/http_get_spec.rb +15 -15
- data/spec/http/http_post_spec.rb +12 -12
- data/spec/http/http_put_spec.rb +14 -14
- data/spec/json_gem_compatibility/compatibility_spec.rb +21 -21
- data/spec/parsing/active_support_spec.rb +6 -6
- data/spec/parsing/chunked_spec.rb +12 -12
- data/spec/parsing/fixtures_spec.rb +4 -4
- data/spec/parsing/one_off_spec.rb +9 -9
- data/yajl-ruby.gemspec +3 -3
- metadata +12 -5
data/ext/yajl_ext.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright (c) 2008-2009 Brian Lopez - http://github.com/brianmario
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
* a copy of this software and associated documentation files (the
|
6
6
|
* "Software"), to deal in the Software without restriction, including
|
@@ -8,10 +8,10 @@
|
|
8
8
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
9
9
|
* permit persons to whom the Software is furnished to do so, subject to
|
10
10
|
* the following conditions:
|
11
|
-
*
|
11
|
+
*
|
12
12
|
* The above copyright notice and this permission notice shall be
|
13
13
|
* included in all copies or substantial portions of the Software.
|
14
|
-
*
|
14
|
+
*
|
15
15
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
16
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
17
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -48,7 +48,7 @@ int utf8Encoding;
|
|
48
48
|
#endif
|
49
49
|
|
50
50
|
static VALUE cParseError, cEncodeError, mYajl, cParser, cEncoder;
|
51
|
-
static ID intern_io_read,
|
51
|
+
static ID intern_io_read, intern_call, intern_keys, intern_to_s,
|
52
52
|
intern_to_json, intern_has_key, intern_to_sym;
|
53
53
|
static ID sym_allow_comments, sym_check_utf8, sym_pretty, sym_indent, sym_terminator, sym_symbolize_keys;
|
54
54
|
|
data/ext/yajl_gen.c
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright 2007-2009, Lloyd Hilaiel.
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* Redistribution and use in source and binary forms, with or without
|
5
5
|
* modification, are permitted provided that the following conditions are
|
6
6
|
* met:
|
7
|
-
*
|
7
|
+
*
|
8
8
|
* 1. Redistributions of source code must retain the above copyright
|
9
9
|
* notice, this list of conditions and the following disclaimer.
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* 2. Redistributions in binary form must reproduce the above copyright
|
12
12
|
* notice, this list of conditions and the following disclaimer in
|
13
13
|
* the documentation and/or other materials provided with the
|
14
14
|
* distribution.
|
15
|
-
*
|
15
|
+
*
|
16
16
|
* 3. Neither the name of Lloyd Hilaiel nor the names of its
|
17
17
|
* contributors may be used to endorse or promote products derived
|
18
18
|
* from this software without specific prior written permission.
|
19
|
-
*
|
19
|
+
*
|
20
20
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
21
21
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
22
22
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
@@ -28,7 +28,7 @@
|
|
28
28
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
29
29
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
30
|
* POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
*/
|
31
|
+
*/
|
32
32
|
|
33
33
|
#include "api/yajl_gen.h"
|
34
34
|
#include "yajl_buf.h"
|
@@ -50,7 +50,7 @@ typedef enum {
|
|
50
50
|
yajl_gen_error
|
51
51
|
} yajl_gen_state;
|
52
52
|
|
53
|
-
struct yajl_gen_t
|
53
|
+
struct yajl_gen_t
|
54
54
|
{
|
55
55
|
unsigned int depth;
|
56
56
|
unsigned int pretty;
|
@@ -125,7 +125,7 @@ yajl_gen_free(yajl_gen g)
|
|
125
125
|
} else if (g->state[g->depth] == yajl_gen_map_val) { \
|
126
126
|
g->print(g->ctx, ":", 1); \
|
127
127
|
if (g->pretty) g->print(g->ctx, " ", 1); \
|
128
|
-
}
|
128
|
+
}
|
129
129
|
|
130
130
|
#define INSERT_WHITESPACE \
|
131
131
|
if (g->pretty) { \
|
@@ -171,7 +171,7 @@ yajl_gen_free(yajl_gen g)
|
|
171
171
|
} \
|
172
172
|
|
173
173
|
#define FINAL_NEWLINE
|
174
|
-
|
174
|
+
|
175
175
|
yajl_gen_status
|
176
176
|
yajl_gen_integer(yajl_gen g, long int number)
|
177
177
|
{
|
@@ -194,7 +194,7 @@ yajl_gen_status
|
|
194
194
|
yajl_gen_double(yajl_gen g, double number)
|
195
195
|
{
|
196
196
|
char i[32];
|
197
|
-
ENSURE_VALID_STATE; ENSURE_NOT_KEY;
|
197
|
+
ENSURE_VALID_STATE; ENSURE_NOT_KEY;
|
198
198
|
if (isnan(number) || isinf(number)) return yajl_gen_invalid_number;
|
199
199
|
INSERT_SEP; INSERT_WHITESPACE;
|
200
200
|
sprintf(i, "%g", number);
|
@@ -222,8 +222,8 @@ yajl_gen_string(yajl_gen g, const unsigned char * str,
|
|
222
222
|
g->print(g->ctx, "\"", 1);
|
223
223
|
yajl_string_encode2(g->print, g->ctx, str, len);
|
224
224
|
g->print(g->ctx, "\"", 1);
|
225
|
-
|
226
|
-
|
225
|
+
|
226
|
+
|
227
227
|
APPENDED_ATOM;
|
228
228
|
FINAL_NEWLINE;
|
229
229
|
return yajl_gen_status_ok;
|
@@ -255,8 +255,8 @@ yajl_gen_status
|
|
255
255
|
yajl_gen_map_open(yajl_gen g)
|
256
256
|
{
|
257
257
|
ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
|
258
|
-
INCREMENT_DEPTH;
|
259
|
-
|
258
|
+
INCREMENT_DEPTH;
|
259
|
+
|
260
260
|
g->state[g->depth] = yajl_gen_map_start;
|
261
261
|
g->print(g->ctx, "{", 1);
|
262
262
|
if (g->pretty) g->print(g->ctx, "\n", 1);
|
@@ -267,7 +267,7 @@ yajl_gen_map_open(yajl_gen g)
|
|
267
267
|
yajl_gen_status
|
268
268
|
yajl_gen_map_close(yajl_gen g)
|
269
269
|
{
|
270
|
-
ENSURE_VALID_STATE;
|
270
|
+
ENSURE_VALID_STATE;
|
271
271
|
(g->depth)--;
|
272
272
|
if (g->pretty) g->print(g->ctx, "\n", 1);
|
273
273
|
APPENDED_ATOM;
|
@@ -281,7 +281,7 @@ yajl_gen_status
|
|
281
281
|
yajl_gen_array_open(yajl_gen g)
|
282
282
|
{
|
283
283
|
ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
|
284
|
-
INCREMENT_DEPTH;
|
284
|
+
INCREMENT_DEPTH;
|
285
285
|
g->state[g->depth] = yajl_gen_array_start;
|
286
286
|
g->print(g->ctx, "[", 1);
|
287
287
|
if (g->pretty) g->print(g->ctx, "\n", 1);
|
data/ext/yajl_lex.c
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright 2007-2009, Lloyd Hilaiel.
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* Redistribution and use in source and binary forms, with or without
|
5
5
|
* modification, are permitted provided that the following conditions are
|
6
6
|
* met:
|
7
|
-
*
|
7
|
+
*
|
8
8
|
* 1. Redistributions of source code must retain the above copyright
|
9
9
|
* notice, this list of conditions and the following disclaimer.
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* 2. Redistributions in binary form must reproduce the above copyright
|
12
12
|
* notice, this list of conditions and the following disclaimer in
|
13
13
|
* the documentation and/or other materials provided with the
|
14
14
|
* distribution.
|
15
|
-
*
|
15
|
+
*
|
16
16
|
* 3. Neither the name of Lloyd Hilaiel nor the names of its
|
17
17
|
* contributors may be used to endorse or promote products derived
|
18
18
|
* from this software without specific prior written permission.
|
19
|
-
*
|
19
|
+
*
|
20
20
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
21
21
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
22
22
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
@@ -28,7 +28,7 @@
|
|
28
28
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
29
29
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
30
|
* POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
*/
|
31
|
+
*/
|
32
32
|
|
33
33
|
#include "yajl_lex.h"
|
34
34
|
#include "yajl_buf.h"
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
#ifdef YAJL_LEXER_DEBUG
|
42
42
|
static const char *
|
43
|
-
tokToStr(yajl_tok tok)
|
43
|
+
tokToStr(yajl_tok tok)
|
44
44
|
{
|
45
45
|
switch (tok) {
|
46
46
|
case yajl_tok_bool: return "bool";
|
@@ -69,13 +69,13 @@ tokToStr(yajl_tok tok)
|
|
69
69
|
* the network or disk). This makes the lexer more complex. The
|
70
70
|
* responsibility of the lexer is to handle transparently the case where
|
71
71
|
* a chunk boundary falls in the middle of a token. This is
|
72
|
-
* accomplished is via a buffer and a character reading abstraction.
|
72
|
+
* accomplished is via a buffer and a character reading abstraction.
|
73
73
|
*
|
74
74
|
* Overview of implementation
|
75
75
|
*
|
76
76
|
* When we lex to end of input string before end of token is hit, we
|
77
77
|
* copy all of the input text composing the token into our lexBuf.
|
78
|
-
*
|
78
|
+
*
|
79
79
|
* Every time we read a character, we do so through the readChar function.
|
80
80
|
* readChar's responsibility is to handle pulling all chars from the buffer
|
81
81
|
* before pulling chars from input text
|
@@ -90,7 +90,7 @@ struct yajl_lexer_t {
|
|
90
90
|
yajl_lex_error error;
|
91
91
|
|
92
92
|
/* a input buffer to handle the case where a token is spread over
|
93
|
-
* multiple chunks */
|
93
|
+
* multiple chunks */
|
94
94
|
yajl_buf buf;
|
95
95
|
|
96
96
|
/* in the case where we have data in the lexBuf, bufOff holds
|
@@ -131,9 +131,12 @@ yajl_lex_alloc(yajl_alloc_funcs * alloc,
|
|
131
131
|
|
132
132
|
yajl_lexer
|
133
133
|
yajl_lex_realloc(yajl_lexer orig) {
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
yajl_buf_clear(orig->buf);
|
135
|
+
orig->bufInUse = 0;
|
136
|
+
orig->bufOff = 0;
|
137
|
+
orig->lineOff = 0;
|
138
|
+
orig->lineOff = 0;
|
139
|
+
return orig;
|
137
140
|
}
|
138
141
|
|
139
142
|
void
|
@@ -177,24 +180,24 @@ static const char charLookupTable[256] =
|
|
177
180
|
/*78*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
178
181
|
|
179
182
|
/* include these so we don't have to always check the range of the char */
|
180
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
181
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
182
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
183
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
184
|
-
|
185
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
186
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
187
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
188
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
189
|
-
|
190
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
191
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
192
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
193
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
194
|
-
|
195
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
196
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
197
|
-
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
183
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
184
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
185
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
186
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
187
|
+
|
188
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
189
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
190
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
191
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
192
|
+
|
193
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
194
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
195
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
196
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
197
|
+
|
198
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
199
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
200
|
+
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
|
198
201
|
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
|
199
202
|
};
|
200
203
|
|
@@ -206,7 +209,7 @@ static const char charLookupTable[256] =
|
|
206
209
|
* yajl_tok_eof - if end of input was hit before validation could
|
207
210
|
* complete
|
208
211
|
* yajl_tok_error - if invalid utf8 was encountered
|
209
|
-
*
|
212
|
+
*
|
210
213
|
* NOTE: on error the offset will point to the first char of the
|
211
214
|
* invalid utf8 */
|
212
215
|
#define UTF8_CHECK_EOF if (*offset >= jsonTextLen) { return yajl_tok_eof; }
|
@@ -220,7 +223,7 @@ yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
|
|
220
223
|
/* single byte */
|
221
224
|
return yajl_tok_string;
|
222
225
|
} else if ((curChar >> 5) == 0x6) {
|
223
|
-
/* two byte */
|
226
|
+
/* two byte */
|
224
227
|
UTF8_CHECK_EOF;
|
225
228
|
curChar = readChar(lexer, jsonText, offset);
|
226
229
|
if ((curChar >> 6) == 0x2) return yajl_tok_string;
|
@@ -246,7 +249,7 @@ yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
|
|
246
249
|
if ((curChar >> 6) == 0x2) return yajl_tok_string;
|
247
250
|
}
|
248
251
|
}
|
249
|
-
}
|
252
|
+
}
|
250
253
|
|
251
254
|
return yajl_tok_error;
|
252
255
|
}
|
@@ -297,8 +300,8 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
|
|
297
300
|
unsigned int i = 0;
|
298
301
|
|
299
302
|
for (i=0;i<4;i++) {
|
300
|
-
STR_CHECK_EOF;
|
301
|
-
curChar = readChar(lexer, jsonText, offset);
|
303
|
+
STR_CHECK_EOF;
|
304
|
+
curChar = readChar(lexer, jsonText, offset);
|
302
305
|
if (!(charLookupTable[curChar] & VHC)) {
|
303
306
|
/* back up to offending char */
|
304
307
|
unreadChar(lexer, offset);
|
@@ -310,8 +313,8 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
|
|
310
313
|
/* back up to offending char */
|
311
314
|
unreadChar(lexer, offset);
|
312
315
|
lexer->error = yajl_lex_string_invalid_escaped_char;
|
313
|
-
goto finish_string_lex;
|
314
|
-
}
|
316
|
+
goto finish_string_lex;
|
317
|
+
}
|
315
318
|
}
|
316
319
|
/* when not validating UTF8 it's a simple table lookup to determine
|
317
320
|
* if the present character is invalid */
|
@@ -319,29 +322,29 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
|
|
319
322
|
/* back up to offending char */
|
320
323
|
unreadChar(lexer, offset);
|
321
324
|
lexer->error = yajl_lex_string_invalid_json_char;
|
322
|
-
goto finish_string_lex;
|
325
|
+
goto finish_string_lex;
|
323
326
|
}
|
324
327
|
/* when in validate UTF8 mode we need to do some extra work */
|
325
328
|
else if (lexer->validateUTF8) {
|
326
329
|
yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen,
|
327
330
|
offset, curChar);
|
328
|
-
|
331
|
+
|
329
332
|
if (t == yajl_tok_eof) {
|
330
333
|
tok = yajl_tok_eof;
|
331
334
|
goto finish_string_lex;
|
332
335
|
} else if (t == yajl_tok_error) {
|
333
336
|
lexer->error = yajl_lex_string_invalid_utf8;
|
334
337
|
goto finish_string_lex;
|
335
|
-
}
|
338
|
+
}
|
336
339
|
}
|
337
|
-
/* accept it, and move on */
|
340
|
+
/* accept it, and move on */
|
338
341
|
}
|
339
342
|
finish_string_lex:
|
340
343
|
/* tell our buddy, the parser, wether he needs to process this string
|
341
344
|
* again */
|
342
345
|
if (hasEscapes && tok == yajl_tok_string) {
|
343
346
|
tok = yajl_tok_string_with_escapes;
|
344
|
-
}
|
347
|
+
}
|
345
348
|
|
346
349
|
return tok;
|
347
350
|
}
|
@@ -360,23 +363,23 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
|
|
360
363
|
|
361
364
|
yajl_tok tok = yajl_tok_integer;
|
362
365
|
|
363
|
-
RETURN_IF_EOF;
|
366
|
+
RETURN_IF_EOF;
|
364
367
|
c = readChar(lexer, jsonText, offset);
|
365
368
|
|
366
369
|
/* optional leading minus */
|
367
370
|
if (c == '-') {
|
368
|
-
RETURN_IF_EOF;
|
369
|
-
c = readChar(lexer, jsonText, offset);
|
371
|
+
RETURN_IF_EOF;
|
372
|
+
c = readChar(lexer, jsonText, offset);
|
370
373
|
}
|
371
374
|
|
372
375
|
/* a single zero, or a series of integers */
|
373
376
|
if (c == '0') {
|
374
|
-
RETURN_IF_EOF;
|
375
|
-
c = readChar(lexer, jsonText, offset);
|
377
|
+
RETURN_IF_EOF;
|
378
|
+
c = readChar(lexer, jsonText, offset);
|
376
379
|
} else if (c >= '1' && c <= '9') {
|
377
380
|
do {
|
378
|
-
RETURN_IF_EOF;
|
379
|
-
c = readChar(lexer, jsonText, offset);
|
381
|
+
RETURN_IF_EOF;
|
382
|
+
c = readChar(lexer, jsonText, offset);
|
380
383
|
} while (c >= '0' && c <= '9');
|
381
384
|
} else {
|
382
385
|
unreadChar(lexer, offset);
|
@@ -387,15 +390,15 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
|
|
387
390
|
/* optional fraction (indicates this is floating point) */
|
388
391
|
if (c == '.') {
|
389
392
|
int numRd = 0;
|
390
|
-
|
393
|
+
|
391
394
|
RETURN_IF_EOF;
|
392
|
-
c = readChar(lexer, jsonText, offset);
|
395
|
+
c = readChar(lexer, jsonText, offset);
|
393
396
|
|
394
397
|
while (c >= '0' && c <= '9') {
|
395
398
|
numRd++;
|
396
399
|
RETURN_IF_EOF;
|
397
|
-
c = readChar(lexer, jsonText, offset);
|
398
|
-
}
|
400
|
+
c = readChar(lexer, jsonText, offset);
|
401
|
+
}
|
399
402
|
|
400
403
|
if (!numRd) {
|
401
404
|
unreadChar(lexer, offset);
|
@@ -408,18 +411,18 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
|
|
408
411
|
/* optional exponent (indicates this is floating point) */
|
409
412
|
if (c == 'e' || c == 'E') {
|
410
413
|
RETURN_IF_EOF;
|
411
|
-
c = readChar(lexer, jsonText, offset);
|
414
|
+
c = readChar(lexer, jsonText, offset);
|
412
415
|
|
413
416
|
/* optional sign */
|
414
417
|
if (c == '+' || c == '-') {
|
415
418
|
RETURN_IF_EOF;
|
416
|
-
c = readChar(lexer, jsonText, offset);
|
419
|
+
c = readChar(lexer, jsonText, offset);
|
417
420
|
}
|
418
421
|
|
419
422
|
if (c >= '0' && c <= '9') {
|
420
423
|
do {
|
421
424
|
RETURN_IF_EOF;
|
422
|
-
c = readChar(lexer, jsonText, offset);
|
425
|
+
c = readChar(lexer, jsonText, offset);
|
423
426
|
} while (c >= '0' && c <= '9');
|
424
427
|
} else {
|
425
428
|
unreadChar(lexer, offset);
|
@@ -428,10 +431,10 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
|
|
428
431
|
}
|
429
432
|
tok = yajl_tok_double;
|
430
433
|
}
|
431
|
-
|
434
|
+
|
432
435
|
/* we always go "one too far" */
|
433
436
|
unreadChar(lexer, offset);
|
434
|
-
|
437
|
+
|
435
438
|
return tok;
|
436
439
|
}
|
437
440
|
|
@@ -443,24 +446,24 @@ yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
|
|
443
446
|
|
444
447
|
yajl_tok tok = yajl_tok_comment;
|
445
448
|
|
446
|
-
RETURN_IF_EOF;
|
449
|
+
RETURN_IF_EOF;
|
447
450
|
c = readChar(lexer, jsonText, offset);
|
448
451
|
|
449
452
|
/* either slash or star expected */
|
450
453
|
if (c == '/') {
|
451
454
|
/* now we throw away until end of line */
|
452
455
|
do {
|
453
|
-
RETURN_IF_EOF;
|
454
|
-
c = readChar(lexer, jsonText, offset);
|
456
|
+
RETURN_IF_EOF;
|
457
|
+
c = readChar(lexer, jsonText, offset);
|
455
458
|
} while (c != '\n');
|
456
459
|
} else if (c == '*') {
|
457
|
-
/* now we throw away until end of comment */
|
460
|
+
/* now we throw away until end of comment */
|
458
461
|
for (;;) {
|
459
|
-
RETURN_IF_EOF;
|
460
|
-
c = readChar(lexer, jsonText, offset);
|
462
|
+
RETURN_IF_EOF;
|
463
|
+
c = readChar(lexer, jsonText, offset);
|
461
464
|
if (c == '*') {
|
462
|
-
RETURN_IF_EOF;
|
463
|
-
c = readChar(lexer, jsonText, offset);
|
465
|
+
RETURN_IF_EOF;
|
466
|
+
c = readChar(lexer, jsonText, offset);
|
464
467
|
if (c == '/') {
|
465
468
|
break;
|
466
469
|
} else {
|
@@ -472,7 +475,7 @@ yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
|
|
472
475
|
lexer->error = yajl_lex_invalid_char;
|
473
476
|
tok = yajl_tok_error;
|
474
477
|
}
|
475
|
-
|
478
|
+
|
476
479
|
return tok;
|
477
480
|
}
|
478
481
|
|
@@ -580,7 +583,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
|
|
580
583
|
goto lexed;
|
581
584
|
}
|
582
585
|
case '-':
|
583
|
-
case '0': case '1': case '2': case '3': case '4':
|
586
|
+
case '0': case '1': case '2': case '3': case '4':
|
584
587
|
case '5': case '6': case '7': case '8': case '9': {
|
585
588
|
/* integer parsing wants to start from the beginning */
|
586
589
|
unreadChar(lexer, offset);
|
@@ -607,11 +610,11 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
|
|
607
610
|
jsonTextLen, offset);
|
608
611
|
if (tok == yajl_tok_comment) {
|
609
612
|
/* "error" is silly, but that's the initial
|
610
|
-
* state of tok. guilty until proven innocent. */
|
613
|
+
* state of tok. guilty until proven innocent. */
|
611
614
|
tok = yajl_tok_error;
|
612
615
|
yajl_buf_clear(lexer->buf);
|
613
616
|
lexer->bufInUse = 0;
|
614
|
-
startOffset = *offset;
|
617
|
+
startOffset = *offset;
|
615
618
|
break;
|
616
619
|
}
|
617
620
|
/* hit error or eof, bail */
|
@@ -632,7 +635,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
|
|
632
635
|
lexer->bufInUse = 1;
|
633
636
|
yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset);
|
634
637
|
lexer->bufOff = 0;
|
635
|
-
|
638
|
+
|
636
639
|
if (tok != yajl_tok_eof) {
|
637
640
|
*outBuf = yajl_buf_data(lexer->buf);
|
638
641
|
*outLen = yajl_buf_len(lexer->buf);
|
@@ -648,7 +651,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
|
|
648
651
|
{
|
649
652
|
assert(*outLen >= 2);
|
650
653
|
(*outBuf)++;
|
651
|
-
*outLen -= 2;
|
654
|
+
*outLen -= 2;
|
652
655
|
}
|
653
656
|
|
654
657
|
|
@@ -679,7 +682,7 @@ yajl_lex_error_to_string(yajl_lex_error error)
|
|
679
682
|
case yajl_lex_string_invalid_escaped_char:
|
680
683
|
return "inside a string, '\\' occurs before a character "
|
681
684
|
"which it may not.";
|
682
|
-
case yajl_lex_string_invalid_json_char:
|
685
|
+
case yajl_lex_string_invalid_json_char:
|
683
686
|
return "invalid character inside string.";
|
684
687
|
case yajl_lex_string_invalid_hex_char:
|
685
688
|
return "invalid (non-hex) character occurs after '\\u' inside "
|
@@ -732,13 +735,13 @@ yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
|
|
732
735
|
unsigned int bufOff = lexer->bufOff;
|
733
736
|
unsigned int bufInUse = lexer->bufInUse;
|
734
737
|
yajl_tok tok;
|
735
|
-
|
738
|
+
|
736
739
|
tok = yajl_lex_lex(lexer, jsonText, jsonTextLen, &offset,
|
737
740
|
&outBuf, &outLen);
|
738
741
|
|
739
742
|
lexer->bufOff = bufOff;
|
740
743
|
lexer->bufInUse = bufInUse;
|
741
744
|
yajl_buf_truncate(lexer->buf, bufLen);
|
742
|
-
|
745
|
+
|
743
746
|
return tok;
|
744
747
|
}
|