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