summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--re.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c400fdb1d2..1c767078bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Dec 29 18:23:46 2010 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): need to escape if the coderage is invalid.
+
Wed Dec 29 10:06:51 2010 Tanaka Akira <akr@fsij.org>
* signal.c: parenthesize macro arguments.
@@ -12,8 +16,6 @@ Wed Dec 29 07:07:06 2010 Eric Hodel <drbrain@segment7.net>
Tue Dec 28 18:36:38 2010 NAKAMURA Usaku <usa@ruby-lang.org>
- * re.c (rb_reg_expr_str): need to escape if the coderage is invalid.
-
* error.c, include/ruby/intern.h (rb_compile_error_with_enc): new
function to raise syntax error, with source encoding'ed message.
diff --git a/re.c b/re.c
index 047acb62f9..2157ee8764 100644
--- a/re.c
+++ b/re.c
@@ -321,11 +321,14 @@ rb_reg_expr_str(VALUE str, const char *s, long len,
rb_encoding *enc, rb_encoding *resenc)
{
const char *p, *pend;
+ int cr = ENC_CODERANGE_UNKNOWN;
int need_escape = 0;
int c, clen;
p = s; pend = p + len;
- if (rb_enc_asciicompat(enc)) {
+ rb_str_coderange_scan_restartable(p, pend, enc, &cr);
+ if (rb_enc_asciicompat(enc) &&
+ (cr == ENC_CODERANGE_VALID || cr == ENC_CODERANGE_7BIT)) {
while (p < pend) {
c = rb_enc_ascget(p, pend, &clen, enc);
if (c == -1) {