On Wed Jan 02 11:19:02 2008, szbalint wrote:
> On Thu Oct 25 08:45:09 2007, ptc wrote:
> > In tools/build/c2str.pl there is the todo item:
> >
> > # TODO maybe cope with escaped \"
> >
> > Do this.
>
> I've attached a patch that should complete this TODO.
>
> The previous attempt failed because it didn't account for the case when
> someone wrote \\" (that is, \ can also be the argument for an escape
> sequence).
I have a counter-patch:
Index: tools/build/c2str.pl
=========================================================
==========
--- tools/build/c2str.pl (revision 28124)
+++ tools/build/c2str.pl (working copy)
@@ -142,10 +142,6 @@
die "Seen line $line before in $infile - can't continue";
}
- # RT#46909 maybe cope with escaped \"
- my $cnt = tr/"/"/;
- die "bogus CONST_STRING at line $line" if $cnt % 2;
-
my $str = extract_delimited; # $_, '"';
$str = substr $str, 1, -1;
## print STDERR "** '$str' $line\n";
With this, if a bogus CONST_STRING is constructed, ala:
STRING *bogus = CONST_STRING(INTERP, "\\"");
The the build errors out with:
/home/coke/bin/perl tools/build/pmc2c.pl --dump src/pmc/codestring.pmc
Badly balanced PMC source
No need to duplicate this logic in this build tool when we're already checking
for it elsewhere.
Comments?