errorinput.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1991 by Sun Microsystems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include "error.h"
int wordc; /* how long the current error message is */
char **wordv; /* the actual error message */
int nerrors;
int language;
Errorclass cpp();
Errorclass lint0();
Errorclass lint1();
Errorclass lint2();
Errorclass lint3();
Errorclass make();
Errorclass f77();
Errorclass pi();
Errorclass ri();
Errorclass troff();
Errorclass mod2();
Errorclass sunf77();
/*
* Eat all of the lines in the input file, attempting to categorize
* them by their various flavors
*/
int *r_errorc;
{
for (;;){
break;
/*
* for convience, convert wordv to be 1 based, instead
* of 0 based.
*/
wordv -= 1;
if ( wordc > 0 &&
/* check for sunf77 errors has to be done before
pccccom to be able to distingush between the two */
) ;
else
errorclass = catchall();
if (wordc)
}
#ifdef FULLDEBUG
#endif
}
/*
* create a new error entry, given a zero based array and count
*/
int errorlength;
char **errorv;
{
if (errorclass == C_TRUE){
/* check canonicalization of the second argument*/
continue;
#ifdef FULLDEBUG
if (errorclass != C_TRUE)
printf("The 2nd word, \"%s\" is not a number.\n",
errorv[1]);
#endif
}
if (errorlength > 0){
if (errorclass == C_TRUE)
case C_SYNC: nsyncerrors++; break;
case C_THISFILE: nthisfile++; break;
}
} /* length > 0 */
}
{
char **nwordv;
/*
* We have either:
* a) file name from cc
* b) Assembler telling world that it is complaining
* c) Noise from make ("Stop.")
* c) Random noise
*/
wordc = 0;
}
/* assembler always alerts us to what happened*/
} else
/* loader complains about unknown symbols*/
}
}
/* cc tells us what file we are in */
/* Sunf77 tells us what subroutine we are in */
}
} else
nwordv[0] = "ld:";
wordc = 4;
return(C_NONSPEC);
} else
/* any other single word messages are considered synchronizing */
if (wordc == 1){
return(C_SYNC);
} else
/* Sunf77 may derive 2-word synchronizing messages ending with a `:' */
wordc = 0;
return(C_SYNC);
}
return(C_UNKNOWN);
} /* end of one long */
{
/*
* Now attempt a cpp error message match
* Examples:
* ./morse.h: 23: undefined control
* morsesend.c: 229: MAGNIBBL: argument mismatch
* morsesend.c: 237: MAGNIBBL: argument mismatch
* test1.c: 6: undefined control
*/
return(C_TRUE);
}
return(C_UNKNOWN);
} /*end of cpp*/
{
/*
* Now attempt a ccom error message match:
* Examples:
* "morsesend.c", line 237: operands of & have incompatible types
* "test.c", line 7: warning: old-fashioned initialization: use =
*/
wordv++; /*compensate*/
wordc--;
return(C_TRUE);
}
return(C_UNKNOWN);
} /* end of ccom */
/*
* Do the error message from the Richie C Compiler for the PDP11,
* which has this source:
*
* if (filename[0])
* fprintf(stderr, "%s:", filename);
* fprintf(stderr, "%d: ", line);
*
*/
{
char *file;
continue;
if (*cp == ':'){
wordc += 1;
return(C_TRUE);
}
}
return(C_UNKNOWN);
}
{
/*
* Attempt a match for the new lint style normal compiler
* error messages, of the form
*
* printf("%s(%d): %s\n", filename, linenumber, message);
*/
if (wordc >= 2){
) {
wordc += 1;
return(C_TRUE);
}
}
}
return (C_UNKNOWN);
}
{
/*
* Now, attempt a match for the various errors that lint
* can complain about.
*
* Look first for type 1 lint errors
*/
/*
* %.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 (wordc > 2
return(C_TRUE);
}
}
return(C_UNKNOWN);
} /* end of lint 1*/
{
char *file;
char *line;
char **nwordv;
/*
* 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
*/
return(C_TRUE);
}
}
return(C_UNKNOWN);
} /* end of lint 2*/
{
return(C_NONSPEC);
}
return(C_UNKNOWN);
}
/*
* Special word vectors for use by F77 recognition
*/
f77()
{
char **nwordv;
/*
* look for f77 errors:
* these printf formats:
*
* Compiler error line %d of %s: %s
* Error on line %d of %s: %s
* Warning on line %d of %s: %s
* Error. No assembly.
*/
wordc = 0;
return(C_SYNC);
}
if (wordc < 6)
return(C_UNKNOWN);
&&(
){
wordc += 2;
return(C_TRUE);
}
return(C_UNKNOWN);
} /* end of f77 */
{
return(C_SYNC);
}
return(C_SYNC);
}
return(C_UNKNOWN);
}
Errorclass ri()
{
/*
* Match an error message produced by ri; here is the
* procedure yanked from the distributed version of ri
* April 24, 1980.
*
* serror(str, x1, x2, x3)
* char str[];
* char *x1, *x2, *x3;
* {
* extern int yylineno;
*
* putc('"', stdout);
* fputs(srcfile, stdout);
* putc('"', stdout);
* fprintf(stdout, " %d: ", yylineno);
* fprintf(stdout, str, x1, x2, x3);
* fprintf(stdout, "\n");
* synerrs++;
* }
*/
return(C_TRUE);
}
return(C_UNKNOWN);
}
{
/*
* Catches random things.
*/
return(C_NONSPEC);
} /* end of catch all*/
{
/*
* troff source error message, from eqn, bib, tbl...
* Just like pcc ccom, except uses `'
*/
wordv++; /*compensate*/
return(C_TRUE);
}
return(C_UNKNOWN);
}
{
/*
* for decwrl modula2 compiler (powell)
*/
){
wordv += 2;
wordc -= 2;
return(C_TRUE);
}
return(C_UNKNOWN);
}
{
/*
* Finally attempt a Sun f77 error message match:
* Examples:
* "bar.f", line 237: Error: no label on format statement
* "test.f", line 7: ANSI extension: Hollerith constant
*/
wordv++; /*compensate*/
wordc--;
return(C_TRUE);
}
return(C_UNKNOWN);
} /* end of Sun f77 */