From: Ben Pfaff Date: Tue, 12 May 2009 03:56:39 +0000 (-0700) Subject: data-parser: Treat " ," the same as ",". X-Git-Tag: v0.6.2-pre1~5 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e591f2e6af157c2573e988ae4f5c5eb8027282fb;p=pspp-builds.git data-parser: Treat " ," the same as ",". The data parser (used e.g. by DATA LIST) was unintentionally treating soft separators (e.g. white space) followed by a hard separator (e.g. a comma) as an empty field, but in fact it should be treated as just a single separator. This fixes it and adds a test. Thanks to pascal barbedor for reporting the problem. --- diff --git a/src/language/data-io/data-parser.c b/src/language/data-io/data-parser.c index dfc04be4..a3a438b7 100644 --- a/src/language/data-io/data-parser.c +++ b/src/language/data-io/data-parser.c @@ -480,7 +480,8 @@ cut_field (const struct data_parser *parser, struct dfm_reader *reader, /* Regular field. */ ss_get_chars (&p, ss_cspan (p, ds_ss (&parser->any_sep)), field); *last_column = dfm_column_start (reader); - if (!ss_ltrim (&p, parser->soft_seps) || ss_is_empty (p)) + if (!ss_ltrim (&p, parser->soft_seps) || ss_is_empty (p) + || ss_find_char (parser->hard_seps, p.string[0]) != SIZE_MAX) { /* Advance past a trailing hard separator, regardless of whether one actually existed. If diff --git a/tests/command/data-list.sh b/tests/command/data-list.sh index 7d3890c3..3f821199 100755 --- a/tests/command/data-list.sh +++ b/tests/command/data-list.sh @@ -76,7 +76,7 @@ begin data. 6 7, 8 9 -0,1,,, +0,1 ,,, ,,,, 2