diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-04 23:33:04 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-04 23:33:04 +0000 |
commit | 54c984a8983c4ca3330d842520f24d3a98675f20 (patch) | |
tree | 6bed790f6b20a419a8bcfc816a04d05dc5f02c80 | |
parent | 7a05bfaaab03375783f6e91bec6032c7edaecb78 (diff) | |
download | ruby-54c984a8983c4ca3330d842520f24d3a98675f20.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | re.c | 6 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 19 |
3 files changed, 30 insertions, 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 @@ -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] = '\\'; diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 6f319b2b02..c5871898fe 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -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}/ |