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