mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (unescape_nonascii): make regexp fixed_encoding if \p is used.
fixed [ruby-core:17279]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a05bfaaab
commit
54c984a898
3 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jul 5 08:29:47 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (unescape_nonascii): make regexp fixed_encoding if \p is used.
|
||||
fixed [ruby-core:17279].
|
||||
|
||||
Fri Jul 4 23:12:53 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (d2time): fix the bug of VT_DATE
|
||||
|
|
6
re.c
6
re.c
|
@ -2163,6 +2163,12 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
|
|||
break;
|
||||
}
|
||||
|
||||
case 'p': /* \p{Hiragana} */
|
||||
if (!*encp) {
|
||||
*encp = enc;
|
||||
}
|
||||
goto escape_asis;
|
||||
|
||||
default: /* \n, \\, \d, \9, etc. */
|
||||
escape_asis:
|
||||
smallbuf[0] = '\\';
|
||||
|
|
|
@ -493,6 +493,25 @@ class TestM17N < Test::Unit::TestCase
|
|||
assert_match(/[[:space:]]/, "\u{00a0}")
|
||||
end
|
||||
|
||||
def test_regexp_property
|
||||
s = '\p{Hiragana}'.force_encoding("euc-jp")
|
||||
assert_equal(Encoding::EUC_JP, s.encoding)
|
||||
r = nil
|
||||
assert_nothing_raised {
|
||||
r = Regexp.new(s)
|
||||
}
|
||||
assert(r.fixed_encoding?)
|
||||
assert_match(r, "\xa4\xa2".force_encoding("euc-jp"))
|
||||
|
||||
r = eval('/\p{Hiragana}/'.force_encoding("euc-jp"))
|
||||
assert(r.fixed_encoding?)
|
||||
assert_match(r, "\xa4\xa2".force_encoding("euc-jp"))
|
||||
|
||||
r = /\p{Hiragana}/e
|
||||
assert(r.fixed_encoding?)
|
||||
assert_match(r, "\xa4\xa2".force_encoding("euc-jp"))
|
||||
end
|
||||
|
||||
def test_regexp_embed_preprocess
|
||||
r1 = /\xa4\xa2/e
|
||||
r2 = /#{r1}/
|
||||
|
|
Loading…
Reference in a new issue