/* This function contains the movement functions that perform RE searching */
static regex_t
*re
= NULL
; /* compiled version of the pattern to search for */
static regexp
*re
; /* compiled version of the pattern to search for */
static prevsf
; /* boolean: previous search direction was forward? */
MARK
m_wsrch(word
, m
, cnt
)
char *word
; /* the word to search for */
MARK m
; /* the starting point */
/* wrap \< and \> around the word */
/* show the searched-for word on the bottom line */
/* search for the word */
return m_fsrch(m
, buffer
);
MARK
m_nsrch(m
, cnt
, cmd
)
MARK m
; /* where to start searching */
long cnt
; /* number of searches to do */
int cmd
; /* command character -- 'n' or 'N' */
int oldprevsf
; /* original value of prevsf, so we can fix any changes */
/* clear the bottom line. In particular, we want to loose any
/* if 'N' command, then invert the "prevsf" variable */
/* search forward if prevsf -- i.e., if previous search was forward */
while (--cnt
>= 0L && m
!= MARK_UNSET
)
m
= m_fsrch(m
, (char *)0);
m
= m_bsrch(m
, (char *)0);
/* restore the old value of prevsf -- if cmd=='N' then it was inverted,
* and the m_fsrch() and m_bsrch() functions force it to a (possibly
* incorrect) value. The value of prevsf isn't supposed to be changed
MARK m
; /* where to start searching */
char *ptrn
; /* pattern to search for */
long l
; /* line# of line to be searched */
char *line
; /* text of line to be searched */
int wrapped
;/* boolean: has our search wrapped yet? */
int pos
; /* where we are in the line */
long delta
= INFINITY
;/* line offset, for things like "/foo/+1" */
/* remember: "previous search was forward" */
/* locate the closing '/', if any */
/* XXX where to free re? */
/* free the previous pattern */
/* compile the pattern */
msg("No previous expression");
/* search forward for the pattern */
m
= (m
| (BLKSIZE
- 1)) + 1;
for (l
= markline(m
); l
!= markline(m
) + 1 || !wrapped
; l
++)
/* if we wrapped once already, then the search failed */
/* else maybe we should wrap now? */
if (!regexec(re
, &line
[pos
], SE_MAX
, rm
, (pos
== 0) ? 0 : REG_NOTBOL
))
if (regexec(re
, &line
[pos
], (pos
== 0)))
msg("search offset too big");
return MARK_AT_LINE(l
) + pos
+ rm
[0].rm_so
;
return MARK_AT_LINE(l
) + (int)(re
->startp
[0] - line
);
msg(*o_wrapscan
? "Not found" : "Hit bottom without finding RE");
MARK m
; /* where to start searching */
char *ptrn
; /* pattern to search for */
long l
; /* line# of line to be searched */
char *line
; /* text of line to be searched */
int wrapped
;/* boolean: has our search wrapped yet? */
int pos
; /* last acceptable idx for a match on this line */
int last
; /* remembered idx of the last acceptable match on this line */
int try; /* an idx at which we strat searching for another match */
long delta
= INFINITY
;/* line offset, for things like "/foo/+1" */
/* remember: "previous search was not forward" */
/* locate the closing '?', if any */
/* XXX where to free re? */
/* free the previous pattern, if any */
/* compile the pattern */
msg("No previous expression");
/* search backward for the pattern */
for (l
= markline(m
); l
!= markline(m
) - 1 || !wrapped
; l
--)
if (!regexec(re
, line
, SE_MAX
, rm
, 0) && rm
[0].rm_so
< pos
)
if (regexec(re
, line
, 1) && (int)(re
->startp
[0] - line
) < pos
)
/* match! now find the last acceptable one in this line */
last
= try + rm
[0].rm_so
;
last
= (int)(re
->startp
[0] - line
);
try = (int)(re
->endp
[0] - line
);
&& !regexec(re
, &line
[try], SE_MAX
, rm
, REG_NOTBOL
)
&& try + rm
[0].rm_so
< pos
);
&& regexec(re
, &line
[try], FALSE
)
&& (int)(re
->startp
[0] - line
) < pos
);
msg("search offset too big");
return MARK_AT_LINE(l
) + last
;
msg(*o_wrapscan
? "Not found" : "Hit top without finding RE");