From 63554ee77cd82daea8a2b04e0d0cffc418542369 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 6 Aug 2010 16:32:04 -0700 Subject: [PATCH] DATA LIST: Don't report an error for an empty final field in LIST format. Also add test to prevent inadvertent regressions. --- src/language/data-io/data-parser.c | 9 +++++---- tests/language/data-io/data-list.at | 30 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/language/data-io/data-parser.c b/src/language/data-io/data-parser.c index 1e68c904..2d7f9f4c 100644 --- a/src/language/data-io/data-parser.c +++ b/src/language/data-io/data-parser.c @@ -597,22 +597,23 @@ parse_delimited_no_span (const struct data_parser *parser, 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; diff --git a/tests/language/data-io/data-list.at b/tests/language/data-io/data-list.at index 58970884..7683b9c5 100644 --- a/tests/language/data-io/data-list.at +++ b/tests/language/data-io/data-list.at @@ -1,5 +1,35 @@ 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. -- 2.30.2