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