Skip to content
Browse files

don't use character constant.

  • Loading branch information...
1 parent ea4d56f commit 4e36f786fba8ace7cd834dd13ad98a8828210081 @akr committed Nov 10, 2007
Showing with 19 additions and 14 deletions.
  1. +4 −4 abnf/parser.y
  2. +15 −10 regexptree.rb
View
8 abnf/parser.y
@@ -100,11 +100,11 @@ class ABNF
es = []
(t = $&)[1...-1].each_byte {|b|
case b
- when ?A..?Z
- b2 = b - ?A + ?a
+ when 0x41..0x5a # ?A..?Z
+ b2 = b - 0x41 + 0x61 # ?A + ?a
es << Term.new(NatSet.new(b, b2))
- when ?a..?z
- b2 = b - ?a + ?A
+ when 0x61..0x7a # ?a..?z
+ b2 = b - 0x61 + 0x41 # ?a + ?A
es << Term.new(NatSet.new(b, b2))
else
es << Term.new(NatSet.new(b))
View
25 regexptree.rb
@@ -378,7 +378,9 @@ def case_insensitive?
up = @natset & UpAlpha
low = @natset & LowAlpha
return false if up.es.length != low.es.length
- up.es.map! {|ch| ch - ?A + ?a}
+ up.es.map! {|ch|
+ ch - 0x41 + 0x61 # ?A + ?a
+ }
up == low
end
@@ -388,7 +390,9 @@ def multiline_insensitive?
def downcase
up = @natset & UpAlpha
- up.es.map! {|ch| ch - ?A + ?a}
+ up.es.map! {|ch|
+ ch - 0x41 + 0x61 # ?A + ?a
+ }
CharClass.new((@natset - UpAlpha) | up)
end
@@ -434,14 +438,15 @@ def pretty_format(out)
def encode_elt(e)
case e
- when ?\t; '\t'
- when ?\n; '\n'
- when ?\r; '\r'
- when ?\f; '\f'
- when ?\v; '\v'
- when ?\a; '\a'
- when ?\e; '\e'
- when ?!, ?", ?%, ?&, ?', ?,, ?:, ?;, ?<, ?=, ?>, ?/, ?0..?9, ?@, ?A..?Z, ?_, ?`, ?a..?z, ?~
+ when 0x09; '\t'
+ when 0x0a; '\n'
+ when 0x0d; '\r'
+ when 0x0c; '\f'
+ when 0x0b; '\v'
+ when 0x07; '\a'
+ when 0x1b; '\e'
+ #when ?!, ?", ?%, ?&, ?', ?,, ?:, ?;, ?<, ?=, ?>, ?/, ?0..?9, ?@, ?A..?Z, ?_, ?`, ?a..?z, ?~
+ when 0x21, 0x22, 0x25, 0x26, 0x27, 0x2c, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x2f, 0x30..0x39, 0x40, 0x41..0x5a, 0x5f, 0x60, 0x61..0x7a, 0x7e
sprintf("%c", e)
else
sprintf("\\x%02x", e)

0 comments on commit 4e36f78

Please sign in to comment.
Something went wrong with that request. Please try again.