/* Copyright (c) 1979 Regents of the University of California */
* grep -- print lines matching (or not matching) a pattern
while (--argc
> 0 && (++argv
)[0][0]=='-') {
while (*cp
) switch (*cp
++) {
fprintf(stderr
, "Unknown flag\n");
else while (--argc
>= 0) {
if (ep
>= &expbuf
[ESIZE
])
if ((c
= *sp
++) == '^') {
if (c
=='\0' || ep
>= &expbuf
[ESIZE
])
} while ((c
= *sp
++) != ']');
fprintf(stderr
, "RE error\n");
return (a
== b
|| iflag
&& (a
^ b
) == ' ' && letter(a
) == letter(b
));
if (c
>= 'a' && c
<= 'z')
if (c
>= 'A' && c
<= 'Z')
if ((f
= open(file
, 0)) < 0) {
fprintf(stderr
, "Can't open %s\n", file
);
if ((c
= read(f
, ibuf
, 512)) <= 0) {
if (p1
< &linebuf
[LBSIZE
-1])
/* fast check for first character */
if (*p1
!=c
&& (!iflag
|| (c
^ *p1
) != ' '
|| letter(c
) != letter(*p1
)))
register char *lp
, *ep
, *curlp
;
for (;;) switch (*ep
++) {
if (cclass(ep
, *lp
++, 1)) {
if (cclass(ep
, *lp
++, 0)) {
while (cclass(ep
, *lp
++, ep
[-1]==(CCL
|STAR
)));
#define uletter(c) (letter(c) || c == '_')
if (uletter(*lp
) && !uletter(lp
[-1]) && !digit(lp
[-1]))
if (!uletter(*lp
) && !digit(*lp
))
fprintf(stderr
, "RE botch\n");
if (n
> 2 && set
[1] == '-') {
if (c
>= (set
[0] & 0177) && c
<= (set
[2] & 0177))
if ((*set
++ & 0177) == c
)
return (c
>='0' && c
<='9');