(xundump): Improve diagnostics. Remove superflous check for

unexpected EOF.
This commit is contained in:
Markus Armbruster 2005-12-02 16:06:24 +00:00
parent 8e6baf0bcb
commit 8d0ec9db08

View file

@ -25,11 +25,11 @@
* *
* --- * ---
* *
* xundump.c: Text loading functions based on xdump output * xundump.c: Load back xdump output
* *
* Known contributors to this file: * Known contributors to this file:
* Ron Koenderink, 2005 * Ron Koenderink, 2005
* * Markus Armbruster, 2005
*/ */
#include <stdio.h> #include <stdio.h>
@ -424,10 +424,10 @@ xundump(FILE *fp, char *file, int expected_table)
type = ef_byname(name); type = ef_byname(name);
if (type < 0) if (type < 0)
return gripe("Table not found %s", name); return gripe("Unknown table `%s'", name);
if (expected_table != EF_BAD && expected_table != type) if (expected_table != EF_BAD && expected_table != type)
return gripe("Incorrect Table expecting %s got %s", return gripe("Expected table `%s', not `%s'",
ef_nameof(expected_table), name); ef_nameof(expected_table), name);
fixed_rows = has_const(ef_cadef(type)); fixed_rows = has_const(ef_cadef(type));
@ -436,8 +436,6 @@ xundump(FILE *fp, char *file, int expected_table)
lineno++; lineno++;
ch = getc(fp); ch = getc(fp);
ungetc(ch, fp); ungetc(ch, fp);
if (ch == EOF)
return gripe("Unexpected EOF");
if (ch == '/') if (ch == '/')
break; break;
/* /*
@ -461,15 +459,15 @@ xundump(FILE *fp, char *file, int expected_table)
} }
if (fscanf(fp, "/%d%c", &rows, &sep) != 2) if (fscanf(fp, "/%d%c", &rows, &sep) != 2)
return gripe("Failed to find number of rows trailer"); return gripe("Expected table footer");
if (row != rows) if (row != rows)
return gripe("Number of rows doesn't match between " return gripe("Read %d rows, which doesn't match footer",
"the trailer and what was read"); row);
if (fixed_rows && row != empfile[type].csize -1) if (fixed_rows && row != empfile[type].csize -1)
return gripe("Number of rows doesn't match, and " return gripe("Table %s requires %d rows, got %d",
"it must for table %s", name); name, empfile[type].csize - 1, row);
if (sep != '\n') if (sep != '\n')
return gripe("Junk after number of rows trailer"); return gripe("Junk after table footer");
if (!fixed_rows) if (!fixed_rows)
xuinitrow(type, row); xuinitrow(type, row);