diff --git a/ChangeLog b/ChangeLog index e09b1d572f..4109dc2fcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 12 09:21:05 2010 NARUSE, Yui + + * re.c (rb_reg_initialize_m): fix wrong index for the lang + option's value 'N'. reported by Masaya TARUI via IRC. + Tue May 11 23:07:22 2010 Tanaka Akira * ext/socket/extconf.rb: test IPPROTO_IP and IPPROTO_IPV6 constants. diff --git a/re.c b/re.c index b1e5c1d34d..e4f1968733 100644 --- a/re.c +++ b/re.c @@ -2894,7 +2894,7 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self) enc = 0; if (argc == 3 && !NIL_P(argv[2])) { char *kcode = StringValuePtr(argv[2]); - if (kcode[0] == 'n' || kcode[1] == 'N') { + if (kcode[0] == 'n' || kcode[0] == 'N') { enc = rb_ascii8bit_encoding(); flags |= ARG_ENCODING_NONE; } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 00c2ddb5e9..888a0cb9e5 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -286,6 +286,10 @@ class TestRegexp < Test::Unit::TestCase assert_equal("bar", "foobarbaz"[Regexp.new("b..", nil, "n")]) assert_equal(//n, Regexp.new("", nil, "n")) + arg_encoding_none = 32 # ARG_ENCODING_NONE is implementation defined value + assert_equal(arg_encoding_none, Regexp.new("", nil, "n").options) + assert_equal(arg_encoding_none, Regexp.new("", nil, "N").options) + assert_raise(RegexpError) { Regexp.new(")(") } end