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