mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/jcode.rb: fixup quote handing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
970dbfde6f
commit
fce2bf70a2
1 changed files with 11 additions and 8 deletions
19
lib/jcode.rb
19
lib/jcode.rb
|
@ -9,7 +9,7 @@ class String
|
||||||
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
|
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
|
||||||
|
|
||||||
def _regex_quote(str)
|
def _regex_quote(str)
|
||||||
str.gsub(/(\\[-\\])|\\(.)|([][\\])/) do
|
str.gsub(/(\\[][\-\\])|\\(.)|([][\\])/) do
|
||||||
$1 || $2 || '\\' + $3
|
$1 || $2 || '\\' + $3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -97,15 +97,18 @@ class String
|
||||||
|
|
||||||
def _expand_ch str
|
def _expand_ch str
|
||||||
a = []
|
a = []
|
||||||
str.scan(/(?:\\([-\\]))|(.)-(.)|(.)/m) do
|
str.scan(/(?:\\(.)|([^\\]))-(?:\\(.)|([^\\]))|(?:\\(.)|(.))/m) do
|
||||||
if s = $1 || $4
|
from = $1 || $2
|
||||||
a.push s
|
to = $3 || $4
|
||||||
elsif $2.length != $3.length
|
one = $5 || $6
|
||||||
|
if one
|
||||||
|
a.push one
|
||||||
|
elsif from.length != to.length
|
||||||
next
|
next
|
||||||
elsif $2.length == 1
|
elsif from.length == 1
|
||||||
$2[0].upto($3[0]) { |c| a.push c.chr }
|
from[0].upto(to[0]) { |c| a.push c.chr }
|
||||||
else
|
else
|
||||||
$2.upto($3) { |c| a.push c }
|
from.upto(to) { |c| a.push c }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
a
|
a
|
||||||
|
|
Loading…
Reference in a new issue