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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcb5f80ad6384640d44889424c39f91ee2db778b17c91b9505b5b3b4c280abf1
4
- data.tar.gz: 85b70200f48f46019ecf1020ca8e1b8ea604bca1161120b3747a8aeac2903682
3
+ metadata.gz: 6b0eec52170402a3d26527fa072d57fef1647f767e8559b8462893ced4f4cf21
4
+ data.tar.gz: 93bba77447858ae77366ff7d8c05ad3199457e2b55a3584dcb6ccca3288d0d4a
5
5
  SHA512:
6
- metadata.gz: f96776be4f9431b160f1d9f588e8688fb7e0c4a431c58a10fa43a71f5a6f95781456287f40db5dfba03bb69350946ad36f246d0b59c196f9dc95218f51005f7a
7
- data.tar.gz: e106b88134f86d82b9740f3e836ecb2aaa4af7ad643b96a4600eaa09392ba5f630c402101a6fb476823c41bc127b5c3d9625c6900a033cf6f9830ca01e57d459
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
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "circarray.h"
5
5
 
6
- CircArray oj_circ_array_new() {
6
+ CircArray oj_circ_array_new(void) {
7
7
  CircArray ca;
8
8
 
9
9
  if (0 == (ca = ALLOC(struct _circArray))) {
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
- memcpy(out->cur, out->opts->create_id, out->opts->create_id_len);
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
- strcpy(out->cur, out->opts->dump_opts.before_sep);
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
- strcpy(out->cur, out->opts->dump_opts.after_sep);
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
- memcpy(out->cur, classname, len);
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
- memcpy(out->cur, attrs->name, attrs->len);
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
- strcpy(out->cur, out->opts->dump_opts.before_sep);
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
- strcpy(out->cur, out->opts->dump_opts.after_sep);
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 buf[32];
194
- char *b = buf + sizeof(buf) - 1;
195
- int neg = 0;
196
- long num = attrs->num;
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
- assure_size(out, (sizeof(buf) - (b - buf)));
216
- for (; '\0' != *b; b++) {
217
- *out->cur++ = *b;
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
- strcpy(out->cur, out->opts->dump_opts.hash_nl);
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
- strcpy(out->cur, out->opts->dump_opts.indent_str);
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
- strcpy(out->cur, out->opts->dump_opts.before_sep);
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
- strcpy(out->cur, out->opts->dump_opts.after_sep);
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
- *out->cur++ = '{';
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
- strcpy(out->cur, out->opts->dump_opts.hash_nl);
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
- strcpy(out->cur, out->opts->dump_opts.indent_str);
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
- memcpy(out->cur, out->opts->create_id, out->opts->create_id_len);
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
- strcpy(out->cur, out->opts->dump_opts.before_sep);
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
- strcpy(out->cur, out->opts->dump_opts.after_sep);
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
- memcpy(out->cur, classname, clen);
414
- out->cur += clen;
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
- memcpy(out->cur, name, nlen);
433
- out->cur += nlen;
434
- *out->cur++ = '"';
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
- memcpy(out->cur, s, len);
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
- memcpy(out->cur, out->opts->create_id, out->opts->create_id_len);
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
- strcpy(out->cur, out->opts->dump_opts.before_sep);
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
- strcpy(out->cur, out->opts->dump_opts.after_sep);
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
- memcpy(out->cur, classname, len);
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
- strcpy(out->cur, out->opts->dump_opts.array_nl);
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
- strcpy(out->cur, out->opts->dump_opts.indent_str);
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
- strcpy(out->cur, out->opts->dump_opts.array_nl);
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
- strcpy(out->cur, out->opts->dump_opts.indent_str);
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
- *out->cur++ = '.';
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
- memcpy(out->cur, name, len);
848
- out->cur += len;
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
  }