/* $Header: ngsrch.c,v 4.3 85/05/01 11:44:51 lwall Exp $
* Revision 4.3 85/05/01 11:44:51 lwall
* Baseline for release with 4.3bsd.
ng_search(patbuf
,get_cmd
)
char *patbuf
; /* if patbuf != buf, get_cmd must */
int get_cmd
; /* be set to FALSE!!! */
char *pattern
; /* unparsed pattern */
register char cmdchr
= *patbuf
; /* what kind of search? */
bool backward
= cmdchr
== '?'; /* direction of search */
if (get_cmd
&& buf
== patbuf
)
if (!finish_command(FALSE
)) /* get rest of command */
for (pattern
= patbuf
+1; *pattern
== ' '; pattern
++) ;
s
= rindex(pattern
,cmdchr
);
if (s
!= Nullch
&& *(s
-1) != '\\') {
if (index(s
,'r') != Nullch
)
if ((s
= ng_comp(&ngcompex
,pattern
,TRUE
,TRUE
)) != Nullch
) {
/* compile regular expression */
printf("\n%s\n",s
) FLUSH
;
fputs("\nSearching...",stdout
) FLUSH
; /* give them something to read */
if (ng
== nextrcline
|| toread
[ng
] < TR_NONE
|| !ng_wanted())
if (toread
[ng
] == TR_NONE
)
if (toread
[ng
] > TR_NONE
)
else if (toread
[ng
] == TR_NONE
)
printf("\n[0 unread in %s--skipping]",rcline
[ng
]) FLUSH
;
return execute(&ngcompex
,rcline
[ng
]) != Nullch
;
ng_comp(compex
,pattern
,RE
,fold
)
register char *s
= pattern
, *d
= ng_pattern
;
return Nullch
; /* reuse old pattern */
else if (strnEQ(s
,"all",3)) {
return compile(compex
,ng_pattern
,RE
,fold
);