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