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