Annotation of 43BSDReno/pgrm/pascal/pxp/error.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)error.c    5.2 (Berkeley) 12/4/87";
                      9: #endif not lint
                     10: 
                     11: /*
                     12:  * pi - Pascal interpreter code translator
                     13:  *
                     14:  * Charles Haley, Bill Joy UCB
                     15:  * Version 1.2 January 1979
                     16:  *
                     17:  *
                     18:  * pxp - Pascal execution profiler
                     19:  *
                     20:  * Bill Joy UCB
                     21:  * Version 1.2 January 1979
                     22:  */
                     23: 
                     24: #include "whoami.h"
                     25: #include "0.h"
                     26: #include "yy.h"
                     27: 
                     28: #ifdef PXP
                     29: extern int yyline;
                     30: extern char errout;
                     31: #endif
                     32: 
                     33: char   errpfx  = 'E';
                     34: extern int yyline;
                     35: /*
                     36:  * Panic is called when impossible
                     37:  * (supposedly, anyways) situations
                     38:  * are encountered.
                     39: #ifdef PI
                     40:  * Panic messages should be short
                     41:  * as they do not go to the message
                     42:  * file.
                     43: #endif
                     44:  */
                     45: panic(s)
                     46:        char *s;
                     47: {
                     48: 
                     49: #ifdef DEBUG
                     50:        fprintf(stderr, "Snark (%s) line=%d yyline=%d\n", s, line, yyline);
                     51: #endif
                     52: #ifdef PXP
                     53:        Perror( "Snark in pxp", s);
                     54: #endif
                     55: #ifdef PI
                     56:        Perror( "Snark in pi", s);
                     57: #endif
                     58:        pexit(DIED);
                     59: }
                     60: 
                     61: extern char *errfile;
                     62: /*
                     63:  * Error is called for
                     64:  * semantic errors and
                     65:  * prints the error and
                     66:  * a line number.
                     67:  */
                     68: error(a1, a2, a3, a4)
                     69: {
                     70: #ifdef PI
                     71:        char buf[256];
                     72:        register int i;
                     73: #endif
                     74: #ifdef PXP
                     75: /*
                     76:        int ofout;
                     77: */
                     78: #endif
                     79: 
                     80:        if (errpfx == 'w' && opt('w') != 0) {
                     81:                errpfx == 'E';
                     82:                return;
                     83:        }
                     84: #ifdef PXP
                     85: /*
                     86:        flush();
                     87:        ofout = fout[0];
                     88:        fout[0] = errout;
                     89: */
                     90: #endif
                     91: #ifdef PI
                     92:        Enocascade = 0;
                     93:        geterr(a1, buf);
                     94:        a1 = buf;
                     95: #endif
                     96:        if (line < 0)
                     97:                line = -line;
                     98:        yySsync();
                     99:        yysetfile(filename);
                    100: #ifdef PI
                    101:        if (errpfx == ' ') {
                    102:                printf("  ");
                    103:                for (i = line; i >= 10; i /= 10)
                    104:                        putchar(' ');
                    105:                printf("... ");
                    106:        } else if (Enoline)
                    107:                printf("  %c - ", errpfx);
                    108:        else
                    109: #endif
                    110:                fprintf(stderr, "%c %d - ", errpfx, line);
                    111:        fprintf(stderr, a1, a2, a3, a4);
                    112:        if (errpfx == 'E')
                    113: #ifdef PI
                    114:                eflg++, cgenflg++;
                    115: #endif
                    116: #ifdef PXP
                    117:                eflg++;
                    118: #endif
                    119:        errpfx = 'E';
                    120: #ifdef PI
                    121:        if (Eholdnl)
                    122:                Eholdnl = 0;
                    123:        else
                    124: #endif
                    125:                putc('\n', stderr);
                    126: #ifdef PXP
                    127: /*
                    128:        flush();
                    129:        fout[0] = ofout;
                    130: */
                    131: #endif
                    132: }
                    133: 
                    134: #ifdef PI
                    135: cerror(a1, a2, a3, a4)
                    136: {
                    137: 
                    138:        if (Enocascade)
                    139:                return;
                    140:        setpfx(' ');
                    141:        error(a1, a2, a3, a4);
                    142: }
                    143: #endif

unix.superglobalmegacorp.com

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