xundump: Permit omitting trailing sectors and realms
We currently require all rows to be present for tables item, sect-chr,
infrastructure, sect, realm.
The first three make sense: the code hard-codes indexes for them, and
malfunctions when entries are blank, so we want to make it hard to
leave any blank by accident.
The last two don't: blank sectors and realms work fine. There, the
restriction is arbitrary. Drop it.
Sectors and realms still can't be omitted "in the middle" (can do that
only with an ID selector), but that's coming soon.
See also commit 4a4ec91
.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
515beef12e
commit
cfa0eac32a
3 changed files with 21 additions and 9 deletions
|
@ -96,6 +96,16 @@ static int add2symset(int, long *, char *);
|
||||||
static int xubody(FILE *);
|
static int xubody(FILE *);
|
||||||
static int xutail(FILE *, struct castr *);
|
static int xutail(FILE *, struct castr *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Does the code hardcode indexes for table TYPE?
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
have_hardcoded_indexes(int type)
|
||||||
|
{
|
||||||
|
return type == EF_ITEM || type == EF_SECTOR_CHR
|
||||||
|
|| type == EF_INFRASTRUCTURE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gripe about the current line to stderr, return -1.
|
* Gripe about the current line to stderr, return -1.
|
||||||
*/
|
*/
|
||||||
|
@ -1053,16 +1063,18 @@ xundump(FILE *fp, char *file, int *plno, int expected_table)
|
||||||
if (CANT_HAPPEN(!ca))
|
if (CANT_HAPPEN(!ca))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (have_hardcoded_indexes(type)) {
|
||||||
|
may_omit_id = may_trunc = 0;
|
||||||
|
} else {
|
||||||
|
may_omit_id = 1;
|
||||||
|
may_trunc = empfile[type].nent < 0;
|
||||||
|
}
|
||||||
|
|
||||||
nca = nf = 0;
|
nca = nf = 0;
|
||||||
may_omit_id = 1;
|
|
||||||
may_trunc = empfile[type].nent < 0;
|
|
||||||
for (i = 0; ca[i].ca_name; i++) {
|
for (i = 0; ca[i].ca_name; i++) {
|
||||||
nca++;
|
nca++;
|
||||||
if (!(ca[i].ca_flags & NSC_EXTRA)) {
|
if (!(ca[i].ca_flags & NSC_EXTRA))
|
||||||
nf += MAX(1, CA_ARRAY_LEN(&ca[i]));
|
nf += MAX(1, CA_ARRAY_LEN(&ca[i]));
|
||||||
if (ca[i].ca_flags & NSC_CONST)
|
|
||||||
may_omit_id = may_trunc = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fldca = malloc(nf * sizeof(*fldca));
|
fldca = malloc(nf * sizeof(*fldca));
|
||||||
fldidx = malloc(nf * sizeof(*fldidx));
|
fldidx = malloc(nf * sizeof(*fldidx));
|
||||||
|
|
|
@ -74,7 +74,7 @@ tests/empdump/xundump-errors/fld-unexpid:6: Table's first part doesn't have this
|
||||||
tests/empdump/xundump-errors/fld-unexpid1:7: Value for field 1 must be 2
|
tests/empdump/xundump-errors/fld-unexpid1:7: Value for field 1 must be 2
|
||||||
tests/empdump/xundump-errors/fld-unksym:2: Unknown level symbol `xxx' in field 11
|
tests/empdump/xundump-errors/fld-unksym:2: Unknown level symbol `xxx' in field 11
|
||||||
tests/empdump/xundump-errors/fld-unparen:2: Unmatched '(' in field 19
|
tests/empdump/xundump-errors/fld-unparen:2: Unmatched '(' in field 19
|
||||||
tests/empdump/xundump-errors/ftr-fewrows:2: Expected 1024 more rows
|
tests/empdump/xundump-errors/ftr-fewrows:2: Expected 34 more rows
|
||||||
tests/empdump/xundump-errors/ftr-fewrows2:4: Expected 13 more rows
|
tests/empdump/xundump-errors/ftr-fewrows2:4: Expected 13 more rows
|
||||||
tests/empdump/xundump-errors/ftr-fewrows3:4: Expected 1 more rows
|
tests/empdump/xundump-errors/ftr-fewrows3:4: Expected 1 more rows
|
||||||
tests/empdump/xundump-errors/ftr-fewrows4:7: Expected row with 2 in field 1, like in table's first part
|
tests/empdump/xundump-errors/ftr-fewrows4:7: Expected row with 2 in field 1, like in table's first part
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
XDUMP sect 0
|
XDUMP sect-chr 0
|
||||||
/0
|
/0
|
||||||
# Expected 1024 more rows
|
# Expected 34 more rows
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue