(xundump): Fix parsing of XDUMP header (really!) and footer.
This commit is contained in:
parent
b2e18c5125
commit
e1420d2a14
1 changed files with 6 additions and 4 deletions
|
@ -416,7 +416,7 @@ xundump(FILE *fp, char *file, int expected_table)
|
||||||
} else
|
} else
|
||||||
lineno++;
|
lineno++;
|
||||||
|
|
||||||
if (fscanf(fp, "XDUMP%*1[ ]%63s%*1[ ]%*d%c", name, &sep) != 2)
|
if (fscanf(fp, "XDUMP%*1[ ]%63[^ \n]%*1[ ]%*[^ \n]%c", name, &sep) != 2)
|
||||||
return gripe("Expected XDUMP header");
|
return gripe("Expected XDUMP header");
|
||||||
if (sep != '\n')
|
if (sep != '\n')
|
||||||
return gripe("Junk after XDUMP header");
|
return gripe("Junk after XDUMP header");
|
||||||
|
@ -434,9 +434,9 @@ xundump(FILE *fp, char *file, int expected_table)
|
||||||
for (row = 0; ; row++) {
|
for (row = 0; ; row++) {
|
||||||
lineno++;
|
lineno++;
|
||||||
ch = getc(fp);
|
ch = getc(fp);
|
||||||
ungetc(ch, fp);
|
|
||||||
if (ch == '/')
|
if (ch == '/')
|
||||||
break;
|
break;
|
||||||
|
ungetc(ch, fp);
|
||||||
/*
|
/*
|
||||||
* TODO
|
* TODO
|
||||||
* Add column count check to the return value of xuflds()
|
* Add column count check to the return value of xuflds()
|
||||||
|
@ -457,8 +457,10 @@ xundump(FILE *fp, char *file, int expected_table)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fscanf(fp, "/%d%c", &rows, &sep) != 2)
|
ch = getc(fp);
|
||||||
return gripe("Expected table footer");
|
ungetc(ch, fp);
|
||||||
|
if (!isdigit(ch) || fscanf(fp, "%d%c", &rows, &sep) != 2)
|
||||||
|
return gripe("Malformed table footer");
|
||||||
if (row != rows)
|
if (row != rows)
|
||||||
return gripe("Read %d rows, which doesn't match footer",
|
return gripe("Read %d rows, which doesn't match footer",
|
||||||
row);
|
row);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue