diff --git a/ChangeLog b/ChangeLog index 37f02112fc..9b5c29d470 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Nov 26 12:12:50 2010 NARUSE, Yui + + * 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 * vm_dump.c (dump_thread): get only required rights of the target diff --git a/regcomp.c b/regcomp.c index 4508bcf8b3..aaa5698562 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3692,6 +3692,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env) int type; int r = 0; +restart: type = NTYPE(node); switch (type) { 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; r = setup_look_behind(node, reg, env); if (r != 0) return r; + if (NTYPE(node) != NT_ANCHOR) goto restart; r = setup_tree(an->target, reg, state, env); } 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; r = setup_look_behind(node, reg, env); if (r != 0) return r; + if (NTYPE(node) != NT_ANCHOR) goto restart; r = setup_tree(an->target, reg, (state | IN_NOT), env); } 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); 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 /* mixed use named group and no-named group */ if (scan_env.num_named > 0 && diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index fabeab1fec..b0a9eb2c16 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -583,6 +583,9 @@ class TestRegexp < Test::Unit::TestCase failcheck('(?