|
Karsten Hopp |
f59ea2 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
f59ea2 |
Subject: Patch 7.3.1105
|
|
Karsten Hopp |
f59ea2 |
Fcc: outbox
|
|
Karsten Hopp |
f59ea2 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
f59ea2 |
Mime-Version: 1.0
|
|
Karsten Hopp |
f59ea2 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
f59ea2 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
f59ea2 |
------------
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
Patch 7.3.1105
|
|
Karsten Hopp |
f59ea2 |
Problem: New regexp engine: too much code in one function. Dead code.
|
|
Karsten Hopp |
f59ea2 |
Solution: Move the recursive nfa_regmatch call to a separate function.
|
|
Karsten Hopp |
f59ea2 |
Remove the dead code.
|
|
Karsten Hopp |
f59ea2 |
Files: src/regexp_nfa.c
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
*** ../vim-7.3.1104/src/regexp_nfa.c 2013-06-02 22:07:57.000000000 +0200
|
|
Karsten Hopp |
f59ea2 |
--- src/regexp_nfa.c 2013-06-02 22:35:43.000000000 +0200
|
|
Karsten Hopp |
f59ea2 |
***************
|
|
Karsten Hopp |
f59ea2 |
*** 3665,3673 ****
|
|
Karsten Hopp |
f59ea2 |
--- 3665,3802 ----
|
|
Karsten Hopp |
f59ea2 |
return val == pos;
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
+ static int recursive_regmatch __ARGS((nfa_state_T *state, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids));
|
|
Karsten Hopp |
f59ea2 |
static int nfa_regmatch __ARGS((nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m));
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
/*
|
|
Karsten Hopp |
f59ea2 |
+ * Recursively call nfa_regmatch()
|
|
Karsten Hopp |
f59ea2 |
+ */
|
|
Karsten Hopp |
f59ea2 |
+ static int
|
|
Karsten Hopp |
f59ea2 |
+ recursive_regmatch(state, prog, submatch, m, listids)
|
|
Karsten Hopp |
f59ea2 |
+ nfa_state_T *state;
|
|
Karsten Hopp |
f59ea2 |
+ nfa_regprog_T *prog;
|
|
Karsten Hopp |
f59ea2 |
+ regsubs_T *submatch;
|
|
Karsten Hopp |
f59ea2 |
+ regsubs_T *m;
|
|
Karsten Hopp |
f59ea2 |
+ int **listids;
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ char_u *save_reginput = reginput;
|
|
Karsten Hopp |
f59ea2 |
+ char_u *save_regline = regline;
|
|
Karsten Hopp |
f59ea2 |
+ int save_reglnum = reglnum;
|
|
Karsten Hopp |
f59ea2 |
+ int save_nfa_match = nfa_match;
|
|
Karsten Hopp |
f59ea2 |
+ save_se_T *save_nfa_endp = nfa_endp;
|
|
Karsten Hopp |
f59ea2 |
+ save_se_T endpos;
|
|
Karsten Hopp |
f59ea2 |
+ save_se_T *endposp = NULL;
|
|
Karsten Hopp |
f59ea2 |
+ int result;
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ if (state->c == NFA_START_INVISIBLE_BEFORE)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ /* The recursive match must end at the current position. */
|
|
Karsten Hopp |
f59ea2 |
+ endposp = &endpos;
|
|
Karsten Hopp |
f59ea2 |
+ if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ endpos.se_u.pos.col = (int)(reginput - regline);
|
|
Karsten Hopp |
f59ea2 |
+ endpos.se_u.pos.lnum = reglnum;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ else
|
|
Karsten Hopp |
f59ea2 |
+ endpos.se_u.ptr = reginput;
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ /* Go back the specified number of bytes, or as far as the
|
|
Karsten Hopp |
f59ea2 |
+ * start of the previous line, to try matching "\@<=" or
|
|
Karsten Hopp |
f59ea2 |
+ * not matching "\@
|
|
Karsten Hopp |
f59ea2 |
+ * TODO: This is very inefficient! Would be better to
|
|
Karsten Hopp |
f59ea2 |
+ * first check for a match with what follows. */
|
|
Karsten Hopp |
f59ea2 |
+ if (state->val <= 0)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ regline = reg_getline(--reglnum);
|
|
Karsten Hopp |
f59ea2 |
+ if (regline == NULL)
|
|
Karsten Hopp |
f59ea2 |
+ /* can't go before the first line */
|
|
Karsten Hopp |
f59ea2 |
+ regline = reg_getline(++reglnum);
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ else
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ if (REG_MULTI && (int)(reginput - regline) < state->val)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ /* Not enough bytes in this line, go to end of
|
|
Karsten Hopp |
f59ea2 |
+ * previous line. */
|
|
Karsten Hopp |
f59ea2 |
+ regline = reg_getline(--reglnum);
|
|
Karsten Hopp |
f59ea2 |
+ if (regline == NULL)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ /* can't go before the first line */
|
|
Karsten Hopp |
f59ea2 |
+ regline = reg_getline(++reglnum);
|
|
Karsten Hopp |
f59ea2 |
+ reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ else
|
|
Karsten Hopp |
f59ea2 |
+ reginput = regline + STRLEN(regline);
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ if ((int)(reginput - regline) >= state->val)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ reginput -= state->val;
|
|
Karsten Hopp |
f59ea2 |
+ #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
f59ea2 |
+ if (has_mbyte)
|
|
Karsten Hopp |
f59ea2 |
+ reginput -= mb_head_off(regline, reginput);
|
|
Karsten Hopp |
f59ea2 |
+ #endif
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ else
|
|
Karsten Hopp |
f59ea2 |
+ reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ /* Call nfa_regmatch() to check if the current concat matches
|
|
Karsten Hopp |
f59ea2 |
+ * at this position. The concat ends with the node
|
|
Karsten Hopp |
f59ea2 |
+ * NFA_END_INVISIBLE */
|
|
Karsten Hopp |
f59ea2 |
+ if (*listids == NULL)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ *listids = (int *)lalloc(sizeof(int) * nstate, TRUE);
|
|
Karsten Hopp |
f59ea2 |
+ if (*listids == NULL)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!"));
|
|
Karsten Hopp |
f59ea2 |
+ return 0;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ #ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
+ if (log_fd != stderr)
|
|
Karsten Hopp |
f59ea2 |
+ fclose(log_fd);
|
|
Karsten Hopp |
f59ea2 |
+ log_fd = NULL;
|
|
Karsten Hopp |
f59ea2 |
+ #endif
|
|
Karsten Hopp |
f59ea2 |
+ /* Have to clear the listid field of the NFA nodes, so that
|
|
Karsten Hopp |
f59ea2 |
+ * nfa_regmatch() and addstate() can run properly after
|
|
Karsten Hopp |
f59ea2 |
+ * recursion. */
|
|
Karsten Hopp |
f59ea2 |
+ nfa_save_listids(prog, *listids);
|
|
Karsten Hopp |
f59ea2 |
+ nfa_endp = endposp;
|
|
Karsten Hopp |
f59ea2 |
+ result = nfa_regmatch(prog, state->out, submatch, m);
|
|
Karsten Hopp |
f59ea2 |
+ nfa_restore_listids(prog, *listids);
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ /* restore position in input text */
|
|
Karsten Hopp |
f59ea2 |
+ reginput = save_reginput;
|
|
Karsten Hopp |
f59ea2 |
+ regline = save_regline;
|
|
Karsten Hopp |
f59ea2 |
+ reglnum = save_reglnum;
|
|
Karsten Hopp |
f59ea2 |
+ nfa_match = save_nfa_match;
|
|
Karsten Hopp |
f59ea2 |
+ nfa_endp = save_nfa_endp;
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ #ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
+ log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
|
|
Karsten Hopp |
f59ea2 |
+ if (log_fd != NULL)
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ fprintf(log_fd, "****************************\n");
|
|
Karsten Hopp |
f59ea2 |
+ fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n");
|
|
Karsten Hopp |
f59ea2 |
+ fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE");
|
|
Karsten Hopp |
f59ea2 |
+ fprintf(log_fd, "****************************\n");
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ else
|
|
Karsten Hopp |
f59ea2 |
+ {
|
|
Karsten Hopp |
f59ea2 |
+ EMSG(_("Could not open temporary log file for writing, displaying on stderr ... "));
|
|
Karsten Hopp |
f59ea2 |
+ log_fd = stderr;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+ #endif
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ return result;
|
|
Karsten Hopp |
f59ea2 |
+ }
|
|
Karsten Hopp |
f59ea2 |
+
|
|
Karsten Hopp |
f59ea2 |
+ /*
|
|
Karsten Hopp |
f59ea2 |
* Main matching routine.
|
|
Karsten Hopp |
f59ea2 |
*
|
|
Karsten Hopp |
f59ea2 |
* Run NFA to determine whether it matches reginput.
|
|
Karsten Hopp |
f59ea2 |
***************
|
|
Karsten Hopp |
f59ea2 |
*** 3881,4051 ****
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
case NFA_END_INVISIBLE:
|
|
Karsten Hopp |
f59ea2 |
! /* This is only encountered after a NFA_START_INVISIBLE or
|
|
Karsten Hopp |
f59ea2 |
* NFA_START_INVISIBLE_BEFORE node.
|
|
Karsten Hopp |
f59ea2 |
* They surround a zero-width group, used with "\@=", "\&",
|
|
Karsten Hopp |
f59ea2 |
* "\@!", "\@<=" and "\@
|
|
Karsten Hopp |
f59ea2 |
* If we got here, it means that the current "invisible" group
|
|
Karsten Hopp |
f59ea2 |
* finished successfully, so return control to the parent
|
|
Karsten Hopp |
f59ea2 |
! * nfa_regmatch(). Submatches are stored in *m, and used in
|
|
Karsten Hopp |
f59ea2 |
! * the parent call. */
|
|
Karsten Hopp |
f59ea2 |
! if (start->c == NFA_MOPEN)
|
|
Karsten Hopp |
f59ea2 |
! /* TODO: do we ever get here? */
|
|
Karsten Hopp |
f59ea2 |
! addstate_here(thislist, t->state->out, &t->subs, &listidx);
|
|
Karsten Hopp |
f59ea2 |
! else
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
#ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
! if (nfa_endp != NULL)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
! fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n",
|
|
Karsten Hopp |
f59ea2 |
! (int)reglnum,
|
|
Karsten Hopp |
f59ea2 |
! (int)nfa_endp->se_u.pos.lnum,
|
|
Karsten Hopp |
f59ea2 |
! (int)(reginput - regline),
|
|
Karsten Hopp |
f59ea2 |
! nfa_endp->se_u.pos.col);
|
|
Karsten Hopp |
f59ea2 |
! else
|
|
Karsten Hopp |
f59ea2 |
! fprintf(log_fd, "Current col: %d, endp col: %d\n",
|
|
Karsten Hopp |
f59ea2 |
! (int)(reginput - regline),
|
|
Karsten Hopp |
f59ea2 |
! (int)(nfa_endp->se_u.ptr - reginput));
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! #endif
|
|
Karsten Hopp |
f59ea2 |
! /* It's only a match if it ends at "nfa_endp" */
|
|
Karsten Hopp |
f59ea2 |
! if (nfa_endp != NULL && (REG_MULTI
|
|
Karsten Hopp |
f59ea2 |
! ? (reglnum != nfa_endp->se_u.pos.lnum
|
|
Karsten Hopp |
f59ea2 |
! || (int)(reginput - regline)
|
|
Karsten Hopp |
f59ea2 |
! != nfa_endp->se_u.pos.col)
|
|
Karsten Hopp |
f59ea2 |
! : reginput != nfa_endp->se_u.ptr))
|
|
Karsten Hopp |
f59ea2 |
! break;
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! /* do not set submatches for \@! */
|
|
Karsten Hopp |
f59ea2 |
! if (!t->state->negated)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! copy_sub(&m->norm, &t->subs.norm);
|
|
Karsten Hopp |
f59ea2 |
! #ifdef FEAT_SYN_HL
|
|
Karsten Hopp |
f59ea2 |
! if (nfa_has_zsubexpr)
|
|
Karsten Hopp |
f59ea2 |
! copy_sub(&m->synt, &t->subs.synt);
|
|
Karsten Hopp |
f59ea2 |
! #endif
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! nfa_match = TRUE;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! break;
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! case NFA_START_INVISIBLE:
|
|
Karsten Hopp |
f59ea2 |
! case NFA_START_INVISIBLE_BEFORE:
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! char_u *save_reginput = reginput;
|
|
Karsten Hopp |
f59ea2 |
! char_u *save_regline = regline;
|
|
Karsten Hopp |
f59ea2 |
! int save_reglnum = reglnum;
|
|
Karsten Hopp |
f59ea2 |
! int save_nfa_match = nfa_match;
|
|
Karsten Hopp |
f59ea2 |
! save_se_T *save_nfa_endp = nfa_endp;
|
|
Karsten Hopp |
f59ea2 |
! save_se_T endpos;
|
|
Karsten Hopp |
f59ea2 |
! save_se_T *endposp = NULL;
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! if (t->state->c == NFA_START_INVISIBLE_BEFORE)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
- /* The recursive match must end at the current position. */
|
|
Karsten Hopp |
f59ea2 |
- endposp = &endpos;
|
|
Karsten Hopp |
f59ea2 |
if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! endpos.se_u.pos.col = (int)(reginput - regline);
|
|
Karsten Hopp |
f59ea2 |
! endpos.se_u.pos.lnum = reglnum;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
else
|
|
Karsten Hopp |
f59ea2 |
! endpos.se_u.ptr = reginput;
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! /* Go back the specified number of bytes, or as far as the
|
|
Karsten Hopp |
f59ea2 |
! * start of the previous line, to try matching "\@<=" or
|
|
Karsten Hopp |
f59ea2 |
! * not matching "\@
|
|
Karsten Hopp |
f59ea2 |
! * TODO: This is very inefficient! Would be better to
|
|
Karsten Hopp |
f59ea2 |
! * first check for a match with what follows. */
|
|
Karsten Hopp |
f59ea2 |
! if (t->state->val <= 0)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! regline = reg_getline(--reglnum);
|
|
Karsten Hopp |
f59ea2 |
! if (regline == NULL)
|
|
Karsten Hopp |
f59ea2 |
! /* can't go before the first line */
|
|
Karsten Hopp |
f59ea2 |
! regline = reg_getline(++reglnum);
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! else
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! if (REG_MULTI
|
|
Karsten Hopp |
f59ea2 |
! && (int)(reginput - regline) < t->state->val)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! /* Not enough bytes in this line, go to end of
|
|
Karsten Hopp |
f59ea2 |
! * previous line. */
|
|
Karsten Hopp |
f59ea2 |
! regline = reg_getline(--reglnum);
|
|
Karsten Hopp |
f59ea2 |
! if (regline == NULL)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! /* can't go before the first line */
|
|
Karsten Hopp |
f59ea2 |
! regline = reg_getline(++reglnum);
|
|
Karsten Hopp |
f59ea2 |
! reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! else
|
|
Karsten Hopp |
f59ea2 |
! reginput = regline + STRLEN(regline);
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! if ((int)(reginput - regline) >= t->state->val)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! reginput -= t->state->val;
|
|
Karsten Hopp |
f59ea2 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
f59ea2 |
! if (has_mbyte)
|
|
Karsten Hopp |
f59ea2 |
! reginput -= mb_head_off(regline, reginput);
|
|
Karsten Hopp |
f59ea2 |
! #endif
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
! else
|
|
Karsten Hopp |
f59ea2 |
! reginput = regline;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
! /* Call nfa_regmatch() to check if the current concat matches
|
|
Karsten Hopp |
f59ea2 |
! * at this position. The concat ends with the node
|
|
Karsten Hopp |
f59ea2 |
! * NFA_END_INVISIBLE */
|
|
Karsten Hopp |
f59ea2 |
! if (listids == NULL)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
! listids = (int *)lalloc(sizeof(int) * nstate, TRUE);
|
|
Karsten Hopp |
f59ea2 |
! if (listids == NULL)
|
|
Karsten Hopp |
f59ea2 |
! {
|
|
Karsten Hopp |
f59ea2 |
! EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!"));
|
|
Karsten Hopp |
f59ea2 |
! return 0;
|
|
Karsten Hopp |
f59ea2 |
! }
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
! #ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
! if (log_fd != stderr)
|
|
Karsten Hopp |
f59ea2 |
! fclose(log_fd);
|
|
Karsten Hopp |
f59ea2 |
! log_fd = NULL;
|
|
Karsten Hopp |
f59ea2 |
! #endif
|
|
Karsten Hopp |
f59ea2 |
! /* Have to clear the listid field of the NFA nodes, so that
|
|
Karsten Hopp |
f59ea2 |
! * nfa_regmatch() and addstate() can run properly after
|
|
Karsten Hopp |
f59ea2 |
! * recursion. */
|
|
Karsten Hopp |
f59ea2 |
! nfa_save_listids(prog, listids);
|
|
Karsten Hopp |
f59ea2 |
! nfa_endp = endposp;
|
|
Karsten Hopp |
f59ea2 |
! result = nfa_regmatch(prog, t->state->out, submatch, m);
|
|
Karsten Hopp |
f59ea2 |
! nfa_restore_listids(prog, listids);
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! /* restore position in input text */
|
|
Karsten Hopp |
f59ea2 |
! reginput = save_reginput;
|
|
Karsten Hopp |
f59ea2 |
! regline = save_regline;
|
|
Karsten Hopp |
f59ea2 |
! reglnum = save_reglnum;
|
|
Karsten Hopp |
f59ea2 |
! nfa_match = save_nfa_match;
|
|
Karsten Hopp |
f59ea2 |
! nfa_endp = save_nfa_endp;
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
- #ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
- log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
|
|
Karsten Hopp |
f59ea2 |
- if (log_fd != NULL)
|
|
Karsten Hopp |
f59ea2 |
- {
|
|
Karsten Hopp |
f59ea2 |
- fprintf(log_fd, "****************************\n");
|
|
Karsten Hopp |
f59ea2 |
- fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n");
|
|
Karsten Hopp |
f59ea2 |
- fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE");
|
|
Karsten Hopp |
f59ea2 |
- fprintf(log_fd, "****************************\n");
|
|
Karsten Hopp |
f59ea2 |
- }
|
|
Karsten Hopp |
f59ea2 |
- else
|
|
Karsten Hopp |
f59ea2 |
- {
|
|
Karsten Hopp |
f59ea2 |
- EMSG(_("Could not open temporary log file for writing, displaying on stderr ... "));
|
|
Karsten Hopp |
f59ea2 |
- log_fd = stderr;
|
|
Karsten Hopp |
f59ea2 |
- }
|
|
Karsten Hopp |
f59ea2 |
- #endif
|
|
Karsten Hopp |
f59ea2 |
/* for \@! it is a match when result is FALSE */
|
|
Karsten Hopp |
f59ea2 |
if (result != t->state->negated)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
--- 4010,4066 ----
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
case NFA_END_INVISIBLE:
|
|
Karsten Hopp |
f59ea2 |
! /*
|
|
Karsten Hopp |
f59ea2 |
! * This is only encountered after a NFA_START_INVISIBLE or
|
|
Karsten Hopp |
f59ea2 |
* NFA_START_INVISIBLE_BEFORE node.
|
|
Karsten Hopp |
f59ea2 |
* They surround a zero-width group, used with "\@=", "\&",
|
|
Karsten Hopp |
f59ea2 |
* "\@!", "\@<=" and "\@
|
|
Karsten Hopp |
f59ea2 |
* If we got here, it means that the current "invisible" group
|
|
Karsten Hopp |
f59ea2 |
* finished successfully, so return control to the parent
|
|
Karsten Hopp |
f59ea2 |
! * nfa_regmatch(). For a look-behind match only when it ends
|
|
Karsten Hopp |
f59ea2 |
! * in the position in "nfa_endp".
|
|
Karsten Hopp |
f59ea2 |
! * Submatches are stored in *m, and used in the parent call.
|
|
Karsten Hopp |
f59ea2 |
! */
|
|
Karsten Hopp |
f59ea2 |
#ifdef ENABLE_LOG
|
|
Karsten Hopp |
f59ea2 |
! if (nfa_endp != NULL)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
if (REG_MULTI)
|
|
Karsten Hopp |
f59ea2 |
! fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n",
|
|
Karsten Hopp |
f59ea2 |
! (int)reglnum,
|
|
Karsten Hopp |
f59ea2 |
! (int)nfa_endp->se_u.pos.lnum,
|
|
Karsten Hopp |
f59ea2 |
! (int)(reginput - regline),
|
|
Karsten Hopp |
f59ea2 |
! nfa_endp->se_u.pos.col);
|
|
Karsten Hopp |
f59ea2 |
else
|
|
Karsten Hopp |
f59ea2 |
! fprintf(log_fd, "Current col: %d, endp col: %d\n",
|
|
Karsten Hopp |
f59ea2 |
! (int)(reginput - regline),
|
|
Karsten Hopp |
f59ea2 |
! (int)(nfa_endp->se_u.ptr - reginput));
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
+ #endif
|
|
Karsten Hopp |
f59ea2 |
+ /* It's only a match if it ends at "nfa_endp" */
|
|
Karsten Hopp |
f59ea2 |
+ if (nfa_endp != NULL && (REG_MULTI
|
|
Karsten Hopp |
f59ea2 |
+ ? (reglnum != nfa_endp->se_u.pos.lnum
|
|
Karsten Hopp |
f59ea2 |
+ || (int)(reginput - regline)
|
|
Karsten Hopp |
f59ea2 |
+ != nfa_endp->se_u.pos.col)
|
|
Karsten Hopp |
f59ea2 |
+ : reginput != nfa_endp->se_u.ptr))
|
|
Karsten Hopp |
f59ea2 |
+ break;
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
! /* do not set submatches for \@! */
|
|
Karsten Hopp |
f59ea2 |
! if (!t->state->negated)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
! copy_sub(&m->norm, &t->subs.norm);
|
|
Karsten Hopp |
f59ea2 |
! #ifdef FEAT_SYN_HL
|
|
Karsten Hopp |
f59ea2 |
! if (nfa_has_zsubexpr)
|
|
Karsten Hopp |
f59ea2 |
! copy_sub(&m->synt, &t->subs.synt);
|
|
Karsten Hopp |
f59ea2 |
! #endif
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
! nfa_match = TRUE;
|
|
Karsten Hopp |
f59ea2 |
! break;
|
|
Karsten Hopp |
f59ea2 |
!
|
|
Karsten Hopp |
f59ea2 |
! case NFA_START_INVISIBLE:
|
|
Karsten Hopp |
f59ea2 |
! case NFA_START_INVISIBLE_BEFORE:
|
|
Karsten Hopp |
f59ea2 |
! result = recursive_regmatch(t->state, prog, submatch, m,
|
|
Karsten Hopp |
f59ea2 |
! &listids);
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
/* for \@! it is a match when result is FALSE */
|
|
Karsten Hopp |
f59ea2 |
if (result != t->state->negated)
|
|
Karsten Hopp |
f59ea2 |
{
|
|
Karsten Hopp |
f59ea2 |
***************
|
|
Karsten Hopp |
f59ea2 |
*** 4056,4067 ****
|
|
Karsten Hopp |
f59ea2 |
#endif
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
/* t->state->out1 is the corresponding END_INVISIBLE node;
|
|
Karsten Hopp |
f59ea2 |
! * Add it to the current list (zero-width match). */
|
|
Karsten Hopp |
f59ea2 |
addstate_here(thislist, t->state->out1->out, &t->subs,
|
|
Karsten Hopp |
f59ea2 |
&listidx);
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
break;
|
|
Karsten Hopp |
f59ea2 |
- }
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
case NFA_BOL:
|
|
Karsten Hopp |
f59ea2 |
if (reginput == regline)
|
|
Karsten Hopp |
f59ea2 |
--- 4071,4081 ----
|
|
Karsten Hopp |
f59ea2 |
#endif
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
/* t->state->out1 is the corresponding END_INVISIBLE node;
|
|
Karsten Hopp |
f59ea2 |
! * Add its out to the current list (zero-width match). */
|
|
Karsten Hopp |
f59ea2 |
addstate_here(thislist, t->state->out1->out, &t->subs,
|
|
Karsten Hopp |
f59ea2 |
&listidx);
|
|
Karsten Hopp |
f59ea2 |
}
|
|
Karsten Hopp |
f59ea2 |
break;
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
case NFA_BOL:
|
|
Karsten Hopp |
f59ea2 |
if (reginput == regline)
|
|
Karsten Hopp |
f59ea2 |
*** ../vim-7.3.1104/src/version.c 2013-06-02 22:07:57.000000000 +0200
|
|
Karsten Hopp |
f59ea2 |
--- src/version.c 2013-06-02 22:37:02.000000000 +0200
|
|
Karsten Hopp |
f59ea2 |
***************
|
|
Karsten Hopp |
f59ea2 |
*** 730,731 ****
|
|
Karsten Hopp |
f59ea2 |
--- 730,733 ----
|
|
Karsten Hopp |
f59ea2 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
f59ea2 |
+ /**/
|
|
Karsten Hopp |
f59ea2 |
+ 1105,
|
|
Karsten Hopp |
f59ea2 |
/**/
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
--
|
|
Karsten Hopp |
f59ea2 |
"I can't complain, but sometimes I still do." (Joe Walsh)
|
|
Karsten Hopp |
f59ea2 |
|
|
Karsten Hopp |
f59ea2 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
f59ea2 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
f59ea2 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
f59ea2 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|