]> git.pond.sub.org Git - empserver/commitdiff
(xundump): Count lines in a saner way: pass line number in and out.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 5 Aug 2007 16:22:41 +0000 (16:22 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 5 Aug 2007 16:22:41 +0000 (16:22 +0000)
Callers changed.

include/prototypes.h
src/lib/common/conftab.c
src/lib/common/xundump.c

index f251d4245033b073fd0c4840046cd632e4d8e946..ef1487616fba743859389a8af7953fd98142833c 100644 (file)
@@ -348,7 +348,7 @@ extern int demand_update_want(int *, int *, int);
 extern int demand_check(void);
 extern int demandupdatecheck(void);
 /* xundump.c */
-extern int xundump(FILE *, char *, int);
+extern int xundump(FILE *, char *, int *, int);
 
 /*
  * src/lib/gen/ *.c 
index 53505e4397c3a873e3d581db9f5a9695b1aab14f..0e596d977ff9d9258ee7c7f4a8ec5ceb1569b93d 100644 (file)
@@ -48,7 +48,7 @@ read_builtin_tables(void)
 {
     struct empfile *ep;
     FILE *fp;
-    int res;
+    int lineno, res;
 
     /*
      * Need to read config files for tables referenced through
@@ -62,7 +62,8 @@ read_builtin_tables(void)
                        ep->file, strerror(errno));
                return -1;
            }
-           res = xundump(fp, ep->file, ep->uid);
+           lineno = 1;
+           res = xundump(fp, ep->file, &lineno, ep->uid);
            if (res >= 0 && getc(fp) != EOF) {
                fprintf(stderr, "%s: Junk after the table\n",
                        ep->file);
@@ -104,7 +105,7 @@ read_custom_tables(void)
 static int
 read_custom_table_file(char *fname)
 {
-    int res, n;
+    int lineno, res, n;
     FILE *fp;
 
     if (!(fp = fopen(fname, "r"))) {
@@ -113,7 +114,8 @@ read_custom_table_file(char *fname)
        return -1;
     }
 
-    for (n = 0; (res = xundump(fp, fname, EF_BAD)) >= 0; n++)
+    lineno = 1;
+    for (n = 0; (res = xundump(fp, fname, &lineno, EF_BAD)) >= 0; n++)
        empfile[res].flags |= EFF_CUSTOM;
     if (res != EF_BAD && n == 0)
        fprintf(stderr, "Warning: configuration file %s is empty\n", fname);
index 44590591bf803942538710866b996417c9dbbaf1..76c6912b8325e7f391198e587609c48c18de16b5 100644 (file)
@@ -29,7 +29,7 @@
  * 
  *  Known contributors to this file:
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2005-2006
+ *     Markus Armbruster, 2005-2007
  */
 
 /*
@@ -737,15 +737,13 @@ xutrailer(FILE *fp, int type, int row)
 }
 
 int
-xundump(FILE *fp, char *file, int expected_table)
+xundump(FILE *fp, char *file, int *plno, int expected_table)
 {
     struct castr *ca;
     int type, nca, nf, i, ch;
 
-    if (fname != file) {
-        fname = file;
-       lineno = 1;
-    }
+    fname = file;
+    lineno = *plno;
 
     if ((type = xuheader(fp, expected_table)) < 0)
        return type;
@@ -779,6 +777,7 @@ xundump(FILE *fp, char *file, int expected_table)
        lineno++;
     ungetc(ch, fp);
 
+    *plno = lineno;
     return type;
 }