summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-26 03:28:48 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-26 03:28:48 (GMT)
commitf8f3585416d93af69f2d0dce595ea933c3d43694 (patch)
tree9ce3f785f024d16c83e1b8263308e2a90c29393e /regcomp.c
parentf55d567b5910fe1dacf623fa471d771c99ba4fef (diff)
* 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
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 4508bcf..aaa5698 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 &&