install approved copyright notice
[unix-history] / usr / src / usr.bin / error / input.c
index 775ba58..28d608b 100644 (file)
@@ -1,4 +1,24 @@
-static char *sccsid = "@(#)input.c     1.5 (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 <stdio.h>
 #include <ctype.h>
 #include "error.h"
 #include <stdio.h>
 #include <ctype.h>
 #include "error.h"
@@ -21,6 +41,8 @@ Errorclass    make();
 Errorclass     f77();
 Errorclass     pi();
 Errorclass     ri();
 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
 /*
  *     Eat all of the lines in the input file, attempting to categorize
  *     them by their various flavors
@@ -43,11 +65,8 @@ eaterrors(r_errorc, r_errorv)
         *      of 0 based.
         */
        wordv -= 1;
         *      of 0 based.
         */
        wordv -= 1;
-       if ( 0
-#ifndef ERNIE
-          || (piflag && ( (errorclass = pi() ) != C_UNKNOWN))
-#endif
-          || (( errorclass = onelong() ) != C_UNKNOWN)
+       if ( wordc > 0 &&
+          ((( errorclass = onelong() ) != C_UNKNOWN)
           || (( errorclass = cpp() ) != C_UNKNOWN)
           || (( errorclass = pccccom() ) != C_UNKNOWN)
           || (( errorclass = richieccom() ) != C_UNKNOWN)
           || (( errorclass = cpp() ) != C_UNKNOWN)
           || (( errorclass = pccccom() ) != C_UNKNOWN)
           || (( errorclass = richieccom() ) != C_UNKNOWN)
@@ -57,10 +76,10 @@ eaterrors(r_errorc, r_errorv)
           || (( errorclass = lint3() ) != C_UNKNOWN)
           || (( errorclass = make() ) != C_UNKNOWN)
           || (( errorclass = f77() ) != C_UNKNOWN)
           || (( errorclass = lint3() ) != C_UNKNOWN)
           || (( errorclass = make() ) != C_UNKNOWN)
           || (( errorclass = f77() ) != C_UNKNOWN)
-#ifdef ERNIE
           || ((errorclass = pi() ) != C_UNKNOWN)
           || (( errorclass = ri() )!= C_UNKNOWN)
           || ((errorclass = pi() ) != C_UNKNOWN)
           || (( errorclass = ri() )!= C_UNKNOWN)
-#endif
+          || (( errorclass = mod2() )!= C_UNKNOWN)
+          || (( errorclass = troff() )!= C_UNKNOWN))
        ) ;
        else
                errorclass = catchall();
        ) ;
        else
                errorclass = catchall();
@@ -133,7 +152,7 @@ Errorclass onelong()
                 *      c)      Random noise
                 */
                wordc = 0;
                 *      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){
                        language = INMAKE; return(C_SYNC);
                }
                if (strcmp(wordv[1], "Assembler:") == 0){
@@ -210,6 +229,7 @@ Errorclass pccccom()
                clob_last(wordv[3], '\0');      /* drop : on line number */
                wordv[2] = wordv[1];    /* overwrite "line" */
                wordv++;                /*compensate*/
                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);
                currentfilename = wordv[1];
                language = INCC;
                return(C_TRUE);
@@ -294,7 +314,7 @@ Errorclass lint1()
         *
         *      Look first for type 1 lint errors
         */
         *
         *      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)
         /*
          * %.7s, arg. %d used inconsistently %s(%d) :: %s(%d)
          * %.7s value used inconsistently %s(%d) :: %s(%d)
@@ -303,7 +323,8 @@ Errorclass lint1()
          * %.7s function value type must be declared before use %s(%d) :: %s(%d)
          */
                language = INLINT;
          * %.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);
                     && (persperdexplode(wordv[wordc-2], &line1, &file1)) ){
                        nwordv1 = wordvsplice(2, wordc, wordv+1);
                        nwordv2 = wordvsplice(2, wordc, wordv+1);
@@ -364,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_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;
 f77()
 {
        char    **nwordv;
@@ -375,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
         *              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]) == ':')
        if (wordc < 6)
                return(C_UNKNOWN);
        if (    (lastchar(wordv[6]) == ':')
@@ -453,3 +480,51 @@ Errorclass catchall()
        language = INUNKNOWN;
        return(C_NONSPEC);
 } /* end of catch all*/
        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);
+}