error.h revision 1.9 1 1.9 agc /* $NetBSD: error.h,v 1.9 2003/08/07 11:13:36 agc Exp $ */
2 1.3 jtc
3 1.1 cgd /*
4 1.3 jtc * Copyright (c) 1980, 1993
5 1.3 jtc * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.9 agc * 3. Neither the name of the University nor the names of its contributors
16 1.1 cgd * may be used to endorse or promote products derived from this software
17 1.1 cgd * without specific prior written permission.
18 1.1 cgd *
19 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 cgd * SUCH DAMAGE.
30 1.1 cgd *
31 1.3 jtc * @(#)error.h 8.1 (Berkeley) 6/6/93
32 1.1 cgd */
33 1.1 cgd
34 1.1 cgd typedef int boolean;
35 1.1 cgd
36 1.1 cgd #define TRUE 1
37 1.1 cgd #define FALSE 0
38 1.1 cgd
39 1.1 cgd #define true 1
40 1.1 cgd #define false 0
41 1.1 cgd /*
42 1.1 cgd * Descriptors for the various languages we know about.
43 1.1 cgd * If you touch these, also touch lang_table
44 1.1 cgd */
45 1.1 cgd #define INUNKNOWN 0
46 1.1 cgd #define INCPP 1
47 1.1 cgd #define INCC 2
48 1.1 cgd #define INAS 3
49 1.1 cgd #define INLD 4
50 1.1 cgd #define INLINT 5
51 1.1 cgd #define INF77 6
52 1.1 cgd #define INPI 7
53 1.1 cgd #define INPC 8
54 1.1 cgd #define INFRANZ 9
55 1.1 cgd #define INLISP 10
56 1.1 cgd #define INVAXIMA 11
57 1.1 cgd #define INRATFOR 12
58 1.1 cgd #define INLEX 13
59 1.1 cgd #define INYACC 14
60 1.1 cgd #define INAPL 15
61 1.1 cgd #define INMAKE 16
62 1.1 cgd #define INRI 17
63 1.1 cgd #define INTROFF 18
64 1.1 cgd #define INMOD2 19
65 1.1 cgd
66 1.1 cgd /*
67 1.1 cgd * We analyze each line in the error message file, and
68 1.1 cgd * attempt to categorize it by type, as well as language.
69 1.1 cgd * Here are the type descriptors.
70 1.1 cgd */
71 1.1 cgd typedef int Errorclass;
72 1.1 cgd
73 1.1 cgd #define C_FIRST 0 /* first error category */
74 1.1 cgd #define C_UNKNOWN 0 /* must be zero */
75 1.1 cgd #define C_IGNORE 1 /* ignore the message; used for pi */
76 1.1 cgd #define C_SYNC 2 /* synchronization errors */
77 1.1 cgd #define C_DISCARD 3 /* touches dangerous files, so discard */
78 1.1 cgd #define C_NONSPEC 4 /* not specific to any file */
79 1.1 cgd #define C_THISFILE 5 /* specific to this file, but at no line */
80 1.1 cgd #define C_NULLED 6 /* refers to special func; so null */
81 1.1 cgd #define C_TRUE 7 /* fits into true error format */
82 1.1 cgd #define C_DUPL 8 /* sub class only; duplicated error message */
83 1.1 cgd #define C_LAST 9 /* last error category */
84 1.1 cgd
85 1.1 cgd #define SORTABLE(x) (!(NOTSORTABLE(x)))
86 1.1 cgd #define NOTSORTABLE(x) (x <= C_NONSPEC)
87 1.1 cgd /*
88 1.1 cgd * Resources to count and print out the error categories
89 1.1 cgd */
90 1.1 cgd extern char *class_table[];
91 1.1 cgd extern int class_count[];
92 1.1 cgd
93 1.1 cgd #define nunknown class_count[C_UNKNOWN]
94 1.1 cgd #define nignore class_count[C_IGNORE]
95 1.1 cgd #define nsyncerrors class_count[C_SYNC]
96 1.1 cgd #define ndiscard class_count[C_DISCARD]
97 1.1 cgd #define nnonspec class_count[C_NONSPEC]
98 1.1 cgd #define nthisfile class_count[C_THISFILE]
99 1.1 cgd #define nnulled class_count[C_NULLED]
100 1.1 cgd #define ntrue class_count[C_TRUE]
101 1.1 cgd #define ndupl class_count[C_DUPL]
102 1.1 cgd
103 1.1 cgd /* places to put the error complaints */
104 1.1 cgd
105 1.1 cgd #define TOTHEFILE 1 /* touch the file */
106 1.1 cgd #define TOSTDOUT 2 /* just print them out (ho-hum) */
107 1.1 cgd
108 1.5 wsanchez extern FILE *errorfile; /* where error file comes from */
109 1.5 wsanchez extern FILE *queryfile; /* where the query responses from the user come from*/
110 1.1 cgd
111 1.1 cgd extern char *processname;
112 1.1 cgd extern char *scriptname;
113 1.1 cgd
114 1.1 cgd extern boolean query;
115 1.1 cgd extern boolean terse;
116 1.7 wiz int inquire(char *, ...); /* inquire for yes/no */
117 1.1 cgd /*
118 1.1 cgd * codes for inquire() to return
119 1.1 cgd */
120 1.1 cgd #define Q_NO 1 /* 'N' */
121 1.1 cgd #define Q_no 2 /* 'n' */
122 1.1 cgd #define Q_YES 3 /* 'Y' */
123 1.1 cgd #define Q_yes 4 /* 'y' */
124 1.1 cgd
125 1.7 wiz int probethisfile(char *);
126 1.1 cgd /*
127 1.1 cgd * codes for probethisfile to return
128 1.1 cgd */
129 1.1 cgd #define F_NOTEXIST 1
130 1.1 cgd #define F_NOTREAD 2
131 1.1 cgd #define F_NOTWRITE 3
132 1.1 cgd #define F_TOUCHIT 4
133 1.1 cgd
134 1.1 cgd /*
135 1.1 cgd * Describes attributes about a language
136 1.1 cgd */
137 1.1 cgd struct lang_desc{
138 1.1 cgd char *lang_name;
139 1.1 cgd char *lang_incomment; /* one of the following defines */
140 1.1 cgd char *lang_outcomment; /* one of the following defines */
141 1.1 cgd };
142 1.1 cgd extern struct lang_desc lang_table[];
143 1.1 cgd
144 1.1 cgd #define CINCOMMENT "/*###"
145 1.1 cgd #define COUTCOMMENT "%%%*/\n"
146 1.1 cgd #define FINCOMMENT "C###"
147 1.1 cgd #define FOUTCOMMENT "%%%\n"
148 1.1 cgd #define NEWLINE "%%%\n"
149 1.1 cgd #define PIINCOMMENT "(*###"
150 1.1 cgd #define PIOUTCOMMENT "%%%*)\n"
151 1.1 cgd #define LISPINCOMMENT ";###"
152 1.1 cgd #define ASINCOMMENT "####"
153 1.1 cgd #define RIINCOMMENT CINCOMMENT
154 1.1 cgd #define RIOUTCOMMENT COUTCOMMENT
155 1.1 cgd #define TROFFINCOMMENT ".\\\"###"
156 1.1 cgd #define TROFFOUTCOMMENT NEWLINE
157 1.1 cgd #define MOD2INCOMMENT "(*###"
158 1.1 cgd #define MOD2OUTCOMMENT "%%%*)\n"
159 1.1 cgd /*
160 1.1 cgd * Defines and resources for determing if a given line
161 1.1 cgd * is to be discarded because it refers to a file not to
162 1.1 cgd * be touched, or if the function reference is to a
163 1.1 cgd * function the user doesn't want recorded.
164 1.1 cgd */
165 1.1 cgd
166 1.1 cgd #define ERRORNAME "/.errorrc"
167 1.5 wsanchez extern int nignored;
168 1.5 wsanchez extern char **names_ignored;
169 1.1 cgd /*
170 1.1 cgd * Structure definition for a full error
171 1.1 cgd */
172 1.1 cgd typedef struct edesc Edesc;
173 1.1 cgd typedef Edesc *Eptr;
174 1.1 cgd
175 1.1 cgd struct edesc{
176 1.1 cgd Eptr error_next; /*linked together*/
177 1.1 cgd int error_lgtext; /* how many on the right hand side*/
178 1.1 cgd char **error_text; /* the right hand side proper*/
179 1.1 cgd Errorclass error_e_class; /* error category of this error*/
180 1.1 cgd Errorclass error_s_class; /* sub descriptor of error_e_class*/
181 1.1 cgd int error_language; /* the language for this error*/
182 1.1 cgd int error_position; /* oridinal position */
183 1.1 cgd int error_line; /* discovered line number*/
184 1.1 cgd int error_no; /* sequence number on input */
185 1.1 cgd };
186 1.1 cgd /*
187 1.1 cgd * Resources for the true errors
188 1.1 cgd */
189 1.1 cgd extern int nerrors;
190 1.1 cgd extern Eptr er_head;
191 1.1 cgd extern Eptr *errors;
192 1.1 cgd /*
193 1.1 cgd * Resources for each of the files mentioned
194 1.1 cgd */
195 1.1 cgd extern int nfiles;
196 1.1 cgd extern Eptr **files; /* array of pointers into errors*/
197 1.5 wsanchez extern boolean *touchedfiles; /* which files we touched */
198 1.4 lukem
199 1.1 cgd /*
200 1.5 wsanchez * The language the compilation is in, as intuited from
201 1.1 cgd * the flavor of error messages analyzed.
202 1.1 cgd */
203 1.5 wsanchez extern int language;
204 1.1 cgd extern char *currentfilename;
205 1.4 lukem
206 1.1 cgd /*
207 1.1 cgd * Functional forwards
208 1.1 cgd */
209 1.7 wiz void arrayify(int *, Eptr **, Eptr);
210 1.7 wiz char *Calloc(int, int);
211 1.7 wiz void clob_last(char *, char);
212 1.7 wiz int countfiles(Eptr *);
213 1.7 wiz Errorclass discardit(Eptr);
214 1.7 wiz void diverterrors(char *, int, Eptr **, int, boolean, int);
215 1.7 wiz void eaterrors(int *, Eptr **);
216 1.7 wiz boolean edit(char *);
217 1.7 wiz void erroradd(int, char **, Errorclass, Errorclass);
218 1.7 wiz void errorprint(FILE *, Eptr, boolean);
219 1.7 wiz void execvarg(int, int *, char ***);
220 1.7 wiz void filenames(int, Eptr **);
221 1.7 wiz void findfiles(int, Eptr *, int *, Eptr ***);
222 1.7 wiz char firstchar(char *);
223 1.7 wiz void getignored(char *);
224 1.7 wiz void hackfile(char *, Eptr **, int, int);
225 1.7 wiz void insert(int);
226 1.7 wiz char lastchar(char *);
227 1.7 wiz int mustoverwrite(FILE *, FILE *);
228 1.7 wiz int mustwrite(char *, int, FILE *);
229 1.7 wiz char next_lastchar(char *);
230 1.7 wiz int nopertain(Eptr **);
231 1.7 wiz int oktotouch(char *);
232 1.7 wiz void onintr(int);
233 1.7 wiz boolean persperdexplode(char *, char **, char **);
234 1.7 wiz int position(char *, char);
235 1.7 wiz boolean preview(char *, int, Eptr **, int);
236 1.7 wiz void printerrors(boolean, int, Eptr []);
237 1.7 wiz char *plural(int);
238 1.7 wiz boolean qpersperdexplode(char *, char **, char **);
239 1.7 wiz int settotouch(char *);
240 1.7 wiz char *substitute(char *, char, char);
241 1.7 wiz void text(Eptr, boolean);
242 1.7 wiz boolean touchfiles(int, Eptr **, int *, char ***);
243 1.7 wiz char *verbform(int);
244 1.7 wiz void wordvbuild(char *, int*, char ***);
245 1.7 wiz int wordvcmp(char **, int, char **);
246 1.7 wiz void wordvprint(FILE *, int, char **);
247 1.7 wiz char **wordvsplice(int, int, char **);
248 1.7 wiz boolean writetouched(int);
249