ignore & before array
[unix-history] / usr / src / old / tbl / te.c
CommitLineData
476fcd16
SL
1#ifndef lint
2static char sccsid[] = "@(#)te.c 4.2 %G%";
3#endif
54302677
BS
4
5 /* te.c: error message control, input line count */
6# include "t..c"
7error(s)
8 char *s;
9{
10fprintf(stderr, "\n%s: line %d: %s\n", ifile, iline, s);
11# ifdef unix
12fprintf(stderr, "tbl quits\n");
13exit(1);
14# endif
15# ifdef gcos
16fprintf(stderr, "run terminated due to error condition detected by tbl preprocessor\n");
17exit(0);
18# endif
19}
20gets1(s)
21 char *s;
22{
23char *p;
24int nbl = 0;
25iline++;
26p=fgets(s,BUFSIZ,tabin);
27while (p==0)
28 {
29 if (swapin()==0)
30 return(0);
31 p = fgets(s,BUFSIZ,tabin);
32 }
33
34while (*s) s++;
35s--;
36if (*s == '\n') *s-- =0;
37for(nbl=0; *s == '\\' && s>p; s--)
38 nbl++;
39if (linstart && nbl % 2) /* fold escaped nl if in table */
40 gets1(s+1);
41
42return(p);
43}
44# define BACKMAX 500
45char backup[BACKMAX];
46char *backp = backup;
47un1getc(c)
48{
49if (c=='\n')
50 iline--;
51*backp++ = c;
52if (backp >= backup+BACKMAX)
53 error("too much backup");
54}
55get1char()
56{
57int c;
58if (backp>backup)
59 c = *--backp;
60else
61 c=getc(tabin);
62if (c== EOF) /* EOF */
63 {
64 if (swapin() ==0)
65 error("unexpected EOF");
66 c = getc(tabin);
67 }
68if (c== '\n')
69 iline++;
70return(c);
71}