summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-09-06 08:12:24 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-09-06 08:12:24 +0000
commit26d37a1b6ef66e54cdef2db8f3359cd13156f568 (patch)
tree2f185754897c86b547c7b4624b8e59008c68a74d /lib
parentf29380628f569131bd7e917b6b9eb05734ffb81e (diff)
* lib/jcode.rb: fixup quote handing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/jcode.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/jcode.rb b/lib/jcode.rb
index c3c3ad1001..0d796a2b01 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -9,7 +9,7 @@ class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
def _regex_quote(str)
- str.gsub(/(\\[-\\])|\\(.)|([][\\])/) do
+ str.gsub(/(\\[][\-\\])|\\(.)|([][\\])/) do
$1 || $2 || '\\' + $3
end
end
@@ -97,15 +97,18 @@ class String
def _expand_ch str
a = []
- str.scan(/(?:\\([-\\]))|(.)-(.)|(.)/m) do
- if s = $1 || $4
- a.push s
- elsif $2.length != $3.length
+ str.scan(/(?:\\(.)|([^\\]))-(?:\\(.)|([^\\]))|(?:\\(.)|(.))/m) do
+ from = $1 || $2
+ to = $3 || $4
+ one = $5 || $6
+ if one
+ a.push one
+ elsif from.length != to.length
next
- elsif $2.length == 1
- $2[0].upto($3[0]) { |c| a.push c.chr }
+ elsif from.length == 1
+ from[0].upto(to[0]) { |c| a.push c.chr }
else
- $2.upto($3) { |c| a.push c }
+ from.upto(to) { |c| a.push c }
end
end
a