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