2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
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.
15 #pragma ident "%Z%%M% %I% %E% SMI"
23 static int alph
, used
, prevc
;
24 static char *p
, key
[20];
27 extern char *mindex();
29 static void chkey(int, char *);
30 static long grec(char *, FILE *);
33 dofile(FILE *f
, char *name
)
35 /* read file f & spit out keys & ptrs */
37 char line
[MAXLINE
], *s
;
38 extern int minlen
, keycount
, labels
;
42 alph
= used
= prevc
= eof
= 0;
46 while (lim
= grec(line
, f
)) {
48 fprintf(stderr
, "line: /%s", line
);
52 for (s
= line
; (c
= *s
) && (used
< keycount
); s
++)
55 if (used
) putchar('\n');
60 while ((c
= getc(f
)) != EOF
&& used
< keycount
)
62 if (used
) putchar('\n');
68 outkey(char *ky
, int lead
, int trail
)
78 if (mindex(".%,!#$%&'();+:*", lead
) != 0)
82 /* Allow years 1000 - 2099 */
83 if (!(ky
[0] == '1' || (ky
[0] == '2' && ky
[1] == '0')) || n
!= 4)
91 grec(char *s
, FILE *f
)
95 long len
= 0L, tlen
= 0L;
101 while (fgets(tm
, 200, f
)) {
103 if (tm
[0] == '%' || tm
[0] == '.')
105 if (tlen
< MAXLINE
&& mindex(iglist
, curtype
) == 0)
108 if (wholefile
== 0 && tm
[0] == '\n')
110 if (wholefile
> 0 && len
>= MAXLINE
) {
116 return (s
[0] ? len
: 0L);
125 if (*p
== '\n') *p
= 0;
130 chkey(int c
, char *name
)
133 extern int wholefile
;
134 if (isalpha(c
) || isdigit(c
)) {
139 for (p
= key
; *p
; p
++)
141 if (outkey(p
= key
, prevc
, c
)) {
145 printf("%s:%ld,%ld\t", name
,
148 printf("%s\t", name
);