* regcomp.c (setup_tree): restart setup_tree() for a node whose

AnchorNode's type is ANCHOR_PREC_BEHIND or ANCHOR_PREC_BEHIND_NOT
  and divide_look_behind_alternatives() divided it to NT_ALT or
  NT_LIST. [ruby-core:33370]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-11-26 03:28:48 +00:00
Родитель f55d567b59
Коммит f8f3585416
3 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Fri Nov 26 12:12:50 2010 NARUSE, Yui <naruse@ruby-lang.org>
* regcomp.c (setup_tree): restart setup_tree() for a node whose
AnchorNode's type is ANCHOR_PREC_BEHIND or ANCHOR_PREC_BEHIND_NOT
and divide_look_behind_alternatives() divided it to NT_ALT or
NT_LIST. [ruby-core:33370]
Fri Nov 26 11:40:11 2010 NAKAMURA Usaku <usa@ruby-lang.org> Fri Nov 26 11:40:11 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* vm_dump.c (dump_thread): get only required rights of the target * vm_dump.c (dump_thread): get only required rights of the target

Просмотреть файл

@ -3692,6 +3692,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
int type; int type;
int r = 0; int r = 0;
restart:
type = NTYPE(node); type = NTYPE(node);
switch (type) { switch (type) {
case NT_LIST: case NT_LIST:
@ -3906,6 +3907,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
r = setup_look_behind(node, reg, env); r = setup_look_behind(node, reg, env);
if (r != 0) return r; if (r != 0) return r;
if (NTYPE(node) != NT_ANCHOR) goto restart;
r = setup_tree(an->target, reg, state, env); r = setup_tree(an->target, reg, state, env);
} }
break; break;
@ -3918,6 +3920,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN; if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
r = setup_look_behind(node, reg, env); r = setup_look_behind(node, reg, env);
if (r != 0) return r; if (r != 0) return r;
if (NTYPE(node) != NT_ANCHOR) goto restart;
r = setup_tree(an->target, reg, (state | IN_NOT), env); r = setup_tree(an->target, reg, (state | IN_NOT), env);
} }
break; break;
@ -5351,6 +5354,15 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env); r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env);
if (r != 0) goto err; if (r != 0) goto err;
#ifdef ONIG_DEBUG_PARSE_TREE
# if 0
fprintf(stderr, "ORIGINAL PARSE TREE:\n");
if (!onig_is_prelude()) {
print_tree(stderr, root);
}
# endif
#endif
#ifdef USE_NAMED_GROUP #ifdef USE_NAMED_GROUP
/* mixed use named group and no-named group */ /* mixed use named group and no-named group */
if (scan_env.num_named > 0 && if (scan_env.num_named > 0 &&

Просмотреть файл

@ -583,6 +583,9 @@ class TestRegexp < Test::Unit::TestCase
failcheck('(?<!.*)') failcheck('(?<!.*)')
check(/(?<=A|B.)C/, [%w(C AC), %w(C BXC)], %w(C BC)) check(/(?<=A|B.)C/, [%w(C AC), %w(C BXC)], %w(C BC))
check(/(?<!A|B.)C/, [%w(C C), %w(C BC)], %w(AC BXC)) check(/(?<!A|B.)C/, [%w(C C), %w(C BC)], %w(AC BXC))
assert_not_match(/(?<!aa|b)c/i, "Aac")
assert_not_match(/(?<!b|aa)c/i, "Aac")
end end
def test_parse_kg def test_parse_kg