summaryrefslogtreecommitdiff
path: root/lib/scanf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-19 00:07:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-19 00:07:25 +0000
commitd371e3583e3b1e0692f92343017b62d2628190ff (patch)
treebe82924ada754f8542f394d0a3d28e0a0b02a098 /lib/scanf.rb
parent1fae66fca28167ca0e25625091c5df49405b8023 (diff)
* lib: revert r31635-r31638 and untabify with expand(1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/scanf.rb')
-rw-r--r--lib/scanf.rb96
1 files changed, 48 insertions, 48 deletions
diff --git a/lib/scanf.rb b/lib/scanf.rb
index ced14a8964..15def5aa12 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -506,28 +506,28 @@ module Scanf
class FormatString
attr_reader :string_left, :last_spec_tried,
- :last_match_tried, :matched_count, :space
+ :last_match_tried, :matched_count, :space
SPECIFIERS = 'diuXxofFeEgGscaA'
REGEX = /
- # possible space, followed by...
- (?:\s*
- # percent sign, followed by...
- %
- # another percent sign, or...
- (?:%|
- # optional assignment suppression flag
- \*?
- # optional maximum field width
- \d*
- # named character class, ...
- (?:\[\[:\w+:\]\]|
- # traditional character class, or...
- \[[^\]]*\]|
- # specifier letter.
- [#{SPECIFIERS}])))|
- # or miscellaneous characters
- [^%\s]+/ix
+ # possible space, followed by...
+ (?:\s*
+ # percent sign, followed by...
+ %
+ # another percent sign, or...
+ (?:%|
+ # optional assignment suppression flag
+ \*?
+ # optional maximum field width
+ \d*
+ # named character class, ...
+ (?:\[\[:\w+:\]\]|
+ # traditional character class, or...
+ \[[^\]]*\]|
+ # specifier letter.
+ [#{SPECIFIERS}])))|
+ # or miscellaneous characters
+ [^%\s]+/ix
def initialize(str)
@specs = []
@@ -578,33 +578,33 @@ end
class IO
- # The trick here is doing a match where you grab one *line*
- # of input at a time. The linebreak may or may not occur
- # at the boundary where the string matches a format specifier.
- # And if it does, some rule about whitespace may or may not
- # be in effect...
- #
- # That's why this is much more elaborate than the string
- # version.
- #
- # For each line:
- # Match succeeds (non-emptily)
- # and the last attempted spec/string sub-match succeeded:
- #
- # could the last spec keep matching?
- # yes: save interim results and continue (next line)
- #
- # The last attempted spec/string did not match:
- #
- # are we on the next-to-last spec in the string?
- # yes:
- # is fmt_string.string_left all spaces?
- # yes: does current spec care about input space?
- # yes: fatal failure
- # no: save interim results and continue
- # no: continue [this state could be analyzed further]
- #
- #
+# The trick here is doing a match where you grab one *line*
+# of input at a time. The linebreak may or may not occur
+# at the boundary where the string matches a format specifier.
+# And if it does, some rule about whitespace may or may not
+# be in effect...
+#
+# That's why this is much more elaborate than the string
+# version.
+#
+# For each line:
+# Match succeeds (non-emptily)
+# and the last attempted spec/string sub-match succeeded:
+#
+# could the last spec keep matching?
+# yes: save interim results and continue (next line)
+#
+# The last attempted spec/string did not match:
+#
+# are we on the next-to-last spec in the string?
+# yes:
+# is fmt_string.string_left all spaces?
+# yes: does current spec care about input space?
+# yes: fatal failure
+# no: save interim results and continue
+# no: continue [this state could be analyzed further]
+#
+#
def scanf(str,&b)
return block_scanf(str,&b) if b
@@ -671,8 +671,8 @@ class IO
def block_scanf(str)
final = []
- # Sub-ideal, since another FS gets created in scanf.
- # But used here to determine the number of specifiers.
+# Sub-ideal, since another FS gets created in scanf.
+# But used here to determine the number of specifiers.
fstr = Scanf::FormatString.new(str)
last_spec = fstr.last_spec
begin