2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * xundump.c: Load back xdump output
29 * Known contributors to this file:
30 * Ron Koenderink, 2005
31 * Markus Armbruster, 2005-2014
35 * See doc/xdump! And keep it up-to-date.
37 * Parsing of machine-readable xdump is not precise: it recognizes
38 * comments, accepts whitespace in place of single space, and accepts
39 * the full human-readable field syntax instead of its machine-
43 * - Normalize terminology: table/rows/columns or file/records/fields
44 * - Loading tables with NSC_STRING elements more than once leaks memory
46 * - Symbolic array indexes
47 * - Option to treat missing and unknown fields as warning, not error
48 * TODO, but hardly worth the effort:
49 * - Permit reordering of array elements
67 static char *fname; /* Name of file being read */
68 static int lineno; /* Current line number */
70 static int cur_type; /* Current table's file type */
71 static int partno; /* Counts from 0..#parts-1 */
72 static void *cur_obj; /* The object being read into */
73 static int cur_id; /* and its index in the table */
75 static unsigned char *idgap; /* idgap && idgap[ID] iff part#0 lacks ID */
76 static int idgap_len; /* #elements in idgap[] */
78 static int human; /* Reading human-readable syntax? */
79 static int ellipsis; /* Header ended with ...? */
80 static int nflds; /* #fields in input records */
81 static struct castr **fldca; /* Map field number to selector */
82 static int *fldidx; /* Map field number to index */
83 static int *caflds; /* Map selector number to #fields seen */
84 static int *cafldspp; /* ditto, in previous parts */
85 static int may_omit_id; /* Okay to omit IDs? */
86 static int may_trunc; /* Okay to truncate? */
88 static int gripe(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
89 static int deffld(int, char *, int);
90 static int chkflds(void);
91 static int setnum(int, double);
92 static int setstr(int, char *);
93 static int setsym(int, char *);
94 static int mtsymset(int, long *);
95 static int add2symset(int, long *, char *);
96 static int xubody(FILE *);
97 static int xutail(FILE *, struct castr *);
100 * Does the code hardcode indexes for table TYPE?
103 have_hardcoded_indexes(int type)
105 return type == EF_ITEM || type == EF_SECTOR_CHR
106 || type == EF_INFRASTRUCTURE;
110 * Gripe about the current line to stderr, return -1.
113 gripe(char *fmt, ...)
117 fprintf(stderr, "%s:%d: ", fname, lineno);
119 vfprintf(stderr, fmt, ap);
126 /* Make TYPE the current table. */
134 old_nelem = type == EF_BAD ? 0 : ef_nelem(type);
139 /* End the current table. */
148 * Seek to current table's ID-th record.
149 * ID must be acceptable.
150 * Store it in cur_obj, and set cur_id accordingly.
151 * Return 0 on success, -1 on failure.
156 struct empfile *ep = &empfile[cur_type];
158 if (id >= ef_nelem(cur_type)) {
159 if (!ef_ensure_space(cur_type, id, 1))
160 return gripe("Can't put ID %d into table %s", id, ep->name);
163 cur_obj = ef_ptr(cur_type, id);
164 if (CANT_HAPPEN(!cur_obj))
172 * Reset the omitted objects to default state.
175 omit_ids(int id1, int id2)
182 idgap = realloc(idgap, id2 * sizeof(*idgap));
183 for (i = idgap_len; i < id1; i++)
185 for (i = id1; i < id2; i++) {
186 ef_blank(cur_type, i, ef_ptr(cur_type, i));
193 * Return the smallest non-omitted ID in ID1..ID2-1 if any, else -1.
196 expected_id(int id1, int id2)
200 for (i = id1; i < id2; i++) {
201 if (i >= idgap_len || !idgap[i])
208 * Get the next object, it has record index ID.
209 * Store it in cur_obj, and set cur_id accordingly.
210 * Reset any omitted objects to default state.
211 * Return 0 on success, -1 on failure.
214 tbl_skip_to_obj(int id)
216 int prev_id = cur_id;
219 if (CANT_HAPPEN(partno != 0))
221 if (!may_omit_id && id != cur_id + 1)
222 return gripe("Expected %d in field %d", cur_id + 1, 1);
224 return gripe("Field %d must be > %d", 1, cur_id);
225 max_id = ef_id_limit(cur_type);
227 return gripe("Field %d must be <= %d", 1, max_id);
229 if (tbl_seek(id) < 0)
232 omit_ids(prev_id + 1, id);
237 * Get the next object.
238 * Store it in cur_obj, and set cur_id accordingly.
239 * Return 0 on success, -1 on failure.
247 if (cur_id >= ef_id_limit(cur_type))
248 return gripe("Too many rows");
249 next_id = cur_id + 1;
251 next_id = expected_id(cur_id + 1, empfile[cur_type].fids);
253 return gripe("Table's first part doesn't have this row");
255 return tbl_seek(next_id);
260 * If the table has variable length, truncate it.
261 * Else ensure we're omitting the same objects as the previous parts.
262 * Reset any omitted objects to default state.
263 * Return 0 on success, -1 on failure.
268 struct empfile *ep = &empfile[cur_type];
271 if (cur_id + 1 < ep->fids) {
274 if (!ef_truncate(cur_type, cur_id + 1))
278 return gripe("Expected %d more rows",
279 ep->fids - (cur_id + 1));
280 omit_ids(cur_id + 1, ep->fids);
283 exp_id = expected_id(cur_id + 1, ep->fids);
285 return gripe("Expected row with %d in field %d,"
286 " like in table's first part",
298 * Read and ignore field separators from FP.
299 * Return first character that is not a field separator.
308 } while (ch == ' ' || ch == '\t');
313 } while (ch != EOF && ch != '\n');
320 * Decode escape sequences in BUF.
321 * Return BUF on success, null pointer on failure.
333 if (sscanf(++src, "%3o%n", &octal_chr, &n) != 1 || n != 3)
335 *dst++ = (char)octal_chr;
345 * Read an identifier from FP into BUF.
346 * BUF must have space for 1024 characters.
347 * Return number of characters read on success, -1 on failure.
350 getid(FILE *fp, char *buf)
353 if (fscanf(fp, "%1023[^\"#()<>= \t\n]%n", buf, &n) != 1
361 * Try to read a field name from FP.
362 * I is the field number, counting from zero.
363 * If a name is read, set fldca[I] and fldidx[I] for it, and update
365 * Return 1 if a name or ... was read, 0 on end of line, -1 on error.
368 xufldname(FILE *fp, int i)
376 return gripe("Unexpected EOF");
383 if (getc(fp) != '.' || getc(fp) != '.')
384 return gripe("Junk in header field %d", i + 1);
386 return gripe("Header fields expected");
389 if (ch != EOF && ch != '\n')
390 return gripe("Junk after ...");
395 if (getid(fp, buf) < 0)
396 return gripe("Junk in header field %d", i + 1);
400 return deffld(i, buf, -1);
404 if (isdigit(ch) || ch == '-' || ch == '+') {
405 if (fscanf(fp, "%d", &idx) != 1)
406 return gripe("Malformed number in index of header field %d",
409 return gripe("Index must not be negative in header field %d",
412 if (getid(fp, buf) < 0)
413 return gripe("Malformed index in header field %d", i + 1);
414 return gripe("Symbolic index in header field %d not yet implemented",
419 return gripe("Malformed index in header field %d", i + 1);
420 return deffld(i, buf, idx);
425 * Try to read a field value from FP.
426 * I is the field number, counting from zero.
427 * Return 1 if a value was read, 0 on end of line, -1 on error.
430 xufld(FILE *fp, int i)
440 return gripe("Unexpected EOF");
442 CANT_HAPPEN(i > nflds);
443 for (j = i; j < nflds; j++) {
444 if (CA_IS_ARRAY(fldca[j]))
445 gripe("Field %s(%d) missing",
446 fldca[j]->ca_name, fldidx[j]);
448 gripe("Field %s missing", fldca[j]->ca_name);
451 return i < nflds ? -1 : 0;
452 case '+': case '-': case '.':
453 case '0': case '1': case '2': case '3': case '4':
454 case '5': case '6': case '7': case '8': case '9':
456 if (fscanf(fp, "%lg", &dbl) != 1)
457 return gripe("Malformed number in field %d", i + 1);
458 return setnum(i, dbl);
465 if (fscanf(fp, "%1023[^\"\n]", buf) != 1 || getc(fp) != '"')
466 return gripe("Malformed string in field %d", i + 1);
468 return gripe("Invalid escape sequence in field %d",
471 return setstr(i, buf);
473 if (mtsymset(i, &set) < 0)
477 if (ch == EOF || ch == '\n')
478 return gripe("Unmatched '(' in field %d", i + 1);
482 if (getid(fp, buf) < 0)
483 return gripe("Junk in field %d", i + 1);
484 if (add2symset(i, &set, buf) < 0)
487 return setnum(i, set);
490 if (getid(fp, buf) < 0)
491 return gripe("Junk in field %d", i + 1);
492 if (!strcmp(buf, "nil"))
493 return setstr(i, NULL);
495 return setsym(i, buf);
500 * Read fields from FP.
501 * Use PARSE() to read each field.
502 * Return number of fields read on success, -1 on error.
505 xuflds(FILE *fp, int (*parse)(FILE *, int))
518 else if (ch != ' ' && ch != '\t')
519 return gripe("Bad field separator after field %d", i + 1);
524 * Define the FLDNO-th field.
525 * If IDX is negative, define as selector NAME, else as NAME(IDX).
526 * Set fldca[FLDNO] and fldidx[FLDNO] accordingly.
528 * Return 1 on success, -1 on error.
531 deffld(int fldno, char *name, int idx)
533 struct castr *ca = ef_cadef(cur_type);
536 res = stmtch(name, ca, offsetof(struct castr, ca_name),
537 sizeof(struct castr));
539 return gripe("Header %s of field %d is %s", name, fldno + 1,
540 res == M_NOTUNIQUE ? "ambiguous" : "unknown");
541 if ((ca[res].ca_flags & NSC_EXTRA) || CANT_HAPPEN(ca[res].ca_get))
542 return gripe("Extraneous header %s in field %d", name, fldno + 1);
543 if (CA_IS_ARRAY(&ca[res])) {
545 return gripe("Header %s requires an index in field %d",
546 ca[res].ca_name, fldno + 1);
547 if (idx >= ca[res].ca_len)
548 return gripe("Header %s(%d) index out of bounds in field %d",
549 ca[res].ca_name, idx, fldno + 1);
550 if (idx < caflds[res])
551 return gripe("Duplicate header %s(%d) in field %d",
552 ca[res].ca_name, idx, fldno + 1);
553 if (idx > caflds[res])
554 return gripe("Expected header %s(%d) in field %d",
555 ca[res].ca_name, caflds[res], fldno + 1);
558 return gripe("Header %s doesn't take an index in field %d",
559 ca[res].ca_name, fldno + 1);
562 return gripe("Duplicate header %s in field %d",
563 ca[res].ca_name, fldno + 1);
565 fldca[fldno] = &ca[res];
572 * Check fields in xdump are sane.
573 * Return 0 on success, -1 on error.
578 struct castr *ca = ef_cadef(cur_type);
579 int i, len, cafldsmax, res = 0;
581 /* Record index must come first, to make cur_id work, see setnum() */
582 if (ca[0].ca_table == cur_type && caflds[0] && fldca[0] != &ca[0])
583 res = gripe("Header field %s must come first", ca[0].ca_name);
586 return res; /* table is split, another part expected */
588 /* Check for missing fields */
589 for (i = 0; ca[i].ca_name; i++) {
590 cafldsmax = MAX(caflds[i], cafldspp[i]);
591 if (ca[i].ca_flags & NSC_EXTRA)
593 len = CA_ARRAY_LEN(&ca[i]);
594 if (!len && !cafldsmax)
595 res = gripe("Header field %s missing", ca[i].ca_name);
596 else if (len && cafldsmax == len - 1)
597 res = gripe("Header field %s(%d) missing",
598 ca[i].ca_name, len - 1);
599 else if (len && cafldsmax < len - 1)
600 res = gripe("Header fields %s(%d) ... %s(%d) missing",
601 ca[i].ca_name, cafldsmax, ca[i].ca_name, len - 1);
608 * Get selector for field FLDNO.
609 * Assign the field's selector index to *IDX, unless it is null.
610 * Return the selector on success, null pointer on error.
612 static struct castr *
613 getfld(int fldno, int *idx)
615 if (fldno >= nflds) {
616 gripe("Too many fields, expected only %d", nflds);
619 if (CANT_HAPPEN(fldno < 0))
622 *idx = fldidx[fldno];
627 * Is a new value for field FLDNO required to match the old one?
630 fldval_must_match(int fldno)
632 struct castr *ca = ef_cadef(cur_type);
633 int i = fldca[fldno] - ca;
636 * Value must match if:
637 * it's for a const selector, unless the object is still blank, or
638 * it was already given in a previous part of a split table.
640 return (cur_id < old_nelem && (fldca[fldno]->ca_flags & NSC_CONST))
641 || fldidx[fldno] < cafldspp[i];
645 * Set value of field FLDNO in current object to DBL.
646 * Return 1 on success, -1 on error.
649 setnum(int fldno, double dbl)
656 ca = getfld(fldno, &idx);
661 if (partno == 0 && ca->ca_table == cur_type) {
662 /* Got record index */
665 return gripe("Field %d can't hold this value", fldno + 1);
666 if (tbl_skip_to_obj(next_id) < 0)
669 if (tbl_next_obj() < 0)
674 memb_ptr += ca->ca_off;
676 switch (ca->ca_type) {
678 old = ((signed char *)memb_ptr)[idx];
679 new = ((signed char *)memb_ptr)[idx] = (signed char)dbl;
682 old = ((unsigned char *)memb_ptr)[idx];
683 new = ((unsigned char *)memb_ptr)[idx] = (unsigned char)dbl;
686 old = ((short *)memb_ptr)[idx];
687 new = ((short *)memb_ptr)[idx] = (short)dbl;
690 old = ((unsigned short *)memb_ptr)[idx];
691 new = ((unsigned short *)memb_ptr)[idx] = (unsigned short)dbl;
694 old = ((int *)memb_ptr)[idx];
695 new = ((int *)memb_ptr)[idx] = (int)dbl;
698 old = ((long *)memb_ptr)[idx];
699 new = ((long *)memb_ptr)[idx] = (long)dbl;
702 old = ((coord *)memb_ptr)[idx];
703 /* FIXME use variant of xrel() that takes orig instead of nation */
704 if (old >= WORLD_X / 2)
706 new = ((coord *)memb_ptr)[idx] = XNORM((coord)dbl);
707 if (new >= WORLD_X / 2)
711 old = ((coord *)memb_ptr)[idx];
712 /* FIXME use variant of yrel() that takes orig instead of nation */
713 if (old >= WORLD_Y / 2)
715 new = ((coord *)memb_ptr)[idx] = YNORM((coord)dbl);
716 if (new >= WORLD_Y / 2)
720 old = ((float *)memb_ptr)[idx];
721 ((float *)memb_ptr)[idx] = (float)dbl;
722 new = dbl; /* suppress new != dbl check */
725 old = ((double *)memb_ptr)[idx];
726 ((double *)memb_ptr)[idx] = dbl;
727 new = dbl; /* suppress new != dbl check */
730 old = ((time_t *)memb_ptr)[idx];
731 new = ((time_t *)memb_ptr)[idx] = (time_t)dbl;
734 return gripe("Field %d doesn't take numbers", fldno + 1);
737 if (fldval_must_match(fldno) && old != dbl)
738 return gripe("Value for field %d must be %g", fldno + 1, old);
740 return gripe("Field %d can't hold this value", fldno + 1);
746 * Set value of field FLDNO in current object to STR.
747 * Return 1 on success, -1 on error.
750 setstr(int fldno, char *str)
753 int must_match, mismatch, idx;
755 char *memb_ptr, *old;
757 ca = getfld(fldno, &idx);
762 if (tbl_next_obj() < 0)
766 memb_ptr += ca->ca_off;
767 must_match = fldval_must_match(fldno);
770 switch (ca->ca_type) {
772 old = ((char **)memb_ptr)[idx];
774 mismatch = old ? !str || strcmp(old, str) : !!str;
776 /* FIXME may leak old value */
777 ((char **)memb_ptr)[idx] = str ? strdup(str) : NULL;
778 len = -1; /* unlimited */
781 if (CANT_HAPPEN(idx))
784 return gripe("Field %d doesn't take nil", fldno + 1);
785 /* Wart: if ca_len <= 1, the terminating null may be omitted */
787 len = sz > 1 ? sz - 1 : sz;
788 if (strlen(str) > len)
789 return gripe("Field %d takes at most %d characters",
790 fldno + 1, (int)len);
793 mismatch = !str || strncmp(old, str, len);
795 strncpy(memb_ptr, str, sz);
798 return gripe("Field %d doesn't take strings", fldno + 1);
803 return gripe("Value for field %d must be \"%.*s\"",
804 fldno + 1, (int)len, old);
806 return gripe("Value for field %d must be nil", fldno + 1);
813 * Resolve symbol name ID in table referred to by CA.
814 * Use field number N for error messages.
815 * Return index in referred table on success, -1 on failure.
818 xunsymbol(char *id, struct castr *ca, int n)
820 int i = ef_elt_byname(ca->ca_table, id);
822 return gripe("%s %s symbol `%s' in field %d",
823 i == M_NOTUNIQUE ? "Ambiguous" : "Unknown",
824 ca->ca_name, id, n + 1);
829 * Map symbol index to symbol value.
830 * CA is the table, and I is the index in it.
833 symval(struct castr *ca, int i)
835 int type = ca->ca_table;
837 if (type != EF_BAD && ef_cadef(type) == symbol_ca)
838 /* symbol table, value is in the table */
839 return ((struct symbol *)ef_ptr(type, i))->value;
840 /* value is the table index */
845 * Set value of field FLDNO in current object to value of symbol SYM.
846 * Return 1 on success, -1 on error.
849 setsym(int fldno, char *sym)
854 ca = getfld(fldno, NULL);
858 if (ca->ca_table == EF_BAD || (ca->ca_flags & NSC_BITS))
859 return gripe("Field %d doesn't take symbols", fldno + 1);
861 i = xunsymbol(sym, ca, fldno);
864 return setnum(fldno, symval(ca, i));
868 * Create an empty symbol set for field FLDNO in *SET.
869 * Return 1 on success, -1 on error.
872 mtsymset(int fldno, long *set)
876 ca = getfld(fldno, NULL);
880 if (ca->ca_table == EF_BAD || ef_cadef(ca->ca_table) != symbol_ca
881 || !(ca->ca_flags & NSC_BITS))
882 return gripe("Field %d doesn't take symbol sets", fldno + 1);
888 * Add a symbol to a symbol set for field FLDNO in *SET.
889 * SYM is the name of the symbol to add.
890 * Return 1 on success, -1 on error.
893 add2symset(int fldno, long *set, char *sym)
898 ca = getfld(fldno, NULL);
902 i = xunsymbol(sym, ca, fldno);
905 *set |= symval(ca, i);
910 * Read an xdump table header line from FP.
911 * Expect header for EXPECTED_TABLE, unless it is EF_BAD.
912 * Recognize header for machine- and human-readable syntax, and set
914 * Return table type on success, -2 on EOF before header, -1 on failure.
917 xuheader(FILE *fp, int expected_table)
923 while ((ch = skipfs(fp)) == '\n')
925 if (ch == EOF && expected_table == EF_BAD)
932 ? fscanf(fp, "config%*[ \t]%63[^ \t#\n]%n", name, &res) != 1
933 : fscanf(fp, "XDUMP%*[ \t]%63[^ \t#\n]%*[ \t]%*[^ \t#\n]%n",
934 name, &res) != 1) || res < 0)
935 return gripe("Expected xdump header");
937 type = ef_byname(name);
939 return gripe("Unknown table `%s'", name);
940 if (expected_table != EF_BAD && expected_table != type)
941 return gripe("Expected table `%s', not `%s'",
942 ef_nameof(expected_table), name);
944 if (!empfile[type].file
945 || !ef_cadef(type) || !(ef_flags(type) & EFF_MEM)) {
946 CANT_HAPPEN(expected_table != EF_BAD);
947 return gripe("Table `%s' is not permitted here", name);
950 if (skipfs(fp) != '\n')
951 return gripe("Junk after xdump header");
958 * Find fields in this xdump.
959 * If reading human-readable syntax, read a field header line from FP.
960 * Else take fields from the table's selectors in CA[].
961 * Set ellipsis, nflds, fldca[], fldidx[] and caflds[] accordingly.
962 * Return 0 on success, -1 on failure.
965 xufldhdr(FILE *fp, struct castr ca[])
971 for (i = 0; ca[i].ca_name; i++)
976 while ((ch = skipfs(fp)) == '\n')
979 nflds = xuflds(fp, xufldname);
982 nflds -= ellipsis != 0;
987 for (i = 0; ca[i].ca_name; i++) {
988 if ((ca[i].ca_flags & NSC_EXTRA))
990 n = CA_ARRAY_LEN(&ca[i]);
998 nflds = fidx - fldidx;
1005 * Read xdump footer from FP.
1006 * CA[] contains the table's selectors.
1007 * The body had RECS records.
1008 * Update cafldspp[] from caflds[].
1009 * Return 0 on success, -1 on failure.
1012 xufooter(FILE *fp, struct castr ca[], int recs)
1018 if (fscanf(fp, "config%n", &res) != 0 || res < 0)
1019 return gripe("Malformed table footer");
1021 if (fscanf(fp, "%d", &n) != 1)
1022 return gripe("Malformed table footer");
1024 return gripe("Read %d rows, which doesn't match footer "
1025 "%d rows", recs, n);
1027 if (skipfs(fp) != '\n')
1028 return gripe("Junk after table footer");
1029 if (tbl_part_done() < 0)
1033 for (i = 0; ca[i].ca_name; i++) {
1034 if (cafldspp[i] < caflds[i])
1035 cafldspp[i] = caflds[i];
1042 * Read an xdump table from FP.
1043 * Both machine- and human-readable xdump syntax are recognized.
1044 * Expect table EXPECTED_TABLE, unless it is EF_BAD.
1045 * Report errors to stderr.
1046 * Messages assume FP starts in the file FILE at line *PLNO.
1047 * Update *PLNO to reflect lines read from FP.
1048 * Return table type on success, -2 on EOF before header, -1 on failure.
1051 xundump(FILE *fp, char *file, int *plno, int expected_table)
1054 int type, nca, nf, i, ch;
1059 if ((type = xuheader(fp, expected_table)) < 0)
1062 ca = ef_cadef(type);
1063 if (CANT_HAPPEN(!ca))
1066 if (have_hardcoded_indexes(type)) {
1067 may_omit_id = may_trunc = 0;
1070 may_trunc = empfile[type].nent < 0;
1074 for (i = 0; ca[i].ca_name; i++) {
1076 if (!(ca[i].ca_flags & NSC_EXTRA))
1077 nf += MAX(1, CA_ARRAY_LEN(&ca[i]));
1079 fldca = malloc(nf * sizeof(*fldca));
1080 fldidx = malloc(nf * sizeof(*fldidx));
1081 caflds = malloc(nca * sizeof(*caflds));
1082 cafldspp = calloc(nca, sizeof(*cafldspp));
1085 if (xutail(fp, ca) < 0)
1094 /* Skip empty lines so that callers can easily check for EOF */
1095 while ((ch = skipfs(fp)) == '\n')
1104 * Read the remainder of an xdump after the table header line from FP.
1105 * CA[] contains the table's selectors.
1106 * Return 0 on success, -1 on failure.
1109 xutail(FILE *fp, struct castr *ca)
1114 if (xufldhdr(fp, ca) < 0)
1116 if ((recs = xubody(fp)) < 0)
1118 if (xufooter(fp, ca, recs) < 0)
1122 if (xuheader(fp, cur_type) < 0)
1128 * Read the body of an xdump table from FP.
1129 * Return number of rows read on success, -1 on failure.
1137 while ((ch = skipfs(fp)) == '\n')
1142 if (xuflds(fp, xufld) < 0)