Skip Menu |

This queue is for tickets about the Data-SExpression CPAN distribution.

Report information
The Basics
Id: 23747
Status: resolved
Priority: 0/
Queue: Data-SExpression

People
Owner: nelhage [...] mit.edu
Requestors: miyamuko [...] mtb.biglobe.ne.jp
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.3
Fixed in: (no value)



Subject: Data::SExpression#read can not parse several strings.
Description: Data::SExpression#read can not parse following cases. * empty string in list. q{("" "")} * newline in a string. "a\nb" Steps to Reproduce: Show quoted text
> perl -MData::SExpression -e "Data::SExpression->new->read(q
{(\"\" \"\")})" Parse error near: '")' at lib/Data/SExpression/Parser.yp line 105. Show quoted text
> perl -MData::SExpression -e "Data::SExpression->new->read(qq
{\"a\nb\"})" Parse error near: '"a b' at lib/Data/SExpression/Parser.yp line 105. Product: Data-SExpressoin-0.3 Perl version: This is perl, v5.8.8 built for MSWin32-x86-multi-thread (ActivePerl 5.8.8.817) Operating System vendor and version: Microsoft Windows XP Professional SP2 Attachments: patch.txt will fix the problem. Thanks.
Subject: patch.txt
diff -r -u Data-SExpression-0.3/lib/Data/SExpression/Parser.yp Data-SExpression-0.3.fix/lib/Data/SExpression/Parser.yp --- Data-SExpression-0.3/lib/Data/SExpression/Parser.yp 2006-08-01 11:30:57.000000000 +0900 +++ Data-SExpression-0.3.fix/lib/Data/SExpression/Parser.yp 2006-11-27 22:33:46.031250000 +0900 @@ -86,7 +86,7 @@ /\G ($symbol_char ($symbol_char | \d )*)/gcx and return ('SYMBOL', $1); - /\G " (.*? [^\\]) "/gcx || /\G ""/gcx + /\G " ([^"\\]* (?: \\. [^"\\]*)*) "/gcx and return ('STRING', $1 || ""); /\G ([().])/gcx diff -r -u Data-SExpression-0.3/t/01-lexer.t Data-SExpression-0.3.fix/t/01-lexer.t --- Data-SExpression-0.3/t/01-lexer.t 2006-08-01 11:36:55.000000000 +0900 +++ Data-SExpression-0.3.fix/t/01-lexer.t 2006-11-27 22:33:46.031250000 +0900 @@ -57,3 +57,51 @@ [[SYMBOL => 'a'], [q{.} => q{.}], [SYMBOL => 'b']]); + +is_deeply(tokenize(q{""}), + [[STRING => '']]); + +is_deeply(tokenize(q{("")}), + [['(' => '('], + [STRING => ''], + [')' => ')']]); + +is_deeply(tokenize(q{("") ("")}), + [['(' => '('], + [STRING => ''], + [')' => ')'], + ['(' => '('], + [STRING => ''], + [')' => ')']]); + +is_deeply(tokenize(q{("") (" ")}), + [['(' => '('], + [STRING => ''], + [')' => ')'], + ['(' => '('], + [STRING => ' '], + [')' => ')']]); + +is_deeply(tokenize(q{("a") ("b")}), + [['(' => '('], + [STRING => 'a'], + [')' => ')'], + ['(' => '('], + [STRING => 'b'], + [')' => ')']]); + + +is_deeply(tokenize(qq{"\n"}), + [[STRING => "\n"]]); + +is_deeply(tokenize(qq{"aa\n"}), + [[STRING => "aa\n"]]); + +is_deeply(tokenize(qq{"\nbb"}), + [[STRING => "\nbb"]]); + +is_deeply(tokenize(qq{"aa\nbb"}), + [[STRING => "aa\nbb"]]); + +is_deeply(tokenize(qq{"aa\nbb\ncc\ndd\n"}), + [[STRING => "aa\nbb\ncc\ndd\n"]]); diff -r -u Data-SExpression-0.3/t/02-scalars.t Data-SExpression-0.3.fix/t/02-scalars.t --- Data-SExpression-0.3/t/02-scalars.t 2006-07-30 11:11:14.000000000 +0900 +++ Data-SExpression-0.3.fix/t/02-scalars.t 2006-11-27 22:33:46.031250000 +0900 @@ -8,7 +8,7 @@ =cut -use Test::More tests => 11; +use Test::More tests => 15; use Symbol; use Data::SExpression; @@ -30,3 +30,21 @@ 7 }), 7, "Skipped comment"); is(scalar $ds->read('+'), qualify_to_ref('+'), "Read '+' symbol"); +is(scalar $ds->read(q{ +"foo +bar +" +}), "foo\nbar\n", "LF is OK"); +is(scalar $ds->read(q{ +" + +" +}), "\n\n", "LF is OK (2)"); +is(scalar $ds->read(q{ +";; not comment" +}), ";; not comment", "comment in string OK"); +is(scalar $ds->read(q{ +" +; not comment +" +}), "\n; not comment\n", "comment in string OK (2)"); diff -r -u Data-SExpression-0.3/t/03-lists.t Data-SExpression-0.3.fix/t/03-lists.t --- Data-SExpression-0.3/t/03-lists.t 2006-07-30 11:11:14.000000000 +0900 +++ Data-SExpression-0.3.fix/t/03-lists.t 2006-11-27 22:33:46.031250000 +0900 @@ -8,7 +8,7 @@ =cut -use Test::More tests => 5; +use Test::More tests => 7; use Test::Deep; use Symbol; @@ -59,6 +59,22 @@ cdr => undef)))), "Read a tree"); +cmp_deeply( + scalar $ds->read(qq{("")}), + methods( + car => "", + cdr => undef), + "Read an empty string"); + +cmp_deeply( + scalar $ds->read(qq{("" "")}), + methods( + car => "", + cdr => methods( + car => "", + cdr => undef)), + "Read an empty strings"); + no warnings 'once'; #For the symbol globs cmp_deeply(
Subject: Re: [rt.cpan.org #23747] Data::SExpression#read can not parse several strings.
Date: Sun, 3 Dec 2006 00:14:08 -0500
To: MIYAMUKO Katsuyuki via RT <bug-Data-SExpression [...] rt.cpan.org>
From: Nelson Elhage <nelhage [...] MIT.EDU>
Thanks for the bug report! I applied your patch, and have uploaded version 0.31 to CPAN. - Nelson Elhage On Sat, Dec 02, 2006 at 11:27:29PM -0500, MIYAMUKO Katsuyuki via RT wrote: Show quoted text
> > Sat Dec 02 23:27:28 2006: Request 23747 was acted upon. > Transaction: Ticket created by miyamuko > Queue: Data-SExpression > Subject: Data::SExpression#read can not parse several strings. > Broken in: 0.3 > Severity: Normal > Owner: Nobody > Requestors: miyamuko+bitcard@gmail.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=23747 > > > > Description: > > Data::SExpression#read can not parse following cases. > > * empty string in list. > q{("" "")} > > * newline in a string. > "a\nb" > > Steps to Reproduce: >
> > perl -MData::SExpression -e "Data::SExpression->new->read(q
> {(\"\" \"\")})" > Parse error near: '")' at lib/Data/SExpression/Parser.yp line 105. >
> > perl -MData::SExpression -e "Data::SExpression->new->read(qq
> {\"a\nb\"})" > Parse error near: '"a > b' at lib/Data/SExpression/Parser.yp line 105. > > Product: > > Data-SExpressoin-0.3 > > Perl version: > > This is perl, v5.8.8 built for MSWin32-x86-multi-thread > (ActivePerl 5.8.8.817) > > Operating System vendor and version: > > Microsoft Windows XP Professional SP2 > > Attachments: > > patch.txt will fix the problem. > > Thanks. >
Show quoted text
> diff -r -u Data-SExpression-0.3/lib/Data/SExpression/Parser.yp Data-SExpression-0.3.fix/lib/Data/SExpression/Parser.yp > --- Data-SExpression-0.3/lib/Data/SExpression/Parser.yp 2006-08-01 11:30:57.000000000 +0900 > +++ Data-SExpression-0.3.fix/lib/Data/SExpression/Parser.yp 2006-11-27 22:33:46.031250000 +0900 > @@ -86,7 +86,7 @@ > /\G ($symbol_char ($symbol_char | \d )*)/gcx > and return ('SYMBOL', $1); > > - /\G " (.*? [^\\]) "/gcx || /\G ""/gcx > + /\G " ([^"\\]* (?: \\. [^"\\]*)*) "/gcx > and return ('STRING', $1 || ""); > > /\G ([().])/gcx > diff -r -u Data-SExpression-0.3/t/01-lexer.t Data-SExpression-0.3.fix/t/01-lexer.t > --- Data-SExpression-0.3/t/01-lexer.t 2006-08-01 11:36:55.000000000 +0900 > +++ Data-SExpression-0.3.fix/t/01-lexer.t 2006-11-27 22:33:46.031250000 +0900 > @@ -57,3 +57,51 @@ > [[SYMBOL => 'a'], > [q{.} => q{.}], > [SYMBOL => 'b']]); > + > +is_deeply(tokenize(q{""}), > + [[STRING => '']]); > + > +is_deeply(tokenize(q{("")}), > + [['(' => '('], > + [STRING => ''], > + [')' => ')']]); > + > +is_deeply(tokenize(q{("") ("")}), > + [['(' => '('], > + [STRING => ''], > + [')' => ')'], > + ['(' => '('], > + [STRING => ''], > + [')' => ')']]); > + > +is_deeply(tokenize(q{("") (" ")}), > + [['(' => '('], > + [STRING => ''], > + [')' => ')'], > + ['(' => '('], > + [STRING => ' '], > + [')' => ')']]); > + > +is_deeply(tokenize(q{("a") ("b")}), > + [['(' => '('], > + [STRING => 'a'], > + [')' => ')'], > + ['(' => '('], > + [STRING => 'b'], > + [')' => ')']]); > + > + > +is_deeply(tokenize(qq{"\n"}), > + [[STRING => "\n"]]); > + > +is_deeply(tokenize(qq{"aa\n"}), > + [[STRING => "aa\n"]]); > + > +is_deeply(tokenize(qq{"\nbb"}), > + [[STRING => "\nbb"]]); > + > +is_deeply(tokenize(qq{"aa\nbb"}), > + [[STRING => "aa\nbb"]]); > + > +is_deeply(tokenize(qq{"aa\nbb\ncc\ndd\n"}), > + [[STRING => "aa\nbb\ncc\ndd\n"]]); > diff -r -u Data-SExpression-0.3/t/02-scalars.t Data-SExpression-0.3.fix/t/02-scalars.t > --- Data-SExpression-0.3/t/02-scalars.t 2006-07-30 11:11:14.000000000 +0900 > +++ Data-SExpression-0.3.fix/t/02-scalars.t 2006-11-27 22:33:46.031250000 +0900 > @@ -8,7 +8,7 @@ > > =cut > > -use Test::More tests => 11; > +use Test::More tests => 15; > use Symbol; > > use Data::SExpression; > @@ -30,3 +30,21 @@ > 7 > }), 7, "Skipped comment"); > is(scalar $ds->read('+'), qualify_to_ref('+'), "Read '+' symbol"); > +is(scalar $ds->read(q{ > +"foo > +bar > +" > +}), "foo\nbar\n", "LF is OK"); > +is(scalar $ds->read(q{ > +" > + > +" > +}), "\n\n", "LF is OK (2)"); > +is(scalar $ds->read(q{ > +";; not comment" > +}), ";; not comment", "comment in string OK"); > +is(scalar $ds->read(q{ > +" > +; not comment > +" > +}), "\n; not comment\n", "comment in string OK (2)"); > diff -r -u Data-SExpression-0.3/t/03-lists.t Data-SExpression-0.3.fix/t/03-lists.t > --- Data-SExpression-0.3/t/03-lists.t 2006-07-30 11:11:14.000000000 +0900 > +++ Data-SExpression-0.3.fix/t/03-lists.t 2006-11-27 22:33:46.031250000 +0900 > @@ -8,7 +8,7 @@ > > =cut > > -use Test::More tests => 5; > +use Test::More tests => 7; > use Test::Deep; > use Symbol; > > @@ -59,6 +59,22 @@ > cdr => undef)))), > "Read a tree"); > > +cmp_deeply( > + scalar $ds->read(qq{("")}), > + methods( > + car => "", > + cdr => undef), > + "Read an empty string"); > + > +cmp_deeply( > + scalar $ds->read(qq{("" "")}), > + methods( > + car => "", > + cdr => methods( > + car => "", > + cdr => undef)), > + "Read an empty strings"); > + > no warnings 'once'; #For the symbol globs > > cmp_deeply(
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #23747] Data::SExpression#read can not parse several strings.
Date: Sat, 6 Jan 2007 08:36:28 +0900
To: bug-Data-SExpression [...] rt.cpan.org
From: "MIYAMUKO Katsuyuki" <miyamuko [...] gmail.com>
Hi, Show quoted text
> Thanks for the bug report! I applied your patch, and have uploaded > version 0.31 to CPAN.
And thank you for applying patch. But I cannot find 0.31 in CPAN. (http://search.cpan.org/~nelhage/Data-SExpression/) And I found 0.31 archive in http://backpan.perl.org/authors/id/N/NE/NELHAGE/, but this looks broken (only 159 bytes). Could you please re-upload 0.31 archive? # I'm sorry my reply is late. -- MIYAMUKO Katsuyuki <miyamuko@gmail.com>
Subject: Re: [rt.cpan.org #23747] Data::SExpression#read can not parse several strings.
Date: Sat, 6 Jan 2007 12:19:35 -0500
To: MIYAMUKO Katsuyuki via RT <bug-Data-SExpression [...] rt.cpan.org>
From: Nelson Elhage <nelhage [...] MIT.EDU>
Whoops, sorry about that! Pushed 0.32 which is not broken. - Nelson On Fri, Jan 05, 2007 at 06:36:47PM -0500, MIYAMUKO Katsuyuki via RT wrote: Show quoted text
> > Queue: Data-SExpression > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=23747 > > > Hi, >
> > Thanks for the bug report! I applied your patch, and have uploaded > > version 0.31 to CPAN.
> > And thank you for applying patch. > > But I cannot find 0.31 in CPAN. > (http://search.cpan.org/~nelhage/Data-SExpression/) > > And I found 0.31 archive in http://backpan.perl.org/authors/id/N/NE/NELHAGE/, > but this looks broken (only 159 bytes). > > Could you please re-upload 0.31 archive? > > > # I'm sorry my reply is late. > > -- > MIYAMUKO Katsuyuki <miyamuko@gmail.com> >
Closing this since 0.32 fixes it.