summaryrefslogtreecommitdiff
path: root/solenv/bin/modules/pre2par
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-12-17 20:27:35 +0000
committerMichael Meeks <michael.meeks@novell.com>2010-12-17 20:27:35 +0000
commit16a9ffe76b5cb56f11aeb66c2f7d54df33871d93 (patch)
tree834d7886fbbe0ad14aab3649f251a839d654b743 /solenv/bin/modules/pre2par
parent48d75286719b771dbc881ffb49fc88c537a15938 (diff)
another 4x faster - down to ~2 seconds now for me.
Diffstat (limited to 'solenv/bin/modules/pre2par')
-rw-r--r--solenv/bin/modules/pre2par/language.pm54
1 files changed, 17 insertions, 37 deletions
diff --git a/solenv/bin/modules/pre2par/language.pm b/solenv/bin/modules/pre2par/language.pm
index 93eaa0838853..a6025e4fc804 100644
--- a/solenv/bin/modules/pre2par/language.pm
+++ b/solenv/bin/modules/pre2par/language.pm
@@ -27,6 +27,7 @@
package pre2par::language;
+use strict;
use pre2par::existence;
##############################################################
@@ -71,39 +72,6 @@ sub get_language_string_from_language_block
return $newstring;
}
-##############################################################
-# Returning the complete block in all languages
-# for a specified string
-##############################################################
-
-sub get_language_block_from_language_file
-{
- my ($searchstring, $langfile) = @_;
-
- my @language_block = ();
-
- for ( my $i = 0; $i <= $#{$langfile}; $i++ )
- {
- if ( ${$langfile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
- {
- my $counter = $i;
-
- push(@language_block, ${$langfile}[$counter]);
- $counter++;
-
- while (( $counter <= $#{$langfile} ) && (!( ${$langfile}[$counter] =~ /^\s*\[/ )))
- {
- push(@language_block, ${$langfile}[$counter]);
- $counter++;
- }
-
- last;
- }
- }
-
- return \@language_block;
-}
-
############################################
# collecting all replace variables
# in a language file
@@ -119,7 +87,20 @@ sub get_all_replace_variables
{
if ( ${$langfile}[$i] =~ /^\s*\[\s*(.*?)\s*\]\s*$/ )
{
- $allvars{$1} = 1;
+ my $variable = $1;
+# print "lang block '$variable'\n";
+ my @lang_block = ();
+ my $counter;
+
+ # Store the complete block in all languages for a specified variable
+ for ( $counter = $i + 1; $counter <= $#{$langfile}; $counter++ ) {
+ my $line = ${$langfile}[$counter];
+ last if ($line =~ /^s*\[/); # next decl.
+ push @lang_block, $line;
+ }
+# print "$variable = '@lang_block'\n";
+ $allvars{$variable} = \@lang_block;
+ $i = $counter - 1;
}
}
@@ -151,9 +132,8 @@ sub localize
# print "line '$oneline' split to '$language' '$variable'\n";
if (defined $replace_hash->{$variable}) {
- my $languageblock = get_language_block_from_language_file($variable, $langfile);
- my $newstring = get_language_string_from_language_block($languageblock, $language);
-
+ my $languageblock = $replace_hash->{$variable};
+ my $newstring = get_language_string_from_language_block($replace_hash->{$variable}, $language);
if ( $newstring eq "" ) { $newstring = "\"" . $variable . "\""; }
$oneline =~ s/$variable/$newstring/g;