oj 2.12.12 → 2.12.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/ext/oj/extconf.rb +1 -1
- data/ext/oj/oj.c +4 -2
- data/ext/oj/parse.c +12 -5
- data/ext/oj/parse.h +1 -0
- data/ext/oj/sparse.c +4 -0
- data/lib/oj/version.rb +1 -1
- metadata +63 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f901c34e6bd4d7a0dec0fbff5e72e62d2ade9f9
|
4
|
+
data.tar.gz: fabea9097473451a41172f859d224d1ba45df888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb4cc5e9d368ac919c849d97abc36cba6510437ee5934a6fa4cddb0eaa185c548baaf0589eda779ddc921b295cdbd99b65d516c957fa4dd77ba82cdfcc8e580f
|
7
|
+
data.tar.gz: b2a6822d4b6a8261040b5585a87c01f6529a3b25376bce9623ea547d4a81a1fef9075f9172bdc9de73ec4469bdb558424c3ed824519c757d7d95647d932910b6
|
data/README.md
CHANGED
@@ -26,15 +26,17 @@ 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
|
-
##
|
29
|
+
## Future Release 2.12.13
|
30
30
|
|
31
|
-
-
|
31
|
+
- Added a check for the second argument to load() is a Hash.
|
32
|
+
|
33
|
+
- Yet another attempt to make floating point numbers display better.
|
32
34
|
|
33
|
-
|
35
|
+
- Thanks to mkillianey for getting the extconf.rb and gemspec file updated.
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
## Current Release 2.12.12
|
38
|
+
|
39
|
+
- Thanks to asurin for adding support for arguments to to_json() that rails uses.
|
38
40
|
|
39
41
|
[Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
|
40
42
|
|
data/ext/oj/extconf.rb
CHANGED
data/ext/oj/oj.c
CHANGED
@@ -725,6 +725,7 @@ load(int argc, VALUE *argv, VALUE self) {
|
|
725
725
|
VALUE ropts = argv[1];
|
726
726
|
VALUE v;
|
727
727
|
|
728
|
+
Check_Type(ropts, T_HASH);
|
728
729
|
if (Qnil != (v = rb_hash_lookup(ropts, mode_sym))) {
|
729
730
|
if (object_sym == v) {
|
730
731
|
mode = ObjectMode;
|
@@ -795,6 +796,7 @@ load_file(int argc, VALUE *argv, VALUE self) {
|
|
795
796
|
VALUE ropts = argv[1];
|
796
797
|
VALUE v;
|
797
798
|
|
799
|
+
Check_Type(ropts, T_HASH);
|
798
800
|
if (Qnil != (v = rb_hash_lookup(ropts, mode_sym))) {
|
799
801
|
if (object_sym == v) {
|
800
802
|
mode = ObjectMode;
|
@@ -1802,8 +1804,8 @@ static struct _Options mimic_object_to_json_options = {
|
|
1802
1804
|
10, // create_id_len
|
1803
1805
|
9, // sec_prec
|
1804
1806
|
0, // dump_opts
|
1805
|
-
|
1806
|
-
"%0.
|
1807
|
+
15, // float_prec
|
1808
|
+
"%0.15g", // float_fmt
|
1807
1809
|
};
|
1808
1810
|
|
1809
1811
|
static VALUE
|
data/ext/oj/parse.c
CHANGED
@@ -395,6 +395,7 @@ read_num(ParseInfo pi) {
|
|
395
395
|
ni.i = 0;
|
396
396
|
ni.num = 0;
|
397
397
|
ni.div = 1;
|
398
|
+
ni.di = 0;
|
398
399
|
ni.len = 0;
|
399
400
|
ni.exp = 0;
|
400
401
|
ni.dec_cnt = 0;
|
@@ -459,6 +460,7 @@ read_num(ParseInfo pi) {
|
|
459
460
|
// TBD move size check here
|
460
461
|
ni.num = ni.num * 10 + d;
|
461
462
|
ni.div *= 10;
|
463
|
+
ni.di++;
|
462
464
|
if (LONG_MAX <= ni.div || DEC_MAX < ni.dec_cnt - zero_cnt) {
|
463
465
|
ni.big = 1;
|
464
466
|
}
|
@@ -726,14 +728,19 @@ oj_num_as_value(NumInfo ni) {
|
|
726
728
|
rnum = rb_funcall(rnum, rb_intern("to_f"), 0);
|
727
729
|
}
|
728
730
|
} else {
|
729
|
-
|
730
|
-
|
731
|
+
// All these machinations are to get rounding to work better.
|
732
|
+
double d = (double)ni->i * (double)ni->div + (double)ni->num;
|
733
|
+
int x = ni->exp - ni->di;
|
734
|
+
|
735
|
+
d = round(d);
|
736
|
+
if (0 < x) {
|
737
|
+
d *= pow(10.0L, x);
|
738
|
+
} else if (0 > x) {
|
739
|
+
d /= pow(10.0L, -x);
|
740
|
+
}
|
731
741
|
if (ni->neg) {
|
732
742
|
d = -d;
|
733
743
|
}
|
734
|
-
if (0 != ni->exp) {
|
735
|
-
d *= pow(10.0L, ni->exp);
|
736
|
-
}
|
737
744
|
rnum = rb_float_new(d);
|
738
745
|
}
|
739
746
|
}
|
data/ext/oj/parse.h
CHANGED
data/ext/oj/sparse.c
CHANGED
@@ -406,6 +406,7 @@ read_num(ParseInfo pi) {
|
|
406
406
|
ni.i = 0;
|
407
407
|
ni.num = 0;
|
408
408
|
ni.div = 1;
|
409
|
+
ni.di = 0;
|
409
410
|
ni.len = 0;
|
410
411
|
ni.exp = 0;
|
411
412
|
ni.dec_cnt = 0;
|
@@ -460,6 +461,7 @@ read_num(ParseInfo pi) {
|
|
460
461
|
ni.dec_cnt++;
|
461
462
|
ni.num = ni.num * 10 + d;
|
462
463
|
ni.div *= 10;
|
464
|
+
ni.di++;
|
463
465
|
if (LONG_MAX <= ni.div || DEC_MAX < ni.dec_cnt - zero_cnt) {
|
464
466
|
ni.big = 1;
|
465
467
|
}
|
@@ -510,6 +512,7 @@ read_nan(ParseInfo pi) {
|
|
510
512
|
ni.i = 0;
|
511
513
|
ni.num = 0;
|
512
514
|
ni.div = 1;
|
515
|
+
ni.di = 0;
|
513
516
|
ni.len = 0;
|
514
517
|
ni.exp = 0;
|
515
518
|
ni.dec_cnt = 0;
|
@@ -679,6 +682,7 @@ oj_sparse2(ParseInfo pi) {
|
|
679
682
|
ni.i = 0;
|
680
683
|
ni.num = 0;
|
681
684
|
ni.div = 1;
|
685
|
+
ni.di = 0;
|
682
686
|
ni.len = 0;
|
683
687
|
ni.exp = 0;
|
684
688
|
ni.dec_cnt = 0;
|
data/lib/oj/version.rb
CHANGED
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.12.
|
4
|
+
version: 2.12.13
|
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-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -171,7 +171,6 @@ rdoc_options:
|
|
171
171
|
- README.md
|
172
172
|
require_paths:
|
173
173
|
- lib
|
174
|
-
- ext
|
175
174
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
175
|
requirements:
|
177
176
|
- - ">="
|
@@ -188,4 +187,64 @@ rubygems_version: 2.4.5
|
|
188
187
|
signing_key:
|
189
188
|
specification_version: 4
|
190
189
|
summary: A fast JSON parser and serializer.
|
191
|
-
test_files:
|
190
|
+
test_files:
|
191
|
+
- test/_test_active.rb
|
192
|
+
- test/_test_active_mimic.rb
|
193
|
+
- test/_test_mimic_rails.rb
|
194
|
+
- test/bug.rb
|
195
|
+
- test/bug2.rb
|
196
|
+
- test/bug3.rb
|
197
|
+
- test/bug_fast.rb
|
198
|
+
- test/bug_load.rb
|
199
|
+
- test/example.rb
|
200
|
+
- test/files.rb
|
201
|
+
- test/helper.rb
|
202
|
+
- test/io.rb
|
203
|
+
- test/isolated/shared.rb
|
204
|
+
- test/isolated/test_mimic_after.rb
|
205
|
+
- test/isolated/test_mimic_alone.rb
|
206
|
+
- test/isolated/test_mimic_as_json.rb
|
207
|
+
- test/isolated/test_mimic_before.rb
|
208
|
+
- test/isolated/test_mimic_define.rb
|
209
|
+
- test/isolated/test_mimic_rails_after.rb
|
210
|
+
- test/isolated/test_mimic_rails_before.rb
|
211
|
+
- test/mod.rb
|
212
|
+
- test/perf.rb
|
213
|
+
- test/perf_compat.rb
|
214
|
+
- test/perf_fast.rb
|
215
|
+
- test/perf_file.rb
|
216
|
+
- test/perf_object.rb
|
217
|
+
- test/perf_saj.rb
|
218
|
+
- test/perf_scp.rb
|
219
|
+
- test/perf_simple.rb
|
220
|
+
- test/perf_strict.rb
|
221
|
+
- test/sample/change.rb
|
222
|
+
- test/sample/dir.rb
|
223
|
+
- test/sample/doc.rb
|
224
|
+
- test/sample/file.rb
|
225
|
+
- test/sample/group.rb
|
226
|
+
- test/sample/hasprops.rb
|
227
|
+
- test/sample/layer.rb
|
228
|
+
- test/sample/line.rb
|
229
|
+
- test/sample/oval.rb
|
230
|
+
- test/sample/rect.rb
|
231
|
+
- test/sample/shape.rb
|
232
|
+
- test/sample/text.rb
|
233
|
+
- test/sample.rb
|
234
|
+
- test/sample_json.rb
|
235
|
+
- test/struct.rb
|
236
|
+
- test/test_compat.rb
|
237
|
+
- test/test_debian.rb
|
238
|
+
- test/test_fast.rb
|
239
|
+
- test/test_file.rb
|
240
|
+
- test/test_gc.rb
|
241
|
+
- test/test_object.rb
|
242
|
+
- test/test_saj.rb
|
243
|
+
- test/test_scp.rb
|
244
|
+
- test/test_serializer.rb
|
245
|
+
- test/test_strict.rb
|
246
|
+
- test/test_various.rb
|
247
|
+
- test/test_writer.rb
|
248
|
+
- test/write_timebars.rb
|
249
|
+
- test/zip.rb
|
250
|
+
has_rdoc: true
|