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