* instruby.rb, ext/extmk.rb, lib/benchmark.rb, lib/cgi.rb,

lib/debug.rb, lib/getoptlong.rb, lib/optparse.rb, lib/time.rb,
  lib/date/format.rb, lib/irb/ruby-lex.rb lib/uri/common.rb: revert
  escape for `-' in character class.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2003-03-29 06:39:50 +00:00
parent fec60bc7c4
commit 0977fe1705
12 changed files with 44 additions and 37 deletions

View File

@ -1,3 +1,10 @@
Sat Mar 29 15:19:48 2003 Tanaka Akira <akr@m17n.org>
* instruby.rb, ext/extmk.rb, lib/benchmark.rb, lib/cgi.rb,
lib/debug.rb, lib/getoptlong.rb, lib/optparse.rb, lib/time.rb,
lib/date/format.rb, lib/irb/ruby-lex.rb lib/uri/common.rb: revert
escape for `-' in character class.
Sat Mar 29 09:48:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Sat Mar 29 09:48:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (avalue_to_svalue): use rb_check_array_type() again. * eval.c (avalue_to_svalue): use rb_check_array_type() again.

View File

@ -127,7 +127,7 @@ def parse_args()
$mflags = Shellwords.shellwords(mflags) $mflags = Shellwords.shellwords(mflags)
if arg = $mflags.first if arg = $mflags.first
arg.insert(0, '-') if /\A[^\-][^=]*\Z/ =~ arg arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
end end
$make, *rest = Shellwords.shellwords($make) $make, *rest = Shellwords.shellwords($make)

View File

@ -25,7 +25,7 @@ def parse_args()
$mflags = Shellwords.shellwords(mflags) $mflags = Shellwords.shellwords(mflags)
if arg = $mflags.first if arg = $mflags.first
arg.insert(0, '-') if /\A[^\-][^=]*\Z/ =~ arg arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
end end
$make, *rest = Shellwords.shellwords($make) $make, *rest = Shellwords.shellwords($make)

View File

@ -577,13 +577,13 @@ module Benchmark
def format(arg0 = nil, *args) def format(arg0 = nil, *args)
fmtstr = (arg0 || FMTSTR).dup fmtstr = (arg0 || FMTSTR).dup
fmtstr.gsub!(/(%[\-+\.\d]*)n/){"#{$1}s" % label} fmtstr.gsub!(/(%[-+\.\d]*)n/){"#{$1}s" % label}
fmtstr.gsub!(/(%[\-+\.\d]*)u/){"#{$1}f" % utime} fmtstr.gsub!(/(%[-+\.\d]*)u/){"#{$1}f" % utime}
fmtstr.gsub!(/(%[\-+\.\d]*)y/){"#{$1}f" % stime} fmtstr.gsub!(/(%[-+\.\d]*)y/){"#{$1}f" % stime}
fmtstr.gsub!(/(%[\-+\.\d]*)U/){"#{$1}f" % cutime} fmtstr.gsub!(/(%[-+\.\d]*)U/){"#{$1}f" % cutime}
fmtstr.gsub!(/(%[\-+\.\d]*)Y/){"#{$1}f" % cstime} fmtstr.gsub!(/(%[-+\.\d]*)Y/){"#{$1}f" % cstime}
fmtstr.gsub!(/(%[\-+\.\d]*)t/){"#{$1}f" % total} fmtstr.gsub!(/(%[-+\.\d]*)t/){"#{$1}f" % total}
fmtstr.gsub!(/(%[\-+\.\d]*)r/){"(#{$1}f)" % real} fmtstr.gsub!(/(%[-+\.\d]*)r/){"(#{$1}f)" % real}
arg0 ? Kernel::format(fmtstr, *args) : fmtstr arg0 ? Kernel::format(fmtstr, *args) : fmtstr
end end

View File

@ -236,7 +236,7 @@ class CGI
url_encoded_string = CGI::escape("string") url_encoded_string = CGI::escape("string")
=end =end
def CGI::escape(string) def CGI::escape(string)
string.gsub(/([^ a-zA-Z0-9_.\-]+)/n) do string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase '%' + $1.unpack('H2' * $1.size).join('%').upcase
end.tr(' ', '+') end.tr(' ', '+')
end end

View File

@ -80,7 +80,7 @@ class Date
when '%F' when '%F'
return unless __strptime(str, '%Y-%m-%d', elem) return unless __strptime(str, '%Y-%m-%d', elem)
when '%G' when '%G'
return unless str.sub!(/\A([\-+]?\d+)/o, '') return unless str.sub!(/\A([-+]?\d+)/o, '')
val = $1.to_i val = $1.to_i
elem[:cwyear] = val elem[:cwyear] = val
when '%g' when '%g'
@ -163,7 +163,7 @@ class Date
when '%x' when '%x'
return unless __strptime(str, '%m/%d/%y', elem) return unless __strptime(str, '%m/%d/%y', elem)
when '%Y' when '%Y'
return unless str.sub!(/\A([\-+]?\d+)/o, '') return unless str.sub!(/\A([-+]?\d+)/o, '')
val = $1.to_i val = $1.to_i
elem[:year] = val elem[:year] = val
when '%y' when '%y'
@ -173,7 +173,7 @@ class Date
elem[:year] = val elem[:year] = val
elem[:cent] ||= if val >= 69 then 19 else 20 end elem[:cent] ||= if val >= 69 then 19 else 20 end
when '%Z', '%z' when '%Z', '%z'
return unless str.sub!(/\A([a-z0-9:+\-]+(?:\s+dst\b)?)/io, '') return unless str.sub!(/\A([a-z0-9:+-]+(?:\s+dst\b)?)/io, '')
val = $1 val = $1
elem[:zone] = val elem[:zone] = val
offset = zone_to_diff(val) offset = zone_to_diff(val)
@ -227,7 +227,7 @@ class Date
def self._parse(str, comp=false) def self._parse(str, comp=false)
str = str.dup str = str.dup
str.gsub!(/[^\-+.\/:0-9a-z]+/ino, ' ') str.gsub!(/[^.\/:0-9a-z+-]+/ino, ' ')
# day # day
if str.sub!(/(#{PARSE_DAYPAT})\S*/ino, ' ') if str.sub!(/(#{PARSE_DAYPAT})\S*/ino, ' ')
@ -246,7 +246,7 @@ class Date
( (
[a-z]+(?:\s+dst)?\b [a-z]+(?:\s+dst)?\b
| |
[\-+]\d+(?::?\d+) [-+]\d+(?::?\d+)
) )
)? )?
/inox, /inox,
@ -308,7 +308,7 @@ class Date
end end
# iso # iso
elsif str.sub!(/([\-+]?\d+)-(\d+)-(-?\d+)/no, ' ') elsif str.sub!(/([-+]?\d+)-(\d+)-(-?\d+)/no, ' ')
year = $1.to_i year = $1.to_i
mon = $2.to_i mon = $2.to_i
mday = $3.to_i mday = $3.to_i
@ -332,7 +332,7 @@ class Date
mday = $4.to_i mday = $4.to_i
# vms # vms
elsif str.sub!(/(-?\d+)-(#{PARSE_MONTHPAT})[^\-]*-(-?\d+)/ino, ' ') elsif str.sub!(/(-?\d+)-(#{PARSE_MONTHPAT})[^-]*-(-?\d+)/ino, ' ')
mday = $1.to_i mday = $1.to_i
mon = ABBR_MONTHS[$2.downcase] mon = ABBR_MONTHS[$2.downcase]
year = $3.to_i year = $3.to_i
@ -363,7 +363,7 @@ class Date
# ddd # ddd
elsif str.sub!( elsif str.sub!(
/([\-+]?)(\d{4,14}) /([-+]?)(\d{4,14})
(?: (?:
\s* \s*
T? T?
@ -375,7 +375,7 @@ class Date
( (
Z Z
| |
[\-+]\d{2,4} [-+]\d{2,4}
) )
\b \b
)? )?
@ -444,7 +444,7 @@ class Date
if ZONES.include?(abb) if ZONES.include?(abb)
offset = ZONES[abb] offset = ZONES[abb]
offset += 3600 if dst offset += 3600 if dst
elsif /\A([+\-])(\d{2}):?(\d{2})?\Z/no =~ str elsif /\A([+-])(\d{2}):?(\d{2})?\Z/no =~ str
offset = $2.to_i * 3600 + $3.to_i * 60 offset = $2.to_i * 3600 + $3.to_i * 60
offset *= -1 if $1 == '-' offset *= -1 if $1 == '-'
end end

View File

@ -425,7 +425,7 @@ class Context
b = previous_line ? previous_line - 10 : binding_line - 5 b = previous_line ? previous_line - 10 : binding_line - 5
e = b + 9 e = b + 9
else else
b, e = $1.split(/[\-,]/) b, e = $1.split(/[-,]/)
if e if e
b = b.to_i b = b.to_i
e = e.to_i e = e.to_i

View File

@ -180,7 +180,7 @@ class GetoptLong
# #
next if i == argument_flag next if i == argument_flag
begin begin
if !i.is_a?(String) || i !~ /^-([^\-]|-.+)$/ if !i.is_a?(String) || i !~ /^-([^-]|-.+)$/
raise ArgumentError, "an invalid option `#{i}'" raise ArgumentError, "an invalid option `#{i}'"
end end
if (@canonical_names.include?(i)) if (@canonical_names.include?(i))

View File

@ -948,7 +948,7 @@ class RubyLex
allow_point = false allow_point = false
when allow_e && "e", allow_e && "E" when allow_e && "e", allow_e && "E"
type = TkFLOAT type = TkFLOAT
if peek(0) =~ /[+\-]/ if peek(0) =~ /[+-]/
getc getc
end end
allow_e = false allow_e = false

View File

@ -1346,14 +1346,14 @@ Default options, which never appear in option summary.
hex = 'x[\da-f]+(?:_[\da-f]+)*' hex = 'x[\da-f]+(?:_[\da-f]+)*'
octal = "0(?:[0-7]*(?:_[0-7]+)*|#{binary}|#{hex})" octal = "0(?:[0-7]*(?:_[0-7]+)*|#{binary}|#{hex})"
integer = "#{octal}|#{decimal}" integer = "#{octal}|#{decimal}"
accept(Integer, %r"\A[\-+]?(?:#{integer})"io) {|s| Integer(s) if s} accept(Integer, %r"\A[-+]?(?:#{integer})"io) {|s| Integer(s) if s}
=begin =begin
: Float : Float
Float number format, and converts to (({Float})). Float number format, and converts to (({Float})).
=end #'#"#`# =end #'#"#`#
float = "(?:#{decimal}(?:\\.(?:#{decimal})?)?|\\.#{decimal})(?:E[\\-+]?#{decimal})?" float = "(?:#{decimal}(?:\\.(?:#{decimal})?)?|\\.#{decimal})(?:E[-+]?#{decimal})?"
floatpat = %r"\A[\-+]?#{float}"io floatpat = %r"\A[-+]?#{float}"io
accept(Float, floatpat) {|s| s.to_f if s} accept(Float, floatpat) {|s| s.to_f if s}
=begin =begin
@ -1361,13 +1361,13 @@ Default options, which never appear in option summary.
Generic numeric format, and converts to (({Integer})) for integer Generic numeric format, and converts to (({Integer})) for integer
format, (({Float})) for float format. format, (({Float})) for float format.
=end #'#"#`# =end #'#"#`#
accept(Numeric, %r"\A[\-+]?(?:#{octal}|#{float})"io) {|s| eval(s) if s} accept(Numeric, %r"\A[-+]?(?:#{octal}|#{float})"io) {|s| eval(s) if s}
=begin =begin
: OptionParser::DecimalInteger : OptionParser::DecimalInteger
Decimal integer format, to be converted to (({Integer})). Decimal integer format, to be converted to (({Integer})).
=end #'#"#`# =end #'#"#`#
DecimalInteger = /\A[\-+]?#{decimal}/io DecimalInteger = /\A[-+]?#{decimal}/io
accept(DecimalInteger) {|s| s.to_i if s} accept(DecimalInteger) {|s| s.to_i if s}
=begin =begin
@ -1375,7 +1375,7 @@ Default options, which never appear in option summary.
Ruby/C like octal/hexadecimal/binary integer format, to be converted Ruby/C like octal/hexadecimal/binary integer format, to be converted
to (({Integer})). to (({Integer})).
=end #'#"#`# =end #'#"#`#
OctalInteger = /\A[\-+]?(?:[0-7]+(?:_[0-7]+)*|0(?:#{binary}|#{hex}))/io OctalInteger = /\A[-+]?(?:[0-7]+(?:_[0-7]+)*|0(?:#{binary}|#{hex}))/io
accept(OctalInteger) {|s| s.oct if s} accept(OctalInteger) {|s| s.oct if s}
=begin =begin

View File

@ -69,9 +69,9 @@ class Time
def zone_offset(zone, year=Time.now.year) def zone_offset(zone, year=Time.now.year)
off = nil off = nil
zone = zone.upcase zone = zone.upcase
if /\A([\-+])(\d\d):?(\d\d)\z/ =~ zone if /\A([+-])(\d\d):?(\d\d)\z/ =~ zone
off = ($1 == '-' ? -1 : 1) * ($2.to_i * 60 + $3.to_i) * 60 off = ($1 == '-' ? -1 : 1) * ($2.to_i * 60 + $3.to_i) * 60
elsif /\A[\-+]\d\d\z/ =~ zone elsif /\A[+-]\d\d\z/ =~ zone
off = zone.to_i * 3600 off = zone.to_i * 3600
elsif ZoneOffset.include?(zone) elsif ZoneOffset.include?(zone)
off = ZoneOffset[zone] * 3600 off = ZoneOffset[zone] * 3600
@ -191,7 +191,7 @@ class Time
(\d{2})\s* (\d{2})\s*
:\s*(\d{2})\s* :\s*(\d{2})\s*
(?::\s*(\d{2}))?\s+ (?::\s*(\d{2}))?\s+
([+\-]\d{4}| ([+-]\d{4}|
UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/ix =~ date UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/ix =~ date
# Since RFC 2822 permit comments, the regexp has no right anchor. # Since RFC 2822 permit comments, the regexp has no right anchor.
day = $1.to_i day = $1.to_i
@ -277,7 +277,7 @@ class Time
T T
(\d\d):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)
(\.\d*)? (\.\d*)?
(Z|[+\-]\d\d:\d\d)? (Z|[+-]\d\d:\d\d)?
\s*\z/ix =~ date \s*\z/ix =~ date
datetime = [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i] datetime = [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i]
datetime << $7.to_f * 1000000 if $7 datetime << $7.to_f * 1000000 if $7

View File

@ -31,7 +31,7 @@ module URI
# mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | # mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
# "(" | ")" # "(" | ")"
# unreserved = alphanum | mark # unreserved = alphanum | mark
UNRESERVED = "\\-_.!~*'()#{ALNUM}" UNRESERVED = "-_.!~*'()#{ALNUM}"
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
# "$" | "," # "$" | ","
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
@ -49,9 +49,9 @@ module URI
FRAGMENT = "#{URIC}*" FRAGMENT = "#{URIC}*"
# domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum # domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
DOMLABEL = "(?:[#{ALNUM}](?:[\\-#{ALNUM}]*[#{ALNUM}])?)" DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
# toplabel = alpha | alpha *( alphanum | "-" ) alphanum # toplabel = alpha | alpha *( alphanum | "-" ) alphanum
TOPLABEL = "(?:[#{ALPHA}](?:[\\-#{ALNUM}]*[#{ALNUM}])?)" TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
# hostname = *( domainlabel "." ) toplabel [ "." ] # hostname = *( domainlabel "." ) toplabel [ "." ]
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?" HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
@ -119,7 +119,7 @@ module URI
REL_SEGMENT = "(?:[#{UNRESERVED};@&=+$,]|#{ESCAPED})+" REL_SEGMENT = "(?:[#{UNRESERVED};@&=+$,]|#{ESCAPED})+"
# scheme = alpha *( alpha | digit | "+" | "-" | "." ) # scheme = alpha *( alpha | digit | "+" | "-" | "." )
SCHEME = "[#{ALPHA}][\\-+.#{ALPHA}\\d]*" SCHEME = "[#{ALPHA}][-+.#{ALPHA}\\d]*"
# abs_path = "/" path_segments # abs_path = "/" path_segments
ABS_PATH = "/#{PATH_SEGMENTS}" ABS_PATH = "/#{PATH_SEGMENTS}"