]> git.pond.sub.org Git - empserver/commitdiff
xundump: Permit omitting trailing sectors and realms
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 8 Feb 2014 14:11:51 +0000 (15:11 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2015 15:53:00 +0000 (16:53 +0100)
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>
src/lib/common/xundump.c
tests/empdump/errors.err
tests/empdump/xundump-errors/ftr-fewrows

index cd903adecfd8b628d7feaca48623ac19669de627..b9b8de26c5f71a3f9ce5c756df5b15ffd22b8a5a 100644 (file)
@@ -96,6 +96,16 @@ static int add2symset(int, long *, char *);
 static int xubody(FILE *);
 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.
  */
@@ -1053,16 +1063,18 @@ xundump(FILE *fp, char *file, int *plno, int expected_table)
     if (CANT_HAPPEN(!ca))
        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;
-    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)) {
+       if (!(ca[i].ca_flags & NSC_EXTRA))
            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));
     fldidx = malloc(nf * sizeof(*fldidx));
index 54258d3abe7054e46e7a2011aec10401de0903a9..abc4e32418a488d9a02cc7a52e5af231e3505169 100644 (file)
@@ -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-unksym:2: Unknown level symbol `xxx' in field 11
 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-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
index 0be2020f68441a69f179ed778f81085589521272..b1fbff52991add6c092b8278b1a465fe6fcb842f 100644 (file)
@@ -1,3 +1,3 @@
-XDUMP sect 0
+XDUMP sect-chr 0
 /0
-# Expected 1024 more rows
+# Expected 34 more rows