From 4a4ec917f64bf780a2538d252122b46b74318c82 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 13 Jun 2011 11:27:04 +0200 Subject: [PATCH] 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. --- src/lib/common/xundump.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/common/xundump.c b/src/lib/common/xundump.c index 1301d7def..e361c8bc4 100644 --- a/src/lib/common/xundump.c +++ b/src/lib/common/xundump.c @@ -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)); -- 2.43.0