summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-06-15 10:52:33 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-06-15 10:52:33 -0700
commitaa71fe4777d2667696e420f7ea15326cfbb45aa8 (patch)
tree0f6ee5a4f7665ed2bfedf07640552f5b2810528b
parent8f640b6d665926c6687d6138c8f6485b43c3a857 (diff)
downloadffi-yajl-aa71fe4777d2667696e420f7ea15326cfbb45aa8.tar.gz
fix very large floats in ffi
-rw-r--r--lib/ffi_yajl/ffi/parser.rb2
-rw-r--r--spec/ffi_yajl/parser_spec.rb1
2 files changed, 1 insertions, 2 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index 7c1dbbc..11682dc 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -51,7 +51,7 @@ module FFI_Yajl
s = stringval.slice(0,stringlen)
s.force_encoding('UTF-8') if defined? Encoding
# XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float.
- v = ( s =~ /\./ ) ? s.to_f : s.to_i
+ v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i
set_value(v)
1
end
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 4f6186e..c3424ef 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -9,7 +9,6 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"key": 23456789012E666}' }
it "should return infinity" do
- skip "handle infinity properly"
infinity = (1.0/0)
expect(parser).to eq({"key" => infinity})
end