* 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:
parent
e7bf1bd4d4
commit
b9c18bdcdd
@ -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>
|
Sat Jan 26 23:46:33 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* sprintf.c (rb_str_format): zero-precision zero should be empty.
|
* sprintf.c (rb_str_format): zero-precision zero should be empty.
|
||||||
|
6
re.c
6
re.c
@ -1908,7 +1908,13 @@ rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
|
|||||||
|
|
||||||
buf = rb_str_buf_new(0);
|
buf = rb_str_buf_new(0);
|
||||||
|
|
||||||
|
if (rb_enc_asciicompat(enc))
|
||||||
*fixed_enc = 0;
|
*fixed_enc = 0;
|
||||||
|
else {
|
||||||
|
*fixed_enc = enc;
|
||||||
|
rb_enc_associate(buf, enc);
|
||||||
|
}
|
||||||
|
|
||||||
if (unescape_nonascii(p, end, enc, buf, fixed_enc, err) != 0)
|
if (unescape_nonascii(p, end, enc, buf, fixed_enc, err) != 0)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
||||||
|
@ -115,4 +115,10 @@ class TestUTF16 < Test::Unit::TestCase
|
|||||||
def test_regexp_union
|
def test_regexp_union
|
||||||
enccall(Regexp, :union, "aa".force_encoding("utf-16be"), "bb".force_encoding("utf-16be"))
|
enccall(Regexp, :union, "aa".force_encoding("utf-16be"), "bb".force_encoding("utf-16be"))
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user