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