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