1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)error.h 5.2 (Berkeley) 06/06/88 13 */ 14 15 typedef int boolean; 16 #define reg register 17 18 #define TRUE 1 19 #define FALSE 0 20 21 #define true 1 22 #define false 0 23 /* 24 * Descriptors for the various languages we know about. 25 * If you touch these, also touch lang_table 26 */ 27 #define INUNKNOWN 0 28 #define INCPP 1 29 #define INCC 2 30 #define INAS 3 31 #define INLD 4 32 #define INLINT 5 33 #define INF77 6 34 #define INPI 7 35 #define INPC 8 36 #define INFRANZ 9 37 #define INLISP 10 38 #define INVAXIMA 11 39 #define INRATFOR 12 40 #define INLEX 13 41 #define INYACC 14 42 #define INAPL 15 43 #define INMAKE 16 44 #define INRI 17 45 #define INTROFF 18 46 #define INMOD2 19 47 48 extern int language; 49 /* 50 * We analyze each line in the error message file, and 51 * attempt to categorize it by type, as well as language. 52 * Here are the type descriptors. 53 */ 54 typedef int Errorclass; 55 56 #define C_FIRST 0 /* first error category */ 57 #define C_UNKNOWN 0 /* must be zero */ 58 #define C_IGNORE 1 /* ignore the message; used for pi */ 59 #define C_SYNC 2 /* synchronization errors */ 60 #define C_DISCARD 3 /* touches dangerous files, so discard */ 61 #define C_NONSPEC 4 /* not specific to any file */ 62 #define C_THISFILE 5 /* specific to this file, but at no line */ 63 #define C_NULLED 6 /* refers to special func; so null */ 64 #define C_TRUE 7 /* fits into true error format */ 65 #define C_DUPL 8 /* sub class only; duplicated error message */ 66 #define C_LAST 9 /* last error category */ 67 68 #define SORTABLE(x) (!(NOTSORTABLE(x))) 69 #define NOTSORTABLE(x) (x <= C_NONSPEC) 70 /* 71 * Resources to count and print out the error categories 72 */ 73 extern char *class_table[]; 74 extern int class_count[]; 75 76 #define nunknown class_count[C_UNKNOWN] 77 #define nignore class_count[C_IGNORE] 78 #define nsyncerrors class_count[C_SYNC] 79 #define ndiscard class_count[C_DISCARD] 80 #define nnonspec class_count[C_NONSPEC] 81 #define nthisfile class_count[C_THISFILE] 82 #define nnulled class_count[C_NULLED] 83 #define ntrue class_count[C_TRUE] 84 #define ndupl class_count[C_DUPL] 85 86 /* places to put the error complaints */ 87 88 #define TOTHEFILE 1 /* touch the file */ 89 #define TOSTDOUT 2 /* just print them out (ho-hum) */ 90 91 FILE *errorfile; /* where error file comes from */ 92 FILE *queryfile; /* where the query responses from the user come from*/ 93 94 extern char *currentfilename; 95 extern char *processname; 96 extern char *scriptname; 97 98 extern boolean query; 99 extern boolean terse; 100 int inquire(); /* inquire for yes/no */ 101 /* 102 * codes for inquire() to return 103 */ 104 #define Q_NO 1 /* 'N' */ 105 #define Q_no 2 /* 'n' */ 106 #define Q_YES 3 /* 'Y' */ 107 #define Q_yes 4 /* 'y' */ 108 109 int probethisfile(); 110 /* 111 * codes for probethisfile to return 112 */ 113 #define F_NOTEXIST 1 114 #define F_NOTREAD 2 115 #define F_NOTWRITE 3 116 #define F_TOUCHIT 4 117 118 /* 119 * Describes attributes about a language 120 */ 121 struct lang_desc{ 122 char *lang_name; 123 char *lang_incomment; /* one of the following defines */ 124 char *lang_outcomment; /* one of the following defines */ 125 }; 126 extern struct lang_desc lang_table[]; 127 128 #define CINCOMMENT "/*###" 129 #define COUTCOMMENT "%%%*/\n" 130 #define FINCOMMENT "C###" 131 #define FOUTCOMMENT "%%%\n" 132 #define NEWLINE "%%%\n" 133 #define PIINCOMMENT "(*###" 134 #define PIOUTCOMMENT "%%%*)\n" 135 #define LISPINCOMMENT ";###" 136 #define ASINCOMMENT "####" 137 #define RIINCOMMENT CINCOMMENT 138 #define RIOUTCOMMENT COUTCOMMENT 139 #define TROFFINCOMMENT ".\\\"###" 140 #define TROFFOUTCOMMENT NEWLINE 141 #define MOD2INCOMMENT "(*###" 142 #define MOD2OUTCOMMENT "%%%*)\n" 143 /* 144 * Defines and resources for determing if a given line 145 * is to be discarded because it refers to a file not to 146 * be touched, or if the function reference is to a 147 * function the user doesn't want recorded. 148 */ 149 #define IG_FILE1 "llib-lc" 150 #define IG_FILE2 "llib-port" 151 #define IG_FILE3 "/usr/lib/llib-lc" 152 #define IG_FILE4 "/usr/lib/llib-port" 153 154 #define ERRORNAME "/.errorrc" 155 int nignored; 156 char **names_ignored; 157 /* 158 * Structure definition for a full error 159 */ 160 typedef struct edesc Edesc; 161 typedef Edesc *Eptr; 162 163 struct edesc{ 164 Eptr error_next; /*linked together*/ 165 int error_lgtext; /* how many on the right hand side*/ 166 char **error_text; /* the right hand side proper*/ 167 Errorclass error_e_class; /* error category of this error*/ 168 Errorclass error_s_class; /* sub descriptor of error_e_class*/ 169 int error_language; /* the language for this error*/ 170 int error_position; /* oridinal position */ 171 int error_line; /* discovered line number*/ 172 int error_no; /* sequence number on input */ 173 }; 174 /* 175 * Resources for the true errors 176 */ 177 extern int nerrors; 178 extern Eptr er_head; 179 extern Eptr *errors; 180 /* 181 * Resources for each of the files mentioned 182 */ 183 extern int nfiles; 184 extern Eptr **files; /* array of pointers into errors*/ 185 boolean *touchedfiles; /* which files we touched */ 186 /* 187 * The langauge the compilation is in, as intuited from 188 * the flavor of error messages analyzed. 189 */ 190 extern int langauge; 191 extern char *currentfilename; 192 /* 193 * Functional forwards 194 */ 195 char *Calloc(); 196 char *strsave(); 197 char *clobberfirst(); 198 char lastchar(); 199 char firstchar(); 200 char next_lastchar(); 201 char **wordvsplice(); 202 int wordvcmp(); 203 boolean persperdexplode(); 204 /* 205 * Printing hacks 206 */ 207 char *plural(), *verbform(); 208