]>
diplodocus.org Git - nmh/blob - docs/historical/mh-nov-1983/cmds/grep.c
16 char linebuf
[LBSIZE
+1];
20 0000,0001,0002,0003,0004,0005,0006,0007,
21 0010,0011,0012,0013,0014,0015,0016,0017,
22 0020,0021,0022,0023,0024,0025,0026,0027,
23 0030,0031,0032,0033,0034,0035,0036,0037,
24 0040,0041,0042,0043,0044,0045,0046,0047,
25 0050,0051,0052,0053,0054,0055,0056,0057,
26 0060,0061,0062,0063,0064,0065,0066,0067,
27 0070,0071,0072,0073,0074,0075,0076,0077,
28 0100,0141,0142,0143,0144,0145,0146,0147,
29 0150,0151,0152,0153,0154,0155,0156,0157,
30 0160,0161,0162,0163,0164,0165,0166,0167,
31 0170,0171,0172,0133,0134,0135,0136,0137,
32 0140,0141,0142,0143,0144,0145,0146,0147,
33 0150,0151,0152,0153,0154,0155,0156,0157,
34 0160,0161,0162,0163,0164,0165,0166,0167,
35 0170,0171,0172,0173,0174,0175,0176,0177,
43 register char *ep
, *sp
;
54 if (ep
>= &expbuf
[ESIZE
])
56 if ((c
= *sp
++) != '*')
84 if ((c
= *sp
++) == '^') {
91 if (c
=='\0' || ep
>= &expbuf
[ESIZE
])
93 } while ((c
= *sp
++) != ']');
98 if ((c
= *sp
++) == '\0')
114 register char *p1
, *p2
;
119 if ((f
= open(file
, 0)) < 0) {
120 fprintf(stderr
, "Grep: Can't open %s\n", file
);
132 if ((c
= read(f
, ibuf
, sizeof ibuf
)) <= 0) {
134 if(lf
) break; /* bodyless comp! */
141 if(lf
) if(c
!= ' ' && c
!= '\t') {
157 if(c
&& p1
< &linebuf
[LBSIZE
-1])
169 /* fast check for first character */
173 if(*p1
==c
|| cc
[*p1
]==c
)
179 /* regular algorithm */
195 register char *lp
, *ep
, *curlp
;
200 for (;;) switch (*ep
++) {
203 if (*ep
++ == *lp
++ || ep
[-1] == cc
[lp
[-1]])
221 if (cclass(ep
, *lp
++, 1)) {
228 if (cclass(ep
, *lp
++, 0)) {
241 while (*lp
++ == *ep
|| cc
[lp
[-1]] == *ep
) ;
248 while (cclass(ep
, *lp
++, ep
[-1]==(CCL
|STAR
)));
257 } while (lp
> curlp
);
261 printf("RE botch\n");
270 register char *set
, c
;