[interchange-cvs] interchange - heins modified lib/Vend/Interpolate.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Thu Aug 1 21:34:01 2002


User:      heins
Date:      2002-08-02 01:33:35 GMT
Modified:  lib/Vend Interpolate.pm
Log:
* Add ability to run GlobalSub in lists

Revision  Changes    Path
2.96      +19 -7     interchange/lib/Vend/Interpolate.pm


rev 2.96, prev_rev 2.95
Index: Interpolate.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.95
retrieving revision 2.96
diff -u -r2.95 -r2.96
--- Interpolate.pm	2 Aug 2002 01:20:53 -0000	2.95
+++ Interpolate.pm	2 Aug 2002 01:33:34 -0000	2.96
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 #=20
-# $Id: Interpolate.pm,v 2.95 2002/08/02 01:20:53 mheins Exp $
+# $Id: Interpolate.pm,v 2.96 2002/08/02 01:33:34 mheins Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -27,7 +27,7 @@
 require Exporter;
 @ISA =3D qw(Exporter);
=20
-$VERSION =3D substr(q$Revision: 2.95 $, 10);
+$VERSION =3D substr(q$Revision: 2.96 $, 10);
=20
 @EXPORT =3D qw (
=20
@@ -4059,7 +4059,7 @@
 			}
 		}
 #::logDebug("Missing mv_field_hash and/or mv_field_names in Vend::Interpol=
ate::labeled_list") unless ref $fh eq 'HASH';
-		$r =3D iterate_array_list($i, $end, $count, $text, $ary, $opt_select, $f=
h);
+		$r =3D iterate_array_list($i, $end, $count, $text, $ary, $opt_select, $f=
h, $opt);
 	}
 	$MVSAFE::Unsafe =3D $save_unsafe;
 	return $r;
@@ -4308,7 +4308,7 @@
 }
=20
 sub iterate_array_list {
-	my ($i, $end, $count, $text, $ary, $opt_select, $fh) =3D @_;
+	my ($i, $end, $count, $text, $ary, $opt_select, $fh, $opt) =3D @_;
=20
 	my $r =3D '';
 	# Optimize for no-match, on-match, etc
@@ -4363,6 +4363,7 @@
 	$run =3D~ s#$IB$QR{_param_if}# defined $fh->{$3} ||
 		::logOnce(@field_msg, $3, "if-$Orig_prefix-param") #ige;
=20
+	$opt ||=3D {};
 	my $oexec =3D { %$opt };
=20
 	for( ; $i <=3D $end ; $i++, $count++ ) {
@@ -4416,7 +4417,11 @@
 		$run =3D~ s#$B$QR{_calc}$E$QR{'/_calc'}#tag_calc($1)#ige;
 		$run =3D~ s#$B$QR{_exec}$E$QR{'/_exec'}#
 					init_calc() if ! $Vend::Calc_initialized;
-					($Vend::Cfg->{Sub}{$1} || sub { 'ERROR' })->($2,$row,$oexec)
+					(
+						$Vend::Cfg->{Sub}{$1} ||
+						$Global::GlobalSub->{$1} ||
+						sub { 'ERROR' }
+					)->($2,$row,$oexec)
 				#ige;
 		$run =3D~ s#$B$QR{_filter}$E$QR{'/_filter'}#filter_value($1,$2)#ige;
 		$run =3D~ s#$B$QR{_last}$E$QR{'/_last'}#
@@ -4456,7 +4461,7 @@
 		return $r;
 	}
=20
-	$opt =3D {} if ! $opt;
+	$opt ||=3D {};
 	my $code_field =3D $opt->{code_field} || 'mv_sku';
 	my ($run, $code, $return, $item);
=20
@@ -4589,7 +4594,14 @@
 		$run =3D~ s#$B$QR{_tag}($All$E[-_]tag[-_]\1\])#
 						tag_dispatch($1,$count, $item, $hash, $2)#ige;
 		$run =3D~ s#$B$QR{_calc}$E$QR{'/_calc'}#tag_calc($1)#ige;
-		$run =3D~ s#$B$QR{_exec}$E$QR{'/_exec'}#init_calc() if ! $Vend::Calc_ini=
tialized;($Vend::Cfg->{Sub}{$1} || sub { 'ERROR' })->($2,$item,$oexec)#ige;
+		$run =3D~ s#$B$QR{_exec}$E$QR{'/_exec'}#
+					init_calc() if ! $Vend::Calc_initialized;
+					(
+						$Vend::Cfg->{Sub}{$1} ||
+						$Global::GlobalSub->{$1} ||
+						sub { 'ERROR' }
+					)->($2,$item,$oexec)
+				#ige;
 		$run =3D~ s#$B$QR{_filter}$E$QR{'/_filter'}#filter_value($1,$2)#ige;
 		$run =3D~ s#$B$QR{_last}$E$QR{'/_last'}#
                     my $tmp =3D interpolate_html($1);