oj 3.13.10 → 3.13.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4f2c04b24ed0dc8c781036c17371378649d1aad9b927b402b2b0f3d67f9f94b
4
- data.tar.gz: 65b50beb64e09569e7bcdcff9675a60b146de5ed78027b90de5def8eb6b57aa8
3
+ metadata.gz: 6c59bab43c76d548574059f41aab7b1604fa74161b59bbc0e958a0919e1cdabe
4
+ data.tar.gz: 8b60a10bb54b6a03f9a23b1db561a6402d1710c942f01d1f175582a08c566a9c
5
5
  SHA512:
6
- metadata.gz: 62a4e36ea67596152899cf389502a69f4f19b354dc5980c66b31ad5163b932245030bfd338ad582ec101572b56fd280c0e784b1d20567f830933627274506503
7
- data.tar.gz: 671d6a7066b4f74c164ce4af83acbab38fcb0743c97c13985ad4f8e7f1431f67288d1bb80f74b7e55d90d6c5e727e01dc72b138b7dfda3220cbc55ae3ebf2856
6
+ metadata.gz: 70ea6740a38970443000f03b67a5222fd450529f6d5d8edbb613feb277ecbeb27350784de26204b962a7815b4bf9cae821cfc8753be6f23ca845d118dfa6465b
7
+ data.tar.gz: 57d7f8b7f7f3d4e2ac37949e820d392840c0d3f36ff35be55c5ba0ba589a6656bf572de39c0f82482d23aa992bb3c8b9a634c106c753c077be8ef994c61c251f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.13.13 - 2022-05-20
4
+
5
+ - Fixed flooding stdout with debug output when dumping.
6
+
7
+ ## 3.13.12 - 2022-05-20
8
+
9
+ - Fixed crash on no arguments to pretty_generate. Now raises an exception.
10
+ - Register all classes and globals.
11
+ - Fixed memory issue with dumping.
12
+
13
+ ## 3.13.11 - 2022-01-05
14
+
15
+ - Fixed write blocking failures on writes to a slow stream with larger writes.
3
16
 
4
17
  ## 3.13.10 - 2021-12-12
5
18
 
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
  }