summaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-17 02:00:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-17 02:00:05 +0000
commitc3da6e5eb3ba28d818b64b9049d9f0fe10800fe3 (patch)
tree04c8df1b84a56c8b55f3f929b0d9744acfe7196c /re.c
parent8bb405d2adb3bb5351cfaaf1bc10bb3ec5acffb6 (diff)
downloadruby-c3da6e5eb3ba28d818b64b9049d9f0fe10800fe3.tar.gz
ruby-c3da6e5eb3ba28d818b64b9049d9f0fe10800fe3.tar.xz
ruby-c3da6e5eb3ba28d818b64b9049d9f0fe10800fe3.zip
* re.c (rb_reg_quote): return US-ASCII string consistently.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/re.c b/re.c
index f6bc8a205..fe4365a2e 100644
--- a/re.c
+++ b/re.c
@@ -2654,7 +2654,7 @@ rb_reg_quote(VALUE str)
}
s += clen;
}
- if (ascii_only && rb_enc_get_index(str) != 0) {
+ if (ascii_only) {
str = rb_str_new3(str);
rb_enc_associate(str, rb_usascii_encoding());
}
@@ -2662,7 +2662,10 @@ rb_reg_quote(VALUE str)
meta_found:
tmp = rb_str_new(0, RSTRING_LEN(str)*2);
- if (!ascii_only) {
+ if (ascii_only) {
+ rb_enc_associate(tmp, rb_usascii_encoding());
+ }
+ else {
rb_enc_copy(tmp, str);
}
t = RSTRING_PTR(tmp);