summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-28 09:57:47 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-28 09:57:47 +0000
commitee09f19fdbf047a31ec1c85e6f53ea4a67ded48c (patch)
tree11333e1be6057ca1395d6e10a87e5e090a84e1da
parent809615987141a9faab189b3b9b74b0f9bd8a2508 (diff)
* regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
handling for look behind anchor. * regexec.c (onig_search): ditto. [Backport #8076] this patch is derived from Onigmo base tree. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--regcomp.c5
-rw-r--r--regexec.c4
3 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1637ccea74..8a90b43ad6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Mar 28 18:54:31 2013 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * regcomp.c (optimize_node_left, set_optimize_info_from_tree): right
+ handling for look behind anchor.
+
+ * regexec.c (onig_search): ditto.
+ [Backport #8076]
+
+ this patch is derived from Onigmo base tree.
+
Thu Mar 28 18:35:01 2013 Luis Lavena <luislavena@gmail.com>
* win32/file.c (get_user_from_path): add internal function that retrieves
diff --git a/regcomp.c b/regcomp.c
index 7c29fb5203..154e2d798f 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4735,6 +4735,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
case ANCHOR_END_BUF:
case ANCHOR_SEMI_END_BUF:
case ANCHOR_END_LINE:
+ case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */
add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
break;
@@ -4758,7 +4759,6 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
break;
case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */
case ANCHOR_LOOK_BEHIND_NOT:
break;
}
@@ -5010,7 +5010,8 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
if (r) return r;
reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF |
- ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML);
+ ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML |
+ ANCHOR_LOOK_BEHIND);
reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF);
diff --git a/regexec.c b/regexec.c
index ee0a5fa2af..55c28178c4 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3560,7 +3560,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
}
}
else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) {
- goto begin_position;
+ if (!(reg->anchor & ANCHOR_LOOK_BEHIND)) {
+ goto begin_position;
+ }
}
}
else if (str == end) { /* empty string */