Skip to content

Commit

Permalink
remove trailing spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jul 8, 2011
1 parent 10c6bfb commit 24f84d6
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 42 deletions.
15 changes: 8 additions & 7 deletions ext/json/ext/parser/parser.c
Expand Up @@ -233,9 +233,9 @@ case 8:
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;}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1819,7 +1820,7 @@ case 5:
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;
Expand Down Expand Up @@ -1876,7 +1877,7 @@ case 9:
_out: {}
}

#line 737 "parser.rl"
#line 738 "parser.rl"

if (cs >= JSON_first_final && p == pe) {
return result;
Expand Down
8 changes: 4 additions & 4 deletions lib/json.rb
Expand Up @@ -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"}')
Expand All @@ -32,7 +32,7 @@
# just as simple.
#
# require 'json'
#
#
# my_hash = {:hello => "goodbye"}
# puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
#
Expand All @@ -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'
Expand Down
14 changes: 7 additions & 7 deletions lib/json/add/core.rb
Expand Up @@ -21,7 +21,7 @@ def as_json(*)
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
Expand Down Expand Up @@ -52,7 +52,7 @@ def as_json(*)
'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)
Expand All @@ -62,7 +62,7 @@ def to_json(*args)

# 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)
Expand All @@ -80,7 +80,7 @@ def as_json(*)
'm' => month,
'd' => day,
'sg' => start,
}
}
end

# Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
Expand Down Expand Up @@ -123,7 +123,7 @@ def as_json(*)
'S' => sec,
'of' => offset.to_s,
'sg' => start,
}
}
end

# Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
Expand All @@ -136,7 +136,7 @@ def to_json(*args)

# 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)
Expand All @@ -162,7 +162,7 @@ def to_json(*args)

# 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)
Expand Down
2 changes: 1 addition & 1 deletion lib/json/common.rb
Expand Up @@ -291,7 +291,7 @@ def load(source, proc = nil)
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
Expand Down
32 changes: 16 additions & 16 deletions lib/json/editor.rb
Expand Up @@ -47,14 +47,14 @@ def Editor.fetch_icon(name)
# 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
Expand All @@ -66,8 +66,8 @@ def Editor.error_dialog(window, text)
# 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|
Expand Down Expand Up @@ -464,7 +464,7 @@ def create
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))

Expand Down Expand Up @@ -503,7 +503,7 @@ def open_location(item)
# 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

Expand Down Expand Up @@ -665,7 +665,7 @@ def collapsed_nodes(item)
collapse_all
else
self.expanded = true
expand_all
expand_all
end
end

Expand Down Expand Up @@ -884,7 +884,7 @@ def ask_for_hash_pair(parent)
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]
Expand Down Expand Up @@ -936,7 +936,7 @@ def ask_for_element(parent = nil, default_type = nil, value_text = @content)
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
Expand Down Expand Up @@ -981,7 +981,7 @@ def ask_for_order
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
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def ask_for_find_term(search = nil)
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)
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def file_save
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)
Expand All @@ -1241,7 +1241,7 @@ def store_file(path)
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
Expand Down Expand Up @@ -1333,7 +1333,7 @@ def ask_for_location

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
Expand Down
2 changes: 1 addition & 1 deletion lib/json/pure/generator.rb
Expand Up @@ -125,7 +125,7 @@ def self.from_state(opts)
# * *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
Expand Down
6 changes: 3 additions & 3 deletions lib/json/pure/parser.rb
Expand Up @@ -41,7 +41,7 @@ class Parser < StringScanner
[^*/]| # 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
Expand Down Expand Up @@ -162,12 +162,12 @@ def parse
?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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_json.rb
Expand Up @@ -150,7 +150,7 @@ def test_parse_array
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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_json_addition.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(a)
def ==(other)
a == other.a
end

def self.json_create(object)
new(*object['args'])
end
Expand Down
2 changes: 1 addition & 1 deletion tools/fuzz.rb
Expand Up @@ -120,7 +120,7 @@ def make_spaces
if $DEBUG
puts "-" * 80
puts json, json.size
else
else
puts json.size
end
begin
Expand Down

0 comments on commit 24f84d6

Please sign in to comment.