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