aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
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 f6bc8a205a..fe4365a2ee 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);