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