oj 2.13.0 → 2.13.1

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
  SHA1:
3
- metadata.gz: bd957508587371c18e701b638fcf8191b3bc444d
4
- data.tar.gz: aef52ecc143c4db76dfd1f9c64914a8a9021ad71
3
+ metadata.gz: 342383c1d1c0650dc81ad7a0f533e21b7ae67fa0
4
+ data.tar.gz: 7ba24a6ed5411eaef0c539076f0396cbed856489
5
5
  SHA512:
6
- metadata.gz: 03d731a64121a180278f340025cb18e0644504ecb954a7a479a03f79fd6c46cd1ed00d48c850830433550ef968402f9f91a6903e888568075c3d38bb2626ed1d
7
- data.tar.gz: 48f98ec630a2fe1f334de5eea37e952b549e7c97d98ab3f86e92a6608dd44e101da5fd853c3191ac76bf4e889609680ef5d97061330b67c7395e29a52cfae5d3
6
+ metadata.gz: 0a80309e5fc8cd37f2d76f99567012697f5776f212bac9ffe38ee4bf4740853f19653cd49b4d0b7238688e89a857d28f7010a3ac5eaee576638175f63c8a3507
7
+ data.tar.gz: 4a191f0f8294dde6558d24445b5f01eacf5276a68a823467caf32599ef6691c1523ed5253686372cee3e322dfdc845d2f88ccac471f9990605afa81a3f6edad7
data/README.md CHANGED
@@ -26,6 +26,10 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
26
26
 
27
27
  [![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
28
28
 
29
+ ## Release 2.13.1
30
+
31
+ - Thanks to Comboy for the fix to a large number rounding bug.
32
+
29
33
  ## Release 2.13.0
30
34
 
31
35
  - Oj no longer raises an exception if the to_hash method of an object does not
@@ -1786,9 +1786,12 @@ dump_struct_obj(VALUE obj, int depth, Out out) {
1786
1786
  size = d3 * out->indent + 2;
1787
1787
  #ifdef RSTRUCT_LEN
1788
1788
  {
1789
- VALUE *vp;
1789
+ const VALUE *vp;
1790
1790
 
1791
- for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_PTR(obj); 0 < i; i--, vp++) {
1791
+ #ifndef RSTRUCT_CONST_PTR
1792
+ # define RSTRUCT_CONST_PTR(st) (const VALUE *)RSTRUCT_PTR(st)
1793
+ #endif
1794
+ for (i = (int)RSTRUCT_LEN(obj), vp = RSTRUCT_CONST_PTR(obj); 0 < i; i--, vp++) {
1792
1795
  if (out->end - out->cur <= (long)size) {
1793
1796
  grow(out, size);
1794
1797
  }
@@ -389,7 +389,6 @@ static void
389
389
  read_num(ParseInfo pi) {
390
390
  struct _NumInfo ni;
391
391
  Val parent = stack_peek(&pi->stack);
392
- int zero_cnt = 0;
393
392
 
394
393
  ni.str = pi->cur;
395
394
  ni.i = 0;
@@ -398,7 +397,6 @@ read_num(ParseInfo pi) {
398
397
  ni.di = 0;
399
398
  ni.len = 0;
400
399
  ni.exp = 0;
401
- ni.dec_cnt = 0;
402
400
  ni.big = 0;
403
401
  ni.infinity = 0;
404
402
  ni.nan = 0;
@@ -427,41 +425,32 @@ read_num(ParseInfo pi) {
427
425
  pi->cur += 3;
428
426
  ni.nan = 1;
429
427
  } else {
428
+ int dec_cnt = 0;
429
+
430
430
  for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
431
- ni.dec_cnt++;
431
+ dec_cnt++;
432
432
  if (ni.big) {
433
433
  ni.big++;
434
434
  } else {
435
435
  int d = (*pi->cur - '0');
436
436
 
437
- if (0 == d) {
438
- zero_cnt++;
439
- } else {
440
- zero_cnt = 0;
441
- }
442
- // TBD move size check here
443
437
  ni.i = ni.i * 10 + d;
444
- if (LONG_MAX <= ni.i || DEC_MAX < ni.dec_cnt - zero_cnt) {
438
+ if (LONG_MAX <= ni.i || DEC_MAX < dec_cnt) {
445
439
  ni.big = 1;
446
440
  }
447
441
  }
448
442
  }
449
443
  if ('.' == *pi->cur) {
444
+ dec_cnt = 0;
450
445
  pi->cur++;
451
446
  for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
452
447
  int d = (*pi->cur - '0');
453
448
 
454
- if (0 == d) {
455
- zero_cnt++;
456
- } else {
457
- zero_cnt = 0;
458
- }
459
- ni.dec_cnt++;
460
- // TBD move size check here
449
+ dec_cnt++;
461
450
  ni.num = ni.num * 10 + d;
462
451
  ni.div *= 10;
463
452
  ni.di++;
464
- if (LONG_MAX <= ni.div || DEC_MAX < ni.dec_cnt - zero_cnt) {
453
+ if (LONG_MAX <= ni.div || DEC_MAX < dec_cnt) {
465
454
  ni.big = 1;
466
455
  }
467
456
  }
@@ -487,7 +476,6 @@ read_num(ParseInfo pi) {
487
476
  ni.exp = -ni.exp;
488
477
  }
489
478
  }
490
- ni.dec_cnt -= zero_cnt;
491
479
  ni.len = pi->cur - ni.str;
492
480
  }
493
481
  if (BigDec == pi->options.bigdec_load) {
@@ -48,7 +48,7 @@ typedef struct _NumInfo {
48
48
  const char *str;
49
49
  size_t len;
50
50
  long exp;
51
- int dec_cnt;
51
+ //int dec_cnt;
52
52
  int big;
53
53
  int infinity;
54
54
  int nan;
@@ -399,7 +399,6 @@ read_str(ParseInfo pi) {
399
399
  static void
400
400
  read_num(ParseInfo pi) {
401
401
  struct _NumInfo ni;
402
- int zero_cnt = 0;
403
402
  char c;
404
403
 
405
404
  reader_protect(&pi->rd);
@@ -409,7 +408,6 @@ read_num(ParseInfo pi) {
409
408
  ni.di = 0;
410
409
  ni.len = 0;
411
410
  ni.exp = 0;
412
- ni.dec_cnt = 0;
413
411
  ni.big = 0;
414
412
  ni.infinity = 0;
415
413
  ni.nan = 0;
@@ -430,39 +428,32 @@ read_num(ParseInfo pi) {
430
428
  }
431
429
  ni.infinity = 1;
432
430
  } else {
431
+ int dec_cnt = 0;
432
+
433
433
  for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
434
- ni.dec_cnt++;
434
+ dec_cnt++;
435
435
  if (ni.big) {
436
436
  ni.big++;
437
437
  } else {
438
438
  int d = (c - '0');
439
439
 
440
- if (0 == d) {
441
- zero_cnt++;
442
- } else {
443
- zero_cnt = 0;
444
- }
445
440
  ni.i = ni.i * 10 + d;
446
- if (LONG_MAX <= ni.i || DEC_MAX < ni.dec_cnt - zero_cnt) {
441
+ if (LONG_MAX <= ni.i || DEC_MAX < dec_cnt) {
447
442
  ni.big = 1;
448
443
  }
449
444
  }
450
445
  }
451
446
  if ('.' == c) {
447
+ dec_cnt = 0;
452
448
  c = reader_get(&pi->rd);
453
449
  for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
454
450
  int d = (c - '0');
455
451
 
456
- if (0 == d) {
457
- zero_cnt++;
458
- } else {
459
- zero_cnt = 0;
460
- }
461
- ni.dec_cnt++;
452
+ dec_cnt++;
462
453
  ni.num = ni.num * 10 + d;
463
454
  ni.div *= 10;
464
455
  ni.di++;
465
- if (LONG_MAX <= ni.div || DEC_MAX < ni.dec_cnt - zero_cnt) {
456
+ if (LONG_MAX <= ni.div || DEC_MAX < dec_cnt) {
466
457
  ni.big = 1;
467
458
  }
468
459
  }
@@ -488,7 +479,6 @@ read_num(ParseInfo pi) {
488
479
  ni.exp = -ni.exp;
489
480
  }
490
481
  }
491
- ni.dec_cnt -= zero_cnt;
492
482
  ni.len = pi->rd.tail - pi->rd.str;
493
483
  if (0 != c) {
494
484
  reader_backup(&pi->rd);
@@ -515,7 +505,6 @@ read_nan(ParseInfo pi) {
515
505
  ni.di = 0;
516
506
  ni.len = 0;
517
507
  ni.exp = 0;
518
- ni.dec_cnt = 0;
519
508
  ni.big = 0;
520
509
  ni.infinity = 0;
521
510
  ni.nan = 1;
@@ -685,7 +674,6 @@ oj_sparse2(ParseInfo pi) {
685
674
  ni.di = 0;
686
675
  ni.len = 0;
687
676
  ni.exp = 0;
688
- ni.dec_cnt = 0;
689
677
  ni.big = 0;
690
678
  ni.infinity = 0;
691
679
  ni.nan = 1;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.13.0'
4
+ VERSION = '2.13.1'
5
5
  end
@@ -109,12 +109,11 @@ class Juice < Minitest::Test
109
109
  :float_precision=>15,
110
110
  :mode=>:object,
111
111
  :escape_mode=>:json,
112
- :time_format=>:unix,
112
+ :time_format=>:unix_zone,
113
113
  :bigdecimal_load=>:auto,
114
114
  :create_id=>'json_class'}, opts)
115
115
  end
116
116
  =end
117
-
118
117
  def test_set_options
119
118
  orig ={
120
119
  :indent=>0,
@@ -901,8 +900,10 @@ class Juice < Minitest::Test
901
900
  b = Oj.load(json, :mode => :strict)
902
901
  assert_equal(30226801971775055948247051683954096612865741943, b)
903
902
  end
903
+
904
904
  def test_bignum_object
905
905
  dump_and_load(7 ** 55, false)
906
+ dump_and_load(10 ** 19, false)
906
907
  end
907
908
 
908
909
  # BigDecimal
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: 2.13.0
4
+ version: 2.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler