(xundump): Count lines in a saner way: pass line number in and out.
Callers changed.
This commit is contained in:
parent
6498d66263
commit
971515ccc9
3 changed files with 12 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue