oj 3.10.11 → 3.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/oj/buf.h +2 -30
- data/ext/oj/cache8.h +1 -29
- data/ext/oj/circarray.c +4 -8
- data/ext/oj/circarray.h +1 -4
- data/ext/oj/code.c +3 -6
- data/ext/oj/code.h +1 -4
- data/ext/oj/compat.c +1 -4
- data/ext/oj/custom.c +1 -4
- data/ext/oj/dump.c +1 -4
- data/ext/oj/dump.h +1 -4
- data/ext/oj/dump_compat.c +1 -4
- data/ext/oj/dump_leaf.c +2 -5
- data/ext/oj/dump_object.c +1 -4
- data/ext/oj/dump_strict.c +1 -4
- data/ext/oj/encode.h +1 -29
- data/ext/oj/err.c +1 -4
- data/ext/oj/err.h +1 -29
- data/ext/oj/fast.c +14 -42
- data/ext/oj/hash.c +4 -32
- data/ext/oj/hash.h +1 -29
- data/ext/oj/hash_test.c +1 -29
- data/ext/oj/mimic_json.c +1 -4
- data/ext/oj/object.c +1 -4
- data/ext/oj/odd.c +1 -4
- data/ext/oj/odd.h +1 -4
- data/ext/oj/oj.c +1 -4
- data/ext/oj/oj.h +1 -4
- data/ext/oj/parse.c +7 -16
- data/ext/oj/parse.h +1 -4
- data/ext/oj/rails.c +1 -4
- data/ext/oj/rails.h +1 -4
- data/ext/oj/reader.c +5 -8
- data/ext/oj/reader.h +2 -5
- data/ext/oj/resolve.c +1 -4
- data/ext/oj/resolve.h +1 -4
- data/ext/oj/rxclass.c +3 -6
- data/ext/oj/rxclass.h +1 -4
- data/ext/oj/saj.c +6 -9
- data/ext/oj/scp.c +1 -4
- data/ext/oj/sparse.c +7 -15
- data/ext/oj/stream_writer.c +4 -9
- data/ext/oj/strict.c +3 -6
- data/ext/oj/string_writer.c +1 -4
- data/ext/oj/trace.c +5 -8
- data/ext/oj/trace.h +1 -4
- data/ext/oj/util.c +1 -1
- data/ext/oj/util.h +1 -1
- data/ext/oj/val_stack.c +1 -29
- data/ext/oj/val_stack.h +1 -29
- data/ext/oj/wab.c +1 -4
- data/lib/oj.rb +0 -8
- data/lib/oj/version.rb +1 -1
- data/test/json_gem/json_common_interface_test.rb +6 -7
- data/test/test_compat.rb +6 -0
- data/test/test_custom.rb +1 -1
- metadata +2 -22
data/ext/oj/hash.c
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
7
|
-
*
|
8
|
-
* - Redistributions of source code must retain the above copyright notice, this
|
9
|
-
* list of conditions and the following disclaimer.
|
10
|
-
*
|
11
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
* this list of conditions and the following disclaimer in the documentation
|
13
|
-
* and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* - Neither the name of Peter Ohler nor the names of its contributors may be
|
16
|
-
* used to endorse or promote products derived from this software without
|
17
|
-
* specific prior written permission.
|
18
|
-
*
|
19
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
1
|
+
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
30
2
|
|
31
3
|
#include "hash.h"
|
32
4
|
#include <stdint.h>
|
@@ -85,7 +57,7 @@ hash_calc(const uint8_t *key, size_t len) {
|
|
85
57
|
h ^= h >> 13;
|
86
58
|
h *= M;
|
87
59
|
h ^= h >> 15;
|
88
|
-
|
60
|
+
|
89
61
|
return h;
|
90
62
|
}
|
91
63
|
|
@@ -115,7 +87,7 @@ hash_get(Hash hash, const char *key, size_t len, VALUE **slotp, VALUE def_value)
|
|
115
87
|
if (0 != slotp) {
|
116
88
|
if (0 != bucket->key) {
|
117
89
|
KeyVal b = ALLOC(struct _keyVal);
|
118
|
-
|
90
|
+
|
119
91
|
b->next = 0;
|
120
92
|
bucket->next = b;
|
121
93
|
bucket = b;
|
@@ -155,7 +127,7 @@ oj_attr_hash_get(const char *key, size_t len, ID **slotp) {
|
|
155
127
|
char*
|
156
128
|
oj_strndup(const char *s, size_t len) {
|
157
129
|
char *d = ALLOC_N(char, len + 1);
|
158
|
-
|
130
|
+
|
159
131
|
memcpy(d, s, len);
|
160
132
|
d[len] = '\0';
|
161
133
|
|
data/ext/oj/hash.h
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
7
|
-
*
|
8
|
-
* - Redistributions of source code must retain the above copyright notice, this
|
9
|
-
* list of conditions and the following disclaimer.
|
10
|
-
*
|
11
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
* this list of conditions and the following disclaimer in the documentation
|
13
|
-
* and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* - Neither the name of Peter Ohler nor the names of its contributors may be
|
16
|
-
* used to endorse or promote products derived from this software without
|
17
|
-
* specific prior written permission.
|
18
|
-
*
|
19
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
1
|
+
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
30
2
|
|
31
3
|
#ifndef OJ_HASH_H
|
32
4
|
#define OJ_HASH_H
|
data/ext/oj/hash_test.c
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
7
|
-
*
|
8
|
-
* - Redistributions of source code must retain the above copyright notice, this
|
9
|
-
* list of conditions and the following disclaimer.
|
10
|
-
*
|
11
|
-
* - Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
* this list of conditions and the following disclaimer in the documentation
|
13
|
-
* and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* - Neither the name of Peter Ohler nor the names of its contributors may be
|
16
|
-
* used to endorse or promote products derived from this software without
|
17
|
-
* specific prior written permission.
|
18
|
-
*
|
19
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
*/
|
1
|
+
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
30
2
|
|
31
3
|
// if windows, comment out the whole file. It's only a performance test.
|
32
4
|
#ifndef _WIN32
|
data/ext/oj/mimic_json.c
CHANGED
data/ext/oj/object.c
CHANGED
data/ext/oj/odd.c
CHANGED
data/ext/oj/odd.h
CHANGED
data/ext/oj/oj.c
CHANGED
data/ext/oj/oj.h
CHANGED
data/ext/oj/parse.c
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2013, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2013 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#include <stdlib.h>
|
7
4
|
#include <stdio.h>
|
@@ -215,18 +212,6 @@ read_escaped_str(ParseInfo pi, const char *start) {
|
|
215
212
|
case '"': buf_append(&buf, '"'); break;
|
216
213
|
case '/': buf_append(&buf, '/'); break;
|
217
214
|
case '\\': buf_append(&buf, '\\'); break;
|
218
|
-
case '\'':
|
219
|
-
// The json gem claims this is not an error despite the
|
220
|
-
// ECMA-404 indicating it is not valid.
|
221
|
-
if (CompatMode == pi->options.mode) {
|
222
|
-
buf_append(&buf, '\'');
|
223
|
-
} else {
|
224
|
-
pi->cur = s;
|
225
|
-
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "invalid escaped character");
|
226
|
-
buf_cleanup(&buf);
|
227
|
-
return;
|
228
|
-
}
|
229
|
-
break;
|
230
215
|
case 'u':
|
231
216
|
s++;
|
232
217
|
if (0 == (code = read_hex(pi, s)) && err_has(&pi->err)) {
|
@@ -266,6 +251,12 @@ read_escaped_str(ParseInfo pi, const char *start) {
|
|
266
251
|
}
|
267
252
|
break;
|
268
253
|
default:
|
254
|
+
// The json gem claims this is not an error despite the
|
255
|
+
// ECMA-404 indicating it is not valid.
|
256
|
+
if (CompatMode == pi->options.mode) {
|
257
|
+
buf_append(&buf, *s);
|
258
|
+
break;
|
259
|
+
}
|
269
260
|
pi->cur = s;
|
270
261
|
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "invalid escaped character");
|
271
262
|
buf_cleanup(&buf);
|
data/ext/oj/parse.h
CHANGED
data/ext/oj/rails.c
CHANGED
data/ext/oj/rails.h
CHANGED
data/ext/oj/reader.c
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#include <stdlib.h>
|
7
4
|
#include <errno.h>
|
@@ -9,7 +6,7 @@
|
|
9
6
|
#include <strings.h>
|
10
7
|
#include <sys/types.h>
|
11
8
|
#if NEEDS_UIO
|
12
|
-
#include <sys/uio.h>
|
9
|
+
#include <sys/uio.h>
|
13
10
|
#endif
|
14
11
|
#include <unistd.h>
|
15
12
|
#include <time.h>
|
@@ -78,13 +75,13 @@ oj_reader_init(Reader reader, VALUE io, int fd, bool to_s) {
|
|
78
75
|
reader->io = io;
|
79
76
|
} else if (to_s) {
|
80
77
|
volatile VALUE rstr = rb_funcall(io, oj_to_s_id, 0);
|
81
|
-
|
78
|
+
|
82
79
|
reader->read_func = 0;
|
83
80
|
reader->in_str = StringValuePtr(rstr);
|
84
81
|
reader->head = (char*)reader->in_str;
|
85
82
|
reader->tail = reader->head;
|
86
83
|
reader->read_end = reader->head + RSTRING_LEN(rstr);
|
87
|
-
} else {
|
84
|
+
} else {
|
88
85
|
rb_raise(rb_eArgError, "parser io argument must be a String or respond to readpartial() or read().\n");
|
89
86
|
}
|
90
87
|
}
|
@@ -107,7 +104,7 @@ oj_reader_read(Reader reader) {
|
|
107
104
|
if (0 >= shift) { /* no space left so allocate more */
|
108
105
|
const char *old = reader->head;
|
109
106
|
size_t size = reader->end - reader->head + BUF_PAD;
|
110
|
-
|
107
|
+
|
111
108
|
if (reader->head == reader->base) {
|
112
109
|
reader->head = ALLOC_N(char, size * 2);
|
113
110
|
memcpy((char*)reader->head, old, size);
|
data/ext/oj/reader.h
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2011 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#ifndef OJ_READER_H
|
7
4
|
#define OJ_READER_H
|
@@ -43,7 +40,7 @@ reader_get(Reader reader) {
|
|
43
40
|
}
|
44
41
|
reader->col++;
|
45
42
|
reader->pos++;
|
46
|
-
|
43
|
+
|
47
44
|
return *reader->tail++;
|
48
45
|
}
|
49
46
|
|
data/ext/oj/resolve.c
CHANGED
data/ext/oj/resolve.h
CHANGED
data/ext/oj/rxclass.c
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2017, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2017 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#include <sys/types.h>
|
7
4
|
#include <stdlib.h>
|
@@ -101,12 +98,12 @@ VALUE
|
|
101
98
|
oj_rxclass_match(RxClass rc, const char *str, int len) {
|
102
99
|
RxC rxc;
|
103
100
|
char buf[4096];
|
104
|
-
|
101
|
+
|
105
102
|
for (rxc = rc->head; NULL != rxc; rxc = rxc->next) {
|
106
103
|
if (Qnil != rxc->rrx) {
|
107
104
|
// Must use a valiabel for this to work.
|
108
105
|
volatile VALUE rstr = rb_str_new(str, len);
|
109
|
-
|
106
|
+
|
110
107
|
//if (Qtrue == rb_funcall(rxc->rrx, rb_intern("match?"), 1, rstr)) {
|
111
108
|
if (Qnil != rb_funcall(rxc->rrx, rb_intern("match"), 1, rstr)) {
|
112
109
|
return rxc->clas;
|
data/ext/oj/rxclass.h
CHANGED
data/ext/oj/saj.c
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2012, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2012 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#if !IS_WINDOWS
|
7
4
|
#include <sys/resource.h> /* for getrlimit() on linux */
|
@@ -213,7 +210,7 @@ read_next(ParseInfo pi, const char *key) {
|
|
213
210
|
static void
|
214
211
|
read_hash(ParseInfo pi, const char *key) {
|
215
212
|
const char *ks;
|
216
|
-
|
213
|
+
|
217
214
|
if (pi->has_hash_start) {
|
218
215
|
call_no_value(pi->handler, oj_hash_start_id, key);
|
219
216
|
}
|
@@ -378,7 +375,7 @@ read_num(ParseInfo pi, const char *key) {
|
|
378
375
|
if (0 == e && 0 == a && 1 == div) {
|
379
376
|
if (big) {
|
380
377
|
char c = *pi->s;
|
381
|
-
|
378
|
+
|
382
379
|
*pi->s = '\0';
|
383
380
|
if (pi->has_add_value) {
|
384
381
|
call_add_value(pi->handler, rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)), key);
|
@@ -396,7 +393,7 @@ read_num(ParseInfo pi, const char *key) {
|
|
396
393
|
} else { /* decimal */
|
397
394
|
if (big) {
|
398
395
|
char c = *pi->s;
|
399
|
-
|
396
|
+
|
400
397
|
*pi->s = '\0';
|
401
398
|
if (pi->has_add_value) {
|
402
399
|
call_add_value(pi->handler, rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)), key);
|
@@ -541,7 +538,7 @@ read_quoted_value(ParseInfo pi) {
|
|
541
538
|
char *h = pi->s; /* head */
|
542
539
|
char *t = h; /* tail */
|
543
540
|
uint32_t code;
|
544
|
-
|
541
|
+
|
545
542
|
h++; /* skip quote character */
|
546
543
|
t++;
|
547
544
|
value = h;
|
@@ -679,7 +676,7 @@ oj_saj_parse(int argc, VALUE *argv, VALUE self) {
|
|
679
676
|
} else {
|
680
677
|
VALUE clas = rb_obj_class(input);
|
681
678
|
volatile VALUE s;
|
682
|
-
|
679
|
+
|
683
680
|
if (oj_stringio_class == clas) {
|
684
681
|
s = rb_funcall2(input, oj_string_id, 0, 0);
|
685
682
|
len = RSTRING_LEN(s) + 1;
|
data/ext/oj/scp.c
CHANGED
data/ext/oj/sparse.c
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2013, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
1
|
+
// Copyright (c) 2013 Peter Ohler. All rights reserved.
|
5
2
|
|
6
3
|
#include <stdlib.h>
|
7
4
|
#include <stdio.h>
|
@@ -228,17 +225,6 @@ read_escaped_str(ParseInfo pi) {
|
|
228
225
|
case '"': buf_append(&buf, '"'); break;
|
229
226
|
case '/': buf_append(&buf, '/'); break;
|
230
227
|
case '\\': buf_append(&buf, '\\'); break;
|
231
|
-
case '\'':
|
232
|
-
// The json gem claims this is not an error despite the
|
233
|
-
// ECMA-404 indicating it is not valid.
|
234
|
-
if (CompatMode == pi->options.mode) {
|
235
|
-
buf_append(&buf, '\'');
|
236
|
-
} else {
|
237
|
-
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "invalid escaped character");
|
238
|
-
buf_cleanup(&buf);
|
239
|
-
return;
|
240
|
-
}
|
241
|
-
break;
|
242
228
|
case 'u':
|
243
229
|
if (0 == (code = read_hex(pi)) && err_has(&pi->err)) {
|
244
230
|
buf_cleanup(&buf);
|
@@ -276,6 +262,12 @@ read_escaped_str(ParseInfo pi) {
|
|
276
262
|
}
|
277
263
|
break;
|
278
264
|
default:
|
265
|
+
// The json gem claims this is not an error despite the
|
266
|
+
// ECMA-404 indicating it is not valid.
|
267
|
+
if (CompatMode == pi->options.mode) {
|
268
|
+
buf_append(&buf, c);
|
269
|
+
break;
|
270
|
+
}
|
279
271
|
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "invalid escaped character");
|
280
272
|
buf_cleanup(&buf);
|
281
273
|
return;
|