bib now prints out `source-file', line line-number: for
authorRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Wed, 15 Jun 1983 06:43:51 +0000 (22:43 -0800)
committerRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Wed, 15 Jun 1983 06:43:51 +0000 (22:43 -0800)
recording errors; error program can now pick up this format

SCCS-vsn: contrib/bib/src/bib.c 1.3
SCCS-vsn: contrib/bib/src/bibargs.c 1.3

usr/src/contrib/bib/src/bib.c
usr/src/contrib/bib/src/bibargs.c

index 2b690e1..9af40ca 100644 (file)
@@ -33,6 +33,8 @@
    extern int foot, sort, personal;
    extern int hyphen, ordcite;
    extern char sortstr[], pfile[], citetemplate[];
    extern int foot, sort, personal;
    extern int hyphen, ordcite;
    extern char sortstr[], pfile[], citetemplate[];
+   char *bibfname;             /* file name currently reading */
+   char *biblineno;            /* line number in that file */
 
 
 main(argc, argv)
 
 
 main(argc, argv)
@@ -66,8 +68,10 @@ main(argc, argv)
                arguments are read by doargs (bibargs.c)
     */
 
                arguments are read by doargs (bibargs.c)
     */
 
-   if (doargs(argc, argv, DEFSTYLE ) == 0)
+   if (doargs(argc, argv, DEFSTYLE ) == 0){
+      bibfname = "<stdin>";
       rdtext(stdin);
       rdtext(stdin);
+   }
 
    /*
     sort references, make citations, add disambiguating characters
 
    /*
     sort references, make citations, add disambiguating characters
@@ -109,6 +113,7 @@ main(argc, argv)
    FILE *fd;
 {  char lastc, c, d;
 
    FILE *fd;
 {  char lastc, c, d;
 
+   biblineno = 0;
    lastc = 0;
    while (getch(c, fd) != EOF)
       if (c == '[' || c == '{')
    lastc = 0;
    while (getch(c, fd) != EOF)
       if (c == '[' || c == '{')
@@ -169,6 +174,8 @@ main(argc, argv)
       else {
          if (lastc) putc(lastc, tfd);
          lastc = c;
       else {
          if (lastc) putc(lastc, tfd);
          lastc = c;
+        if (c == '\n')
+               biblineno++;
          }
    if (lastc) putc(lastc, tfd);
 }
          }
    if (lastc) putc(lastc, tfd);
 }
@@ -289,7 +296,7 @@ main(argc, argv)
       return(refspos[numrefs]);
       }
    else {
       return(refspos[numrefs]);
       }
    else {
-      fprintf(stderr,"no reference matching %s\n", huntstr);
+      bibwarning("no reference matching %s\n", huntstr);
       return( (long) -1 );
       }
 }
       return( (long) -1 );
       }
 }
@@ -346,7 +353,7 @@ main(argc, argv)
       if (*p == '\n')
          if (*(p+1) == '\n') { /* end */
             if (*(p+2) != 0)
       if (*p == '\n')
          if (*(p+1) == '\n') { /* end */
             if (*(p+2) != 0)
-               fprintf(stderr,"multiple references match %s\n",huntstr);
+               bibwarning("multiple references match %s\n", huntstr);
             *(p+1) = 0;
             break;
             }
             *(p+1) = 0;
             break;
             }
@@ -728,7 +735,7 @@ int  fn, footrefs[];
          putc(c, ofd);
       }
    if (dumped == false)
          putc(c, ofd);
       }
    if (dumped == false)
-      fprintf(stderr,"Warning: references never dumped\n");
+      bibwarning("Warning: references never dumped\n", (char *)0);
 }
 
 
 }
 
 
@@ -764,3 +771,13 @@ int  fn, footrefs[];
       }
    fprintf(ofd,".][\n");
 }
       }
    fprintf(ofd,".][\n");
 }
+/*
+ *     print out a warning message
+ */
+bibwarning(msg, arg)
+       char    *msg;
+       char    *arg;
+{
+       fprintf(stderr, "`%s', line %d: ", bibfname, biblineno);
+       fprintf(stderr, msg, arg);
+}
index 94425c2..6379c9e 100644 (file)
@@ -27,6 +27,8 @@
    char *words[MAXDEFS];        /* defined words                             */
    char *defs[MAXDEFS];         /* defined word definitions                  */
    int  wordtop = -1;           /* top of defined words array                */
    char *words[MAXDEFS];        /* defined words                             */
    char *defs[MAXDEFS];         /* defined word definitions                  */
    int  wordtop = -1;           /* top of defined words array                */
+   char *bibfname;
+   char *biblineno;
 
 /* where output goes */
    extern FILE *tfd;
 
 /* where output goes */
    extern FILE *tfd;
                           style = false;
                           incfile( defstyle );
                           }
                           style = false;
                           incfile( defstyle );
                           }
+                      bibfname = "<stdin>";
                        rdtext(stdin);
                        numfiles++;
                        break;
                        rdtext(stdin);
                        numfiles++;
                        break;
             error(": can't open");
             }
          else {
             error(": can't open");
             }
          else {
+            bibfname = argv[i];
             rdtext(fd);
             fclose(fd);
             }
             rdtext(fd);
             fclose(fd);
             }