1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate #include <locale.h> 19*7c478bd9Sstevel@tonic-gate #include "refer..c" 20*7c478bd9Sstevel@tonic-gate #define BSIZ 250 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate getq(v) 23*7c478bd9Sstevel@tonic-gate char *v[]; 24*7c478bd9Sstevel@tonic-gate { 25*7c478bd9Sstevel@tonic-gate static char buff[BSIZ]; 26*7c478bd9Sstevel@tonic-gate static int eof = 0; 27*7c478bd9Sstevel@tonic-gate extern char *sinput; 28*7c478bd9Sstevel@tonic-gate char *p; 29*7c478bd9Sstevel@tonic-gate int c, n = 0, las = 0; 30*7c478bd9Sstevel@tonic-gate if (eof) return(-1); 31*7c478bd9Sstevel@tonic-gate p = buff; 32*7c478bd9Sstevel@tonic-gate while ( (c = (sinput ? *sinput++ : getchar()) ) > 0) 33*7c478bd9Sstevel@tonic-gate { 34*7c478bd9Sstevel@tonic-gate if (c== '\n') 35*7c478bd9Sstevel@tonic-gate break; 36*7c478bd9Sstevel@tonic-gate if (isalpha(c) || isdigit(c)) 37*7c478bd9Sstevel@tonic-gate { 38*7c478bd9Sstevel@tonic-gate if (las==0) 39*7c478bd9Sstevel@tonic-gate { 40*7c478bd9Sstevel@tonic-gate v[n++] = p; 41*7c478bd9Sstevel@tonic-gate las=1; 42*7c478bd9Sstevel@tonic-gate } 43*7c478bd9Sstevel@tonic-gate if (las++ <= 6) 44*7c478bd9Sstevel@tonic-gate *p++ = c; 45*7c478bd9Sstevel@tonic-gate } 46*7c478bd9Sstevel@tonic-gate else 47*7c478bd9Sstevel@tonic-gate { 48*7c478bd9Sstevel@tonic-gate if (las>0) 49*7c478bd9Sstevel@tonic-gate *p++ = 0; 50*7c478bd9Sstevel@tonic-gate las=0; 51*7c478bd9Sstevel@tonic-gate } 52*7c478bd9Sstevel@tonic-gate } 53*7c478bd9Sstevel@tonic-gate *p=0; 54*7c478bd9Sstevel@tonic-gate if (p > buff + BSIZ) 55*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("query long than %d characters\n"), BSIZ); 56*7c478bd9Sstevel@tonic-gate assert(p < buff + BSIZ); 57*7c478bd9Sstevel@tonic-gate if (sinput==0 && c<= 0) eof=1; 58*7c478bd9Sstevel@tonic-gate # if D1 59*7c478bd9Sstevel@tonic-gate fprintf(stderr, "no. keys %d\n",n); 60*7c478bd9Sstevel@tonic-gate for(c=0; c<n; c++) 61*7c478bd9Sstevel@tonic-gate fprintf(stderr, "keys X%sX\n", v[c]); 62*7c478bd9Sstevel@tonic-gate # endif 63*7c478bd9Sstevel@tonic-gate return(n); 64*7c478bd9Sstevel@tonic-gate } 65