1*11a8fa6cSceastha /*
2*11a8fa6cSceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*11a8fa6cSceastha * Use is subject to license terms.
4*11a8fa6cSceastha */
5*11a8fa6cSceastha
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate */
147c478bd9Sstevel@tonic-gate
157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate #include <locale.h>
187c478bd9Sstevel@tonic-gate #include "refer..c"
197c478bd9Sstevel@tonic-gate #define BSIZ 250
207c478bd9Sstevel@tonic-gate
21*11a8fa6cSceastha int
getq(char * v[])22*11a8fa6cSceastha getq(char *v[])
237c478bd9Sstevel@tonic-gate {
247c478bd9Sstevel@tonic-gate static char buff[BSIZ];
257c478bd9Sstevel@tonic-gate static int eof = 0;
267c478bd9Sstevel@tonic-gate extern char *sinput;
277c478bd9Sstevel@tonic-gate char *p;
287c478bd9Sstevel@tonic-gate int c, n = 0, las = 0;
29*11a8fa6cSceastha if (eof)
30*11a8fa6cSceastha return (-1);
317c478bd9Sstevel@tonic-gate p = buff;
32*11a8fa6cSceastha while ((c = (sinput ? *sinput++ : getchar())) > 0) {
337c478bd9Sstevel@tonic-gate if (c == '\n')
347c478bd9Sstevel@tonic-gate break;
35*11a8fa6cSceastha if (isalpha(c) || isdigit(c)) {
36*11a8fa6cSceastha if (las == 0) {
377c478bd9Sstevel@tonic-gate v[n++] = p;
387c478bd9Sstevel@tonic-gate las = 1;
397c478bd9Sstevel@tonic-gate }
407c478bd9Sstevel@tonic-gate if (las++ <= 6)
417c478bd9Sstevel@tonic-gate *p++ = c;
42*11a8fa6cSceastha } else {
437c478bd9Sstevel@tonic-gate if (las > 0)
447c478bd9Sstevel@tonic-gate *p++ = 0;
457c478bd9Sstevel@tonic-gate las = 0;
467c478bd9Sstevel@tonic-gate }
477c478bd9Sstevel@tonic-gate }
487c478bd9Sstevel@tonic-gate *p = 0;
497c478bd9Sstevel@tonic-gate if (p > buff + BSIZ)
50*11a8fa6cSceastha fprintf(stderr, gettext("query long than %d characters\n"),
51*11a8fa6cSceastha BSIZ);
527c478bd9Sstevel@tonic-gate assert(p < buff + BSIZ);
537c478bd9Sstevel@tonic-gate if (sinput == 0 && c <= 0) eof = 1;
547c478bd9Sstevel@tonic-gate #if D1
557c478bd9Sstevel@tonic-gate fprintf(stderr, "no. keys %d\n", n);
567c478bd9Sstevel@tonic-gate for (c = 0; c < n; c++)
577c478bd9Sstevel@tonic-gate fprintf(stderr, "keys X%sX\n", v[c]);
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate return (n);
607c478bd9Sstevel@tonic-gate }
61