From 8abe6f4141127f019f6346f81baa778cbab15224 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 06:37:48 +0900 Subject: remove trailing spaces. * Rakefile (EXT_PARSER_SRC): remove trailing spaces. --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rakefile b/Rakefile index 133119b..e48f6b1 100644 --- a/Rakefile +++ b/Rakefile @@ -363,6 +363,8 @@ else else sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2" end + src = File.read("parser.c").gsub(/[ \t]+$/, '') + File.open("parser.c", "w") {|f| f.print src} end end -- cgit v1.2.3-24-ge0c7 From d1c383904523a6e017e3ea9a919aeb0d611218e7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 7 Jul 2011 23:20:33 +0900 Subject: re-initialize test * tests/test_json.rb (test_allocate): add re-initialize test. --- tests/test_json.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_json.rb b/tests/test_json.rb index d320498..5b43ec9 100755 --- a/tests/test_json.rb +++ b/tests/test_json.rb @@ -408,9 +408,11 @@ EOT end if defined?(JSON::Ext::Parser) - def test_uninitialized + def test_allocate + parser = JSON::Ext::Parser.new("{}") + assert_raise(TypeError, '[ruby-core:35079]') {parser.__send__(:initialize, "{}")} parser = JSON::Ext::Parser.allocate - assert_raise(TypeError) {parser.source} + assert_raise(TypeError, '[ruby-core:35079]') {parser.source} end end end -- cgit v1.2.3-24-ge0c7 From 08793aa47dfca15f678842fd5cd583fe2fb67136 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 06:39:42 +0900 Subject: no force_encoding * ext/json/ext/parser/parser.rl (JSON_parse_string): no needs to use force_encoding. --- ext/json/ext/parser/parser.c | 30 ++++++++++-------------------- ext/json/ext/parser/parser.rl | 20 +++++--------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index bb6c780..4910865 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -69,7 +69,7 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) #ifdef HAVE_RUBY_ENCODING_H static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE, CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE; -static ID i_encoding, i_encode, i_encode_bang, i_force_encoding; +static ID i_encoding, i_encode; #else static ID i_iconv; #endif @@ -1575,21 +1575,13 @@ static VALUE convert_encoding(VALUE source) VALUE encoding = rb_funcall(source, i_encoding, 0); if (encoding == CEncoding_ASCII_8BIT) { if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32BE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32BE); } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16BE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16BE); } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32LE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32LE); } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16LE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); } else { FORCE_UTF8(source); } @@ -1741,16 +1733,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -#line 1745 "parser.c" +#line 1737 "parser.c" { cs = JSON_start; } -#line 742 "parser.rl" +#line 734 "parser.rl" p = json->source; pe = p + json->len; -#line 1754 "parser.c" +#line 1746 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1827,7 +1819,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1831 "parser.c" +#line 1823 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1884,7 +1876,7 @@ case 9: _out: {} } -#line 745 "parser.rl" +#line 737 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; @@ -1975,8 +1967,6 @@ void Init_parser() CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit")); i_encoding = rb_intern("encoding"); i_encode = rb_intern("encode"); - i_encode_bang = rb_intern("encode!"); - i_force_encoding = rb_intern("force_encoding"); #else i_iconv = rb_intern("iconv"); #endif diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index 44ddfa6..b18f06f 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -67,7 +67,7 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) #ifdef HAVE_RUBY_ENCODING_H static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE, CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE; -static ID i_encoding, i_encode, i_encode_bang, i_force_encoding; +static ID i_encoding, i_encode; #else static ID i_iconv; #endif @@ -573,21 +573,13 @@ static VALUE convert_encoding(VALUE source) VALUE encoding = rb_funcall(source, i_encoding, 0); if (encoding == CEncoding_ASCII_8BIT) { if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32BE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32BE); } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16BE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16BE); } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32LE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32LE); } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { - source = rb_str_dup(source); - rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16LE); - source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8); + source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); } else { FORCE_UTF8(source); } @@ -832,8 +824,6 @@ void Init_parser() CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit")); i_encoding = rb_intern("encoding"); i_encode = rb_intern("encode"); - i_encode_bang = rb_intern("encode!"); - i_force_encoding = rb_intern("force_encoding"); #else i_iconv = rb_intern("iconv"); #endif -- cgit v1.2.3-24-ge0c7 From 1b19c43a4f459988474f86ccbbfc92a420af58e8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 06:46:06 +0900 Subject: should not modify argument * ext/json/ext/parser/parser.h (FORCE_UTF8): should not modify encoding of the argument. --- ext/json/ext/parser/parser.h | 2 +- tests/test_json.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/json/ext/parser/parser.h b/ext/json/ext/parser/parser.h index 2be640e..f2ce5a4 100644 --- a/ext/json/ext/parser/parser.h +++ b/ext/json/ext/parser/parser.h @@ -9,7 +9,7 @@ #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" -#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) +#define FORCE_UTF8(obj) ((obj) = rb_enc_associate(rb_str_dup(obj), rb_utf8_encoding())) #else #define FORCE_UTF8(obj) #endif diff --git a/tests/test_json.rb b/tests/test_json.rb index 5b43ec9..825a507 100755 --- a/tests/test_json.rb +++ b/tests/test_json.rb @@ -415,4 +415,10 @@ EOT assert_raise(TypeError, '[ruby-core:35079]') {parser.source} end end + + def test_argument_encoding + source = "{}".force_encoding("ascii-8bit") + JSON::Parser.new(source) + assert_equal Encoding::ASCII_8BIT, source.encoding + end if defined?(Encoding::ASCII_8BIT) end -- cgit v1.2.3-24-ge0c7 From 62b2f6ab3c97697883c820cf13d6b8a85b1f053e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 16:13:39 +0900 Subject: Adjust indent. --- ext/json/ext/parser/parser.rl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index b18f06f..3257a48 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -120,9 +120,9 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, fhold; fbreak; } else { if (NIL_P(json->object_class)) { - rb_hash_aset(*result, last_name, v); + rb_hash_aset(*result, last_name, v); } else { - rb_funcall(*result, i_aset, 2, last_name, v); + rb_funcall(*result, i_aset, 2, last_name, v); } fexec np; } -- cgit v1.2.3-24-ge0c7 From 10c6bfba2f03577ad3a5b7b1abff31a35378f45e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 16:41:47 +0900 Subject: Duplicate the argument of convert_encoding() only. --- ext/json/ext/parser/parser.h | 2 +- ext/json/ext/parser/parser.rl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/json/ext/parser/parser.h b/ext/json/ext/parser/parser.h index f2ce5a4..2be640e 100644 --- a/ext/json/ext/parser/parser.h +++ b/ext/json/ext/parser/parser.h @@ -9,7 +9,7 @@ #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" -#define FORCE_UTF8(obj) ((obj) = rb_enc_associate(rb_str_dup(obj), rb_utf8_encoding())) +#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) #else #define FORCE_UTF8(obj) #endif diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index 3257a48..21b445e 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -581,6 +581,7 @@ static VALUE convert_encoding(VALUE source) } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); } else { + source = rb_str_dup(source); FORCE_UTF8(source); } } else { -- cgit v1.2.3-24-ge0c7 From 24f84d63beef15eafd2e59df3d809f1928774d00 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 Jul 2011 17:25:17 +0900 Subject: remove trailing spaces. --- ext/json/ext/parser/parser.c | 15 ++++++++------- lib/json.rb | 8 ++++---- lib/json/add/core.rb | 14 +++++++------- lib/json/common.rb | 2 +- lib/json/editor.rb | 32 ++++++++++++++++---------------- lib/json/pure/generator.rb | 2 +- lib/json/pure/parser.rb | 6 +++--- tests/test_json.rb | 2 +- tests/test_json_addition.rb | 2 +- tools/fuzz.rb | 2 +- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 4910865..af57b81 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -233,9 +233,9 @@ tr11: p--; {p++; cs = 9; goto _out;} } else { if (NIL_P(json->object_class)) { - rb_hash_aset(*result, last_name, v); + rb_hash_aset(*result, last_name, v); } else { - rb_funcall(*result, i_aset, 2, last_name, v); + rb_funcall(*result, i_aset, 2, last_name, v); } {p = (( np))-1;} } @@ -1583,6 +1583,7 @@ static VALUE convert_encoding(VALUE source) } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); } else { + source = rb_str_dup(source); FORCE_UTF8(source); } } else { @@ -1733,16 +1734,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -#line 1737 "parser.c" +#line 1738 "parser.c" { cs = JSON_start; } -#line 734 "parser.rl" +#line 735 "parser.rl" p = json->source; pe = p + json->len; -#line 1746 "parser.c" +#line 1747 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1819,7 +1820,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1823 "parser.c" +#line 1824 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1876,7 +1877,7 @@ case 9: _out: {} } -#line 737 "parser.rl" +#line 738 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; diff --git a/lib/json.rb b/lib/json.rb index cc33f72..d7bc1a2 100644 --- a/lib/json.rb +++ b/lib/json.rb @@ -15,7 +15,7 @@ # # To parse a JSON string received by another application, or generated within # your existing application: -# +# # require 'json' # # my_hash = JSON.parse('{"hello": "goodbye"}') @@ -32,7 +32,7 @@ # just as simple. # # require 'json' -# +# # my_hash = {:hello => "goodbye"} # puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}" # @@ -41,8 +41,8 @@ # require 'json' # puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}" # -# JSON.generate only allows objects or arrays to be converted -# to JSON syntax. While to_json accepts many Ruby classes +# JSON.generate only allows objects or arrays to be converted +# to JSON syntax. While to_json accepts many Ruby classes # even though it only acts a method for serialization: # # require 'json' diff --git a/lib/json/add/core.rb b/lib/json/add/core.rb index 9c06a9b..e9850af 100644 --- a/lib/json/add/core.rb +++ b/lib/json/add/core.rb @@ -21,7 +21,7 @@ class Symbol def to_json(*a) as_json.to_json(*a) end - + # Deserializes JSON string by converting the string value stored in the object to a Symbol def self.json_create(o) o['s'].to_sym @@ -52,7 +52,7 @@ class Time 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000 } end - + # Stores class name (Time) with number of seconds since epoch and number of # microseconds for Time as JSON string def to_json(*args) @@ -62,7 +62,7 @@ end # Date serialization/deserialization class Date - + # Deserializes JSON string by converting Julian year y, month # m, day d and Day of Calendar Reform sg to Date. def self.json_create(object) @@ -80,7 +80,7 @@ class Date 'm' => month, 'd' => day, 'sg' => start, - } + } end # Stores class name (Date) with Julian year y, month m, day @@ -123,7 +123,7 @@ class DateTime 'S' => sec, 'of' => offset.to_s, 'sg' => start, - } + } end # Stores class name (DateTime) with Julian year y, month m, @@ -136,7 +136,7 @@ end # Range serialization/deserialization class Range - + # Deserializes JSON string by constructing new Range object with arguments # a serialized by to_json. def self.json_create(object) @@ -162,7 +162,7 @@ end # Struct serialization/deserialization class Struct - + # Deserializes JSON string by constructing new Struct object with values # v serialized by to_json. def self.json_create(object) diff --git a/lib/json/common.rb b/lib/json/common.rb index 1cbbf1c..1a5f048 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -291,7 +291,7 @@ module JSON recurse_proc(result, &proc) if proc result end - + # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_ def recurse_proc(result, &proc) case result diff --git a/lib/json/editor.rb b/lib/json/editor.rb index 3450455..985a554 100644 --- a/lib/json/editor.rb +++ b/lib/json/editor.rb @@ -47,14 +47,14 @@ module JSON # Opens an error dialog on top of _window_ showing the error message # _text_. def Editor.error_dialog(window, text) - dialog = MessageDialog.new(window, Dialog::MODAL, - MessageDialog::ERROR, + dialog = MessageDialog.new(window, Dialog::MODAL, + MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all dialog.run rescue TypeError - dialog = MessageDialog.new(Editor.window, Dialog::MODAL, - MessageDialog::ERROR, + dialog = MessageDialog.new(Editor.window, Dialog::MODAL, + MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all dialog.run @@ -66,8 +66,8 @@ module JSON # message _text_. If yes was answered _true_ is returned, otherwise # _false_. def Editor.question_dialog(window, text) - dialog = MessageDialog.new(window, Dialog::MODAL, - MessageDialog::QUESTION, + dialog = MessageDialog.new(window, Dialog::MODAL, + MessageDialog::QUESTION, MessageDialog::BUTTONS_YES_NO, text) dialog.show_all dialog.run do |response| @@ -464,7 +464,7 @@ module JSON add_separator add_item("Append new node", ?a, &method(:append_new_node)) add_item("Insert new node before", ?i, &method(:insert_new_node)) - add_separator + add_separator add_item("Collapse/Expand node (recursively)", ?e, &method(:collapse_expand)) @@ -503,7 +503,7 @@ module JSON # Revert the current JSON document in the editor to the saved version. def revert(item) window.instance_eval do - @filename and file_open(@filename) + @filename and file_open(@filename) end end @@ -665,7 +665,7 @@ module JSON collapse_all else self.expanded = true - expand_all + expand_all end end @@ -884,7 +884,7 @@ module JSON dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT @key = key_input.text type = ALL_TYPES[@type = type_input.active] @@ -936,7 +936,7 @@ module JSON dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT type = types[type_input.active] @content = case type @@ -981,7 +981,7 @@ module JSON dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT return @order = order_input.text, reverse_checkbox.active? end @@ -1016,7 +1016,7 @@ module JSON dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT begin return Regexp.new(regex_input.text, icase_checkbox.active? ? Regexp::IGNORECASE : 0) @@ -1215,7 +1215,7 @@ module JSON end end - # Save the current file as the filename + # Save the current file as the filename def file_save_as filename = select_file('Save as a JSON file') store_file(filename) @@ -1241,7 +1241,7 @@ module JSON rescue SystemCallError => e Editor.error_dialog(self, "Failed to store JSON file: #{e}!") end - + # Load the file named _filename_ into the editor as a JSON document. def load_file(filename) if filename @@ -1333,7 +1333,7 @@ module JSON dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT return @location = location_input.text end diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb index 9790250..3687e30 100644 --- a/lib/json/pure/generator.rb +++ b/lib/json/pure/generator.rb @@ -125,7 +125,7 @@ module JSON # * *indent*: a string used to indent levels (default: ''), # * *space*: a string that is put after, a : or , delimiter (default: ''), # * *space_before*: a string that is put before a : pair delimiter (default: ''), - # * *object_nl*: a string that is put at the end of a JSON object (default: ''), + # * *object_nl*: a string that is put at the end of a JSON object (default: ''), # * *array_nl*: a string that is put at the end of a JSON array (default: ''), # * *check_circular*: is deprecated now, use the :max_nesting option instead, # * *max_nesting*: sets the maximum level of data structure nesting in diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index 8043e67..d612018 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -41,7 +41,7 @@ module JSON [^*/]| # normal chars /[^*]| # slashes that do not start a nested comment \*[^/]| # asterisks that do not end this comment - /(?=\*/) # single slash before this comment's end + /(?=\*/) # single slash before this comment's end )* \*/ # the End of this comment |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr @@ -162,12 +162,12 @@ module JSON ?n => "\n", ?r => "\r", ?t => "\t", - ?u => nil, + ?u => nil, }) EMPTY_8BIT_STRING = '' if ::String.method_defined?(:encode) - EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT + EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT end def parse_string diff --git a/tests/test_json.rb b/tests/test_json.rb index 825a507..b367e90 100755 --- a/tests/test_json.rb +++ b/tests/test_json.rb @@ -150,7 +150,7 @@ class TC_JSON < Test::Unit::TestCase assert_equal(@ary, parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]]'\ ',[false],[true]]')) - assert_equal(@ary, parse(%Q{ [ [1] , ["foo"] , [3.14] \t , [47.11e+2] + assert_equal(@ary, parse(%Q{ [ [1] , ["foo"] , [3.14] \t , [47.11e+2]\s , [2718.0E-3 ],\r[ null] , [[1, -2, 3 ]], [false ],[ true]\n ] })) end diff --git a/tests/test_json_addition.rb b/tests/test_json_addition.rb index c8bfb41..a8181e8 100755 --- a/tests/test_json_addition.rb +++ b/tests/test_json_addition.rb @@ -19,7 +19,7 @@ class TC_JSONAddition < Test::Unit::TestCase def ==(other) a == other.a end - + def self.json_create(object) new(*object['args']) end diff --git a/tools/fuzz.rb b/tools/fuzz.rb index 4dacd95..c0fae12 100755 --- a/tools/fuzz.rb +++ b/tools/fuzz.rb @@ -120,7 +120,7 @@ loop do if $DEBUG puts "-" * 80 puts json, json.size - else + else puts json.size end begin -- cgit v1.2.3-24-ge0c7