mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_prepare_re): add enable_warning parameter.
(rb_reg_adjust_startpos): disable warning by rb_reg_prepare_re. (rb_reg_search): follow rb_reg_prepare_re parameter change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a197a30a94
commit
b8fd2fabbe
3 changed files with 13 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Feb 17 20:45:10 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (rb_reg_prepare_re): add enable_warning parameter.
|
||||
(rb_reg_adjust_startpos): disable warning by rb_reg_prepare_re.
|
||||
(rb_reg_search): follow rb_reg_prepare_re parameter change.
|
||||
|
||||
Sun Feb 17 20:12:41 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* test/ruby/test_regexp.rb: add tests to achieve over 90% test
|
||||
|
|
9
re.c
9
re.c
|
@ -1041,7 +1041,7 @@ rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
|
|||
rb_encoding **fixed_enc, onig_errmsg_buffer err);
|
||||
|
||||
static void
|
||||
rb_reg_prepare_re(VALUE re, VALUE str)
|
||||
rb_reg_prepare_re(VALUE re, VALUE str, int enable_warning)
|
||||
{
|
||||
int need_recompile = 0;
|
||||
rb_encoding *enc;
|
||||
|
@ -1068,7 +1068,8 @@ rb_reg_prepare_re(VALUE re, VALUE str)
|
|||
RREGEXP(re)->ptr->enc != enc) {
|
||||
need_recompile = 1;
|
||||
}
|
||||
if ((RBASIC(re)->flags & REG_ENCODING_NONE) &&
|
||||
if (enable_warning &&
|
||||
(RBASIC(re)->flags & REG_ENCODING_NONE) &&
|
||||
enc != rb_ascii8bit_encoding() &&
|
||||
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
|
||||
rb_warn("regexp match /.../n against to %s string",
|
||||
|
@ -1119,7 +1120,7 @@ rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, int reverse)
|
|||
OnigEncoding enc;
|
||||
UChar *p, *string;
|
||||
|
||||
rb_reg_prepare_re(re, str);
|
||||
rb_reg_prepare_re(re, str, 0);
|
||||
|
||||
if (reverse) {
|
||||
range = -pos;
|
||||
|
@ -1158,7 +1159,7 @@ rb_reg_search(VALUE re, VALUE str, int pos, int reverse)
|
|||
return -1;
|
||||
}
|
||||
|
||||
rb_reg_prepare_re(re, str);
|
||||
rb_reg_prepare_re(re, str, 1);
|
||||
|
||||
if (!reverse) {
|
||||
range += RSTRING_LEN(str);
|
||||
|
|
|
@ -109,6 +109,8 @@ class TestM17NComb < Test::Unit::TestCase
|
|||
s("\xe0\xa0\xa1"),
|
||||
|
||||
#"aa".force_encoding("utf-16be"),
|
||||
#"aaaa".force_encoding("utf-32be"),
|
||||
#"aaa".force_encoding("utf-32be"),
|
||||
]
|
||||
|
||||
def combination(*args)
|
||||
|
|
Loading…
Reference in a new issue