summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2004-02-10 13:30:46 +0000
committerRüdiger Timm <rt@openoffice.org>2004-02-10 13:30:46 +0000
commitcddb8c877669737df65ed909faf1454aebf34c2d (patch)
treec020ba9dac7931b83c13a3fa3a005763f2a0cb29 /solenv
parent6da3fa1afb3044e38133575367552451fc1f48ab (diff)
INTEGRATION: CWS newscp2 (1.2.2); FILE MERGED
2004/02/05 12:28:10 is 1.2.2.1: Issue number: Submitted by: Reviewed by:
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/modules/par2script/work.pm73
1 files changed, 53 insertions, 20 deletions
diff --git a/solenv/bin/modules/par2script/work.pm b/solenv/bin/modules/par2script/work.pm
index a94032c6c84c..f9cf2f4b2337 100644
--- a/solenv/bin/modules/par2script/work.pm
+++ b/solenv/bin/modules/par2script/work.pm
@@ -2,9 +2,9 @@
#
# $RCSfile: work.pm,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: kz $ $Date: 2004-01-29 11:46:35 $
+# last change: $Author: rt $ $Date: 2004-02-10 14:30:46 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -180,7 +180,7 @@ sub make_complete_pathes_for_parfiles
sub put_item_into_collector
{
- my ( $item, $parfile, $collector, $parfilename ) = @_;
+ my ( $item, $parfile, $collector ) = @_;
my $include = 0;
@@ -505,13 +505,11 @@ sub set_scriptversion_into_installation_object
sub collect_all_items
{
- my ($parfiles) = @_;
+ my ($parfile) = @_;
my @setupscript = ();
my $setupscript = \@setupscript;
- my %allitemshash = ();
-
for ( my $i = 0; $i <= $#par2script::globals::allitems; $i++ )
{
my $oneitem = $par2script::globals::allitems[$i];
@@ -519,11 +517,7 @@ sub collect_all_items
my @itemcollector = ();
my $itemcollector = \@itemcollector;
- for ( my $j = 0; $j <= $#{$parfiles}; $j++ )
- {
- my $parfile = par2script::files::read_file(${$parfiles}[$j]);
- put_item_into_collector($oneitem, $parfile, $itemcollector, ${$parfiles}[$j]);
- }
+ put_item_into_collector($oneitem, $parfile, $itemcollector);
# testing uniqueness of each gid
@@ -626,15 +620,19 @@ sub add_definitionblock_into_script
}
}
- $insertline = $insertline + 2;
-
if ( $insertline != -1 )
{
+ $insertline = $insertline + 2;
# inserting an empty line at the end of the block if required
if (!(${$newblock}[$#{$newblock}] =~ /^\s*$/)) { push(@{$newblock}, "\n"); }
# inserting the new block
splice( @{$script}, $insertline, 0, @{$newblock} );
}
+ else
+ {
+ die "ERROR: Could not include definition block. Found no definition of $gid!\n";
+ }
+
}
############################################
@@ -650,7 +648,7 @@ sub remove_definitionblock_from_script
for ( my $i = 0; $i <= $#{$script}; $i++ )
{
- if ( ${$script}[$i] =~ /^\s*\w+\s+$gid\s*$/ )
+ if ( ${$script}[$i] =~ /^\s*\w+\s+$gid\s*$/i )
{
$startline = $i;
last;
@@ -659,16 +657,16 @@ sub remove_definitionblock_from_script
if ( $startline != -1 )
{
- while (! ( ${$script}[$startline] =~ /^\s*End\s*$/i ) )
+ my $endline = $startline;
+
+ while (! ( ${$script}[$endline] =~ /^\s*End\s*$/i ) )
{
- splice(@{$script}, $startline, 1);
- # $startline++; # keeping the number constant!
+ $endline++;
}
- splice(@{$script}, $startline, 1); # removing the line "End"
- splice(@{$script}, $startline, 1); # removing the next empty line
+ my $blocklength = $endline - $startline + 2; # "+2" because of endline and emptyline
+ splice(@{$script}, $startline, $blocklength);
}
-
}
############################################
@@ -697,4 +695,39 @@ sub get_value_from_definitionblock
return $value;
}
+##################################################
+# Collecting the content of all par files.
+# Then the files do not need to be opened twice.
+##################################################
+
+sub read_all_parfiles
+{
+ my ($parfiles) = @_;
+
+ my @parfilecontent = ();
+
+ for ( my $i = 0; $i <= $#{$parfiles}; $i++ )
+ {
+ my $parfile = par2script::files::read_file(${$parfiles}[$i]);
+ add_array_into_array(\@parfilecontent, $parfile);
+ push(@parfilecontent, "\n");
+ }
+
+ return \@parfilecontent;
+}
+
+##########################################################
+# Add the content of an array to another array
+##########################################################
+
+sub add_array_into_array
+{
+ my ($basearray, $newarray) = @_;
+
+ for ( my $i = 0; $i <= $#{$newarray}; $i++ )
+ {
+ push(@{$basearray}, ${$newarray}[$i]);
+ }
+}
+
1;