Philip Fominykh | 1 May 10:19

csv issue with "foo"\n

Hello,

There is an issue with csv parser, where if a quoted field is followed 
immediately by newline, the newline is ignored.

The following test demonstrates the problem; and a fix.

Cheers,
Philip

diff --git a/extra/csv/csv-tests.factor b/extra/csv/csv-tests.factor
index 6ab26c7..858736a 100644
--- a/extra/csv/csv-tests.factor
+++ b/extra/csv/csv-tests.factor
@@ -46,9 +46,11 @@ IN: csv.tests
 [ "Year,Make,Model\n1997,Ford,E350\n2000,Mercury,Cougar" 
    <string-reader> csv ] named-unit-test

-   
+"Quoted field followed immediately by newline"
+[ { { "foo" "bar" }
+    { "1"   "2" } } ]
+[ "foo,\"bar\"\n1,2" <string-reader> csv ] named-unit-test

-   
 ! !!!!!!!!  other tests

 [ { { "Phil Dawes" } } ] 
diff --git a/extra/csv/csv.factor b/extra/csv/csv.factor
index 3953ce0..b1953f5 100644
(Continue reading)

Phil Dawes | 1 May 12:50

Re: csv issue with "foo"\n

Cool many thanks Philip, I'll add it to my git repo.

Philip Fominykh wrote:
> Hello,
> 
> There is an issue with csv parser, where if a quoted field is followed 
> immediately by newline, the newline is ignored.
> 
> The following test demonstrates the problem; and a fix.
> 
> Cheers,
> Philip
> 
> diff --git a/extra/csv/csv-tests.factor b/extra/csv/csv-tests.factor
> index 6ab26c7..858736a 100644
> --- a/extra/csv/csv-tests.factor
> +++ b/extra/csv/csv-tests.factor
> @@ -46,9 +46,11 @@ IN: csv.tests
>  [ "Year,Make,Model\n1997,Ford,E350\n2000,Mercury,Cougar" 
>     <string-reader> csv ] named-unit-test
>  
> -   
> +"Quoted field followed immediately by newline"
> +[ { { "foo" "bar" }
> +    { "1"   "2" } } ]
> +[ "foo,\"bar\"\n1,2" <string-reader> csv ] named-unit-test
>  
> -   
>  ! !!!!!!!!  other tests
>     
(Continue reading)

Phil Dawes | 1 May 12:58

Re: csv issue with "foo"\n

Applied to my repo, all tests pass:

git pull http://phildawes.net/2008/factor.git master

Phil Dawes wrote:
> Cool many thanks Philip, I'll add it to my git repo.
> 
> Philip Fominykh wrote:
>> Hello,
>>
>> There is an issue with csv parser, where if a quoted field is followed 
>> immediately by newline, the newline is ignored.
>>
>> The following test demonstrates the problem; and a fix.
>>
>> Cheers,
>> Philip
>>
>> diff --git a/extra/csv/csv-tests.factor b/extra/csv/csv-tests.factor
>> index 6ab26c7..858736a 100644
>> --- a/extra/csv/csv-tests.factor
>> +++ b/extra/csv/csv-tests.factor
>> @@ -46,9 +46,11 @@ IN: csv.tests
>>  [ "Year,Make,Model\n1997,Ford,E350\n2000,Mercury,Cougar" 
>>     <string-reader> csv ] named-unit-test
>>  
>> -   
>> +"Quoted field followed immediately by newline"
>> +[ { { "foo" "bar" }
>> +    { "1"   "2" } } ]
(Continue reading)


Gmane