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