ruby-changes:35911
From: nobu <ko1@a...>
Date: Fri, 17 Oct 2014 15:06:59 +0900 (JST)
Subject: [ruby-changes:35911] nobu:r47992 (trunk): re.c: mak eregexps with binary escapes ASCII-8BIT
nobu 2014-10-17 15:06:43 +0900 (Fri, 17 Oct 2014) New Revision: 47992 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47992 Log: re.c: mak eregexps with binary escapes ASCII-8BIT * re.c (unescape_nonascii): make dynamically compiled US-ASCII regexps ASCII-8BIT encoding if binary (hexadecimal, control, meta) escapes are contained, as well as literal regexps. [ruby-dev:48626] [Bug #10382] Modified files: trunk/ChangeLog trunk/re.c trunk/test/ruby/test_m17n.rb Index: re.c =================================================================== --- re.c (revision 47991) +++ re.c (revision 47992) @@ -2284,8 +2284,15 @@ unescape_nonascii(const char *p, const c https://github.com/ruby/ruby/blob/trunk/re.c#L2284 case 'C': /* \C-X, \C-\M-X */ case 'M': /* \M-X, \M-\C-X, \M-\cX */ p = p-2; - if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0) - return -1; + if (enc == rb_usascii_encoding()) { + c = read_escaped_byte(&p, end, err); + if (c == -1) return -1; + rb_str_buf_cat(buf, &c, 1); + } + else { + if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0) + return -1; + } break; case 'u': Index: ChangeLog =================================================================== --- ChangeLog (revision 47991) +++ ChangeLog (revision 47992) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 17 15:06:49 2014 Nobuyoshi Nakada <nobu@r...> + + * re.c (unescape_nonascii): make dynamically compiled US-ASCII + regexps ASCII-8BIT encoding if binary (hexadecimal, control, + meta) escapes are contained, as well as literal regexps. + [ruby-dev:48626] [Bug #10382] + Fri Oct 17 03:05:08 2014 Eric Wong <e@8...> * test/-ext-/bug_reporter/test_bug_reporter.rb Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 47991) +++ test/ruby/test_m17n.rb (revision 47992) @@ -480,6 +480,9 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L480 assert_regexp_fixed_ascii8bit(eval(a(%{/\xc2\xa1/n}))) assert_regexp_fixed_ascii8bit(eval(a(%q{/\xc2\xa1/}))) + s = '\xc2\xa1' + assert_regexp_fixed_ascii8bit(/#{s}/) + assert_raise(SyntaxError) { eval("/\xa1\xa1/n".force_encoding("euc-jp")) } [/\xc2\xa1/n, eval(a(%{/\xc2\xa1/})), eval(a(%{/\xc2\xa1/n}))].each {|r| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/