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_preprocess): force fixed encoding when ASCII

incompatible source string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-01-26 21:01:52 +00:00
parent e7bf1bd4d4
commit b9c18bdcdd
3 changed files with 18 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Sun Jan 27 05:56:39 2008 Tanaka Akira <akr@fsij.org>
* re.c (rb_reg_preprocess): force fixed encoding when ASCII
incompatible source string.
Sat Jan 26 23:46:33 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_str_format): zero-precision zero should be empty.

8
re.c
View file

@ -1908,7 +1908,13 @@ rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
buf = rb_str_buf_new(0);
*fixed_enc = 0;
if (rb_enc_asciicompat(enc))
*fixed_enc = 0;
else {
*fixed_enc = enc;
rb_enc_associate(buf, enc);
}
if (unescape_nonascii(p, end, enc, buf, fixed_enc, err) != 0)
return Qnil;

View file

@ -115,4 +115,10 @@ class TestUTF16 < Test::Unit::TestCase
def test_regexp_union
enccall(Regexp, :union, "aa".force_encoding("utf-16be"), "bb".force_encoding("utf-16be"))
end
def test_empty_regexp
s = "".force_encoding("utf-16be")
assert_equal(Encoding.find("utf-16be"), Regexp.new(s).encoding,
"Regexp.new(#{encdump s}).encoding")
end
end