1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* re.c (rb_reg_initialize_m): specify ARG_ENCODING_NONE instead of

ARG_ENCODING_FIXED for Regexp.new("", nil, "n").  [ruby-dev:36761]

* test/ruby/test_regexp.rb (TestRegexp#test_initialize): test
  updated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-10-18 10:29:06 +00:00
parent 7adbfbb793
commit fcce99c52d
3 changed files with 11 additions and 2 deletions

View file

@ -27,6 +27,14 @@ Fri Oct 17 22:04:38 2008 wanabe <s.wanabe@gmail.com>
* array.c: recycle shared-array when it isn't referenced.
Fri Oct 17 20:29:26 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_initialize_m): specify ARG_ENCODING_NONE instead of
ARG_ENCODING_FIXED for Regexp.new("", nil, "n"). [ruby-dev:36761]
* test/ruby/test_regexp.rb (TestRegexp#test_initialize): test
updated.
Fri Oct 17 19:46:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/ifchange, win32/ifchange.bat: --timestamp option added.

2
re.c
View file

@ -2795,7 +2795,7 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
char *kcode = StringValuePtr(argv[2]);
if (kcode[0] == 'n' || kcode[1] == 'N') {
enc = rb_ascii8bit_encoding();
flags |= ARG_ENCODING_FIXED;
flags |= ARG_ENCODING_NONE;
}
else {
rb_warn("encoding option is ignored - %s", kcode);

View file

@ -272,8 +272,9 @@ class TestRegexp < Test::Unit::TestCase
Thread.new { $SAFE = 4; re.instance_eval { initialize(re) } }.join
end
assert_equal(Encoding.find("ASCII-8BIT"), Regexp.new("b..", nil, "n").encoding)
assert_equal(Encoding.find("US-ASCII"), Regexp.new("b..", nil, "n").encoding)
assert_equal("bar", "foobarbaz"[Regexp.new("b..", nil, "n")])
assert_equal(//n, Regexp.new("", nil, "n"))
assert_raise(RegexpError) { Regexp.new(")(") }
end