xref: /titanic_53/usr/src/cmd/refer/refer5.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 "refer..c"
19*7c478bd9Sstevel@tonic-gate #define SAME 0
20*7c478bd9Sstevel@tonic-gate #define NFLAB 3000		/* number of bytes to record all labels */
21*7c478bd9Sstevel@tonic-gate #define NLABC 1000		/* max number of labels */
22*7c478bd9Sstevel@tonic-gate 
23*7c478bd9Sstevel@tonic-gate static char sig[MXSIG];
24*7c478bd9Sstevel@tonic-gate static char bflab[NFLAB];
25*7c478bd9Sstevel@tonic-gate static char *labtab[NLABC];
26*7c478bd9Sstevel@tonic-gate static char *lbp = bflab;
27*7c478bd9Sstevel@tonic-gate static char labc[NLABC];
28*7c478bd9Sstevel@tonic-gate static char stbuff[50];
29*7c478bd9Sstevel@tonic-gate static int  prevsig;
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate putsig (nf, flds, nref, nstline, endline, toindex)   /* choose signal style */
32*7c478bd9Sstevel@tonic-gate char *flds[], *nstline, *endline;
33*7c478bd9Sstevel@tonic-gate {
34*7c478bd9Sstevel@tonic-gate 	char t[100], t1[MXSIG], t2[100], format[10], *sd, *stline;
35*7c478bd9Sstevel@tonic-gate 	int addon, another = 0;
36*7c478bd9Sstevel@tonic-gate 	static FILE *fhide = 0;
37*7c478bd9Sstevel@tonic-gate 	int i;
38*7c478bd9Sstevel@tonic-gate 	char tag;
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate 	if (labels) {
41*7c478bd9Sstevel@tonic-gate 		if (nf == 0)	/* old */
42*7c478bd9Sstevel@tonic-gate 			sprintf(t, "%s%c", labtab[nref], labc[nref]);
43*7c478bd9Sstevel@tonic-gate 		else {
44*7c478bd9Sstevel@tonic-gate 			*t = 0;
45*7c478bd9Sstevel@tonic-gate 			if (keywant)
46*7c478bd9Sstevel@tonic-gate 				fpar(nf, flds, t, keywant, 1, 0);
47*7c478bd9Sstevel@tonic-gate 			if (science && t[0] == 0) {
48*7c478bd9Sstevel@tonic-gate 				if (fpar(nf, flds, t, 'A', 1, 0) != 0) {
49*7c478bd9Sstevel@tonic-gate 					if (fpar(nf, flds, t2, 'D', 1, 0) != 0) {
50*7c478bd9Sstevel@tonic-gate 						strcat(t, ", ");
51*7c478bd9Sstevel@tonic-gate 						strcat(t, t2);
52*7c478bd9Sstevel@tonic-gate 					}
53*7c478bd9Sstevel@tonic-gate 				}
54*7c478bd9Sstevel@tonic-gate 			} else if (t[0] == 0) {
55*7c478bd9Sstevel@tonic-gate 				sprintf(format,
56*7c478bd9Sstevel@tonic-gate 					nmlen>0 ? "%%.%ds%%s" : "%%s%%s",
57*7c478bd9Sstevel@tonic-gate 					nmlen);
58*7c478bd9Sstevel@tonic-gate 				/* format is %s%s for default labels */
59*7c478bd9Sstevel@tonic-gate 				/* or %.3s%s eg if wanted */
60*7c478bd9Sstevel@tonic-gate 				if (fpar(nf, flds, t2, 'D', 1, 0)) {
61*7c478bd9Sstevel@tonic-gate 					sd = t2;
62*7c478bd9Sstevel@tonic-gate 					if (dtlen > 0) {
63*7c478bd9Sstevel@tonic-gate 						int n = strlen(sd) - dtlen;
64*7c478bd9Sstevel@tonic-gate 						if (n > 0)
65*7c478bd9Sstevel@tonic-gate 							sd += n;
66*7c478bd9Sstevel@tonic-gate 					}
67*7c478bd9Sstevel@tonic-gate 				} else {
68*7c478bd9Sstevel@tonic-gate 					sd = "";
69*7c478bd9Sstevel@tonic-gate 				}
70*7c478bd9Sstevel@tonic-gate 				t1[0] = 0;
71*7c478bd9Sstevel@tonic-gate 				fpar(nf, flds, t1, 'A', 1, 0);
72*7c478bd9Sstevel@tonic-gate 				sprintf(t, format, t1, sd);
73*7c478bd9Sstevel@tonic-gate 			}
74*7c478bd9Sstevel@tonic-gate 			if (keywant) {
75*7c478bd9Sstevel@tonic-gate 				addon = 0;
76*7c478bd9Sstevel@tonic-gate 				for (sd = t; *sd; sd++)
77*7c478bd9Sstevel@tonic-gate 					;
78*7c478bd9Sstevel@tonic-gate 				if (*--sd == '-') {
79*7c478bd9Sstevel@tonic-gate 					addon = 1;
80*7c478bd9Sstevel@tonic-gate 					*sd = 0;
81*7c478bd9Sstevel@tonic-gate 				}
82*7c478bd9Sstevel@tonic-gate 			}
83*7c478bd9Sstevel@tonic-gate 			if ((!keywant || addon) && !science) {
84*7c478bd9Sstevel@tonic-gate 			    addch(t, keylet(t, nref));
85*7c478bd9Sstevel@tonic-gate 			}
86*7c478bd9Sstevel@tonic-gate 			else {
87*7c478bd9Sstevel@tonic-gate 			    tokeytab (t,nref);
88*7c478bd9Sstevel@tonic-gate 			}
89*7c478bd9Sstevel@tonic-gate 		}
90*7c478bd9Sstevel@tonic-gate 	}
91*7c478bd9Sstevel@tonic-gate 	else {
92*7c478bd9Sstevel@tonic-gate 		if (sort)
93*7c478bd9Sstevel@tonic-gate 			sprintf(t, "%c%d%c", FLAG, nref, FLAG);
94*7c478bd9Sstevel@tonic-gate 		else
95*7c478bd9Sstevel@tonic-gate 			sprintf(t, "%d", nref);
96*7c478bd9Sstevel@tonic-gate 	}
97*7c478bd9Sstevel@tonic-gate 	another = (sd = lookat()) ? prefix(".[", sd) : 0;
98*7c478bd9Sstevel@tonic-gate 	if (another && (strcmp(".[\n", sd) != SAME))
99*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, (char *)gettext("File %s line %d: punctuation ignored from: %s"),
100*7c478bd9Sstevel@tonic-gate 			Ifile, Iline, sd);
101*7c478bd9Sstevel@tonic-gate 	if ((strlen(sig) + strlen(t)) > MXSIG)
102*7c478bd9Sstevel@tonic-gate 		err(gettext("sig overflow (%d)"), MXSIG);
103*7c478bd9Sstevel@tonic-gate 	strcat(sig, t);
104*7c478bd9Sstevel@tonic-gate #if EBUG
105*7c478bd9Sstevel@tonic-gate 	fprintf(stderr, "sig is now %s leng %d\n",sig,strlen(sig));
106*7c478bd9Sstevel@tonic-gate #endif
107*7c478bd9Sstevel@tonic-gate 	trimnl(nstline);
108*7c478bd9Sstevel@tonic-gate 	trimnl(endline);
109*7c478bd9Sstevel@tonic-gate 	stline = stbuff;
110*7c478bd9Sstevel@tonic-gate 	if (prevsig == 0) {
111*7c478bd9Sstevel@tonic-gate 		strcpy (stline, nstline);
112*7c478bd9Sstevel@tonic-gate 		prevsig=1;
113*7c478bd9Sstevel@tonic-gate 	}
114*7c478bd9Sstevel@tonic-gate 	if (stline[2] || endline[2]) {
115*7c478bd9Sstevel@tonic-gate 		stline += 2;
116*7c478bd9Sstevel@tonic-gate 		endline += 2;
117*7c478bd9Sstevel@tonic-gate 	}
118*7c478bd9Sstevel@tonic-gate 	else {
119*7c478bd9Sstevel@tonic-gate 		stline  = "\\*([.";
120*7c478bd9Sstevel@tonic-gate 		endline = "\\*(.]";
121*7c478bd9Sstevel@tonic-gate 	}
122*7c478bd9Sstevel@tonic-gate 	if (science) {
123*7c478bd9Sstevel@tonic-gate 		stline = " (";
124*7c478bd9Sstevel@tonic-gate 		endline = ")";
125*7c478bd9Sstevel@tonic-gate 	}
126*7c478bd9Sstevel@tonic-gate 	if (bare == 0) {
127*7c478bd9Sstevel@tonic-gate 		if (!another) {
128*7c478bd9Sstevel@tonic-gate 			sprintf(t1, "%s%s%s\n", stline, sig, endline);
129*7c478bd9Sstevel@tonic-gate 			if (strlen(t1) > MXSIG)
130*7c478bd9Sstevel@tonic-gate 				err(gettext("t1 overflow (%d)"), MXSIG);
131*7c478bd9Sstevel@tonic-gate 			append(t1);
132*7c478bd9Sstevel@tonic-gate 			flout();
133*7c478bd9Sstevel@tonic-gate 			sig[0] = 0;
134*7c478bd9Sstevel@tonic-gate 			prevsig = 0;
135*7c478bd9Sstevel@tonic-gate 			if (fo == fhide) {
136*7c478bd9Sstevel@tonic-gate 				int ch;
137*7c478bd9Sstevel@tonic-gate 				fclose(fhide);
138*7c478bd9Sstevel@tonic-gate 				fhide = fopen(hidenam, "r");
139*7c478bd9Sstevel@tonic-gate 				fo = ftemp;
140*7c478bd9Sstevel@tonic-gate 				while ((ch = getc(fhide)) != EOF)
141*7c478bd9Sstevel@tonic-gate 					putc(ch, fo);
142*7c478bd9Sstevel@tonic-gate 				fclose(fhide);
143*7c478bd9Sstevel@tonic-gate 				unlink(hidenam);
144*7c478bd9Sstevel@tonic-gate 			}
145*7c478bd9Sstevel@tonic-gate 		}
146*7c478bd9Sstevel@tonic-gate 		else {
147*7c478bd9Sstevel@tonic-gate 			if (labels) {
148*7c478bd9Sstevel@tonic-gate 				strcat(sig, ",\\|");
149*7c478bd9Sstevel@tonic-gate 			} else {
150*7c478bd9Sstevel@tonic-gate 				/*
151*7c478bd9Sstevel@tonic-gate 				 * Seperate reference numbers with AFLAG
152*7c478bd9Sstevel@tonic-gate 				 * for later sorting and condensing.
153*7c478bd9Sstevel@tonic-gate 				 */
154*7c478bd9Sstevel@tonic-gate 				t1[0] = AFLAG;
155*7c478bd9Sstevel@tonic-gate 				t1[1] = '\0';
156*7c478bd9Sstevel@tonic-gate 				strcat(sig, t1);
157*7c478bd9Sstevel@tonic-gate 			}
158*7c478bd9Sstevel@tonic-gate 			if (fo == ftemp) {	/* hide if need be */
159*7c478bd9Sstevel@tonic-gate 				sprintf(hidenam, "/tmp/rj%dc", getpid());
160*7c478bd9Sstevel@tonic-gate #if EBUG
161*7c478bd9Sstevel@tonic-gate 				fprintf(stderr, "hiding in %s\n", hidenam);
162*7c478bd9Sstevel@tonic-gate #endif
163*7c478bd9Sstevel@tonic-gate 				fhide = fopen(hidenam, "w");
164*7c478bd9Sstevel@tonic-gate 				if (fhide == NULL)
165*7c478bd9Sstevel@tonic-gate 					err(gettext("Can't get scratch file %s"),
166*7c478bd9Sstevel@tonic-gate 						hidenam);
167*7c478bd9Sstevel@tonic-gate 				fo = fhide;
168*7c478bd9Sstevel@tonic-gate 			}
169*7c478bd9Sstevel@tonic-gate 		}
170*7c478bd9Sstevel@tonic-gate 	}
171*7c478bd9Sstevel@tonic-gate 	if (bare < 2)
172*7c478bd9Sstevel@tonic-gate 		if (nf > 0 && toindex)
173*7c478bd9Sstevel@tonic-gate 			fprintf(fo,".ds [F %s%c",t,sep);
174*7c478bd9Sstevel@tonic-gate 	if (bare > 0)
175*7c478bd9Sstevel@tonic-gate 		flout();
176*7c478bd9Sstevel@tonic-gate #if EBUG
177*7c478bd9Sstevel@tonic-gate 	fprintf(stderr, "sig is now %s\n",sig);
178*7c478bd9Sstevel@tonic-gate #endif
179*7c478bd9Sstevel@tonic-gate }
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate char *
182*7c478bd9Sstevel@tonic-gate fpar (nf, flds, out, c, seq, prepend)
183*7c478bd9Sstevel@tonic-gate char *flds[], *out;
184*7c478bd9Sstevel@tonic-gate {
185*7c478bd9Sstevel@tonic-gate 	char *p, *s;
186*7c478bd9Sstevel@tonic-gate 	int i, fnd = 0;
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate 	for(i = 0; i < nf; i++)
189*7c478bd9Sstevel@tonic-gate 		if (flds[i][1] == c && ++fnd >= seq) {
190*7c478bd9Sstevel@tonic-gate 			/* for titles use first word otherwise last */
191*7c478bd9Sstevel@tonic-gate 			if (c == 'T' || c == 'J') {
192*7c478bd9Sstevel@tonic-gate 				p = flds[i]+3;
193*7c478bd9Sstevel@tonic-gate 				if (prefix("A ", p))
194*7c478bd9Sstevel@tonic-gate 					p += 2;
195*7c478bd9Sstevel@tonic-gate 				if (prefix("An ", p))
196*7c478bd9Sstevel@tonic-gate 					p += 3;
197*7c478bd9Sstevel@tonic-gate 				if (prefix("The ", p))
198*7c478bd9Sstevel@tonic-gate 					p += 4;
199*7c478bd9Sstevel@tonic-gate 				mycpy2(out, p, 20);
200*7c478bd9Sstevel@tonic-gate 				return(out);
201*7c478bd9Sstevel@tonic-gate 			}
202*7c478bd9Sstevel@tonic-gate 			/* if its not 'L' then use just the last word */
203*7c478bd9Sstevel@tonic-gate 			s = p = flds[i]+2;
204*7c478bd9Sstevel@tonic-gate 			if (c != 'L') {
205*7c478bd9Sstevel@tonic-gate 			    for(; *p; p++);
206*7c478bd9Sstevel@tonic-gate 			    while (p > s && *p != ' ')
207*7c478bd9Sstevel@tonic-gate 				    p--;
208*7c478bd9Sstevel@tonic-gate 			}
209*7c478bd9Sstevel@tonic-gate 			/* special wart for authors */
210*7c478bd9Sstevel@tonic-gate 			if (c == 'A' && (p[-1] == ',' || p[1] =='(')) {
211*7c478bd9Sstevel@tonic-gate 				p--;
212*7c478bd9Sstevel@tonic-gate 				while (p > s && *p != ' ')
213*7c478bd9Sstevel@tonic-gate 					p--;
214*7c478bd9Sstevel@tonic-gate 				mycpy(out, p+1);
215*7c478bd9Sstevel@tonic-gate 			}
216*7c478bd9Sstevel@tonic-gate 			else
217*7c478bd9Sstevel@tonic-gate 				strcpy(out, p+1);
218*7c478bd9Sstevel@tonic-gate 			if (c == 'A' && prepend)
219*7c478bd9Sstevel@tonic-gate 				initadd(out, flds[i]+2, p);
220*7c478bd9Sstevel@tonic-gate 			return(out);
221*7c478bd9Sstevel@tonic-gate 		}
222*7c478bd9Sstevel@tonic-gate 	return(0);
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate putkey(nf, flds, nref, keystr)
226*7c478bd9Sstevel@tonic-gate char *flds[], *keystr;
227*7c478bd9Sstevel@tonic-gate {
228*7c478bd9Sstevel@tonic-gate 	char t1[50], *sf;
229*7c478bd9Sstevel@tonic-gate 	int ctype, i, count;
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate 	fprintf(fo, ".\\\"");
232*7c478bd9Sstevel@tonic-gate 	if (nf <= 0)
233*7c478bd9Sstevel@tonic-gate 		fprintf(fo, "%s%c%c", labtab[nref], labc[nref], sep);
234*7c478bd9Sstevel@tonic-gate 	else {
235*7c478bd9Sstevel@tonic-gate 		while (ctype = *keystr++) {
236*7c478bd9Sstevel@tonic-gate 			count = atoi(keystr);
237*7c478bd9Sstevel@tonic-gate 			if (*keystr=='+')
238*7c478bd9Sstevel@tonic-gate 				count=999;
239*7c478bd9Sstevel@tonic-gate 			if (count <= 0)
240*7c478bd9Sstevel@tonic-gate 				count = 1;
241*7c478bd9Sstevel@tonic-gate 			for(i = 1; i <= count; i++) {
242*7c478bd9Sstevel@tonic-gate 				sf = fpar(nf, flds, t1, ctype, i, 1);
243*7c478bd9Sstevel@tonic-gate 				if (sf == 0)
244*7c478bd9Sstevel@tonic-gate 					break;
245*7c478bd9Sstevel@tonic-gate 				sf = artskp(sf);
246*7c478bd9Sstevel@tonic-gate 				fprintf(fo, "%s%c", sf, '-');
247*7c478bd9Sstevel@tonic-gate 			}
248*7c478bd9Sstevel@tonic-gate 		}
249*7c478bd9Sstevel@tonic-gate 		fprintf(fo, "%c%d%c%c", FLAG, nref, FLAG, sep);
250*7c478bd9Sstevel@tonic-gate 	}
251*7c478bd9Sstevel@tonic-gate }
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate tokeytab (t, nref)
255*7c478bd9Sstevel@tonic-gate char *t;
256*7c478bd9Sstevel@tonic-gate {
257*7c478bd9Sstevel@tonic-gate 	strcpy(labtab[nref]=lbp, t);
258*7c478bd9Sstevel@tonic-gate 	while (*lbp++)
259*7c478bd9Sstevel@tonic-gate 		;
260*7c478bd9Sstevel@tonic-gate }
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate keylet(t, nref)
263*7c478bd9Sstevel@tonic-gate char *t;
264*7c478bd9Sstevel@tonic-gate {
265*7c478bd9Sstevel@tonic-gate 	int i;
266*7c478bd9Sstevel@tonic-gate 	int x = 'a' - 1;
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate 	for(i = 1; i < nref; i++) {
269*7c478bd9Sstevel@tonic-gate 		if (strcmp(labtab[i], t) == 0)
270*7c478bd9Sstevel@tonic-gate 			x = labc[i];
271*7c478bd9Sstevel@tonic-gate 	}
272*7c478bd9Sstevel@tonic-gate 	tokeytab (t, nref);
273*7c478bd9Sstevel@tonic-gate 	if (lbp-bflab > NFLAB)
274*7c478bd9Sstevel@tonic-gate 		err(gettext("bflab overflow (%d)"), NFLAB);
275*7c478bd9Sstevel@tonic-gate 	if (nref > NLABC)
276*7c478bd9Sstevel@tonic-gate 		err(gettext("nref in labc overflow (%d)"), NLABC);
277*7c478bd9Sstevel@tonic-gate #if EBUG
278*7c478bd9Sstevel@tonic-gate 	fprintf(stderr, "lbp up to %d of %d\n", lbp-bflab, NFLAB);
279*7c478bd9Sstevel@tonic-gate #endif
280*7c478bd9Sstevel@tonic-gate 	return(labc[nref] = x+1);
281*7c478bd9Sstevel@tonic-gate }
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate mycpy(s, t)
284*7c478bd9Sstevel@tonic-gate char *s, *t;
285*7c478bd9Sstevel@tonic-gate {
286*7c478bd9Sstevel@tonic-gate 	while (*t && *t != ',' && *t != ' ')
287*7c478bd9Sstevel@tonic-gate 		*s++ = *t++;
288*7c478bd9Sstevel@tonic-gate 	*s = 0;
289*7c478bd9Sstevel@tonic-gate }
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate mycpy2(s, t, n)
292*7c478bd9Sstevel@tonic-gate char *s, *t;
293*7c478bd9Sstevel@tonic-gate {
294*7c478bd9Sstevel@tonic-gate 	int c;
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 	while (n-- && (c= *t++) > 0) {
297*7c478bd9Sstevel@tonic-gate 		if (c == ' ')
298*7c478bd9Sstevel@tonic-gate 			c = '-';
299*7c478bd9Sstevel@tonic-gate 		*s++ = c;
300*7c478bd9Sstevel@tonic-gate 	}
301*7c478bd9Sstevel@tonic-gate 	*s = 0;
302*7c478bd9Sstevel@tonic-gate }
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate initadd(to, from, stop)
305*7c478bd9Sstevel@tonic-gate char *to, *from, *stop;
306*7c478bd9Sstevel@tonic-gate {
307*7c478bd9Sstevel@tonic-gate 	int c, nalph = 1;
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate 	while (*to)
310*7c478bd9Sstevel@tonic-gate 		to++;
311*7c478bd9Sstevel@tonic-gate 	while (from < stop) {
312*7c478bd9Sstevel@tonic-gate 		c = *from++;
313*7c478bd9Sstevel@tonic-gate 		if (!isalpha(c)) {
314*7c478bd9Sstevel@tonic-gate 			if (nalph)
315*7c478bd9Sstevel@tonic-gate 				*to++ = '.';
316*7c478bd9Sstevel@tonic-gate 			nalph = 0;
317*7c478bd9Sstevel@tonic-gate 			continue;
318*7c478bd9Sstevel@tonic-gate 		}
319*7c478bd9Sstevel@tonic-gate 		if (nalph++ == 0)
320*7c478bd9Sstevel@tonic-gate 			*to++ = c;
321*7c478bd9Sstevel@tonic-gate 	}
322*7c478bd9Sstevel@tonic-gate 	*to = 0;
323*7c478bd9Sstevel@tonic-gate }
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate static char *articles[] = {
326*7c478bd9Sstevel@tonic-gate 	"the ", "an ", "a ", 0
327*7c478bd9Sstevel@tonic-gate };
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate char *
330*7c478bd9Sstevel@tonic-gate artskp(s)	/* skips over initial "a ", "an ", "the " in s */
331*7c478bd9Sstevel@tonic-gate char *s;
332*7c478bd9Sstevel@tonic-gate {
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate 	char **p, *r1, *r2;
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate 	for (p = articles; *p; p++) {
337*7c478bd9Sstevel@tonic-gate 		r2 = s;
338*7c478bd9Sstevel@tonic-gate 		for (r1 = *p; ((*r1 ^ *r2) & ~040 ) == 0; r1++)
339*7c478bd9Sstevel@tonic-gate 			r2++;
340*7c478bd9Sstevel@tonic-gate 		if (*r1 == 0 && *r2 != 0)
341*7c478bd9Sstevel@tonic-gate 			return(r2);
342*7c478bd9Sstevel@tonic-gate 	}
343*7c478bd9Sstevel@tonic-gate 	return(s);
344*7c478bd9Sstevel@tonic-gate }
345