|
|
1.1 ! root 1: static char ID[] = "@(#) errors.c: 1.4 12/1/83"; ! 2: ! 3: /* ! 4: * ! 5: * "errors.c" is a file containing a routine "aerror" that prints ! 6: * out error messages and (currently) terminates execution when ! 7: * an error is encountered. It prints out the file and line ! 8: * number where the error was encountered and uses a switch ! 9: * statement to select a diagnostic message based on the error ! 10: * code. If this error was reported by anything other than ! 11: * "makeinst" (indicated by "pass" being non-zero), the command ! 12: * "rm" is "exec"ed to remove all temporary files. The following ! 13: * global variables are used in this file: ! 14: * ! 15: * line Gives the line number in the current file being ! 16: * assembled. ! 17: * ! 18: * file A character array that contains the name of the ! 19: * file being assembled. ! 20: * ! 21: * fderr The file descriptor for error output. ! 22: * ! 23: * filenames This is an array of pointers to character strings ! 24: * that contains pointers to all of the file names ! 25: * obtained from the argument list. This array is used ! 26: * to obtain the names of the temporary files to be ! 27: * removed. ! 28: * ! 29: */ ! 30: ! 31: #include <stdio.h> ! 32: #include <signal.h> ! 33: #include "systems.h" ! 34: #include "gendefs.h" ! 35: ! 36: #define MAXERRS 30 ! 37: ! 38: unsigned short ! 39: line = 1, ! 40: cline = 0; /* `c' line number (from `.ln') */ ! 41: short anyerrs = 0; ! 42: char file[134]; ! 43: char cfile[15] = { "" }; /* name of `c' source file */ ! 44: ! 45: FILE *fderr; ! 46: ! 47: char *filenames[16]; ! 48: ! 49: #if M4ON ! 50: short rflag = NO; /* if set, remove (unlink) input when through */ ! 51: #endif ! 52: ! 53: onintr() ! 54: { ! 55: signal(SIGINT,onintr); ! 56: signal(SIGTERM,onintr); ! 57: delexit(); ! 58: } ! 59: ! 60: aerror(str) ! 61: register char *str; ! 62: { ! 63: errmsg("",str); ! 64: delexit(); ! 65: } ! 66: ! 67: yyerror(str) ! 68: char *str; ! 69: { ! 70: errmsg("",str); ! 71: if (++anyerrs > MAXERRS) { ! 72: fprintf(stderr,"Too many errors - Goodbye\n"); ! 73: delexit(); ! 74: } ! 75: } ! 76: ! 77: werror(str) ! 78: char *str; ! 79: { ! 80: errmsg("Warning: ",str); ! 81: } ! 82: ! 83: errmsg(str1,str2) ! 84: char *str1,*str2; ! 85: { ! 86: char *msgfile; ! 87: static short firsterr = 1; ! 88: ! 89: if (firsterr) { ! 90: if (cfile[0] == '\0') ! 91: msgfile = file; ! 92: else ! 93: msgfile = cfile; ! 94: fprintf(stderr,"Assembler: %s\n",msgfile); ! 95: firsterr = 0; ! 96: } ! 97: fprintf(stderr,"\taline %u",line); ! 98: if (cline != 0) ! 99: fprintf(stderr,"(cline %u)",cline); ! 100: else ! 101: fprintf(stderr,"\t"); ! 102: fprintf(stderr,": %s%s\n",str1,str2); ! 103: } ! 104: ! 105: delexit() ! 106: { ! 107: unlink(filenames[1]); /* unlink object (.o) file */ ! 108: deltemps(); ! 109: exit(127); ! 110: } ! 111: ! 112: deltemps() ! 113: { ! 114: register short i; ! 115: ! 116: #if M4ON ! 117: if (rflag) ! 118: unlink(file); ! 119: #endif ! 120: for (i = 2; i < NFILES; ++i) ! 121: unlink(filenames[i]); ! 122: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.