json-maglev- 1.6.5 → 1.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +4 -3
  3. data/CHANGES +9 -0
  4. data/Gemfile +2 -2
  5. data/README.rdoc +1 -1
  6. data/Rakefile +48 -58
  7. data/VERSION +1 -1
  8. data/ext/json/ext/generator/generator.c +17 -8
  9. data/ext/json/ext/generator/generator.h +1 -0
  10. data/ext/json/ext/parser/parser.c +18 -17
  11. data/ext/json/ext/parser/parser.rl +1 -0
  12. data/install.rb +7 -3
  13. data/java/src/json/ext/StringDecoder.java +1 -0
  14. data/json.gemspec +4 -7
  15. data/json_pure.gemspec +4 -7
  16. data/lib/json/common.rb +1 -0
  17. data/lib/json/light_object.rb +45 -0
  18. data/lib/json/pure/generator.rb +6 -2
  19. data/lib/json/version.rb +1 -1
  20. data/tests/test_json.rb +16 -4
  21. data/tests/test_json_addition.rb +4 -4
  22. data/tests/test_json_encoding.rb +1 -1
  23. data/tests/test_json_fixtures.rb +1 -1
  24. data/tests/test_json_generate.rb +19 -17
  25. data/tests/test_json_string_matching.rb +1 -1
  26. data/tests/test_json_unicode.rb +1 -1
  27. metadata +7 -56
  28. data/benchmarks/data-p4-3GHz-ruby18/.keep +0 -0
  29. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
  30. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
  31. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
  32. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
  33. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
  34. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
  35. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
  36. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
  37. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
  38. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
  39. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
  40. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
  41. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
  42. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
  43. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
  44. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
  45. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
  46. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
  47. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
  48. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
  49. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
  50. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
  51. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
  52. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
  53. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
  54. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
  55. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
  56. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
  57. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
  58. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
  59. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
  60. data/benchmarks/data/.keep +0 -0
  61. data/benchmarks/generator2_benchmark.rb +0 -222
  62. data/benchmarks/generator_benchmark.rb +0 -224
  63. data/benchmarks/ohai.json +0 -1216
  64. data/benchmarks/ohai.ruby +0 -1
  65. data/benchmarks/parser2_benchmark.rb +0 -251
  66. data/benchmarks/parser_benchmark.rb +0 -259
data/.gitignore CHANGED
@@ -6,3 +6,6 @@ pkg
6
6
  java/Json.iml
7
7
  Gemfile.lock
8
8
  .rvmrc
9
+ *.rbc
10
+ .rbx
11
+ .AppleDouble
data/.travis.yml CHANGED
@@ -6,10 +6,11 @@ rvm:
6
6
  - 1.8.7
7
7
  - 1.9.2
8
8
  - 1.9.3
9
- - rbx
10
- - rbx-2.0
9
+ - rbx-18mode
10
+ - rbx-19mode
11
11
  - ree
12
- - jruby
12
+ - jruby-18mode
13
+ - jruby-19mode
13
14
  - ruby-head
14
15
 
15
16
  script: "bundle exec rake"
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ 2012-04-27 (1.6.7)
2
+ * Fix possible crash when trying to parse nil value.
3
+ 2012-02-11 (1.6.6)
4
+ * Propagate src encoding to values made from it (fixes 1.9 mode converting
5
+ everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
6
+ <tom.enebo@gmail.com>), should fix
7
+ https://github.com/flori/json/issues#issue/119.
8
+ * Fix https://github.com/flori/json/issues#issue/124 Thx to Jason Hutchens.
9
+ * Fix https://github.com/flori/json/issues#issue/117
1
10
  2012-01-15 (1.6.5)
2
11
  * Vit Ondruch <v.ondruch@tiscali.cz> reported a bug that shows up when using
3
12
  optimisation under GCC 4.7. Thx to him, Bohuslav Kabrda
data/Gemfile CHANGED
@@ -6,10 +6,10 @@ gemspec :name => 'json'
6
6
  gemspec :name => 'json_pure'
7
7
  gemspec :name => 'json-java'
8
8
 
9
- group :development do
9
+ group :development, :test do
10
10
  gem 'simplecov', :platform => :mri_19
11
11
  end
12
12
 
13
13
  group :test do
14
- gem 'test-unit', :platform => :mri_19
14
+ gem 'test-unit', '2.4.7', :platform => :mri_19
15
15
  end
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = JSON implementation for Ruby http://travis-ci.org/flori/json.png?branch=master
1
+ = JSON implementation for Ruby {<img src="https://secure.travis-ci.org/flori/json.png" />}[http://travis-ci.org/flori/json]
2
2
 
3
3
  == Description
4
4
 
data/Rakefile CHANGED
@@ -4,21 +4,27 @@ rescue LoadError
4
4
  end
5
5
 
6
6
  require 'rbconfig'
7
- begin
8
- include RbConfig
9
- rescue NameError
10
- include Config
11
- end
12
-
7
+ include\
8
+ begin
9
+ RbConfig
10
+ rescue NameError
11
+ Config
12
+ end
13
13
 
14
14
  require 'rake/clean'
15
- CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], 'doc', 'Gemfile.lock'
15
+ CLOBBER.include 'doc', 'Gemfile.lock'
16
16
  CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
17
17
  FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
18
18
  FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"],
19
19
  FileList['java/src/**/*.class']
20
20
 
21
- MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
21
+ require 'rake/testtask'
22
+ class UndocumentedTestTask < Rake::TestTask
23
+ def desc(*) end
24
+ end
25
+
26
+ MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
27
+ BUNDLE = ENV['BUNDLE'] || %w[bundle].find { |c| system(c, '-v') }
22
28
  PKG_NAME = 'json'
23
29
  PKG_TITLE = 'JSON Implementation for Ruby'
24
30
  PKG_VERSION = File.read('VERSION').chomp
@@ -44,19 +50,9 @@ JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
44
50
  RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
45
51
  RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
46
52
 
47
- def myruby(*args, &block)
48
- @myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
49
- options = (Hash === args.last) ? args.pop : {}
50
- if args.length > 1 then
51
- sh(*([@myruby] + args + [options]), &block)
52
- else
53
- sh("#{@myruby} #{args.first}", options, &block)
54
- end
55
- end
56
-
57
53
  desc "Installing library (pure)"
58
54
  task :install_pure => :version do
59
- myruby 'install.rb'
55
+ ruby 'install.rb'
60
56
  end
61
57
 
62
58
  task :install_ext_really do
@@ -75,11 +71,7 @@ desc "Installing library (extension)"
75
71
  task :install_ext => [ :compile, :install_pure, :install_ext_really ]
76
72
 
77
73
  desc "Installing library (extension)"
78
- if RUBY_PLATFORM =~ /java/
79
- task :install => :install_pure
80
- else
81
- task :install => :install_ext
82
- end
74
+ task :install => :install_ext
83
75
 
84
76
  if defined?(Gem) and defined?(Gem::PackageTask)
85
77
  spec_pure = Gem::Specification.new do |s|
@@ -92,7 +84,6 @@ if defined?(Gem) and defined?(Gem::PackageTask)
92
84
 
93
85
  s.require_path = 'lib'
94
86
  s.add_development_dependency 'permutation'
95
- s.add_development_dependency 'bullshit'
96
87
  s.add_development_dependency 'sdoc'
97
88
  s.add_development_dependency 'rake', '~>0.9.2'
98
89
 
@@ -133,7 +124,6 @@ if defined?(Gem) and defined?(Gem::PackageTask)
133
124
  s.require_paths << 'ext'
134
125
  s.require_paths << 'lib'
135
126
  s.add_development_dependency 'permutation'
136
- s.add_development_dependency 'bullshit'
137
127
  s.add_development_dependency 'sdoc'
138
128
 
139
129
  s.extra_rdoc_files << 'README.rdoc'
@@ -182,18 +172,26 @@ EOT
182
172
  end
183
173
 
184
174
  desc "Testing library (pure ruby)"
185
- task :test_pure => :clean do
186
- ENV['JSON'] = 'pure'
187
- ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
188
- myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
175
+ task :test_pure => [ :clean, :do_test_pure ]
176
+
177
+ UndocumentedTestTask.new do |t|
178
+ t.name = 'do_test_pure'
179
+ t.libs << 'lib'
180
+ t.test_files = FileList['tests/test_*.rb']
181
+ t.verbose = true
182
+ t.options = '-v'
189
183
  end
190
184
 
191
185
  desc "Testing library (pure ruby and extension)"
192
- task :test => [ :test_pure, :test_ext ]
186
+ task :test do
187
+ sh "env JSON=pure #{BUNDLE} exec rake test_pure" or exit 1
188
+ sh "env JSON=ext #{BUNDLE} exec rake test_ext" or exit 1
189
+ end
193
190
 
194
191
  namespace :gems do
192
+ desc 'Install all development gems'
195
193
  task :install do
196
- sh 'bundle'
194
+ sh "#{BUNDLE}"
197
195
  end
198
196
  end
199
197
 
@@ -250,9 +248,14 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
250
248
  end
251
249
 
252
250
  desc "Testing library (jruby)"
253
- task :test_ext => :create_jar do
254
- ENV['JSON'] = 'ext'
255
- myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
251
+ task :test_ext => [ :create_jar, :do_test_ext ]
252
+
253
+ UndocumentedTestTask.new do |t|
254
+ t.name = 'do_test_ext'
255
+ t.libs << 'lib'
256
+ t.test_files = FileList['tests/test_*.rb']
257
+ t.verbose = true
258
+ t.options = '-v'
256
259
  end
257
260
 
258
261
  file JRUBY_PARSER_JAR => :compile do
@@ -304,7 +307,7 @@ else
304
307
 
305
308
  file EXT_PARSER_DL => EXT_PARSER_SRC do
306
309
  cd EXT_PARSER_DIR do
307
- myruby 'extconf.rb'
310
+ ruby 'extconf.rb'
308
311
  sh MAKE
309
312
  end
310
313
  cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
@@ -312,36 +315,23 @@ else
312
315
 
313
316
  file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
314
317
  cd EXT_GENERATOR_DIR do
315
- myruby 'extconf.rb'
318
+ ruby 'extconf.rb'
316
319
  sh MAKE
317
320
  end
318
321
  cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
319
322
  end
320
323
 
321
324
  desc "Testing library (extension)"
322
- task :test_ext => :compile do
323
- ENV['JSON'] = 'ext'
324
- ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
325
- myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
325
+ task :test_ext => [ :compile, :do_test_ext ]
326
+
327
+ UndocumentedTestTask.new do |t|
328
+ t.name = 'do_test_ext'
329
+ t.libs << 'ext' << 'lib'
330
+ t.test_files = FileList['tests/test_*.rb']
331
+ t.verbose = true
332
+ t.options = '-v'
326
333
  end
327
334
 
328
- desc "Benchmarking parser"
329
- task :benchmark_parser do
330
- ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
331
- myruby 'benchmarks/parser_benchmark.rb'
332
- myruby 'benchmarks/parser2_benchmark.rb'
333
- end
334
-
335
- desc "Benchmarking generator"
336
- task :benchmark_generator do
337
- ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
338
- myruby 'benchmarks/generator_benchmark.rb'
339
- myruby 'benchmarks/generator2_benchmark.rb'
340
- end
341
-
342
- desc "Benchmarking library"
343
- task :benchmark => [ :benchmark_parser, :benchmark_generator ]
344
-
345
335
  desc "Create RDOC documentation"
346
336
  task :doc => [ :version, EXT_PARSER_SRC ] do
347
337
  sh "sdoc -o doc -t '#{PKG_TITLE}' -m README.rdoc README.rdoc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.5
1
+ 1.6.7
@@ -852,6 +852,21 @@ static VALUE cState_partial_generate(VALUE self, VALUE obj)
852
852
  return fbuffer_to_s(buffer);
853
853
  }
854
854
 
855
+ /*
856
+ * This function returns true if string is either a JSON array or JSON object.
857
+ * It might suffer from false positives, e. g. syntactically incorrect JSON in
858
+ * the string or certain UTF-8 characters on the right hand side.
859
+ */
860
+ static int isArrayOrObject(VALUE string)
861
+ {
862
+ long string_len = RSTRING_LEN(string);
863
+ char *p = RSTRING_PTR(string), *q = p + string_len - 1;
864
+ if (string_len < 2) return 0;
865
+ for (; p < q && isspace(*p); p++);
866
+ for (; q > p && isspace(*q); q--);
867
+ return *p == '[' && *q == ']' || *p == '{' && *q == '}';
868
+ }
869
+
855
870
  /*
856
871
  * call-seq: generate(obj)
857
872
  *
@@ -862,15 +877,9 @@ static VALUE cState_partial_generate(VALUE self, VALUE obj)
862
877
  static VALUE cState_generate(VALUE self, VALUE obj)
863
878
  {
864
879
  VALUE result = cState_partial_generate(self, obj);
865
- VALUE re, args[2];
866
880
  GET_STATE(self);
867
- if (!state->quirks_mode) {
868
- args[0] = rb_str_new2("\\A\\s*(?:\\[.*\\]|\\{.*\\})\\s*\\Z");
869
- args[1] = CRegexp_MULTILINE;
870
- re = rb_class_new_instance(2, args, rb_cRegexp);
871
- if (NIL_P(rb_funcall(re, i_match, 1, result))) {
872
- rb_raise(eGeneratorError, "only generation of JSON objects or arrays allowed");
873
- }
881
+ if (!state->quirks_mode && !isArrayOrObject(result)) {
882
+ rb_raise(eGeneratorError, "only generation of JSON objects or arrays allowed");
874
883
  }
875
884
  return result;
876
885
  }
@@ -4,6 +4,7 @@
4
4
  #include <string.h>
5
5
  #include <assert.h>
6
6
  #include <math.h>
7
+ #include <ctype.h>
7
8
 
8
9
  #include "ruby.h"
9
10
 
@@ -1731,6 +1731,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1731
1731
  source = convert_encoding(StringValue(source));
1732
1732
  }
1733
1733
  json->current_nesting = 0;
1734
+ StringValue(source);
1734
1735
  json->len = RSTRING_LEN(source);
1735
1736
  json->source = RSTRING_PTR(source);;
1736
1737
  PARSER_SET_REFERENCE(json, Vsource, source);
@@ -1738,7 +1739,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1738
1739
  }
1739
1740
 
1740
1741
 
1741
- #line 1742 "parser.c"
1742
+ #line 1743 "parser.c"
1742
1743
  static const int JSON_start = 1;
1743
1744
  static const int JSON_first_final = 10;
1744
1745
  static const int JSON_error = 0;
@@ -1746,7 +1747,7 @@ static const int JSON_error = 0;
1746
1747
  static const int JSON_en_main = 1;
1747
1748
 
1748
1749
 
1749
- #line 749 "parser.rl"
1750
+ #line 750 "parser.rl"
1750
1751
 
1751
1752
 
1752
1753
  static VALUE cParser_parse_strict(VALUE self)
@@ -1757,16 +1758,16 @@ static VALUE cParser_parse_strict(VALUE self)
1757
1758
  GET_PARSER;
1758
1759
 
1759
1760
 
1760
- #line 1761 "parser.c"
1761
+ #line 1762 "parser.c"
1761
1762
  {
1762
1763
  cs = JSON_start;
1763
1764
  }
1764
1765
 
1765
- #line 759 "parser.rl"
1766
+ #line 760 "parser.rl"
1766
1767
  p = json->source;
1767
1768
  pe = p + json->len;
1768
1769
 
1769
- #line 1770 "parser.c"
1770
+ #line 1771 "parser.c"
1770
1771
  {
1771
1772
  if ( p == pe )
1772
1773
  goto _test_eof;
@@ -1822,7 +1823,7 @@ case 5:
1822
1823
  goto st1;
1823
1824
  goto st5;
1824
1825
  tr3:
1825
- #line 738 "parser.rl"
1826
+ #line 739 "parser.rl"
1826
1827
  {
1827
1828
  char *np;
1828
1829
  json->current_nesting = 1;
@@ -1831,7 +1832,7 @@ tr3:
1831
1832
  }
1832
1833
  goto st10;
1833
1834
  tr4:
1834
- #line 731 "parser.rl"
1835
+ #line 732 "parser.rl"
1835
1836
  {
1836
1837
  char *np;
1837
1838
  json->current_nesting = 1;
@@ -1843,7 +1844,7 @@ st10:
1843
1844
  if ( ++p == pe )
1844
1845
  goto _test_eof10;
1845
1846
  case 10:
1846
- #line 1847 "parser.c"
1847
+ #line 1848 "parser.c"
1847
1848
  switch( (*p) ) {
1848
1849
  case 13: goto st10;
1849
1850
  case 32: goto st10;
@@ -1900,7 +1901,7 @@ case 9:
1900
1901
  _out: {}
1901
1902
  }
1902
1903
 
1903
- #line 762 "parser.rl"
1904
+ #line 763 "parser.rl"
1904
1905
 
1905
1906
  if (cs >= JSON_first_final && p == pe) {
1906
1907
  return result;
@@ -1912,7 +1913,7 @@ case 9:
1912
1913
 
1913
1914
 
1914
1915
 
1915
- #line 1916 "parser.c"
1916
+ #line 1917 "parser.c"
1916
1917
  static const int JSON_quirks_mode_start = 1;
1917
1918
  static const int JSON_quirks_mode_first_final = 10;
1918
1919
  static const int JSON_quirks_mode_error = 0;
@@ -1920,7 +1921,7 @@ static const int JSON_quirks_mode_error = 0;
1920
1921
  static const int JSON_quirks_mode_en_main = 1;
1921
1922
 
1922
1923
 
1923
- #line 787 "parser.rl"
1924
+ #line 788 "parser.rl"
1924
1925
 
1925
1926
 
1926
1927
  static VALUE cParser_parse_quirks_mode(VALUE self)
@@ -1931,16 +1932,16 @@ static VALUE cParser_parse_quirks_mode(VALUE self)
1931
1932
  GET_PARSER;
1932
1933
 
1933
1934
 
1934
- #line 1935 "parser.c"
1935
+ #line 1936 "parser.c"
1935
1936
  {
1936
1937
  cs = JSON_quirks_mode_start;
1937
1938
  }
1938
1939
 
1939
- #line 797 "parser.rl"
1940
+ #line 798 "parser.rl"
1940
1941
  p = json->source;
1941
1942
  pe = p + json->len;
1942
1943
 
1943
- #line 1944 "parser.c"
1944
+ #line 1945 "parser.c"
1944
1945
  {
1945
1946
  if ( p == pe )
1946
1947
  goto _test_eof;
@@ -1974,7 +1975,7 @@ st0:
1974
1975
  cs = 0;
1975
1976
  goto _out;
1976
1977
  tr2:
1977
- #line 779 "parser.rl"
1978
+ #line 780 "parser.rl"
1978
1979
  {
1979
1980
  char *np = JSON_parse_value(json, p, pe, &result);
1980
1981
  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1984,7 +1985,7 @@ st10:
1984
1985
  if ( ++p == pe )
1985
1986
  goto _test_eof10;
1986
1987
  case 10:
1987
- #line 1988 "parser.c"
1988
+ #line 1989 "parser.c"
1988
1989
  switch( (*p) ) {
1989
1990
  case 13: goto st10;
1990
1991
  case 32: goto st10;
@@ -2073,7 +2074,7 @@ case 9:
2073
2074
  _out: {}
2074
2075
  }
2075
2076
 
2076
- #line 800 "parser.rl"
2077
+ #line 801 "parser.rl"
2077
2078
 
2078
2079
  if (cs >= JSON_quirks_mode_first_final && p == pe) {
2079
2080
  return result;
@@ -715,6 +715,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
715
715
  source = convert_encoding(StringValue(source));
716
716
  }
717
717
  json->current_nesting = 0;
718
+ StringValue(source);
718
719
  json->len = RSTRING_LEN(source);
719
720
  json->source = RSTRING_PTR(source);;
720
721
  PARSER_SET_REFERENCE(json, Vsource, source);