[ic] It seems that [if]tag return nothing when result is 0.

murahashi interchange-users@interchange.redhat.com
Mon Mar 11 21:46:01 2002


Jon, 
Thank you for your reply.

----- Original Message ----- 
From: "Jon Jensen" <jon@redhat.com>
To: <interchange-users@interchange.redhat.com>
Sent: Tuesday, March 12, 2002 2:24 AM
Subject: Re: [ic] It seems that [if]tag return nothing when result is 0.


> On Mon, 11 Mar 2002, murahashi wrote:
> 
> > I have strange behavior of [if] tag below.
> > I want to have 0 or 1 from the following sample.
> > In case of A or B , It works.
> > It seems that [if]tag return nothing when result is 0.
> > Is that right? Am I something wrong?
> 
> It looks like you found a bug in the [if] tag when using [else]0[/else].
> Following is a patch against Interchange 4.9 in CVS, which I'll commit to
> CVS.
> 
> Thanks!
> Jon
> 
> 
> Index: Parse.pm
> ===================================================================
> RCS file: /var/cvs/interchange/lib/Vend/Parse.pm,v
> retrieving revision 2.15
> diff -u -r2.15 Parse.pm
> --- Parse.pm 4 Mar 2002 23:45:17 -0000 2.15
> +++ Parse.pm 11 Mar 2002 17:22:33 -0000
> @@ -674,7 +674,7 @@
>   $tmpbuf = $p->{ABORT} ? '' : $p->{OUT};
>   }
>   if($attr->{reparse} ) {
> - $$buf = ($routine->(@args,$tmpbuf) || '') . $$buf;
> + $$buf = ($routine->(@args,$tmpbuf)) . $$buf;
>   }
>   else {
>   $self->{OUT} .= &{$routine}(@args,$tmpbuf);
> Index: Interpolate.pm
> ===================================================================
> RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
> retrieving revision 2.61
> diff -u -r2.61 Interpolate.pm
> --- Interpolate.pm 28 Feb 2002 17:32:15 -0000 2.61
> +++ Interpolate.pm 11 Mar 2002 17:22:35 -0000
> @@ -1470,11 +1470,11 @@
>   $out = $body;
>   }
>   elsif ($elsif) {
> - $else = '[else]' . $else . '[/else]' if $else;
> + $else = '[else]' . $else . '[/else]' if length $else;
>   $elsif =~ s#(.*?)$QR{'/elsif'}(.*)#$1${2}[/elsif]#s;
>   $out = '[if ' . $elsif . $else . '[/if]';
>   }
> - elsif ($else) {
> + elsif (length $else) {
>   $out = $else;
>   }
>   return $out;
> @@ -3103,11 +3103,11 @@
>   $out = $body;
>   }
>   elsif ($elsif) {
> - $else = '[else]' . $else . '[/else]' if $else;
> + $else = '[else]' . $else . '[/else]' if length $else;
>   $elsif =~ s#(.*?)$QR{'/elsif'}(.*)#$1${2}[/elsif]#s;
>   $out = '[if ' . $elsif . $else . '[/if]';
>   }
> - elsif ($else) {
> + elsif (length $else) {
>   $out = $else;
>   }
>   else {
> 
> 
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users
>