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