Skip to content

Commit

Permalink
* lib/jcode.rb: fixup quote handing.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
eban committed Sep 6, 2001
1 parent 970dbfd commit fce2bf7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/jcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,15 +97,18 @@ def succ

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
Expand Down

0 comments on commit fce2bf7

Please sign in to comment.