From e591f2e6af157c2573e988ae4f5c5eb8027282fb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 11 May 2009 20:56:39 -0700 Subject: [PATCH] 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. --- src/language/data-io/data-parser.c | 3 ++- tests/command/data-list.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 -- 2.30.2