error.h revision 1.14 1 1.14 dholland /* $NetBSD: error.h,v 1.14 2009/08/13 05:53:58 dholland 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.14 dholland #include <stdbool.h>
35 1.14 dholland
36 1.12 dholland typedef int boolean;
37 1.1 cgd
38 1.1 cgd /*
39 1.12 dholland * Descriptors for the various languages we know about.
40 1.12 dholland * If you touch these, also touch lang_table
41 1.12 dholland */
42 1.12 dholland #define INUNKNOWN 0
43 1.12 dholland #define INCPP 1
44 1.12 dholland #define INCC 2
45 1.12 dholland #define INAS 3
46 1.12 dholland #define INLD 4
47 1.12 dholland #define INLINT 5
48 1.12 dholland #define INF77 6
49 1.12 dholland #define INPI 7
50 1.12 dholland #define INPC 8
51 1.12 dholland #define INFRANZ 9
52 1.12 dholland #define INLISP 10
53 1.12 dholland #define INVAXIMA 11
54 1.12 dholland #define INRATFOR 12
55 1.12 dholland #define INLEX 13
56 1.12 dholland #define INYACC 14
57 1.12 dholland #define INAPL 15
58 1.12 dholland #define INMAKE 16
59 1.12 dholland #define INRI 17
60 1.12 dholland #define INTROFF 18
61 1.12 dholland #define INMOD2 19
62 1.12 dholland
63 1.12 dholland /*
64 1.12 dholland * We analyze each line in the error message file, and
65 1.12 dholland * attempt to categorize it by type, as well as language.
66 1.12 dholland * Here are the type descriptors.
67 1.12 dholland */
68 1.12 dholland typedef int Errorclass;
69 1.12 dholland
70 1.12 dholland #define C_FIRST 0 /* first error category */
71 1.12 dholland #define C_UNKNOWN 0 /* must be zero */
72 1.12 dholland #define C_IGNORE 1 /* ignore the message; used for pi */
73 1.12 dholland #define C_SYNC 2 /* synchronization errors */
74 1.12 dholland #define C_DISCARD 3 /* touches dangerous files, so discard */
75 1.12 dholland #define C_NONSPEC 4 /* not specific to any file */
76 1.12 dholland #define C_THISFILE 5 /* specific to this file, but at no line */
77 1.12 dholland #define C_NULLED 6 /* refers to special func; so null */
78 1.12 dholland #define C_TRUE 7 /* fits into true error format */
79 1.12 dholland #define C_DUPL 8 /* sub class only; duplicated error message */
80 1.12 dholland #define C_LAST 9 /* last error category */
81 1.12 dholland
82 1.12 dholland #define SORTABLE(x) (!(NOTSORTABLE(x)))
83 1.12 dholland #define NOTSORTABLE(x) (x <= C_NONSPEC)
84 1.12 dholland
85 1.12 dholland /*
86 1.12 dholland * Resources to count and print out the error categories
87 1.12 dholland */
88 1.12 dholland extern char *class_table[];
89 1.12 dholland extern int class_count[];
90 1.12 dholland
91 1.12 dholland #define nunknown class_count[C_UNKNOWN]
92 1.12 dholland #define nignore class_count[C_IGNORE]
93 1.12 dholland #define nsyncerrors class_count[C_SYNC]
94 1.12 dholland #define ndiscard class_count[C_DISCARD]
95 1.12 dholland #define nnonspec class_count[C_NONSPEC]
96 1.12 dholland #define nthisfile class_count[C_THISFILE]
97 1.12 dholland #define nnulled class_count[C_NULLED]
98 1.12 dholland #define ntrue class_count[C_TRUE]
99 1.12 dholland #define ndupl class_count[C_DUPL]
100 1.1 cgd
101 1.1 cgd /* places to put the error complaints */
102 1.1 cgd
103 1.12 dholland #define TOTHEFILE 1 /* touch the file */
104 1.12 dholland #define TOSTDOUT 2 /* just print them out (ho-hum) */
105 1.12 dholland
106 1.12 dholland extern FILE *errorfile; /* where error file comes from */
107 1.12 dholland extern FILE *queryfile; /* where the query responses from the user come from*/
108 1.1 cgd
109 1.12 dholland extern char *processname;
110 1.12 dholland extern char *scriptname;
111 1.1 cgd
112 1.14 dholland extern char *suffixlist;
113 1.14 dholland
114 1.12 dholland extern boolean query;
115 1.12 dholland extern boolean terse;
116 1.13 dholland int inquire(const char *, ...); /* inquire for yes/no */
117 1.12 dholland
118 1.12 dholland /*
119 1.12 dholland * codes for inquire() to return
120 1.12 dholland */
121 1.12 dholland #define Q_error -1 /* an error occurred */
122 1.12 dholland #define Q_NO 1 /* 'N' */
123 1.12 dholland #define Q_no 2 /* 'n' */
124 1.12 dholland #define Q_YES 3 /* 'Y' */
125 1.12 dholland #define Q_yes 4 /* 'y' */
126 1.1 cgd
127 1.12 dholland /*
128 1.12 dholland * Describes attributes about a language
129 1.12 dholland */
130 1.12 dholland struct lang_desc {
131 1.12 dholland char *lang_name;
132 1.13 dholland const char *lang_incomment; /* one of the following defines */
133 1.13 dholland const char *lang_outcomment; /* one of the following defines */
134 1.1 cgd };
135 1.1 cgd extern struct lang_desc lang_table[];
136 1.1 cgd
137 1.12 dholland #define CINCOMMENT "/*###"
138 1.12 dholland #define COUTCOMMENT "%%%*/\n"
139 1.12 dholland #define FINCOMMENT "C###"
140 1.12 dholland #define FOUTCOMMENT "%%%\n"
141 1.12 dholland #define NEWLINE "%%%\n"
142 1.12 dholland #define PIINCOMMENT "(*###"
143 1.12 dholland #define PIOUTCOMMENT "%%%*)\n"
144 1.12 dholland #define LISPINCOMMENT ";###"
145 1.12 dholland #define ASINCOMMENT "####"
146 1.12 dholland #define RIINCOMMENT CINCOMMENT
147 1.12 dholland #define RIOUTCOMMENT COUTCOMMENT
148 1.12 dholland #define TROFFINCOMMENT ".\\\"###"
149 1.12 dholland #define TROFFOUTCOMMENT NEWLINE
150 1.12 dholland #define MOD2INCOMMENT "(*###"
151 1.12 dholland #define MOD2OUTCOMMENT "%%%*)\n"
152 1.12 dholland
153 1.12 dholland /*
154 1.12 dholland * Defines and resources for determing if a given line
155 1.12 dholland * is to be discarded because it refers to a file not to
156 1.12 dholland * be touched, or if the function reference is to a
157 1.12 dholland * function the user doesn't want recorded.
158 1.12 dholland */
159 1.12 dholland
160 1.12 dholland #define ERRORNAME "/.errorrc"
161 1.12 dholland extern int nignored;
162 1.12 dholland extern char **names_ignored;
163 1.12 dholland
164 1.12 dholland /*
165 1.12 dholland * Structure definition for a full error
166 1.12 dholland */
167 1.12 dholland typedef struct edesc Edesc;
168 1.12 dholland typedef Edesc *Eptr;
169 1.12 dholland
170 1.12 dholland struct edesc {
171 1.12 dholland Eptr error_next; /* linked together */
172 1.12 dholland int error_lgtext; /* how many on the right hand side */
173 1.12 dholland char **error_text; /* the right hand side proper */
174 1.12 dholland Errorclass error_e_class; /* error category of this error */
175 1.12 dholland Errorclass error_s_class; /* sub descriptor of error_e_class */
176 1.12 dholland int error_language; /* the language for this error */
177 1.12 dholland int error_position; /* oridinal position */
178 1.12 dholland int error_line; /* discovered line number */
179 1.12 dholland int error_no; /* sequence number on input */
180 1.1 cgd };
181 1.12 dholland
182 1.1 cgd /*
183 1.12 dholland * Resources for the true errors
184 1.1 cgd */
185 1.12 dholland extern int nerrors;
186 1.12 dholland extern Eptr er_head;
187 1.11 dholland
188 1.14 dholland extern int cur_wordc;
189 1.14 dholland extern char **cur_wordv;
190 1.14 dholland
191 1.14 dholland
192 1.1 cgd /*
193 1.12 dholland * Resources for each of the files mentioned
194 1.1 cgd */
195 1.12 dholland extern int nfiles;
196 1.12 dholland extern Eptr **files; /* array of pointers into errors */
197 1.12 dholland extern boolean *touchedfiles; /* which files we touched */
198 1.4 lukem
199 1.1 cgd /*
200 1.12 dholland * The language the compilation is in, as intuited from
201 1.12 dholland * the flavor of error messages analyzed.
202 1.1 cgd */
203 1.12 dholland extern int language;
204 1.12 dholland extern char *currentfilename;
205 1.4 lukem
206 1.1 cgd /*
207 1.1 cgd * Functional forwards
208 1.1 cgd */
209 1.12 dholland void arrayify(int *, Eptr **, Eptr);
210 1.14 dholland void *Calloc(size_t, size_t);
211 1.12 dholland void clob_last(char *, char);
212 1.7 wiz Errorclass discardit(Eptr);
213 1.12 dholland void eaterrors(int *, Eptr **);
214 1.12 dholland void erroradd(int, char **, Errorclass, Errorclass);
215 1.12 dholland void filenames(int, Eptr **);
216 1.12 dholland void findfiles(int, Eptr *, int *, Eptr ***);
217 1.13 dholland char firstchar(const char *);
218 1.13 dholland void getignored(const char *);
219 1.13 dholland char lastchar(const char *);
220 1.13 dholland char next_lastchar(const char *);
221 1.12 dholland void onintr(int);
222 1.14 dholland bool persperdexplode(char *, char **, char **);
223 1.11 dholland Errorclass pi(void);
224 1.13 dholland int position(const char *, char);
225 1.14 dholland void printerrors(bool, int, Eptr []);
226 1.13 dholland const char *plural(int);
227 1.12 dholland char *substitute(char *, char, char);
228 1.14 dholland bool touchfiles(int, Eptr **, int *, char ***);
229 1.13 dholland const char *verbform(int);
230 1.12 dholland void wordvbuild(char *, int*, char ***);
231 1.12 dholland int wordvcmp(char **, int, char **);
232 1.12 dholland void wordvprint(FILE *, int, char **);
233 1.12 dholland char **wordvsplice(int, int, char **);
234