diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 23:07:22 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 23:07:22 +0000 |
commit | 00cdba732f4ec132947ac33479e423ae5da016cc (patch) | |
tree | 77f6f87f3666f53723501f254ebd18f1e286098d /re.c | |
parent | 48aad600bab75a6b5866c9a46b5828351cc6878a (diff) | |
download | ruby-00cdba732f4ec132947ac33479e423ae5da016cc.tar.gz |
* re.c (rb_reg_desc): Regexps of ASCII Compatible encoding may
contain non-ASCII characters. So in that case its encoding
must keep original encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -380,8 +380,12 @@ static VALUE rb_reg_desc(const char *s, long len, VALUE re) { VALUE str = rb_str_buf_new2("/"); - - rb_enc_associate(str, rb_usascii_encoding()); + if (rb_enc_asciicompat(rb_enc_get(re))) { + rb_enc_copy(str, re); + } + else { + rb_enc_associate(str, rb_usascii_encoding()); + } rb_reg_expr_str(str, s, len); rb_str_buf_cat2(str, "/"); if (re) { |