1 /*- 2 * %sccs.include.proprietary.c% 3 */ 4 5 #ifndef lint 6 static char sccsid[] = "@(#)hunt3.c 4.3 (Berkeley) 04/18/91"; 7 #endif /* not lint */ 8 9 #include "refer..c" 10 #define BSIZ 250 11 12 getq(v) 13 char *v[]; 14 { 15 static char buff[BSIZ]; 16 static int eof = 0; 17 extern char *sinput; 18 char *p; 19 int c, n = 0, las = 0; 20 if (eof) return(-1); 21 p = buff; 22 while ( (c = (sinput ? *sinput++ : getchar()) ) > 0) 23 { 24 if (c== '\n') 25 break; 26 if (isalpha(c) || isdigit(c)) 27 { 28 if (las==0) 29 { 30 v[n++] = p; 31 las=1; 32 } 33 if (las++ <= 6) 34 *p++ = c; 35 } 36 else 37 { 38 if (las>0) 39 *p++ = 0; 40 las=0; 41 } 42 } 43 *p=0; 44 if (p > buff + BSIZ) 45 fprintf(stderr, "query long than %d characters\n", BSIZ); 46 assert(p < buff + BSIZ); 47 if (sinput==0 && c<= 0) eof=1; 48 # if D1 49 fprintf(stderr, "no. keys %d\n",n); 50 for(c=0; c<n; c++) 51 fprintf(stderr, "keys X%sX\n", v[c]); 52 # endif 53 return(n); 54 } 55