Fix error message of /.../n with embeded non ASCII-8BIT string.
* re.c (rb_reg_preprocess_dregexp): add options to arguments. * re.c (rb_reg_new_ary): follow above. * re.c (rb_reg_preprocess_dregexp): change error message when /.../n has a non escaped non ASCII character in non ASCII-8BIT script. [ruby-dev:38524] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
93b9f2cc5e
commit
88c0b8fec9
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Wed Aug 5 10:20:39 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (rb_reg_preprocess_dregexp): add options to arguments.
|
||||||
|
|
||||||
|
* re.c (rb_reg_new_ary): follow above.
|
||||||
|
|
||||||
|
* re.c (rb_reg_preprocess_dregexp): change error message when
|
||||||
|
/.../n has a non escaped non ASCII character in non ASCII-8BIT
|
||||||
|
script. [ruby-dev:38524]
|
||||||
|
|
||||||
Wed Aug 5 03:28:41 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Aug 5 03:28:41 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/test/unit.rb (Test::Unit.setup_argv): expands paths before
|
* lib/test/unit.rb (Test::Unit.setup_argv): expands paths before
|
||||||
|
13
re.c
13
re.c
@ -2264,13 +2264,14 @@ rb_reg_check_preprocess(VALUE str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_reg_preprocess_dregexp(VALUE ary)
|
rb_reg_preprocess_dregexp(VALUE ary, int options)
|
||||||
{
|
{
|
||||||
rb_encoding *fixed_enc = 0;
|
rb_encoding *fixed_enc = 0;
|
||||||
rb_encoding *regexp_enc = 0;
|
rb_encoding *regexp_enc = 0;
|
||||||
onig_errmsg_buffer err = "";
|
onig_errmsg_buffer err = "";
|
||||||
int i;
|
int i;
|
||||||
VALUE result = 0;
|
VALUE result = 0;
|
||||||
|
rb_encoding *ascii8bit = rb_ascii8bit_encoding();
|
||||||
|
|
||||||
if (RARRAY_LEN(ary) == 0) {
|
if (RARRAY_LEN(ary) == 0) {
|
||||||
rb_raise(rb_eArgError, "no arguments given");
|
rb_raise(rb_eArgError, "no arguments given");
|
||||||
@ -2282,10 +2283,16 @@ rb_reg_preprocess_dregexp(VALUE ary)
|
|||||||
char *p, *end;
|
char *p, *end;
|
||||||
rb_encoding *src_enc;
|
rb_encoding *src_enc;
|
||||||
|
|
||||||
|
src_enc = rb_enc_get(str);
|
||||||
|
if (options & ARG_ENCODING_NONE &&
|
||||||
|
src_enc != ascii8bit &&
|
||||||
|
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
|
||||||
|
rb_raise(rb_eRegexpError, "/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
|
||||||
|
}
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
p = RSTRING_PTR(str);
|
p = RSTRING_PTR(str);
|
||||||
end = p + RSTRING_LEN(str);
|
end = p + RSTRING_LEN(str);
|
||||||
src_enc = rb_enc_get(str);
|
|
||||||
|
|
||||||
buf = rb_reg_preprocess(p, end, src_enc, &fixed_enc, err);
|
buf = rb_reg_preprocess(p, end, src_enc, &fixed_enc, err);
|
||||||
|
|
||||||
@ -2421,7 +2428,7 @@ rb_reg_new_str(VALUE s, int options)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_reg_new_ary(VALUE ary, int opt)
|
rb_reg_new_ary(VALUE ary, int opt)
|
||||||
{
|
{
|
||||||
return rb_reg_new_str(rb_reg_preprocess_dregexp(ary), opt);
|
return rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user