Commmit
638bf380e550 ("combine-files: Allow matching string
variables to have different widths.") introduced a bug in the
case where the variables in data files being combined didn't
have the same variable order. This is kind of an
embarrassing bug since the input files having the same order
of variables is an exceptional case anyhow. This commit
should fix the problem.
The test as updated will crash if the bug regresses.
Thanks to Frans Houweling for reporting the bug.
{
r = xmalloc (sizeof *r);
*r = (struct comb_resizer) {
- .output_proto = caseproto_ref (dict_get_proto (proc.dict)),
+ .output_proto = caseproto_ref (dict_get_proto (cf->dict)),
.indexes = xnmalloc (dict_get_n_vars (cf->dict),
sizeof *r->indexes),
};
cf->resizer = r;
}
- r->indexes[r->n_indexes++] = var_get_dict_index (dv);
+
+ size_t dict_index = var_get_dict_index (dv);
+ r->output_proto = caseproto_set_width (r->output_proto,
+ dict_index, mw);
+ r->indexes[r->n_indexes++] = dict_index;
}
}
}
AT_SETUP([MATCH FILES with different string widths])
AT_DATA([match-files.sps], [dnl
-DATA LIST LIST NOTABLE/name (A6) x.
+DATA LIST LIST NOTABLE/x (F8.2) name (A6).
BEGIN DATA.
-al,7
-brad,8
-carl,9
+7,al
+8,brad
+9,carl
END DATA.
SAVE OUTFILE='x.sav'.
carl,2
dan,3
END DATA.
-MATCH FILES/FILE='x.sav'/FILE=*/BY name.
-LIST.
+MATCH FILES/FILE=*/FILE='x.sav'/BY name.
+LIST/name x y.
])
AT_CHECK([pspp -O format=csv match-files.sps], [0], [dnl
Table: Data List