[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: [zzdev] Re: [zzdev] zob2java problems on Mac



> Wow, now I'm learning Perl...
> 
> I've isolated the bug. And it has apparently nothing to do with 
> newlines. In the code:
> 
> >     while ($level > 0) {
> >         die "Unbalanced braces" if $str eq "";
> >         $str =~ /^([^{}]*)([{}])(.*)$/s;
> >         if ($2 eq "{") { ++$level; }
> >         if ($2 eq "}") { --$level; }
> >         $str = $3;
> >         $rv = $rv . $1 . $2;
> >     }
> 
> in parse_balanced, the value of $1 and $2 changes (in MacPerl) when
> doing $str = $3, and this has disastrous effects. My simple patch looks
> like this:
> 
> >     while ($level > 0) {
> >         die "Unbalanced braces" if $str eq "";
> >         $str =~ /^([^{}]*)([{}])(.*)$/s;
> >         my ($first, $second) = ($1, $2);
> >         if ($2 eq "{") { ++$level; }
> >         if ($2 eq "}") { --$level; }
> >         $str = $3;
> >         $rv = $rv . $first . $second;
> >     }
> 
> ... and outputs the right thing. If this isn't somehow frowned upon, or
> stupid (remember, I don't *really* know what I'm doing ;) ), could you
> change it in the repository? It *should* work on others than MacPerl, right?

Which version of Perl is you MacPerl? If it's the same as the most recent
Perl version, then a bug report would be in order. I remember seeing this
in a Perl version some years ago.

I've committed the change.

	Tuomas