[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PSPP-BUG: fields not read as expected in data list free
From: |
Ben Pfaff |
Subject: |
Re: PSPP-BUG: fields not read as expected in data list free |
Date: |
Mon, 11 May 2009 21:01:51 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
pascal barbedor <address@hidden> writes:
> here is a minimal program that does not read fields as expected (0.6.1 and
> 0.7.2):
>
> DATA LIST FREE TABLE / rubrique (A18) value (A32).
>
> BEGIN DATA.
> S20.G01.00.017.002,'31'
> S20.G01.00.017.003,'32'
> S20.G01.00.018,'A00'
> S30.G01.00.001 ,'xxx'
> S30.G01.00.002 ,'xxx'
> S30.G01.00.003 ,'xxx'
> END DATA.
>
> LIST.
Thanks for the great bug report. The minimal test case was very
helpful.
I fixed this by pushing the following patch to the stable branch.
commit e591f2e6af157c2573e988ae4f5c5eb8027282fb
Author: Ben Pfaff <address@hidden>
Date: Mon May 11 20:56:39 2009 -0700
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 <address@hidden> for reporting the problem.
diff --git a/src/language/data-io/data-parser.c
b/src/language/data-io/data-parser.c
index dfc04be..a3a438b 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 7d3890c..3f82119 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
--
Ben Pfaff
http://benpfaff.org