mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (reg_fragment_setenc_gen): associate ASCII-8BIT only if
str has only ASCII characters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e27f4ef689
commit
14b9d47ae0
2 changed files with 18 additions and 4 deletions
|
@ -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.
|
||||
|
|
17
parse.y
17
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
|
||||
|
|
Loading…
Add table
Reference in a new issue