aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-16 22:21:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-16 22:21:42 +0000
commit1e8bbf315464f212ee53de3929c02de0b73c92a1 (patch)
tree38ce2dd344237fb7ae4959a825f742a0aba87201 /re.c
parent4709e330cf23e91157da30c58e33017d1ff4433e (diff)
downloadruby-1e8bbf315464f212ee53de3929c02de0b73c92a1.tar.gz
* .gdbinit (rp): REGEXP handling fixed.
* string.c (rb_str_rindex_m): need not to call rb_enc_check on regexp. * re.c (unescape_escaped_nonascii): try ASCII-8BIT encoding for broken strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/re.c b/re.c
index fa00e8ceab..03d9dc3527 100644
--- a/re.c
+++ b/re.c
@@ -1967,8 +1967,12 @@ unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
l = rb_enc_precise_mbclen(chbuf, chbuf+chlen, enc);
if (MBCLEN_INVALID_P(l)) {
- strcpy(err, "invalid multibyte escape");
- return -1;
+ if (*encp == 0)
+ enc = *encp = rb_ascii8bit_encoding();
+ else if (*encp != rb_ascii8bit_encoding()) {
+ strcpy(err, "invalid multibyte escape");
+ return -1;
+ }
}
if (1 < chlen || (chbuf[0] & 0x80)) {
rb_str_buf_cat(buf, chbuf, chlen);