Home | History | Annotate | Line # | Download | only in error
error.h revision 1.2
      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, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by the University of
     16  *	California, Berkeley and its contributors.
     17  * 4. Neither the name of the University nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  *
     33  *	from: @(#)error.h	5.5 (Berkeley) 6/1/90
     34  *	$Id: error.h,v 1.2 1993/08/01 18:16:46 mycroft Exp $
     35  */
     36 
     37 typedef	int	boolean;
     38 #define	reg	register
     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 FILE	*errorfile;	/* where error file comes from */
    114 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();			/* 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();
    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 int	nignored;
    174 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 boolean	*touchedfiles;			/* which files we touched */
    204 /*
    205  *	The langauge the compilation is in, as intuited from
    206  *	the flavor of error messages analyzed.
    207  */
    208 extern	int	langauge;
    209 extern	char	*currentfilename;
    210 /*
    211  *	Functional forwards
    212  */
    213 char	*Calloc();
    214 char	*strsave();
    215 char	*clobberfirst();
    216 char	lastchar();
    217 char	firstchar();
    218 char	next_lastchar();
    219 char	**wordvsplice();
    220 int	wordvcmp();
    221 boolean	persperdexplode();
    222 /*
    223  *	Printing hacks
    224  */
    225 char	*plural(), *verbform();
    226