* 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
This commit is contained in:
usa 2013-03-28 09:57:47 +00:00
parent 8096159871
commit ee09f19fdb
3 changed files with 16 additions and 3 deletions

View file

@ -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> Thu Mar 28 18:35:01 2013 Luis Lavena <luislavena@gmail.com>
* win32/file.c (get_user_from_path): add internal function that retrieves * win32/file.c (get_user_from_path): add internal function that retrieves

View file

@ -4735,6 +4735,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
case ANCHOR_END_BUF: case ANCHOR_END_BUF:
case ANCHOR_SEMI_END_BUF: case ANCHOR_SEMI_END_BUF:
case ANCHOR_END_LINE: case ANCHOR_END_LINE:
case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */
add_opt_anc_info(&opt->anc, NANCHOR(node)->type); add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
break; break;
@ -4758,7 +4759,6 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
break; break;
case ANCHOR_PREC_READ_NOT: case ANCHOR_PREC_READ_NOT:
case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */
case ANCHOR_LOOK_BEHIND_NOT: case ANCHOR_LOOK_BEHIND_NOT:
break; break;
} }
@ -5010,7 +5010,8 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
if (r) return r; if (r) return r;
reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF | 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); reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF);

View file

@ -3560,7 +3560,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
} }
} }
else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) { 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 */ else if (str == end) { /* empty string */