oj 3.13.11 → 3.13.23
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/CHANGELOG.md +50 -0
- data/README.md +2 -0
- data/ext/oj/buf.h +4 -0
- data/ext/oj/circarray.c +1 -1
- data/ext/oj/code.c +15 -22
- data/ext/oj/compat.c +10 -10
- data/ext/oj/custom.c +62 -108
- data/ext/oj/dump.c +85 -97
- data/ext/oj/dump.h +12 -8
- data/ext/oj/dump_compat.c +46 -88
- data/ext/oj/dump_leaf.c +14 -58
- data/ext/oj/dump_object.c +33 -156
- data/ext/oj/dump_strict.c +17 -29
- data/ext/oj/extconf.rb +5 -4
- data/ext/oj/fast.c +24 -22
- data/ext/oj/intern.c +15 -11
- data/ext/oj/intern.h +1 -1
- data/ext/oj/mimic_json.c +44 -32
- data/ext/oj/object.c +42 -41
- data/ext/oj/odd.c +83 -63
- data/ext/oj/odd.h +13 -13
- data/ext/oj/oj.c +57 -22
- data/ext/oj/oj.h +24 -3
- data/ext/oj/parse.c +114 -78
- data/ext/oj/parse.h +2 -0
- data/ext/oj/parser.c +77 -21
- data/ext/oj/parser.h +12 -0
- data/ext/oj/rails.c +41 -65
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +2 -0
- data/ext/oj/saj.c +11 -23
- data/ext/oj/saj2.c +333 -85
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/sparse.c +4 -0
- data/ext/oj/stream_writer.c +3 -1
- data/ext/oj/strict.c +13 -13
- data/ext/oj/string_writer.c +12 -5
- data/ext/oj/usual.c +82 -129
- data/ext/oj/usual.h +68 -0
- data/ext/oj/val_stack.c +1 -1
- data/ext/oj/validate.c +21 -26
- data/ext/oj/wab.c +21 -26
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/state.rb +1 -1
- data/lib/oj/version.rb +1 -1
- data/pages/Compatibility.md +1 -1
- data/pages/Options.md +6 -0
- 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 +3 -8
- data/test/foo.rb +3 -3
- data/test/helper.rb +8 -2
- data/test/json_gem/json_generator_test.rb +5 -4
- data/test/json_gem/json_parser_test.rb +8 -1
- data/test/json_gem/test_helper.rb +7 -3
- data/test/perf_dump.rb +50 -0
- data/test/test_compat.rb +25 -0
- data/test/test_custom.rb +13 -2
- data/test/test_file.rb +23 -7
- data/test/test_gc.rb +11 -0
- data/test/test_object.rb +8 -10
- data/test/test_parser.rb +3 -19
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +92 -2
- data/test/test_scp.rb +2 -4
- data/test/test_strict.rb +2 -0
- data/test/test_various.rb +8 -3
- data/test/test_wab.rb +2 -0
- data/test/tests.rb +9 -0
- data/test/tests_mimic.rb +9 -0
- data/test/tests_mimic_addition.rb +9 -0
- metadata +13 -116
data/ext/oj/rails.c
CHANGED
@@ -167,17 +167,14 @@ static void dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
|
|
167
167
|
}
|
168
168
|
fill_indent(out, d3);
|
169
169
|
*out->cur++ = '"';
|
170
|
-
|
171
|
-
out->cur += len;
|
170
|
+
APPEND_CHARS(out->cur, name, len);
|
172
171
|
*out->cur++ = '"';
|
173
172
|
if (0 < out->opts->dump_opts.before_size) {
|
174
|
-
|
175
|
-
out->cur += out->opts->dump_opts.before_size;
|
173
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
176
174
|
}
|
177
175
|
*out->cur++ = ':';
|
178
176
|
if (0 < out->opts->dump_opts.after_size) {
|
179
|
-
|
180
|
-
out->cur += out->opts->dump_opts.after_size;
|
177
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
181
178
|
}
|
182
179
|
#ifdef RSTRUCT_LEN
|
183
180
|
v = RSTRUCT_GET(obj, i);
|
@@ -323,20 +320,15 @@ static void dump_time(VALUE obj, int depth, Out out, bool as_ok) {
|
|
323
320
|
long long sec;
|
324
321
|
long long nsec;
|
325
322
|
|
326
|
-
#ifdef HAVE_RB_TIME_TIMESPEC
|
327
323
|
if (16 <= sizeof(struct timespec)) {
|
328
324
|
struct timespec ts = rb_time_timespec(obj);
|
329
325
|
|
330
326
|
sec = (long long)ts.tv_sec;
|
331
327
|
nsec = ts.tv_nsec;
|
332
328
|
} else {
|
333
|
-
sec =
|
334
|
-
nsec =
|
329
|
+
sec = NUM2LL(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
330
|
+
nsec = NUM2LL(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
335
331
|
}
|
336
|
-
#else
|
337
|
-
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
338
|
-
nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
339
|
-
#endif
|
340
332
|
dump_sec_nano(obj, sec, nsec, out);
|
341
333
|
}
|
342
334
|
|
@@ -345,9 +337,9 @@ static void dump_timewithzone(VALUE obj, int depth, Out out, bool as_ok) {
|
|
345
337
|
long long nsec = 0;
|
346
338
|
|
347
339
|
if (rb_respond_to(obj, oj_tv_nsec_id)) {
|
348
|
-
nsec =
|
340
|
+
nsec = NUM2LL(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
349
341
|
} else if (rb_respond_to(obj, oj_tv_usec_id)) {
|
350
|
-
nsec =
|
342
|
+
nsec = NUM2LL(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
|
351
343
|
}
|
352
344
|
dump_sec_nano(obj, sec, nsec, out);
|
353
345
|
}
|
@@ -405,14 +397,12 @@ static void dump_row(VALUE row, StrLen cols, int ccnt, int depth, Out out) {
|
|
405
397
|
assure_size(out, size);
|
406
398
|
if (out->opts->dump_opts.use) {
|
407
399
|
if (0 < out->opts->dump_opts.array_size) {
|
408
|
-
|
409
|
-
out->cur += out->opts->dump_opts.array_size;
|
400
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
410
401
|
}
|
411
402
|
if (0 < out->opts->dump_opts.indent_size) {
|
412
403
|
int i;
|
413
404
|
for (i = d2; 0 < i; i--) {
|
414
|
-
|
415
|
-
out->cur += out->opts->dump_opts.indent_size;
|
405
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
416
406
|
}
|
417
407
|
}
|
418
408
|
} else {
|
@@ -429,15 +419,13 @@ static void dump_row(VALUE row, StrLen cols, int ccnt, int depth, Out out) {
|
|
429
419
|
assure_size(out, size);
|
430
420
|
if (out->opts->dump_opts.use) {
|
431
421
|
if (0 < out->opts->dump_opts.array_size) {
|
432
|
-
|
433
|
-
out->cur += out->opts->dump_opts.array_size;
|
422
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
434
423
|
}
|
435
424
|
if (0 < out->opts->dump_opts.indent_size) {
|
436
425
|
int i;
|
437
426
|
|
438
427
|
for (i = depth; 0 < i; i--) {
|
439
|
-
|
440
|
-
out->cur += out->opts->dump_opts.indent_size;
|
428
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
441
429
|
}
|
442
430
|
}
|
443
431
|
} else {
|
@@ -477,14 +465,12 @@ static void dump_activerecord_result(VALUE obj, int depth, Out out, bool as_ok)
|
|
477
465
|
assure_size(out, size);
|
478
466
|
if (out->opts->dump_opts.use) {
|
479
467
|
if (0 < out->opts->dump_opts.array_size) {
|
480
|
-
|
481
|
-
out->cur += out->opts->dump_opts.array_size;
|
468
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
482
469
|
}
|
483
470
|
if (0 < out->opts->dump_opts.indent_size) {
|
484
471
|
int i;
|
485
472
|
for (i = d2; 0 < i; i--) {
|
486
|
-
|
487
|
-
out->cur += out->opts->dump_opts.indent_size;
|
473
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
488
474
|
}
|
489
475
|
}
|
490
476
|
} else {
|
@@ -500,15 +486,13 @@ static void dump_activerecord_result(VALUE obj, int depth, Out out, bool as_ok)
|
|
500
486
|
assure_size(out, size);
|
501
487
|
if (out->opts->dump_opts.use) {
|
502
488
|
if (0 < out->opts->dump_opts.array_size) {
|
503
|
-
|
504
|
-
out->cur += out->opts->dump_opts.array_size;
|
489
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
505
490
|
}
|
506
491
|
if (0 < out->opts->dump_opts.indent_size) {
|
507
492
|
int i;
|
508
493
|
|
509
494
|
for (i = depth; 0 < i; i--) {
|
510
|
-
|
511
|
-
out->cur += out->opts->dump_opts.indent_size;
|
495
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
512
496
|
}
|
513
497
|
}
|
514
498
|
} else {
|
@@ -533,7 +517,7 @@ static void dump_as_string(VALUE obj, int depth, Out out, bool as_ok) {
|
|
533
517
|
static void dump_as_json(VALUE obj, int depth, Out out, bool as_ok) {
|
534
518
|
volatile VALUE ja;
|
535
519
|
|
536
|
-
if (Yes == out->opts->trace) {
|
520
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
537
521
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyIn);
|
538
522
|
}
|
539
523
|
// Some classes elect to not take an options argument so check the arity
|
@@ -543,7 +527,7 @@ static void dump_as_json(VALUE obj, int depth, Out out, bool as_ok) {
|
|
543
527
|
} else {
|
544
528
|
ja = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
545
529
|
}
|
546
|
-
if (Yes == out->opts->trace) {
|
530
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
547
531
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyOut);
|
548
532
|
}
|
549
533
|
|
@@ -908,7 +892,6 @@ static VALUE protect_dump(VALUE ov) {
|
|
908
892
|
}
|
909
893
|
|
910
894
|
static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *argv) {
|
911
|
-
char buf[4096];
|
912
895
|
struct _out out;
|
913
896
|
struct _options copts = *opts;
|
914
897
|
volatile VALUE rstr = Qnil;
|
@@ -925,9 +908,9 @@ static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *a
|
|
925
908
|
} else {
|
926
909
|
copts.escape_mode = RailsEsc;
|
927
910
|
}
|
928
|
-
|
929
|
-
out
|
930
|
-
|
911
|
+
|
912
|
+
oj_out_init(&out);
|
913
|
+
|
931
914
|
out.omit_nil = copts.dump_opts.omit_nil;
|
932
915
|
out.caller = 0;
|
933
916
|
out.cur = out.buf;
|
@@ -963,9 +946,9 @@ static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *a
|
|
963
946
|
if (Yes == copts.circular) {
|
964
947
|
oj_cache8_delete(out.circ_cache);
|
965
948
|
}
|
966
|
-
|
967
|
-
|
968
|
-
|
949
|
+
|
950
|
+
oj_out_free(&out);
|
951
|
+
|
969
952
|
if (0 != line) {
|
970
953
|
rb_jump_tag(line);
|
971
954
|
}
|
@@ -1175,12 +1158,15 @@ oj_optimize_rails(VALUE self) {
|
|
1175
1158
|
*
|
1176
1159
|
* The Oj ActiveSupport compliant encoder.
|
1177
1160
|
*/
|
1178
|
-
void oj_mimic_rails_init() {
|
1161
|
+
void oj_mimic_rails_init(void) {
|
1179
1162
|
VALUE rails = rb_define_module_under(Oj, "Rails");
|
1180
1163
|
|
1181
1164
|
rb_define_module_function(rails, "encode", rails_encode, -1);
|
1182
1165
|
|
1183
1166
|
encoder_class = rb_define_class_under(rails, "Encoder", rb_cObject);
|
1167
|
+
rb_gc_register_address(&encoder_class);
|
1168
|
+
rb_undef_alloc_func(encoder_class);
|
1169
|
+
|
1184
1170
|
rb_define_module_function(encoder_class, "new", encoder_new, -1);
|
1185
1171
|
rb_define_module_function(rails, "optimize", rails_optimize, -1);
|
1186
1172
|
rb_define_module_function(rails, "deoptimize", rails_deoptimize, -1);
|
@@ -1263,19 +1249,17 @@ static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
|
|
1263
1249
|
} else {
|
1264
1250
|
size = d2 * out->indent + 2;
|
1265
1251
|
}
|
1252
|
+
assure_size(out, size * cnt);
|
1266
1253
|
cnt--;
|
1267
1254
|
for (i = 0; i <= cnt; i++) {
|
1268
|
-
assure_size(out, size);
|
1269
1255
|
if (out->opts->dump_opts.use) {
|
1270
1256
|
if (0 < out->opts->dump_opts.array_size) {
|
1271
|
-
|
1272
|
-
out->cur += out->opts->dump_opts.array_size;
|
1257
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
1273
1258
|
}
|
1274
1259
|
if (0 < out->opts->dump_opts.indent_size) {
|
1275
1260
|
int i;
|
1276
1261
|
for (i = d2; 0 < i; i--) {
|
1277
|
-
|
1278
|
-
out->cur += out->opts->dump_opts.indent_size;
|
1262
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
1279
1263
|
}
|
1280
1264
|
}
|
1281
1265
|
} else {
|
@@ -1290,15 +1274,13 @@ static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
|
|
1290
1274
|
assure_size(out, size);
|
1291
1275
|
if (out->opts->dump_opts.use) {
|
1292
1276
|
if (0 < out->opts->dump_opts.array_size) {
|
1293
|
-
|
1294
|
-
out->cur += out->opts->dump_opts.array_size;
|
1277
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.array_nl, out->opts->dump_opts.array_size);
|
1295
1278
|
}
|
1296
1279
|
if (0 < out->opts->dump_opts.indent_size) {
|
1297
1280
|
int i;
|
1298
1281
|
|
1299
1282
|
for (i = depth; 0 < i; i--) {
|
1300
|
-
|
1301
|
-
out->cur += out->opts->dump_opts.indent_size;
|
1283
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
1302
1284
|
}
|
1303
1285
|
}
|
1304
1286
|
} else {
|
@@ -1336,14 +1318,12 @@ static int hash_cb(VALUE key, VALUE value, VALUE ov) {
|
|
1336
1318
|
size = depth * out->opts->dump_opts.indent_size + out->opts->dump_opts.hash_size + 1;
|
1337
1319
|
assure_size(out, size);
|
1338
1320
|
if (0 < out->opts->dump_opts.hash_size) {
|
1339
|
-
|
1340
|
-
out->cur += out->opts->dump_opts.hash_size;
|
1321
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.hash_nl, out->opts->dump_opts.hash_size);
|
1341
1322
|
}
|
1342
1323
|
if (0 < out->opts->dump_opts.indent_size) {
|
1343
1324
|
int i;
|
1344
1325
|
for (i = depth; 0 < i; i--) {
|
1345
|
-
|
1346
|
-
out->cur += out->opts->dump_opts.indent_size;
|
1326
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
1347
1327
|
}
|
1348
1328
|
}
|
1349
1329
|
if (rtype == T_STRING) {
|
@@ -1354,13 +1334,11 @@ static int hash_cb(VALUE key, VALUE value, VALUE ov) {
|
|
1354
1334
|
size = out->opts->dump_opts.before_size + out->opts->dump_opts.after_size + 2;
|
1355
1335
|
assure_size(out, size);
|
1356
1336
|
if (0 < out->opts->dump_opts.before_size) {
|
1357
|
-
|
1358
|
-
out->cur += out->opts->dump_opts.before_size;
|
1337
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
1359
1338
|
}
|
1360
1339
|
*out->cur++ = ':';
|
1361
1340
|
if (0 < out->opts->dump_opts.after_size) {
|
1362
|
-
|
1363
|
-
out->cur += out->opts->dump_opts.after_size;
|
1341
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
1364
1342
|
}
|
1365
1343
|
}
|
1366
1344
|
dump_rails_val(value, depth, out, true);
|
@@ -1403,15 +1381,13 @@ static void dump_hash(VALUE obj, int depth, Out out, bool as_ok) {
|
|
1403
1381
|
size = depth * out->opts->dump_opts.indent_size + out->opts->dump_opts.hash_size + 1;
|
1404
1382
|
assure_size(out, size);
|
1405
1383
|
if (0 < out->opts->dump_opts.hash_size) {
|
1406
|
-
|
1407
|
-
out->cur += out->opts->dump_opts.hash_size;
|
1384
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.hash_nl, out->opts->dump_opts.hash_size);
|
1408
1385
|
}
|
1409
1386
|
if (0 < out->opts->dump_opts.indent_size) {
|
1410
1387
|
int i;
|
1411
1388
|
|
1412
1389
|
for (i = depth; 0 < i; i--) {
|
1413
|
-
|
1414
|
-
out->cur += out->opts->dump_opts.indent_size;
|
1390
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.indent_str, out->opts->dump_opts.indent_size);
|
1415
1391
|
}
|
1416
1392
|
}
|
1417
1393
|
}
|
@@ -1488,7 +1464,7 @@ static DumpFunc rails_funcs[] = {
|
|
1488
1464
|
static void dump_rails_val(VALUE obj, int depth, Out out, bool as_ok) {
|
1489
1465
|
int type = rb_type(obj);
|
1490
1466
|
|
1491
|
-
if (Yes == out->opts->trace) {
|
1467
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1492
1468
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
1493
1469
|
}
|
1494
1470
|
if (MAX_DEPTH < depth) {
|
@@ -1499,14 +1475,14 @@ static void dump_rails_val(VALUE obj, int depth, Out out, bool as_ok) {
|
|
1499
1475
|
|
1500
1476
|
if (NULL != f) {
|
1501
1477
|
f(obj, depth, out, as_ok);
|
1502
|
-
if (Yes == out->opts->trace) {
|
1478
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1503
1479
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
1504
1480
|
}
|
1505
1481
|
return;
|
1506
1482
|
}
|
1507
1483
|
}
|
1508
1484
|
oj_dump_nil(Qnil, depth, out, false);
|
1509
|
-
if (Yes == out->opts->trace) {
|
1485
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1510
1486
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
1511
1487
|
}
|
1512
1488
|
}
|
data/ext/oj/rails.h
CHANGED
data/ext/oj/reader.c
CHANGED
data/ext/oj/saj.c
CHANGED
@@ -210,10 +210,7 @@ static void read_hash(ParseInfo pi, const char *key) {
|
|
210
210
|
pi->s++;
|
211
211
|
} else {
|
212
212
|
if (pi->has_error) {
|
213
|
-
call_error("invalid format, expected , or } while in an object",
|
214
|
-
pi,
|
215
|
-
__FILE__,
|
216
|
-
__LINE__);
|
213
|
+
call_error("invalid format, expected , or } while in an object", pi, __FILE__, __LINE__);
|
217
214
|
}
|
218
215
|
raise_error("invalid format, expected , or } while in an object", pi->str, pi->s);
|
219
216
|
}
|
@@ -243,10 +240,7 @@ static void read_array(ParseInfo pi, const char *key) {
|
|
243
240
|
break;
|
244
241
|
} else {
|
245
242
|
if (pi->has_error) {
|
246
|
-
call_error("invalid format, expected , or ] while in an array",
|
247
|
-
pi,
|
248
|
-
__FILE__,
|
249
|
-
__LINE__);
|
243
|
+
call_error("invalid format, expected , or ] while in an array", pi, __FILE__, __LINE__);
|
250
244
|
}
|
251
245
|
raise_error("invalid format, expected , or ] while in an array", pi->str, pi->s);
|
252
246
|
}
|
@@ -276,7 +270,7 @@ static void read_str(ParseInfo pi, const char *key) {
|
|
276
270
|
#endif
|
277
271
|
|
278
272
|
static void read_num(ParseInfo pi, const char *key) {
|
279
|
-
char
|
273
|
+
char *start = pi->s;
|
280
274
|
int64_t n = 0;
|
281
275
|
long a = 0;
|
282
276
|
long div = 1;
|
@@ -351,9 +345,7 @@ static void read_num(ParseInfo pi, const char *key) {
|
|
351
345
|
|
352
346
|
*pi->s = '\0';
|
353
347
|
if (pi->has_add_value) {
|
354
|
-
call_add_value(pi->handler,
|
355
|
-
rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)),
|
356
|
-
key);
|
348
|
+
call_add_value(pi->handler, rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)), key);
|
357
349
|
}
|
358
350
|
*pi->s = c;
|
359
351
|
} else {
|
@@ -371,9 +363,7 @@ static void read_num(ParseInfo pi, const char *key) {
|
|
371
363
|
|
372
364
|
*pi->s = '\0';
|
373
365
|
if (pi->has_add_value) {
|
374
|
-
call_add_value(pi->handler,
|
375
|
-
rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)),
|
376
|
-
key);
|
366
|
+
call_add_value(pi->handler, rb_funcall(rb_cObject, oj_bigdecimal_id, 1, rb_str_new2(start)), key);
|
377
367
|
}
|
378
368
|
*pi->s = c;
|
379
369
|
} else {
|
@@ -505,9 +495,9 @@ static char *unicode_to_chars(ParseInfo pi, char *t, uint32_t code) {
|
|
505
495
|
* reached again. Do not read the character after the terminating quote.
|
506
496
|
*/
|
507
497
|
static char *read_quoted_value(ParseInfo pi) {
|
508
|
-
char
|
509
|
-
char
|
510
|
-
char
|
498
|
+
char *value = 0;
|
499
|
+
char *h = pi->s; /* head */
|
500
|
+
char *t = h; /* tail */
|
511
501
|
uint32_t code;
|
512
502
|
|
513
503
|
h++; /* skip quote character */
|
@@ -588,15 +578,13 @@ static void saj_parse(VALUE handler, char *json) {
|
|
588
578
|
pi.str = json;
|
589
579
|
pi.s = json;
|
590
580
|
#if IS_WINDOWS
|
591
|
-
pi.stack_min = (void *)((char *)&obj -
|
592
|
-
(512 * 1024)); /* assume a 1M stack and give half to ruby */
|
581
|
+
pi.stack_min = (void *)((char *)&obj - (512L * 1024L)); /* assume a 1M stack and give half to ruby */
|
593
582
|
#else
|
594
583
|
{
|
595
584
|
struct rlimit lim;
|
596
585
|
|
597
586
|
if (0 == getrlimit(RLIMIT_STACK, &lim) && RLIM_INFINITY != lim.rlim_cur) {
|
598
|
-
pi.stack_min = (void *)((char *)&obj - (lim.rlim_cur / 4 *
|
599
|
-
3)); /* let 3/4ths of the stack be used only */
|
587
|
+
pi.stack_min = (void *)((char *)&obj - (lim.rlim_cur / 4 * 3)); /* let 3/4ths of the stack be used only */
|
600
588
|
} else {
|
601
589
|
pi.stack_min = 0; /* indicates not to check stack limit */
|
602
590
|
}
|
@@ -633,7 +621,7 @@ static void saj_parse(VALUE handler, char *json) {
|
|
633
621
|
*/
|
634
622
|
VALUE
|
635
623
|
oj_saj_parse(int argc, VALUE *argv, VALUE self) {
|
636
|
-
char
|
624
|
+
char *json = 0;
|
637
625
|
size_t len = 0;
|
638
626
|
VALUE input = argv[1];
|
639
627
|
|