Annotation of researchv9/cmd/tbl/te.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.