xref: /csrg-svn/usr.bin/error/error.h (revision 17499)
1*17499Srrh /*	error.h	1.5	84/12/11	*/
214545Ssam 
31454Sroot typedef	int	boolean;
45596Srrh #define	reg	register
51454Sroot 
61454Sroot #define	TRUE	1
71454Sroot #define	FALSE	0
85596Srrh 
95596Srrh #define	true	1
105596Srrh #define	false	0
111454Sroot /*
121454Sroot  *	Descriptors for the various languages we know about.
131454Sroot  *	If you touch these, also touch lang_table
141454Sroot  */
151454Sroot #define	INUNKNOWN	0
161454Sroot #define	INCPP	1
171454Sroot #define	INCC	2
181454Sroot #define	INAS	3
191454Sroot #define	INLD	4
201454Sroot #define	INLINT	5
211454Sroot #define	INF77	6
221454Sroot #define	INPI	7
231454Sroot #define	INPC	8
241454Sroot #define	INFRANZ	9
251454Sroot #define	INLISP	10
261454Sroot #define	INVAXIMA	11
271454Sroot #define	INRATFOR	12
281454Sroot #define	INLEX	13
291454Sroot #define	INYACC	14
301454Sroot #define	INAPL	15
311454Sroot #define	INMAKE	16
321454Sroot #define	INRI	17
3313106Srrh #define	INTROFF	18
34*17499Srrh #define	INMOD2	19
351454Sroot 
361454Sroot extern	int	language;
371454Sroot /*
381454Sroot  *	We analyze each line in the error message file, and
391454Sroot  *	attempt to categorize it by type, as well as language.
401454Sroot  *	Here are the type descriptors.
411454Sroot  */
421454Sroot typedef	int	Errorclass;
431454Sroot 
445596Srrh #define	C_FIRST	0		/* first error category */
451454Sroot #define	C_UNKNOWN	0	/* must be zero */
461454Sroot #define	C_IGNORE	1	/* ignore the message; used for pi */
471454Sroot #define	C_SYNC		2	/* synchronization errors */
481454Sroot #define	C_DISCARD	3	/* touches dangerous files, so discard */
491454Sroot #define	C_NONSPEC	4	/* not specific to any file */
501454Sroot #define	C_THISFILE	5	/* specific to this file, but at no line */
511454Sroot #define	C_NULLED	6	/* refers to special func; so null */
521454Sroot #define	C_TRUE		7	/* fits into true error format */
531454Sroot #define	C_DUPL		8	/* sub class only; duplicated error message */
545596Srrh #define	C_LAST	9		/* last error category */
551454Sroot 
561454Sroot #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
571454Sroot #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
581454Sroot /*
591454Sroot  *	Resources to count and print out the error categories
601454Sroot  */
611454Sroot extern	char		*class_table[];
621454Sroot extern	int		class_count[];
631454Sroot 
641454Sroot #define	nunknown	class_count[C_UNKNOWN]
651454Sroot #define	nignore		class_count[C_IGNORE]
665596Srrh #define	nsyncerrors	class_count[C_SYNC]
671454Sroot #define	ndiscard	class_count[C_DISCARD]
681454Sroot #define	nnonspec	class_count[C_NONSPEC]
691454Sroot #define	nthisfile	class_count[C_THISFILE]
705596Srrh #define	nnulled		class_count[C_NULLED]
715596Srrh #define	ntrue		class_count[C_TRUE]
721454Sroot #define	ndupl		class_count[C_DUPL]
731454Sroot 
741454Sroot /* places to put the error complaints */
751454Sroot 
765596Srrh #define	TOTHEFILE	1	/* touch the file */
771454Sroot #define	TOSTDOUT	2	/* just print them out (ho-hum) */
781454Sroot 
791454Sroot FILE	*errorfile;	/* where error file comes from */
801454Sroot FILE	*queryfile;	/* where the query responses from the user come from*/
811454Sroot 
821454Sroot extern	char	*currentfilename;
831454Sroot extern	char	*processname;
841454Sroot extern	char	*scriptname;
851454Sroot 
861454Sroot extern	boolean	query;
875596Srrh extern	boolean	terse;
885596Srrh int	inquire();			/* inquire for yes/no */
895596Srrh /*
905596Srrh  *	codes for inquire() to return
915596Srrh  */
925596Srrh #define	Q_NO	1			/* 'N' */
935596Srrh #define	Q_no	2			/* 'n' */
945596Srrh #define	Q_YES	3			/* 'Y' */
955596Srrh #define	Q_yes	4			/* 'y' */
965596Srrh 
975596Srrh int	probethisfile();
981454Sroot /*
995596Srrh  *	codes for probethisfile to return
1005596Srrh  */
1015596Srrh #define	F_NOTEXIST	1
1025596Srrh #define	F_NOTREAD	2
1035596Srrh #define	F_NOTWRITE	3
1045596Srrh #define	F_TOUCHIT	4
1055596Srrh 
1065596Srrh /*
1071454Sroot  *	Describes attributes about a language
1081454Sroot  */
1091454Sroot struct lang_desc{
1101454Sroot 	char	*lang_name;
1111454Sroot 	char	*lang_incomment;	/* one of the following defines */
1121454Sroot 	char	*lang_outcomment;	/* one of the following defines */
1131454Sroot };
1141454Sroot extern struct lang_desc lang_table[];
1151454Sroot 
1161454Sroot #define	CINCOMMENT	"/*###"
1171454Sroot #define	COUTCOMMENT	"%%%*/\n"
1181454Sroot #define	FINCOMMENT	"C###"
1191454Sroot #define	FOUTCOMMENT	"%%%\n"
1201454Sroot #define	NEWLINE		"%%%\n"
1211454Sroot #define	PIINCOMMENT	"(*###"
1221454Sroot #define	PIOUTCOMMENT	"%%%*)\n"
1231454Sroot #define	LISPINCOMMENT	";###"
1241454Sroot #define	ASINCOMMENT	"####"
1255596Srrh #define	RIINCOMMENT	CINCOMMENT
1261454Sroot #define	RIOUTCOMMENT	COUTCOMMENT
12713106Srrh #define	TROFFINCOMMENT	".\\\"###"
12813106Srrh #define	TROFFOUTCOMMENT	NEWLINE
129*17499Srrh #define	MOD2INCOMMENT	"(*###"
130*17499Srrh #define	MOD2OUTCOMMENT	"%%%*)\n"
1311454Sroot /*
1321454Sroot  *	Defines and resources for determing if a given line
1331454Sroot  *	is to be discarded because it refers to a file not to
1341454Sroot  *	be touched, or if the function reference is to a
1351454Sroot  *	function the user doesn't want recorded.
1361454Sroot  */
1375596Srrh #define	IG_FILE1	"llib-lc"
1385596Srrh #define	IG_FILE2	"llib-port"
1391454Sroot #define	IG_FILE3	"/usr/lib/llib-lc"
1401454Sroot #define	IG_FILE4	"/usr/lib/llib-port"
1411454Sroot 
1425596Srrh #define	ERRORNAME	"/.errorrc"
1431454Sroot int	nignored;
1441454Sroot char	**names_ignored;
1451454Sroot /*
1461454Sroot  *	Structure definition for a full error
1471454Sroot  */
1485596Srrh typedef struct edesc	Edesc;
1495596Srrh typedef	Edesc	*Eptr;
1505596Srrh 
1515596Srrh struct edesc{
1525596Srrh 	Eptr	error_next;		/*linked together*/
1531454Sroot 	int	error_lgtext;		/* how many on the right hand side*/
1541454Sroot 	char	**error_text;		/* the right hand side proper*/
1551454Sroot 	Errorclass	error_e_class;	/* error category of this error*/
1561454Sroot 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
1571454Sroot 	int	error_language;		/* the language for this error*/
1581454Sroot 	int	error_position;		/* oridinal position */
1591454Sroot 	int	error_line;		/* discovered line number*/
1601454Sroot 	int	error_no;		/* sequence number on input */
1611454Sroot };
1621454Sroot /*
1631454Sroot  *	Resources for the true errors
1641454Sroot  */
1651454Sroot extern	int	nerrors;
1665596Srrh extern	Eptr	er_head;
1675596Srrh extern	Eptr	*errors;
1681454Sroot /*
1691454Sroot  *	Resources for each of the files mentioned
1701454Sroot  */
1711454Sroot extern	int	nfiles;
1725596Srrh extern	Eptr	**files;	/* array of pointers into errors*/
1735596Srrh boolean	*touchedfiles;			/* which files we touched */
1741454Sroot /*
1751454Sroot  *	The langauge the compilation is in, as intuited from
1761454Sroot  *	the flavor of error messages analyzed.
1771454Sroot  */
1781454Sroot extern	int	langauge;
1791454Sroot extern	char	*currentfilename;
1801454Sroot /*
1811454Sroot  *	Functional forwards
1821454Sroot  */
1831454Sroot char	*Calloc();
1841454Sroot char	*strsave();
1851454Sroot char	*clobberfirst();
1861454Sroot char	lastchar();
1871454Sroot char	firstchar();
1881454Sroot char	next_lastchar();
1891454Sroot char	**wordvsplice();
1901454Sroot int	wordvcmp();
1911454Sroot boolean	persperdexplode();
1925596Srrh /*
1935596Srrh  *	Printing hacks
1945596Srrh  */
1955596Srrh char	*plural(), *verbform();
196