summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 06:06:43 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 06:06:43 (GMT)
commita2797a454c94318c2e4448f61a72074220c7d880 (patch)
treed62ab80093be0fbb0b830dd3c219b8cc6acb7348 /re.c
parent4f07b141908272b6a09be3d27ccb01e950ce7b6e (diff)
re.c: mak eregexps with binary escapes ASCII-8BIT
* re.c (unescape_nonascii): make dynamically compiled US-ASCII regexps ASCII-8BIT encoding if binary (hexadecimal, control, meta) escapes are contained, as well as literal regexps. [ruby-dev:48626] [Bug #10382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/re.c b/re.c
index d110fe6..9258f83 100644
--- a/re.c
+++ b/re.c
@@ -2284,8 +2284,15 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
case 'C': /* \C-X, \C-\M-X */
case 'M': /* \M-X, \M-\C-X, \M-\cX */
p = p-2;
- if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0)
- return -1;
+ if (enc == rb_usascii_encoding()) {
+ c = read_escaped_byte(&p, end, err);
+ if (c == -1) return -1;
+ rb_str_buf_cat(buf, &c, 1);
+ }
+ else {
+ if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0)
+ return -1;
+ }
break;
case 'u':