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