ruby-changes:4025
From: ko1@a...
Date: Sun, 17 Feb 2008 11:00:20 +0900 (JST)
Subject: [ruby-changes:4025] akr - Ruby:r15515 (trunk): * re.c (rb_reg_quote): return US-ASCII string consistently.
akr 2008-02-17 11:00:05 +0900 (Sun, 17 Feb 2008) New Revision: 15515 Modified files: trunk/ChangeLog trunk/re.c trunk/test/ruby/test_m17n.rb Log: * re.c (rb_reg_quote): return US-ASCII string consistently. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15515&r2=15514&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=15515&r2=15514&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=15515&r2=15514&diff_format=u Index: re.c =================================================================== --- re.c (revision 15514) +++ re.c (revision 15515) @@ -2654,7 +2654,7 @@ } s += clen; } - if (ascii_only && rb_enc_get_index(str) != 0) { + if (ascii_only) { str = rb_str_new3(str); rb_enc_associate(str, rb_usascii_encoding()); } @@ -2662,7 +2662,10 @@ meta_found: tmp = rb_str_new(0, RSTRING_LEN(str)*2); - if (!ascii_only) { + if (ascii_only) { + rb_enc_associate(tmp, rb_usascii_encoding()); + } + else { rb_enc_copy(tmp, str); } t = RSTRING_PTR(tmp); Index: ChangeLog =================================================================== --- ChangeLog (revision 15514) +++ ChangeLog (revision 15515) @@ -1,3 +1,7 @@ +Sun Feb 17 10:59:04 2008 Tanaka Akira <akr@f...> + + * re.c (rb_reg_quote): return US-ASCII string consistently. + Sun Feb 17 09:17:08 2008 Tanaka Akira <akr@f...> * string.c (rb_str_times): reduce loop overhead. Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 15514) +++ test/ruby/test_m17n.rb (revision 15515) @@ -523,16 +523,14 @@ def test_quote assert_regexp_generic_ascii(/#{Regexp.quote(a("a"))}#{Regexp.quote(e("e"))}/) - # Regexp.quote returns ASCII-8BIT string for ASCII only string - # to make generic regexp if possible. - assert_encoding("ASCII-8BIT", Regexp.quote(a("")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(e("")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(s("")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(u("")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(a("a")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(e("a")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(s("a")).encoding) - assert_encoding("ASCII-8BIT", Regexp.quote(u("a")).encoding) + assert_encoding("US-ASCII", Regexp.quote(a("")).encoding) + assert_encoding("US-ASCII", Regexp.quote(e("")).encoding) + assert_encoding("US-ASCII", Regexp.quote(s("")).encoding) + assert_encoding("US-ASCII", Regexp.quote(u("")).encoding) + assert_encoding("US-ASCII", Regexp.quote(a("a")).encoding) + assert_encoding("US-ASCII", Regexp.quote(e("a")).encoding) + assert_encoding("US-ASCII", Regexp.quote(s("a")).encoding) + assert_encoding("US-ASCII", Regexp.quote(u("a")).encoding) assert_encoding("ASCII-8BIT", Regexp.quote(a("\xc2\xa1")).encoding) assert_encoding("EUC-JP", Regexp.quote(e("\xc2\xa1")).encoding) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/