return type;
}
+static int
+xuheader1(FILE *fp, int type, struct castr ca[])
+{
+ struct castr **fca;
+ int *fidx;
+ int ch, i, j, n;
+
+ cur_type = type;
+
+ if (human) {
+ while ((ch = skipfs(fp)) == '\n')
+ lineno++;
+ ungetc(ch, fp);
+ if (xuflds(fp, xufldname) < 0)
+ return -1;
+ } else {
+ fca = fldca;
+ fidx = fldidx;
+
+ for (i = 0; ca[i].ca_name; i++) {
+ if ((ca[i].ca_flags & NSC_EXTRA))
+ continue;
+ n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0;
+ j = 0;
+ do {
+ *fca++ = &ca[i];
+ *fidx++ = j;
+ } while (++j < n);
+ }
+ }
+
+ return 0;
+}
+
static int
xutrailer(FILE *fp, int type, int row)
{
fldidx = calloc(nflds, sizeof(*fldidx));
caflds = calloc(nca, sizeof(*caflds));
- cur_type = type;
- if (human) {
- while ((ch = skipfs(fp)) == '\n')
- lineno++;
- ungetc(ch, fp);
- if (xuflds(fp, xufldname) < 0)
- type = EF_BAD;
- } else {
- struct castr **fca = fldca;
- int *fidx = fldidx;
- int i, j, n;
- for (i = 0; ca[i].ca_name; i++) {
- if ((ca[i].ca_flags & NSC_EXTRA))
- continue;
- n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0;
- j = 0;
- do {
- *fca++ = &ca[i];
- *fidx++ = j;
- } while (++j < n);
- }
- }
-
- if (type >= 0 && xundump1(fp, type, ca) < 0)
+ if (xuheader1(fp, type, ca) < 0 || xundump1(fp, type, ca) < 0)
type = EF_BAD;
free(caflds);
int need_sentinel = !EF_IS_GAME_STATE(type);
int row, ch;
+ cur_type = type;
+
for (row = 0;; ++row) {
while ((ch = skipfs(fp)) == '\n')
lineno++;
if (xuflds(fp, xufld) < 0)
return -1;
}
+
if (row != ep->fids) {
if (fixed_rows)
return gripe("Table %s requires %d rows, got %d",