X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/d31142de3e4e91bdd5a4c8e42f260d075a0c30a9..78ce69fa25ed13e7810ebb22608a0d0c2d57a68b:/usr/src/usr.bin/error/input.c diff --git a/usr/src/usr.bin/error/input.c b/usr/src/usr.bin/error/input.c index 2f983a7b00..28d608b76e 100644 --- a/usr/src/usr.bin/error/input.c +++ b/usr/src/usr.bin/error/input.c @@ -1,4 +1,24 @@ -static char *sccsid = "@(#)input.c 1.6 (Berkeley) 82/05/04"; +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static char sccsid[] = "@(#)input.c 5.3 (Berkeley) %G%"; +#endif /* not lint */ + #include #include #include "error.h" @@ -21,6 +41,8 @@ Errorclass make(); Errorclass f77(); Errorclass pi(); Errorclass ri(); +Errorclass troff(); +Errorclass mod2(); /* * Eat all of the lines in the input file, attempting to categorize * them by their various flavors @@ -43,8 +65,8 @@ eaterrors(r_errorc, r_errorv) * of 0 based. */ wordv -= 1; - if ( 0 - || (( errorclass = onelong() ) != C_UNKNOWN) + if ( wordc > 0 && + ((( errorclass = onelong() ) != C_UNKNOWN) || (( errorclass = cpp() ) != C_UNKNOWN) || (( errorclass = pccccom() ) != C_UNKNOWN) || (( errorclass = richieccom() ) != C_UNKNOWN) @@ -56,6 +78,8 @@ eaterrors(r_errorc, r_errorv) || (( errorclass = f77() ) != C_UNKNOWN) || ((errorclass = pi() ) != C_UNKNOWN) || (( errorclass = ri() )!= C_UNKNOWN) + || (( errorclass = mod2() )!= C_UNKNOWN) + || (( errorclass = troff() )!= C_UNKNOWN)) ) ; else errorclass = catchall(); @@ -128,7 +152,7 @@ Errorclass onelong() * c) Random noise */ wordc = 0; - if (strcmp(wordv[2], "Stop.") == 0){ + if (strcmp(wordv[1], "Stop.") == 0){ language = INMAKE; return(C_SYNC); } if (strcmp(wordv[1], "Assembler:") == 0){ @@ -205,6 +229,7 @@ Errorclass pccccom() clob_last(wordv[3], '\0'); /* drop : on line number */ wordv[2] = wordv[1]; /* overwrite "line" */ wordv++; /*compensate*/ + wordc--; currentfilename = wordv[1]; language = INCC; return(C_TRUE); @@ -289,7 +314,7 @@ Errorclass lint1() * * Look first for type 1 lint errors */ - if (strcmp(wordv[wordc-1], "::") == 0){ + if (wordc > 1 && strcmp(wordv[wordc-1], "::") == 0){ /* * %.7s, arg. %d used inconsistently %s(%d) :: %s(%d) * %.7s value used inconsistently %s(%d) :: %s(%d) @@ -298,7 +323,8 @@ Errorclass lint1() * %.7s function value type must be declared before use %s(%d) :: %s(%d) */ language = INLINT; - if ( (persperdexplode(wordv[wordc], &line2, &file2)) + if (wordc > 2 + && (persperdexplode(wordv[wordc], &line2, &file2)) && (persperdexplode(wordv[wordc-2], &line1, &file1)) ){ nwordv1 = wordvsplice(2, wordc, wordv+1); nwordv2 = wordvsplice(2, wordc, wordv+1); @@ -359,6 +385,7 @@ Errorclass lint3() char *F77_fatal[3] = {"Compiler", "error", "line"}; char *F77_error[3] = {"Error", "on", "line"}; char *F77_warning[3] = {"Warning", "on", "line"}; +char *F77_no_ass[3] = {"Error.","No","assembly."}; f77() { char **nwordv; @@ -370,7 +397,12 @@ f77() * Compiler error line %d of %s: %s * Error on line %d of %s: %s * Warning on line %d of %s: %s + * Error. No assembly. */ + if (wordc == 3 && wordvcmp(wordv+1, 3, F77_no_ass) == 0) { + wordc = 0; + return(C_SYNC); + } if (wordc < 6) return(C_UNKNOWN); if ( (lastchar(wordv[6]) == ':') @@ -448,3 +480,51 @@ Errorclass catchall() language = INUNKNOWN; return(C_NONSPEC); } /* end of catch all*/ + +Errorclass troff() +{ + /* + * troff source error message, from eqn, bib, tbl... + * Just like pcc ccom, except uses `' + */ + 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" */ + wordv++; /*compensate*/ + currentfilename = wordv[1]; + language = INTROFF; + return(C_TRUE); + } + return(C_UNKNOWN); +} +Errorclass mod2() +{ + /* + * for decwrl modula2 compiler (powell) + */ + if ( ( (strcmp(wordv[1], "!!!") == 0) /* early version */ + ||(strcmp(wordv[1], "File") == 0)) /* later version */ + && (lastchar(wordv[2]) == ',') /* file name */ + && (strcmp(wordv[3], "line") == 0) + && (isdigit(firstchar(wordv[4]))) /* line number */ + && (lastchar(wordv[4]) == ':') /* line number */ + ){ + clob_last(wordv[2], '\0'); /* drop last , on file name */ + clob_last(wordv[4], '\0'); /* drop last : on line number */ + wordv[3] = wordv[2]; /* file name on top of "line" */ + wordv += 2; + wordc -= 2; + currentfilename = wordv[1]; + language = INMOD2; + return(C_TRUE); + } + return(C_UNKNOWN); +}