BSD 3 development
[unix-history] / usr / src / cmd / refer / hunt3.c
CommitLineData
42d6e430
BJ
1# include "refer..c"
2getq(v)
3 char *v[];
4{
5# define BSIZ 250
6static char buff[BSIZ];
7static int eof = 0;
8extern char *sinput;
9char *p;
10int c, n = 0, las = 0;
11if (eof) return(-1);
12p = buff;
13while ( (c = (sinput ? *sinput++ : getchar()) ) > 0)
14 {
15 if (c== '\n')
16 break;
17 if (isalpha(c) || isdigit(c))
18 {
19 if (las==0)
20 {
21 v[n++] = p;
22 las=1;
23 }
24 if (las++ <= 6)
25 *p++ = c;
26 }
27 else
28 {
29 if (las>0)
30 *p++ = 0;
31 las=0;
32 }
33 }
34*p=0;
35assert(p<buff+BSIZ);
36if (sinput==0 && c<= 0) eof=1;
37# if D1
38fprintf(stderr, "no. keys %d\n",n);
39for(c=0; c<n; c++)
40 fprintf(stderr, "keys X%sX\n", v[c]);
41# endif
42return(n);
43}