const char *encoding = dfm_reader_get_legacy_encoding (reader);
struct string tmp = DS_EMPTY_INITIALIZER;
struct substring s;
- struct field *f;
+ struct field *f, *end;
if (dfm_eof (reader))
return false;
- for (f = parser->fields; f < &parser->fields[parser->field_cnt]; f++)
+ end = &parser->fields[parser->field_cnt];
+ for (f = parser->fields; f < end; f++)
{
int first_column, last_column;
if (!cut_field (parser, reader, &first_column, &last_column, &tmp, &s))
{
- if (settings_get_undefined ())
+ if (f < end - 1 && settings_get_undefined ())
msg (SW, _("Missing value(s) for all variables from %s onward. "
"These will be filled with the system-missing value "
"or blanks, as appropriate."),
f->name);
- for (; f < &parser->fields[parser->field_cnt]; f++)
+ for (; f < end; f++)
value_set_missing (case_data_rw_idx (c, f->case_idx),
fmt_var_width (&f->format));
goto exit;
AT_BANNER([DATA LIST])
+AT_SETUP([DATA LIST LIST with empty fields])
+AT_DATA([data-list.pspp], [dnl
+DATA LIST LIST NOTABLE /A B C (F1.0).
+BEGIN DATA.
+,,
+,,3
+,2,
+,2,3
+1,,
+1,,3
+1,2,
+1,2,3
+END DATA.
+
+LIST.
+])
+AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
+Table: Data List
+A,B,C
+.,.,.
+.,.,3
+.,2,.
+.,2,3
+1,.,.
+1,.,3
+1,2,.
+1,2,3
+])
+AT_CLEANUP
+
AT_SETUP([DATA LIST LIST with explicit delimiters])
AT_DATA([data-list.pspp], [dnl
data list list ('|','X') /A B C D.