oj 3.12.1 → 3.12.2

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: 7316e25014cf4268799f3f1e4a01a74fada832b1d68bf64d82cbeb42b2caf1dd
4
- data.tar.gz: a02fdb9676efeacfec86475ff35afdb88cfef33e0c94188355cad69401ee2304
3
+ metadata.gz: 89a87064f6668864cec4ab0c43892b4950c8ef7a9f7ea3da22f459af5bcd0083
4
+ data.tar.gz: bc078e8b28d710a2194e2943343db687ec15d35d2556efff2f9e46936f3bb0b0
5
5
  SHA512:
6
- metadata.gz: 8f83d20545998db46a7dd0bd0e2560f47198fbb0f192bc80f17ffbce046e38727e0c143e022f8d00ba2332e2cb0be27ddda294b6a96d6f4b091ec95e282d2f01
7
- data.tar.gz: e62a125cf992f510296bbe6b3eeeaaadaa8ccd2891b764a290518f785b706a797af7fbd247ac360364cd610e67ad038488d6eefb55e4dc028a3b20540995e4df
6
+ metadata.gz: 95cb66c13e871bf85a351348b0c458c53fe2cd4057886396a62b763386fafe5d99c97143151808eb70dd526b8f13740cd43e266805c6b3454eac1be6940897db
7
+ data.tar.gz: '09e24c7ec1daf2c10850b071eb4060aed265db662a92a78439eee1746b22437396f3358f82d982e040874c0916af3c38def244e03416e4971c2c5649823ff7c2'
data/ext/oj/dump.c CHANGED
@@ -535,59 +535,57 @@ void oj_dump_xml_time(VALUE obj, Out out) {
535
535
  }
536
536
  if ((0 == nsec && !out->opts->sec_prec_set) || 0 == out->opts->sec_prec) {
537
537
  if (0 == tzsecs && rb_funcall2(obj, oj_utcq_id, 0, 0)) {
538
- sprintf(buf,
539
- "%04d-%02d-%02dT%02d:%02d:%02dZ",
540
- ti.year,
541
- ti.mon,
542
- ti.day,
543
- ti.hour,
544
- ti.min,
545
- ti.sec);
546
- oj_dump_cstr(buf, 20, 0, 0, out);
538
+ int len = sprintf(buf,
539
+ "%04d-%02d-%02dT%02d:%02d:%02dZ",
540
+ ti.year,
541
+ ti.mon,
542
+ ti.day,
543
+ ti.hour,
544
+ ti.min,
545
+ ti.sec);
546
+ oj_dump_cstr(buf, len, 0, 0, out);
547
547
  } else {
548
- sprintf(buf,
549
- "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
550
- ti.year,
551
- ti.mon,
552
- ti.day,
553
- ti.hour,
554
- ti.min,
555
- ti.sec,
556
- tzsign,
557
- tzhour,
558
- tzmin);
559
- oj_dump_cstr(buf, 25, 0, 0, out);
548
+ int len = sprintf(buf,
549
+ "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
550
+ ti.year,
551
+ ti.mon,
552
+ ti.day,
553
+ ti.hour,
554
+ ti.min,
555
+ ti.sec,
556
+ tzsign,
557
+ tzhour,
558
+ tzmin);
559
+ oj_dump_cstr(buf, len, 0, 0, out);
560
560
  }
561
561
  } else if (0 == tzsecs && rb_funcall2(obj, oj_utcq_id, 0, 0)) {
562
562
  char format[64] = "%04d-%02d-%02dT%02d:%02d:%02d.%09ldZ";
563
- int len = 30;
563
+ int len;
564
564
 
565
565
  if (9 > out->opts->sec_prec) {
566
566
  format[32] = '0' + out->opts->sec_prec;
567
- len -= 9 - out->opts->sec_prec;
568
567
  }
569
- sprintf(buf, format, ti.year, ti.mon, ti.day, ti.hour, ti.min, ti.sec, (long)nsec);
568
+ len = sprintf(buf, format, ti.year, ti.mon, ti.day, ti.hour, ti.min, ti.sec, (long)nsec);
570
569
  oj_dump_cstr(buf, len, 0, 0, out);
571
570
  } else {
572
571
  char format[64] = "%04d-%02d-%02dT%02d:%02d:%02d.%09ld%c%02d:%02d";
573
- int len = 35;
572
+ int len;
574
573
 
575
574
  if (9 > out->opts->sec_prec) {
576
575
  format[32] = '0' + out->opts->sec_prec;
577
- len -= 9 - out->opts->sec_prec;
578
576
  }
579
- sprintf(buf,
580
- format,
581
- ti.year,
582
- ti.mon,
583
- ti.day,
584
- ti.hour,
585
- ti.min,
586
- ti.sec,
587
- (long)nsec,
588
- tzsign,
589
- tzhour,
590
- tzmin);
577
+ len = sprintf(buf,
578
+ format,
579
+ ti.year,
580
+ ti.mon,
581
+ ti.day,
582
+ ti.hour,
583
+ ti.min,
584
+ ti.sec,
585
+ (long)nsec,
586
+ tzsign,
587
+ tzhour,
588
+ tzmin);
591
589
  oj_dump_cstr(buf, len, 0, 0, out);
592
590
  }
593
591
  }
@@ -827,9 +825,8 @@ void oj_dump_cstr(const char *str, size_t cnt, bool is_sym, bool escape1, Out ou
827
825
  if (is_sym) {
828
826
  *out->cur++ = ':';
829
827
  }
830
- for (; '\0' != *str; str++) {
831
- *out->cur++ = *str;
832
- }
828
+ memcpy(out->cur, str, cnt);
829
+ out->cur += cnt;
833
830
  *out->cur++ = '"';
834
831
  } else {
835
832
  const char *end = str + cnt;
@@ -1206,7 +1203,7 @@ void oj_dump_float(VALUE obj, int depth, Out out, bool as_ok) {
1206
1203
  if ((int)sizeof(buf) <= cnt) {
1207
1204
  cnt = sizeof(buf) - 1;
1208
1205
  }
1209
- strncpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
1206
+ memcpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
1210
1207
  buf[cnt] = '\0';
1211
1208
  } else {
1212
1209
  cnt = oj_dump_float_printf(buf, sizeof(buf), obj, d, out->opts->float_fmt);
data/ext/oj/dump_strict.c CHANGED
@@ -98,7 +98,7 @@ static void dump_float(VALUE obj, int depth, Out out, bool as_ok) {
98
98
  if ((int)sizeof(buf) <= cnt) {
99
99
  cnt = sizeof(buf) - 1;
100
100
  }
101
- strncpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
101
+ memcpy(buf, rb_string_value_ptr((VALUE *)&rstr), cnt);
102
102
  buf[cnt] = '\0';
103
103
  } else {
104
104
  cnt = oj_dump_float_printf(buf, sizeof(buf), obj, d, out->opts->float_fmt);
data/ext/oj/object.c CHANGED
@@ -433,22 +433,22 @@ void oj_set_obj_ivar(Val parent, Val kval, VALUE value) {
433
433
  char *buf = ALLOC_N(char, klen + 2);
434
434
 
435
435
  if ('~' == *key) {
436
- strncpy(buf, key + 1, klen - 1);
436
+ memcpy(buf, key + 1, klen - 1);
437
437
  buf[klen - 1] = '\0';
438
438
  } else {
439
439
  *buf = '@';
440
- strncpy(buf + 1, key, klen);
440
+ memcpy(buf + 1, key, klen);
441
441
  buf[klen + 1] = '\0';
442
442
  }
443
443
  var_id = rb_intern(buf);
444
444
  xfree(buf);
445
445
  } else {
446
446
  if ('~' == *key) {
447
- strncpy(attr, key + 1, klen - 1);
447
+ memcpy(attr, key + 1, klen - 1);
448
448
  attr[klen - 1] = '\0';
449
449
  } else {
450
450
  *attr = '@';
451
- strncpy(attr + 1, key, klen);
451
+ memcpy(attr + 1, key, klen);
452
452
  attr[klen + 1] = '\0';
453
453
  }
454
454
  var_id = rb_intern(attr);
data/lib/oj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.12.1'
4
+ VERSION = '3.12.2'
5
5
  end
data/pages/Options.md CHANGED
@@ -251,7 +251,13 @@ compatibility. Using just indent as an integer gives better performance.
251
251
 
252
252
  ### :symbol_keys [Boolean]
253
253
 
254
- Use symbols instead of strings for hash keys. :symbolize_names is an alias.
254
+ Use symbols instead of strings for hash keys.
255
+
256
+ ### :symbolize_names [Boolean]
257
+
258
+ Like :symbol_keys has keys are made into symbols but only when
259
+ mimicing the JSON gem and then only as the JSON gem honors it so
260
+ JSON.parse honors the option but JSON.load does not.
255
261
 
256
262
  ### :trace
257
263
 
data/test/foo.rb CHANGED
@@ -8,13 +8,6 @@ end
8
8
 
9
9
  require 'oj'
10
10
 
11
- Oj.default_options = {cache_keys: false, cache_str: 0}
11
+ p = Oj::Parser.new(:debug)
12
12
 
13
- [:compat, :strict, :object].each { |mode|
14
- GC.start
15
- t = Time.now
16
- Oj.load_file('pt_lemma_lookup.json', mode: mode)
17
- puts "#{mode}: #{Time.now - t}"
18
- }
19
-
20
- # check saj and scp
13
+ p.parse("[true, false]")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.1
4
+ version: 3.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.2.3
288
+ rubygems_version: 3.2.22
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: A fast JSON parser and serializer.