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

Defined functions

derror defined in line 116; never used
error defined in line 58; used 2 times
yysetfile defined in line 126; used 1 times
  • in line 77

Defined variables

errpfx defined in line 17; used 8 times
hadsome defined in line 124; never used
lastname defined in line 124; used 2 times
printed defined in line 124; used 1 times
Last modified: 1986-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2423
Valid CSS Valid XHTML 1.0 Strict