[Libreoffice-commits] .: solenv/bin
Michael Meeks
mmeeks at kemper.freedesktop.org
Fri Feb 4 04:04:47 PST 2011
solenv/bin/modules/installer/remover.pm | 4
solenv/bin/modules/installer/setupscript.pm | 127 +++++++++++-----------------
2 files changed, 56 insertions(+), 75 deletions(-)
New commits:
commit c5b32fafd8bf47908897ad27ed64dd75ed26f2fc
Author: Jan Darmochwal <jdarmochwal at gmx.de>
Date: Thu Feb 3 12:30:37 2011 +0100
Accelerate Perl installer builder
speed up get_all_items_from_script
diff --git a/solenv/bin/modules/installer/remover.pm b/solenv/bin/modules/installer/remover.pm
index 75af6e8..2c039ec 100644
--- a/solenv/bin/modules/installer/remover.pm
+++ b/solenv/bin/modules/installer/remover.pm
@@ -37,8 +37,8 @@ sub remove_leading_and_ending_whitespaces
{
my ( $stringref ) = @_;
- $$stringref =~ s/^\s*//;
- $$stringref =~ s/\s*$//;
+ $$stringref =~ s/^\s+//;
+ $$stringref =~ s/\s+$//;
}
sub remove_leading_and_ending_quotationmarks
diff --git a/solenv/bin/modules/installer/setupscript.pm b/solenv/bin/modules/installer/setupscript.pm
index 7d3f77f..4e2fbf6 100644
--- a/solenv/bin/modules/installer/setupscript.pm
+++ b/solenv/bin/modules/installer/setupscript.pm
@@ -303,94 +303,75 @@ sub get_all_items_from_script
my ($scriptref, $searchitem) = @_;
my @allitemarray = ();
-
- my ($itemkey, $itemvalue, $valuecounter);
+
+ my ($itemkey, $itemvalue);
for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
{
my $line = ${$scriptref}[$i];
-
- if ( $line =~ /^\s*\Q$searchitem\E\s+(\S+)\s*$/ )
+
+ next unless ($line =~ /^\s*\Q$searchitem\E\s+(\S+)\s*$/);
+ my $gid = $1;
+
+ my %oneitemhash = ();
+ my $ismultilang = 0;
+
+ $oneitemhash{'gid'} = $gid;
+
+ while (!( $line =~ /^\s*End\s*$/ ))
{
- my $gid = $1;
- my $counter = $i + 1;
-
- my %oneitemhash = ();
- my $ismultilang = 0;
-
- $oneitemhash{'gid'} = $gid;
-
- while (!( $line =~ /^\s*End\s*$/ ))
+ if ( $i >= $#{$scriptref} ) {
+ installer::exiter::exit_program("Invalid setup script file. End of file reached before 'End' line of '$searchitem' section.", "get_all_items_from_script");
+ }
+ $line = ${$scriptref}[++$i];
+
+ if ( $line =~ /^\s*(.+?)\=\s*(.+?)\;\s*$/ ) # only oneliner!
{
- if ( $counter > $#{$scriptref} ) {
- installer::exiter::exit_program("Invalid setup script file. End of file reached before 'End' line of '$searchitem' section.", "get_all_items_from_script");
- }
- $line = ${$scriptref}[$counter];
- $counter++;
+ $itemkey = $1;
+ $itemvalue = $2;
- if ( $line =~ /^\s*(.+?)\s*\=\s*(.+?)\s*\;\s*$/ ) # only oneliner!
- {
- $itemkey = $1;
- $itemvalue = $2;
+ $itemkey =~ s/\s+$//;
+ $itemvalue =~ s/\s+$//;
- installer::remover::remove_leading_and_ending_quotationmarks(\$itemvalue);
- $itemvalue =~ s/\s*$//; # removing ending whitespaces. Could be introduced by empty variables.
+ installer::remover::remove_leading_and_ending_quotationmarks(\$itemvalue);
- $oneitemhash{$itemkey} = $itemvalue;
+ $oneitemhash{$itemkey} = $itemvalue;
- if ( $itemkey =~ /^\s*\S+\s+\(\S+\)\s*$/ )
- {
- $ismultilang = 1;
- }
- }
- else
+ $ismultilang ||= $itemkey =~ /^\S+\s+\(\S+\)$/;
+ }
+ elsif (($searchitem eq "Module") &&
+ ($line =~ /^\s*.+?\s*\=\s*\(/) &&
+ (!($line =~ /\)\;\s*$/))) # more than one line, for instance files at modules!
+ {
+ $line =~ /^\s*(.+?)\s*\=\s*(.+?)\s*$/; # the first line
+ $itemkey = $1;
+ $itemvalue = $2;
+
+ # collecting the complete itemvalue
+ do
{
- if ( $searchitem eq "Module" ) # more than one line, for instance files at modules!
- {
- if (( $line =~ /^\s*(.+?)\s*\=\s*\(/ ) && (!($line =~ /\)\;\s*$ / )))
- {
- if ( $line =~ /^\s*(.+?)\s*\=\s*(.+)/ ) # the first line
- {
- $itemkey = $1;
- $itemvalue = $2;
- $itemvalue =~ s/\s*$//;
- }
-
- # collecting the complete itemvalue
-
- $valuecounter = $counter;
- $line = ${$scriptref}[$valuecounter];
- installer::remover::remove_leading_and_ending_whitespaces(\$line);
- $itemvalue = $itemvalue . $line;
-
- while (!( $line =~ /\)\;\s*$/ ))
- {
- $valuecounter++;
- $line = ${$scriptref}[$valuecounter];
- installer::remover::remove_leading_and_ending_whitespaces(\$line);
- $itemvalue = $itemvalue . $line;
- }
-
- # removing ending ";"
- $itemvalue =~ s/\;\s*$//;
-
- $oneitemhash{$itemkey} = $itemvalue;
-
- if ( $itemkey =~ /^\s*\S+\s+\(\S+\)\s*$/ )
- {
- $ismultilang = 1;
- }
- }
+ if ( $i >= $#{$scriptref} ) {
+ installer::exiter::exit_program("Invalid setup script file. Premature end of file.", "get_all_items_from_script");
}
- }
+ $line = ${$scriptref}[++$i];
+ installer::remover::remove_leading_and_ending_whitespaces(\$line);
+ $itemvalue .= $line;
+ } while (!($line =~ /\)\;\s*$/));
+
+ # removing ending ";"
+ $itemvalue =~ s/\;\s*$//;
+
+ $oneitemhash{$itemkey} = $itemvalue;
+
+ $ismultilang ||= $itemkey =~ /^\S+\s+\(\S+\)$/;
}
-
- $oneitemhash{'ismultilingual'} = $ismultilang;
-
- push(@allitemarray, \%oneitemhash);
}
+
+ $oneitemhash{'ismultilingual'} = $ismultilang+0;
+
+ push(@allitemarray, \%oneitemhash);
}
-
+
return \@allitemarray;
}
More information about the Libreoffice-commits
mailing list