From da42c102c18156c2192df203cb2f79b88aa8092f Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 5 Jan 2008 16:39:38 +0000 Subject: [PATCH] * re.c (rb_reg_initialize_str): /\x80/n is not an error even if script encoding is EUC-JP. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ re.c | 10 ++++++++-- test/ruby/test_m17n.rb | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79545d07f1..f3f90ea9b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jan 6 01:38:07 2008 Tanaka Akira + + * re.c (rb_reg_initialize_str): /\x80/n is not an error even if script + encoding is EUC-JP. + Sun Jan 6 00:48:12 2008 NARUSE, Yui * lib/resolv.rb (Reolv::DNS#each_address): get A record and then AAAA diff --git a/re.c b/re.c index 9de2a0efa3..50fa341d15 100644 --- a/re.c +++ b/re.c @@ -2035,8 +2035,14 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc, static int rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err) { - return rb_reg_initialize(obj, RSTRING_PTR(str), RSTRING_LEN(str), rb_enc_get(str), - options, err); + int ret; + rb_encoding *enc = rb_enc_get(str); + if (options & ARG_ENCODING_NONE) + enc = rb_ascii8bit_encoding(); + ret = rb_reg_initialize(obj, RSTRING_PTR(str), RSTRING_LEN(str), enc, + options, err); + RB_GC_GUARD(str); + return ret; } static VALUE diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 28db8377b9..daa8af7fc4 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -382,6 +382,8 @@ class TestM17N < Test::Unit::TestCase assert_warning(%r{regexp match /.../n against to UTF-8 string}) { assert_equal(nil, r =~ u("\xc2\xa1")) } + + assert_nothing_raised { eval(e("/\\x80/n")) } end def test_regexp_ascii