]> git.pond.sub.org Git - empserver/commitdiff
Forbid omitting rows in config item and sect-chr
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 13 Jun 2011 09:27:04 +0000 (11:27 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:51:44 +0000 (16:51 +0200)
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

index 1301d7def96aad3492bfc2f7c202ca9656f373e7..e361c8bc4691771dbaf87034a5de2d5d037f3562 100644 (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));