Blob
1 /* te.c: error message control, input line count */2 # include "t.h"4 void5 error(char *s)6 {7 fprint(2, "\n%s:%d: %s\n", ifile, iline, s);8 fprint(2, "tbl quits\n");9 exits(s);10 }13 char *14 gets1(char *s, int size)15 {16 char *p, *ns;17 int nbl;19 iline++;20 ns = s;21 p = Brdline(tabin, '\n');22 while (p == 0) {23 if (swapin() == 0)24 return(0);25 p = Brdline(tabin, '\n');26 }27 nbl = Blinelen(tabin)-1;28 if(nbl >= size)29 error("input buffer too small");30 p[nbl] = 0;31 strcpy(s, p);32 s += nbl;33 for (nbl = 0; *s == '\\' && s > ns; s--)34 nbl++;35 if (linstart && nbl % 2) /* fold escaped nl if in table */36 gets1(s + 1, size - (s-ns));38 return(p);39 }42 # define BACKMAX 50043 char backup[BACKMAX];44 char *backp = backup;46 void47 un1getc(int c)48 {49 if (c == '\n')50 iline--;51 *backp++ = c;52 if (backp >= backup + BACKMAX)53 error("too much backup");54 }57 int58 get1char(void)59 {60 int c;61 if (backp > backup)62 c = *--backp;63 else64 c = Bgetc(tabin);65 if (c == 0) /* EOF */ {66 if (swapin() == 0)67 error("unexpected EOF");68 c = Bgetc(tabin);69 }70 if (c == '\n')71 iline++;72 return(c);73 }