diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | re.c | 10 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 2 |
3 files changed, 15 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Sun Jan 6 01:38:07 2008 Tanaka Akira <akr@fsij.org> + + * 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 <naruse@ruby-lang.org> * lib/resolv.rb (Reolv::DNS#each_address): get A record and then AAAA @@ -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 |