[interchange-cvs] interchange - racke modified 2 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Feb 28 09:42:01 2002


User:      racke
Date:      2002-02-28 14:41:59 GMT
Modified:  lib/Vend Tag: STABLE_4_8-branch Parse.pm Util.pm
Log:
new usertag parse_locale added

Revision  Changes    Path
No                   revision



No                   revision



2.0.2.5   +6 -2      interchange/lib/Vend/Parse.pm


rev 2.0.2.5, prev_rev 2.0.2.4
Index: Parse.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Parse.pm,v
retrieving revision 2.0.2.4
retrieving revision 2.0.2.5
diff -u -r2.0.2.4 -r2.0.2.5
--- Parse.pm	24 Jan 2002 05:07:01 -0000	2.0.2.4
+++ Parse.pm	28 Feb 2002 14:41:59 -0000	2.0.2.5
@@ -1,6 +1,6 @@
 # Vend::Parse - Parse Interchange tags
 # 
-# $Id: Parse.pm,v 2.0.2.4 2002/01/24 05:07:01 jon Exp $
+# $Id: Parse.pm,v 2.0.2.5 2002/02/28 14:41:59 racke Exp $
 #
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -35,7 +35,7 @@
 
 @ISA = qw(Exporter Vend::Parser);
 
-$VERSION = substr(q$Revision: 2.0.2.4 $, 10);
+$VERSION = substr(q$Revision: 2.0.2.5 $, 10);
 
 @EXPORT = ();
 @EXPORT_OK = qw(find_matching_end);
@@ -102,6 +102,7 @@
 				or               1
 				order            2
 				page             2
+				parse_locale     0
 				perl             1
 				price            1
 				profile          1
@@ -192,6 +193,7 @@
 				msg				=> [qw( key )],
 				mvasp			=> [qw( tables )],
 				options			=> [qw( code )],
+				parse_locale	=> [qw( )],			 
 				price			=> [qw( code )],
 				profile			=> [qw( name )],
 				process      	=> [qw( target secure )],
@@ -321,6 +323,7 @@
 						msg				1
                         mvasp           1
                         perl            1
+                        parse_locale    1
                         query           1
                         region          1
                         restrict        1
@@ -540,6 +543,7 @@
 # MVASP
 				mvasp			=> \&Vend::Interpolate::mvasp,
 # END MVASP
+				parse_locale    => \&Vend::Util::parse_locale,
 				price        	=> \&Vend::Interpolate::tag_price,
 				process      	=> \&Vend::Interpolate::tag_process,
 				profile      	=> \&Vend::Interpolate::tag_profile,



2.1.2.5   +28 -16    interchange/lib/Vend/Util.pm


rev 2.1.2.5, prev_rev 2.1.2.4
Index: Util.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Util.pm,v
retrieving revision 2.1.2.4
retrieving revision 2.1.2.5
diff -u -r2.1.2.4 -r2.1.2.5
--- Util.pm	24 Jan 2002 05:07:02 -0000	2.1.2.4
+++ Util.pm	28 Feb 2002 14:41:59 -0000	2.1.2.5
@@ -1,6 +1,6 @@
 # Vend::Util - Interchange utility functions
 #
-# $Id: Util.pm,v 2.1.2.4 2002/01/24 05:07:02 jon Exp $
+# $Id: Util.pm,v 2.1.2.5 2002/02/28 14:41:59 racke Exp $
 # 
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -74,7 +74,7 @@
 use Errno;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.1.2.4 $, 10);
+$VERSION = substr(q$Revision: 2.1.2.5 $, 10);
 
 BEGIN {
 	eval {
@@ -822,6 +822,30 @@
 	return $text;
 }
 
+sub parse_locale {
+	my ($input) = @_;
+
+	# avoid copying big strings
+	my $r = ref($input) ? $input : \$input;
+	
+	if($Vend::Cfg->{Locale}) {
+		my $key;
+		$$r =~ s~\[L(\s+([^\]]+))?\]([\000-\377]*?)\[/L\]~
+						$key = $2 || $3;		
+						defined $Vend::Cfg->{Locale}{$key}
+						?  ($Vend::Cfg->{Locale}{$key})	: $3 ~eg;
+		$$r =~ s~\[LC\]([\000-\377]*?)\[/LC\]~
+						find_locale_bit($1) ~eg;
+		undef $Lang;
+	}
+	else {
+		$$r =~ s~\[L(?:\s+[^\]]+)?\]([\000-\377]*?)\[/L\]~$1~g;
+	}
+
+	# return scalar string if one get passed initially
+	return ref($input) ? $input : $$r;
+}
+
 # Reads in a page from the page directory with the name FILE and ".html"
 # appended. If the HTMLsuffix configuration has changed (because of setting in
 # catalog.cfg or Locale definitions) it will substitute that. Returns the
@@ -910,20 +934,8 @@
 	}
 
 	return unless defined $contents;
-	
-	if($Vend::Cfg->{Locale}) {
-		my $key;
-		$contents =~ s~\[L(\s+([^\]]+))?\]([\000-\377]*?)\[/L\]~
-						$key = $2 || $3;		
-						defined $Vend::Cfg->{Locale}{$key}
-						?  ($Vend::Cfg->{Locale}{$key})	: $3 ~eg;
-		$contents =~ s~\[LC\]([\000-\377]*?)\[/LC\]~
-						find_locale_bit($1) ~eg;
-		undef $Lang;
-	}
-	else {
-		$contents =~ s~\[L(?:\s+[^\]]+)?\]([\000-\377]*?)\[/L\]~$1~g;
-	}
+
+	parse_locale(\$contents);
 
 	return $contents;
 }