* Copyright (c) 1992 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Rodney Ruddock of the University of Guelph.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)search.c 5.1 (Berkeley) %G%";
* searches forward through the buffer (wrapping if necessary) for a
* line that contains a match to the RE.
l_patt
= get_pattern(ss
, inputt
, errnum
, 0);
if ((RE_flag
== 0) && (l_patt
[1] == '\0'))
else if (l_patt
[1] || (RE_patt
== NULL
))
RE_sol
= (RE_patt
[1] == '^')?1:0;
if ((l_patt
[1]) && (regfree(&RE_comp
), l_err
= regcomp(&RE_comp
, &RE_patt
[1], 0)))
regerror(l_err
, &RE_comp
, help_msg
, 128);
/* find a line that has the RE in it */
while (1) /*(l_temp != current)*/
get_line(l_temp
->handle
, l_temp
->len
);
if (regexec(&RE_comp
, text
, (size_t)RE_SEC
, RE_match
, 0))
if (l_temp
== (current
->below
))
strcpy(help_msg
, "RE not found");
* Searches backward through the buffer (wrapping if necessary) to find
* a line that contains a match to the RE.
*search_r(inputt
, errnum
)
l_patt
= get_pattern(ss
, inputt
, errnum
, 0);
if ((RE_flag
== 0) && (l_patt
[1] == '\0'))
else if (l_patt
[1] || (RE_patt
== NULL
))
RE_sol
= (RE_patt
[1] == '^')?1:0;
if ((l_patt
[1]) && (regfree(&RE_comp
), l_err
= regcomp(&RE_comp
, &RE_patt
[1], 0)))
regerror(l_err
, &RE_comp
, help_msg
, 128);
/* search for a line that has the RE in it */
while (1) /*(l_temp != (current->above))*/
get_line(l_temp
->handle
, l_temp
->len
);
if (regexec(&RE_comp
, text
, (size_t)RE_SEC
, RE_match
, 0))
if (l_temp
== (current
->above
))
strcpy(help_msg
, "RE not found");