summary refs log tree commit
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2011-07-08 17:25:17 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2011-07-08 17:25:17 +0900
commit24f84d63beef15eafd2e59df3d809f1928774d00 (patch)
treed6f214810ad4799af45b8b780ad13c076d80995d
parent10c6bfba2f03577ad3a5b7b1abff31a35378f45e (diff)
downloadruby-json-24f84d63beef15eafd2e59df3d809f1928774d00.tar.gz
remove trailing spaces.
-rw-r--r--ext/json/ext/parser/parser.c15
-rw-r--r--lib/json.rb8
-rw-r--r--lib/json/add/core.rb14
-rw-r--r--lib/json/common.rb2
-rw-r--r--lib/json/editor.rb32
-rw-r--r--lib/json/pure/generator.rb2
-rw-r--r--lib/json/pure/parser.rb6
-rwxr-xr-xtests/test_json.rb2
-rwxr-xr-xtests/test_json_addition.rb2
-rwxr-xr-xtools/fuzz.rb2
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\"}"
 #
-# <tt>JSON.generate</tt> only allows objects or arrays to be converted
-# to JSON syntax. While <tt>to_json</tt> accepts many Ruby classes
+# <tt>JSON.generate</tt> only allows objects or arrays to be converted
+# to JSON syntax. While <tt>to_json</tt> 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 <tt>string</tt> 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 <tt>y</tt>, month
   # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> 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 <tt>y</tt>, month <tt>m</tt>, day
@@ -123,7 +123,7 @@ class DateTime
       'S' => sec,
       'of' => offset.to_s,
       'sg' => start,
-    }
+    }
   end
 
   # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
@@ -136,7 +136,7 @@ end
 
 # Range serialization/deserialization
 class Range
-  
+
   # Deserializes JSON string by constructing new Range object with arguments
   # <tt>a</tt> serialized by <tt>to_json</tt>.
   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
   # <tt>v</tt> serialized by <tt>to_json</tt>.
   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