[interchange-cvs] interchange - jon modified 2 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Tue Feb 17 10:58:29 EST 2004
User: jon
Date: 2004-02-17 15:58:28 GMT
Modified: lib/Vend Interpolate.pm
Modified: dist/test/products tests.asc
Log:
Optimize no-op [if] checks when test is false.
Add many new tests of [if] tag.
Revision Changes Path
2.205 +10 -6 interchange/lib/Vend/Interpolate.pm
rev 2.205, prev_rev 2.204
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.204
retrieving revision 2.205
diff -u -u -r2.204 -r2.205
--- Interpolate.pm 16 Feb 2004 21:25:10 -0000 2.204
+++ Interpolate.pm 17 Feb 2004 15:58:28 -0000 2.205
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.204 2004/02/16 21:25:10 jon Exp $
+# $Id: Interpolate.pm,v 2.205 2004/02/17 15:58:28 jon Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.204 $, 10);
+$VERSION = substr(q$Revision: 2.205 $, 10);
@EXPORT = qw (
@@ -1433,13 +1433,17 @@
RUNSAFE: {
last RUNSAFE if defined $status;
- last RUNSAFE if $status = ($noop && $op) ? 1 : 0;
+
+ if ($noop) {
+ $status = $op ? 1 : 0;
+ last RUNSAFE;
+ }
+
$ready_safe->trap(@{$Global::SafeTrap});
$ready_safe->untrap(@{$Global::SafeUntrap});
- $status = $ready_safe->reval($op) ? 1 : 0
- unless $@;
+ $status = $ready_safe->reval($op) ? 1 : 0;
if ($@) {
- logError qq%Bad if '@_': $@%;
+ logError "Bad if '@_': $@";
$status = 0;
}
}
2.15 +71 -2 interchange/dist/test/products/tests.asc
rev 2.15, prev_rev 2.14
Index: tests.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/tests.asc,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -u -r2.14 -r2.15
--- tests.asc 16 Feb 2004 21:25:11 -0000 2.14
+++ tests.asc 17 Feb 2004 15:58:28 -0000 2.15
@@ -2382,14 +2382,17 @@
%%%
000152
%%
-[calc interpolate=0]
+[perl]
$CGI->{somecgi1} = '1 2 3 4';
$CGI->{somecgi2} = 1;
$CGI->{somecgi3} = 1234;
$CGI->{somecgi4} = 'a1234';
delete $CGI->{nocgi};
+ $CGI->{'?weirdcgi?'} = 'yes';
+ $Tag->tmp('somescratch', 'y');
+ $Tag->tmp('noscratch');
return;
-[/calc]
+[/perl]
1=[if cgi somecgi1]true[else]false[/else][/if]
2=[if cgi somecgi1][or cgi nocgi]true[else]false[/else][/if]
3=[if cgi somecgi1][and cgi nocgi]true[else]false[/else][/if]
@@ -2410,6 +2413,39 @@
18=[if cgi nocgi][or cgi nocgi]true[else]false[/else][/if]
19=[if cgi nocgi][or cgi somecgi4]true[else]false[/else][/if]
20=[if cgi nocgi][or cgi somecgi4][or cgi nocgi]true[else]false[/else][/if]
+21=[if cgi somecgi1 =~ /nope/][or cgi somecgi2 != 1]true[else]false[/else][/if]
+22=[if cgi somecgi1 badop err][or cgi nocgi]true[else]false[/else][/if]
+23=[if cgi somecgi1 badop err][or cgi somecgi4]true[else]false[/else][/if]
+24=[if cgi somecgi1 !~ /\b2\s+3\b/][or cgi ?weirdcgi? badop err]true[else]false[/else][/if]
+25=[if cgi somecgi1 =~ /\b2\s+3\b/][or cgi ?weirdcgi? badop err]true[else]false[/else][/if]
+26=[if cgi somecgi1 =~ /\b2\s+3\b/][and cgi ?weirdcgi? badop err]true[else]false[/else][/if]
+27=[if cgi ?weirdcgi? eq 'no']true[else]false[/else][/if]
+28=[if cgi ?weirdcgi? eq 'no'][or cgi somecgi2 == 1]true[else]false[/else][/if]
+29=[if cgi ?weirdcgi?][or cgi somecgi2 == 999]true[else]false[/else][/if]
+30=[if cgi ?weirdcgi? eq 'ja'][or cgi somecgi2 == 999]true[else]false[/else][/if]
+31=[if scratch somescratch]true[else]false[/else][/if]
+32=[if scratch somescratch == 1]true[else]false[/else][/if]
+33=[if scratch somescratch ne 'ja']true[else]false[/else][/if]
+34=[if scratch noscratch][or scratch somescratch =~ /^Y(?:es)?/i]true[else]false[/else][/if]
+35=[if scratch noscratch][and scratch somescratch =~ /^Y(?:es)?/i]true[else]false[/else][/if]
+36=[if scratch noscratch][and scratch somescratch =~ /^y/][and cgi ?weirdcgi?]true[else]false[/else][/if]
+37=[if scratch noscratch][or scratch somescratch =~ /^y/][and cgi ?weirdcgi?]true[else]false[/else][/if]
+38=[if scratch noscratch][or scratch somescratch !~ /^y/][and cgi ?weirdcgi?]true[else]false[/else][/if]
+39=[if scratch noscratch][or scratch somescratch =~ /^y/][or cgi ?weirdcgi?]true[else]false[/else][/if]
+40=[if scratch noscratch][and cgi nocgi][and scratch somescratch =~ /^y/][and cgi ?weirdcgi?]true[else]false[/else][/if]
+41=[if scratch noscratch][or cgi nocgi][or scratch somescratch =~ /^y/][or cgi ?weirdcgi?]true[else]false[/else][/if]
+42=[if scratch noscratch][or cgi nocgi][or scratch somescratch =~ /^y/][and cgi ?weirdcgi?]true[else]false[/else][/if]
+43=[if scratch noscratch][or cgi nocgi][or scratch somescratch =~ /^y/][and cgi nocgi]true[else]false[/else][/if]
+44=[if type=explicit compare="return undef"]true[else]false[/else][/if]
+45=[if type=explicit compare="my $v = 1.5 * 2; $v + 5 > 5"]true[else]false[/else][/if]
+46=[if type=explicit compare="my $v = 1.5 * 2; $v + 5 < 5"]true[else]false[/else][/if]
+47=[if type=explicit compare=| return 1 if $Scratch->{somescratch} |]true[else]false[/else][/if]
+48=[if type=explicit compare=| return 0 if $Scratch->{somescratch} |]true[else]false[/else][/if]
+49=[if op=ne term=somecgi1 type=cgi compare=' 1 2 3 4 ']true[else]false[/else][/if]
+50=[if op=ne term=somecgi1 type=cgi compare='1 2 3 4']true[else]false[/else][/if]
+51=[if op=ne term=somecgi1 type=cgi compare=| 1 2 3 4 |]true[else]false[/else][/if]
+52=[if op=ne term=somecgi1 type=cgi compare=" q{1 2 3 4} "]true[else]false[/else][/if]
+53=[if type=explicit compare=" $CGI->{somecgi1} ne q{1 2 3 4} "]true[else]false[/else][/if]
%%
1=true
2=true
@@ -2431,6 +2467,39 @@
18=false
19=true
20=true
+21=false
+22=false
+23=true
+24=false
+25=true
+26=false
+27=false
+28=true
+29=true
+30=false
+31=true
+32=false
+33=true
+34=true
+35=false
+36=false
+37=true
+38=false
+39=true
+40=false
+41=true
+42=true
+43=false
+44=false
+45=true
+46=false
+47=true
+48=false
+49=true
+50=false
+51=false
+52=true
+53=false
%%
%%
More information about the interchange-cvs
mailing list