summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y17
2 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index cc4071606..747c97de7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 24 21:46:24 2008 Tanaka Akira <akr@fsij.org>
+
+ * parse.y (reg_fragment_setenc_gen): associate ASCII-8BIT only if
+ str has only ASCII characters.
+
Thu Jan 24 20:46:17 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* test/ruby/test_m17n.rb: follow to the following changes.
diff --git a/parse.y b/parse.y
index b43dc64b7..140e320fe 100644
--- a/parse.y
+++ b/parse.y
@@ -8475,17 +8475,26 @@ reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
if (c) {
int opt, idx;
rb_char_to_option_kcode(c, &opt, &idx);
- if (idx != ENCODING_GET(str) && !ENCODING_IS_ASCII8BIT(str) &&
+ if (idx != ENCODING_GET(str) &&
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
- compile_error(PARSER_ARG
- "regexp encoding option '%c' differs from source encoding '%s'",
- c, rb_enc_name(rb_enc_get(str)));
+ goto error;
}
ENCODING_SET(str, idx);
}
else if (RE_OPTION_ENCODING_NONE(options)) {
+ if (!ENCODING_IS_ASCII8BIT(str) &&
+ rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
+ c = 'n';
+ goto error;
+ }
rb_enc_associate(str, rb_ascii8bit_encoding());
}
+ return;
+
+error:
+ compile_error(PARSER_ARG
+ "regexp encoding option '%c' differs from source encoding '%s'",
+ c, rb_enc_name(rb_enc_get(str)));
}
static void