oj 3.13.11 → 3.13.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/ext/oj/circarray.c +1 -1
- data/ext/oj/code.c +15 -22
- data/ext/oj/custom.c +28 -55
- data/ext/oj/dump.c +65 -88
- data/ext/oj/dump.h +12 -8
- data/ext/oj/dump_compat.c +43 -80
- data/ext/oj/dump_leaf.c +14 -58
- data/ext/oj/dump_object.c +28 -96
- data/ext/oj/dump_strict.c +12 -24
- data/ext/oj/fast.c +9 -9
- data/ext/oj/intern.c +9 -2
- data/ext/oj/intern.h +1 -1
- data/ext/oj/mimic_json.c +26 -24
- data/ext/oj/odd.c +83 -63
- data/ext/oj/odd.h +13 -13
- data/ext/oj/oj.c +28 -16
- data/ext/oj/oj.h +20 -2
- data/ext/oj/parse.c +3 -2
- data/ext/oj/parser.c +10 -15
- data/ext/oj/rails.c +38 -57
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +2 -0
- data/ext/oj/saj.c +11 -23
- data/ext/oj/stream_writer.c +3 -1
- data/ext/oj/string_writer.c +12 -5
- data/ext/oj/wab.c +8 -8
- data/lib/oj/version.rb +1 -1
- data/test/activesupport7/abstract_unit.rb +49 -0
- data/test/activesupport7/decoding_test.rb +125 -0
- data/test/activesupport7/encoding_test.rb +486 -0
- data/test/activesupport7/encoding_test_cases.rb +104 -0
- data/test/activesupport7/time_zone_test_helpers.rb +47 -0
- data/test/bar.rb +1 -8
- data/test/foo.rb +3 -3
- data/test/json_gem/json_generator_test.rb +2 -0
- data/test/perf_dump.rb +50 -0
- data/test/test_object.rb +12 -7
- metadata +15 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b0eec52170402a3d26527fa072d57fef1647f767e8559b8462893ced4f4cf21
|
4
|
+
data.tar.gz: 93bba77447858ae77366ff7d8c05ad3199457e2b55a3584dcb6ccca3288d0d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c95fa98149c6b8686376ab6d0f5744ca8a1312f62336a04c23da68d1e76c66c1d0a82ed755e945478623abfae85dac0d58ea84715d61d42dc0441455c3982d6
|
7
|
+
data.tar.gz: 00eb3b90452e1adc6cf58e4eec3be107076ee99544c7b0d70b7cff6aa9a758b9a330391669a0622f95681cf3e4dc3cf47bdc2be8496a322f1d9432f2557b052a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 3.13.14 - 2022-06-03
|
4
|
+
|
5
|
+
- Double fclose() due to bad merger fixed by tonobo.
|
6
|
+
|
7
|
+
## 3.13.13 - 2022-05-20
|
8
|
+
|
9
|
+
- Fixed flooding stdout with debug output when dumping.
|
10
|
+
|
11
|
+
## 3.13.12 - 2022-05-20
|
12
|
+
|
13
|
+
- Fixed crash on no arguments to pretty_generate. Now raises an exception.
|
14
|
+
- Register all classes and globals.
|
15
|
+
- Fixed memory issue with dumping.
|
16
|
+
|
3
17
|
## 3.13.11 - 2022-01-05
|
4
18
|
|
5
19
|
- Fixed write blocking failures on writes to a slow stream with larger writes.
|
data/ext/oj/circarray.c
CHANGED
data/ext/oj/code.c
CHANGED
@@ -140,21 +140,17 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
140
140
|
if (with_class) {
|
141
141
|
fill_indent(out, d2);
|
142
142
|
*out->cur++ = '"';
|
143
|
-
|
144
|
-
out->cur += out->opts->create_id_len;
|
143
|
+
APPEND_CHARS(out->cur, out->opts->create_id, out->opts->create_id_len);
|
145
144
|
*out->cur++ = '"';
|
146
145
|
if (0 < out->opts->dump_opts.before_size) {
|
147
|
-
|
148
|
-
out->cur += out->opts->dump_opts.before_size;
|
146
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
149
147
|
}
|
150
148
|
*out->cur++ = ':';
|
151
149
|
if (0 < out->opts->dump_opts.after_size) {
|
152
|
-
|
153
|
-
out->cur += out->opts->dump_opts.after_size;
|
150
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
154
151
|
}
|
155
152
|
*out->cur++ = '"';
|
156
|
-
|
157
|
-
out->cur += len;
|
153
|
+
APPEND_CHARS(out->cur, classname, len);
|
158
154
|
*out->cur++ = '"';
|
159
155
|
no_comma = false;
|
160
156
|
}
|
@@ -168,17 +164,14 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
168
164
|
}
|
169
165
|
fill_indent(out, d2);
|
170
166
|
*out->cur++ = '"';
|
171
|
-
|
172
|
-
out->cur += attrs->len;
|
167
|
+
APPEND_CHARS(out->cur, attrs->name, attrs->len);
|
173
168
|
*out->cur++ = '"';
|
174
169
|
if (0 < out->opts->dump_opts.before_size) {
|
175
|
-
|
176
|
-
out->cur += out->opts->dump_opts.before_size;
|
170
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
177
171
|
}
|
178
172
|
*out->cur++ = ':';
|
179
173
|
if (0 < out->opts->dump_opts.after_size) {
|
180
|
-
|
181
|
-
out->cur += out->opts->dump_opts.after_size;
|
174
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
182
175
|
}
|
183
176
|
if (Qundef == attrs->value) {
|
184
177
|
if (Qundef != attrs->time) {
|
@@ -190,10 +183,11 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
190
183
|
default: oj_dump_time(attrs->time, out, false); break;
|
191
184
|
}
|
192
185
|
} else {
|
193
|
-
char
|
194
|
-
char
|
195
|
-
int
|
196
|
-
long
|
186
|
+
char buf[32];
|
187
|
+
char *b = buf + sizeof(buf) - 1;
|
188
|
+
int neg = 0;
|
189
|
+
long num = attrs->num;
|
190
|
+
size_t cnt = 0;
|
197
191
|
|
198
192
|
if (0 > num) {
|
199
193
|
neg = 1;
|
@@ -212,10 +206,9 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
212
206
|
} else {
|
213
207
|
*b = '0';
|
214
208
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
}
|
209
|
+
cnt = sizeof(buf) - (b - buf) - 1;
|
210
|
+
assure_size(out, cnt);
|
211
|
+
APPEND_CHARS(out->cur, b, cnt);
|
219
212
|
}
|
220
213
|
} else {
|
221
214
|
oj_dump_compat_val(attrs->value, d3, out, true);
|
data/ext/oj/custom.c
CHANGED
@@ -295,15 +295,13 @@ static int hash_cb(VALUE key, VALUE value, VALUE ov) {
|
|
295
295
|
assure_size(out,
|
296
296
|
depth * out->opts->dump_opts.indent_size + out->opts->dump_opts.hash_size + 1);
|
297
297
|
if (0 < out->opts->dump_opts.hash_size) {
|
298
|
-
|
299
|
-
out->cur += out->opts->dump_opts.hash_size;
|
298
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.hash_nl, out->opts->dump_opts.hash_size);
|
300
299
|
}
|
301
300
|
if (0 < out->opts->dump_opts.indent_size) {
|
302
301
|
int i;
|
303
302
|
|
304
303
|
for (i = depth; 0 < i; i--) {
|
305
|
-
|
306
|
-
out->cur += out->opts->dump_opts.indent_size;
|
304
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
307
305
|
}
|
308
306
|
}
|
309
307
|
}
|
@@ -317,13 +315,11 @@ static int hash_cb(VALUE key, VALUE value, VALUE ov) {
|
|
317
315
|
} else {
|
318
316
|
assure_size(out, out->opts->dump_opts.before_size + out->opts->dump_opts.after_size + 2);
|
319
317
|
if (0 < out->opts->dump_opts.before_size) {
|
320
|
-
|
321
|
-
out->cur += out->opts->dump_opts.before_size;
|
318
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
322
319
|
}
|
323
320
|
*out->cur++ = ':';
|
324
321
|
if (0 < out->opts->dump_opts.after_size) {
|
325
|
-
|
326
|
-
out->cur += out->opts->dump_opts.after_size;
|
322
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
327
323
|
}
|
328
324
|
}
|
329
325
|
oj_dump_custom_val(value, depth, out, true);
|
@@ -344,8 +340,7 @@ static void dump_hash(VALUE obj, int depth, Out out, bool as_ok) {
|
|
344
340
|
cnt = (int)RHASH_SIZE(obj);
|
345
341
|
assure_size(out, 2);
|
346
342
|
if (0 == cnt) {
|
347
|
-
|
348
|
-
*out->cur++ = '}';
|
343
|
+
APPEND_CHARS(out->cur, "{}", 2);
|
349
344
|
} else {
|
350
345
|
*out->cur++ = '{';
|
351
346
|
out->depth = depth + 1;
|
@@ -361,15 +356,13 @@ static void dump_hash(VALUE obj, int depth, Out out, bool as_ok) {
|
|
361
356
|
out,
|
362
357
|
depth * out->opts->dump_opts.indent_size + out->opts->dump_opts.hash_size + 1);
|
363
358
|
if (0 < out->opts->dump_opts.hash_size) {
|
364
|
-
|
365
|
-
out->cur += out->opts->dump_opts.hash_size;
|
359
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.hash_nl, out->opts->dump_opts.hash_size);
|
366
360
|
}
|
367
361
|
if (0 < out->opts->dump_opts.indent_size) {
|
368
362
|
int i;
|
369
363
|
|
370
364
|
for (i = depth; 0 < i; i--) {
|
371
|
-
|
372
|
-
out->cur += out->opts->dump_opts.indent_size;
|
365
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
373
366
|
}
|
374
367
|
}
|
375
368
|
}
|
@@ -397,23 +390,18 @@ static void dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
|
|
397
390
|
assure_size(out, size);
|
398
391
|
fill_indent(out, d2);
|
399
392
|
*out->cur++ = '"';
|
400
|
-
|
401
|
-
out->cur += out->opts->create_id_len;
|
393
|
+
APPEND_CHARS(out->cur, out->opts->create_id, out->opts->create_id_len);
|
402
394
|
*out->cur++ = '"';
|
403
395
|
if (0 < out->opts->dump_opts.before_size) {
|
404
|
-
|
405
|
-
out->cur += out->opts->dump_opts.before_size;
|
396
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
406
397
|
}
|
407
398
|
*out->cur++ = ':';
|
408
399
|
if (0 < out->opts->dump_opts.after_size) {
|
409
|
-
|
410
|
-
out->cur += out->opts->dump_opts.after_size;
|
400
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
411
401
|
}
|
412
402
|
*out->cur++ = '"';
|
413
|
-
|
414
|
-
out->cur
|
415
|
-
*out->cur++ = '"';
|
416
|
-
*out->cur++ = ',';
|
403
|
+
APPEND_CHARS(out->cur, classname, clen);
|
404
|
+
APPEND_CHARS(out->cur, "\",", 2);
|
417
405
|
}
|
418
406
|
if (odd->raw) {
|
419
407
|
v = rb_funcall(obj, *odd->attrs, 0);
|
@@ -429,12 +417,9 @@ static void dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
|
|
429
417
|
assure_size(out, size);
|
430
418
|
fill_indent(out, d2);
|
431
419
|
*out->cur++ = '"';
|
432
|
-
|
433
|
-
out->cur
|
434
|
-
|
435
|
-
*out->cur++ = ':';
|
436
|
-
memcpy(out->cur, s, len);
|
437
|
-
out->cur += len;
|
420
|
+
APPEND_CHARS(out->cur, name, nlen);
|
421
|
+
APPEND_CHARS(out->cur, "\":", 2);
|
422
|
+
APPEND_CHARS(out->cur, s, len);
|
438
423
|
*out->cur = '\0';
|
439
424
|
}
|
440
425
|
} else {
|
@@ -514,8 +499,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
|
|
514
499
|
len = (int)RSTRING_LEN(rs);
|
515
500
|
|
516
501
|
assure_size(out, len + 1);
|
517
|
-
|
518
|
-
out->cur += len;
|
502
|
+
APPEND_CHARS(out->cur, s, len);
|
519
503
|
*out->cur = '\0';
|
520
504
|
} else if (Yes == out->opts->as_json && rb_respond_to(obj, oj_as_json_id)) {
|
521
505
|
volatile VALUE aj;
|
@@ -633,21 +617,17 @@ static void dump_obj_attrs(VALUE obj, VALUE clas, slot_t id, int depth, Out out)
|
|
633
617
|
assure_size(out, size);
|
634
618
|
fill_indent(out, d2);
|
635
619
|
*out->cur++ = '"';
|
636
|
-
|
637
|
-
out->cur += out->opts->create_id_len;
|
620
|
+
APPEND_CHARS(out->cur, out->opts->create_id, out->opts->create_id_len);
|
638
621
|
*out->cur++ = '"';
|
639
622
|
if (0 < out->opts->dump_opts.before_size) {
|
640
|
-
|
641
|
-
out->cur += out->opts->dump_opts.before_size;
|
623
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
642
624
|
}
|
643
625
|
*out->cur++ = ':';
|
644
626
|
if (0 < out->opts->dump_opts.after_size) {
|
645
|
-
|
646
|
-
out->cur += out->opts->dump_opts.after_size;
|
627
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
647
628
|
}
|
648
629
|
*out->cur++ = '"';
|
649
|
-
|
650
|
-
out->cur += len;
|
630
|
+
APPEND_CHARS(out->cur, classname, len);
|
651
631
|
*out->cur++ = '"';
|
652
632
|
class_written = true;
|
653
633
|
}
|
@@ -731,19 +711,17 @@ static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
|
|
731
711
|
} else {
|
732
712
|
size = d2 * out->indent + 2;
|
733
713
|
}
|
714
|
+
assure_size(out, size * cnt);
|
734
715
|
cnt--;
|
735
716
|
for (i = 0; i <= cnt; i++) {
|
736
|
-
assure_size(out, size);
|
737
717
|
if (out->opts->dump_opts.use) {
|
738
718
|
if (0 < out->opts->dump_opts.array_size) {
|
739
|
-
|
740
|
-
out->cur += out->opts->dump_opts.array_size;
|
719
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
741
720
|
}
|
742
721
|
if (0 < out->opts->dump_opts.indent_size) {
|
743
722
|
int i;
|
744
723
|
for (i = d2; 0 < i; i--) {
|
745
|
-
|
746
|
-
out->cur += out->opts->dump_opts.indent_size;
|
724
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
747
725
|
}
|
748
726
|
}
|
749
727
|
} else {
|
@@ -758,15 +736,13 @@ static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
|
|
758
736
|
assure_size(out, size);
|
759
737
|
if (out->opts->dump_opts.use) {
|
760
738
|
if (0 < out->opts->dump_opts.array_size) {
|
761
|
-
|
762
|
-
out->cur += out->opts->dump_opts.array_size;
|
739
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
763
740
|
}
|
764
741
|
if (0 < out->opts->dump_opts.indent_size) {
|
765
742
|
int i;
|
766
743
|
|
767
744
|
for (i = depth; 0 < i; i--) {
|
768
|
-
|
769
|
-
out->cur += out->opts->dump_opts.indent_size;
|
745
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
770
746
|
}
|
771
747
|
}
|
772
748
|
} else {
|
@@ -800,8 +776,7 @@ static void dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
|
|
800
776
|
*out->cur++ = '"';
|
801
777
|
oj_dump_custom_val(rb_funcall(obj, oj_begin_id, 0), d3, out, false);
|
802
778
|
assure_size(out, 3);
|
803
|
-
|
804
|
-
*out->cur++ = '.';
|
779
|
+
APPEND_CHARS(out->cur, "..", 2);
|
805
780
|
if (Qtrue == rb_funcall(obj, oj_exclude_end_id, 0)) {
|
806
781
|
*out->cur++ = '.';
|
807
782
|
}
|
@@ -844,10 +819,8 @@ static void dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
|
|
844
819
|
assure_size(out, size + len + 3);
|
845
820
|
fill_indent(out, d3);
|
846
821
|
*out->cur++ = '"';
|
847
|
-
|
848
|
-
out->cur
|
849
|
-
*out->cur++ = '"';
|
850
|
-
*out->cur++ = ':';
|
822
|
+
APPEND_CHARS(out->cur, name, len);
|
823
|
+
APPEND_CHARS(out->cur, "\":", 2);
|
851
824
|
oj_dump_custom_val(v, d3, out, true);
|
852
825
|
*out->cur++ = ',';
|
853
826
|
}
|