static char *sccsid
= "@(#)input.c 1.6 (Berkeley) 82/05/04";
int wordc
; /* how long the current error message is */
char **wordv
; /* the actual error message */
Errorclass
pccccom(); /* Portable C Compiler C Compiler */
Errorclass
richieccom(); /* Richie Compiler for 11 */
* Eat all of the lines in the input file, attempting to categorize
* them by their various flavors
static char inbuffer
[BUFSIZ
];
eaterrors(r_errorc
, r_errorv
)
Errorclass errorclass
= C_SYNC
;
if (fgets(inbuffer
, BUFSIZ
, errorfile
) == NULL
)
wordvbuild(inbuffer
, &wordc
, &wordv
);
* for convience, convert wordv to be 1 based, instead
|| (( errorclass
= onelong() ) != C_UNKNOWN
)
|| (( errorclass
= cpp() ) != C_UNKNOWN
)
|| (( errorclass
= pccccom() ) != C_UNKNOWN
)
|| (( errorclass
= richieccom() ) != C_UNKNOWN
)
|| (( errorclass
= lint0() ) != C_UNKNOWN
)
|| (( errorclass
= lint1() ) != C_UNKNOWN
)
|| (( errorclass
= lint2() ) != C_UNKNOWN
)
|| (( errorclass
= lint3() ) != C_UNKNOWN
)
|| (( errorclass
= make() ) != C_UNKNOWN
)
|| (( errorclass
= f77() ) != C_UNKNOWN
)
|| ((errorclass
= pi() ) != C_UNKNOWN
)
|| (( errorclass
= ri() )!= C_UNKNOWN
)
erroradd(wordc
, wordv
+1, errorclass
, C_UNKNOWN
);
printf("%d errorentrys\n", nerrors
);
arrayify(r_errorc
, r_errorv
, er_head
);
* create a new error entry, given a zero based array and count
erroradd(errorlength
, errorv
, errorclass
, errorsubclass
)
Errorclass errorsubclass
;
if (errorclass
== C_TRUE
){
/* check canonicalization of the second argument*/
for(cp
= errorv
[1]; *cp
&& isdigit(*cp
); cp
++)
errorclass
= (*cp
== '\0') ? C_TRUE
: C_NONSPEC
;
if (errorclass
!= C_TRUE
)
printf("The 2nd word, \"%s\" is not a number.\n",
newerror
= (Eptr
)Calloc(1, sizeof(Edesc
));
newerror
->error_language
= language
; /* language is global */
newerror
->error_text
= errorv
;
newerror
->error_lgtext
= errorlength
;
if (errorclass
== C_TRUE
)
newerror
->error_line
= atoi(errorv
[1]);
newerror
->error_e_class
= errorclass
;
newerror
->error_s_class
= errorsubclass
;
switch(newerror
->error_e_class
= discardit(newerror
)){
case C_SYNC
: nsyncerrors
++; break;
case C_DISCARD
: ndiscard
++; break;
case C_NULLED
: nnulled
++; break;
case C_NONSPEC
: nnonspec
++; break;
case C_THISFILE
: nthisfile
++; break;
case C_TRUE
: ntrue
++; break;
case C_UNKNOWN
: nunknown
++; break;
case C_IGNORE
: nignore
++; break;
newerror
->error_next
= er_head
;
newerror
->error_no
= nerrors
++;
if ( (wordc
== 1) && (language
!= INLD
) ){
* b) Assembler telling world that it is complaining
* c) Noise from make ("Stop.")
if (strcmp(wordv
[2], "Stop.") == 0){
language
= INMAKE
; return(C_SYNC
);
if (strcmp(wordv
[1], "Assembler:") == 0){
/* assembler always alerts us to what happened*/
language
= INAS
; return(C_SYNC
);
if (strcmp(wordv
[1], "Undefined:") == 0){
/* loader complains about unknown symbols*/
language
= INLD
; return(C_SYNC
);
if (lastchar(wordv
[1]) == ':'){
/* cc tells us what file we are in */
currentfilename
= wordv
[1];
(void)substitute(currentfilename
, ':', '\0');
language
= INCC
; return(C_SYNC
);
if ( (wordc
== 1) && (language
== INLD
) ){
nwordv
= (char **)Calloc(4, sizeof(char *));
nwordv
[3] = "undefined.";
* Now attempt a cpp error message match
* ./morse.h: 23: undefined control
* morsesend.c: 229: MAGNIBBL: argument mismatch
* morsesend.c: 237: MAGNIBBL: argument mismatch
* test1.c: 6: undefined control
if ( (language
!= INLD
) /* loader errors have almost same fmt*/
&& (lastchar(wordv
[1]) == ':')
&& (isdigit(firstchar(wordv
[2])))
&& (lastchar(wordv
[2]) == ':') ){
clob_last(wordv
[1], '\0');
clob_last(wordv
[2], '\0');
* Now attempt a ccom error message match:
* "morsesend.c", line 237: operands of & have incompatible types
* "test.c", line 7: warning: old-fashioned initialization: use =
* "subdir.d/foo2.h", line 1: illegal initialization
if ( (firstchar(wordv
[1]) == '"')
&& (lastchar(wordv
[1]) == ',')
&& (next_lastchar(wordv
[1]) == '"')
&& (strcmp(wordv
[2],"line") == 0)
&& (isdigit(firstchar(wordv
[3])))
&& (lastchar(wordv
[3]) == ':') ){
clob_last(wordv
[1], '\0'); /* drop last , */
clob_last(wordv
[1], '\0'); /* drop last " */
wordv
[1]++; /* drop first " */
clob_last(wordv
[3], '\0'); /* drop : on line number */
wordv
[2] = wordv
[1]; /* overwrite "line" */
currentfilename
= wordv
[1];
* Do the error message from the Richie C Compiler for the PDP11,
* fprintf(stderr, "%s:", filename);
* fprintf(stderr, "%d: ", line);
if (lastchar(wordv
[1]) == ':'){
cp
= wordv
[1] + strlen(wordv
[1]) - 1;
clob_last(wordv
[1], '\0'); /* last : */
*cp
= '\0'; /* first : */
nwordv
= wordvsplice(1, wordc
, wordv
+1);
currentfilename
= wordv
[1];
* Attempt a match for the new lint style normal compiler
* error messages, of the form
* printf("%s(%d): %s\n", filename, linenumber, message);
if ( (lastchar(wordv
[1]) == ':')
&& (next_lastchar(wordv
[1]) == ')')
clob_last(wordv
[1], '\0'); /* colon */
if (persperdexplode(wordv
[1], &line
, &file
)){
nwordv
= wordvsplice(1, wordc
, wordv
+1);
nwordv
[0] = file
; /* file name */
nwordv
[1] = line
; /* line number */
wordv
[1][strlen(wordv
[1])] = ':';
char **nwordv1
, **nwordv2
;
* Now, attempt a match for the various errors that lint
* Look first for type 1 lint errors
if (strcmp(wordv
[wordc
-1], "::") == 0){
* %.7s, arg. %d used inconsistently %s(%d) :: %s(%d)
* %.7s value used inconsistently %s(%d) :: %s(%d)
* %.7s multiply declared %s(%d) :: %s(%d)
* %.7s value declared inconsistently %s(%d) :: %s(%d)
* %.7s function value type must be declared before use %s(%d) :: %s(%d)
if ( (persperdexplode(wordv
[wordc
], &line2
, &file2
))
&& (persperdexplode(wordv
[wordc
-2], &line1
, &file1
)) ){
nwordv1
= wordvsplice(2, wordc
, wordv
+1);
nwordv2
= wordvsplice(2, wordc
, wordv
+1);
nwordv1
[0] = file1
; nwordv1
[1] = line1
;
erroradd(wordc
+2, nwordv1
, C_TRUE
, C_DUPL
); /* takes 0 based*/
nwordv2
[0] = file2
; nwordv2
[1] = line2
;
wordv
= nwordv2
- 1; /* 1 based */
* Look for type 2 lint errors
* %.7s used( %s(%d) ), but not defined
* %.7s defined( %s(%d) ), but never used
* %.7s declared( %s(%d) ), but never used or defined
* bufp defined( "./metric.h"(10) ), but never used
if ( (lastchar(wordv
[2]) == '(' /* ')' */ )
&& (strcmp(wordv
[4], "),") == 0) ){
if (persperdexplode(wordv
[3], &line
, &file
)){
nwordv
= wordvsplice(2, wordc
, wordv
+1);
nwordv
[0] = file
; nwordv
[1] = line
;
wordv
= nwordv
- 1; /* 1 based */
char *Lint31
[4] = {"returns", "value", "which", "is"};
char *Lint32
[6] = {"value", "is", "used,", "but", "none", "returned"};
if ( (wordvcmp(wordv
+2, 4, Lint31
) == 0)
|| (wordvcmp(wordv
+2, 6, Lint32
) == 0) ){
* Special word vectors for use by F77 recognition
char *F77_fatal
[3] = {"Compiler", "error", "line"};
char *F77_error
[3] = {"Error", "on", "line"};
char *F77_warning
[3] = {"Warning", "on", "line"};
* Error messages from /usr/src/cmd/f77/error.c, with
* Compiler error line %d of %s: %s
* Error on line %d of %s: %s
* Warning on line %d of %s: %s
if ( (lastchar(wordv
[6]) == ':')
(wordvcmp(wordv
+1, 3, F77_fatal
) == 0)
|| (wordvcmp(wordv
+1, 3, F77_error
) == 0)
|| (wordvcmp(wordv
+1, 3, F77_warning
) == 0) )
nwordv
= wordvsplice(2, wordc
, wordv
+1);
clob_last(nwordv
[0],'\0');
wordv
= nwordv
- 1; /* 1 based */
char *Make_Croak
[3] = {"***", "Error", "code"};
char *Make_NotRemade
[5] = {"not", "remade", "because", "of", "errors"};
if (wordvcmp(wordv
+1, 3, Make_Croak
) == 0){
if (wordvcmp(wordv
+2, 5, Make_NotRemade
) == 0){
* Match an error message produced by ri; here is the
* procedure yanked from the distributed version of ri
* serror(str, x1, x2, x3)
* fputs(srcfile, stdout);
* fprintf(stdout, " %d: ", yylineno);
* fprintf(stdout, str, x1, x2, x3);
if ( (firstchar(wordv
[1]) == '"')
&&(lastchar(wordv
[1]) == '"')
&&(lastchar(wordv
[2]) == ':')
&&(isdigit(firstchar(wordv
[2]))) ){
clob_last(wordv
[1], '\0'); /* drop the last " */
wordv
[1]++; /* skip over the first " */
clob_last(wordv
[2], '\0');