Forbid omitting rows in config item and sect-chr

Forbid omitting rows for tables with const fields: item and sect-chr.
This is consistent with the rule for truncation.

The server expects certain entries in these two tables, and
malfunctions when they're blank.  Omitting them in the builtin tables
has always left them blank, but deities are not supposed to edit them,
and maintainers are supposed to know what they're doing, so the issue
was deemed unimportant and ignored.  However, I plan to blank out
omitted rows in custom tables as well, and then the issue isn't
unimportant anymore.
This commit is contained in:
Markus Armbruster 2011-06-13 11:27:04 +02:00
parent 4e23c45e61
commit 4a4ec917f6

View file

@ -82,6 +82,7 @@ static struct castr **fldca; /* Map field number to selector */
static int *fldidx; /* Map field number to index */
static int *caflds; /* Map selector number to #fields seen */
static int *cafldspp; /* ditto, in previous parts */
static int may_omit_id; /* Okay to omit IDs? */
static int may_trunc; /* Okay to truncate? */
static int gripe(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
@ -224,6 +225,8 @@ tbl_skip_to_obj(int id)
int max_id, exp_id;
if (partno == 0) {
if (!may_omit_id && id != cur_id + 1)
return gripe("Expected %d in field %d", cur_id + 1, 1);
if (id <= cur_id)
return gripe("Field %d must be > %d", 1, cur_id);
max_id = ef_id_limit(cur_type);
@ -1075,13 +1078,14 @@ xundump(FILE *fp, char *file, int *plno, int expected_table)
return -1;
nca = nf = 0;
may_omit_id = 1;
may_trunc = empfile[type].nent < 0;
for (i = 0; ca[i].ca_name; i++) {
nca++;
if (!(ca[i].ca_flags & NSC_EXTRA)) {
nf += MAX(1, ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0);
if (ca[i].ca_flags & NSC_CONST)
may_trunc = 0;
may_omit_id = may_trunc = 0;
}
}
fldca = malloc(nf * sizeof(*fldca));