summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-05-19 14:17:09 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-05-19 14:17:09 +0000
commit0d5106d1fc7aed594dd31930583fe7f62a3ec966 (patch)
treed42e3fb1dd2700feee1d1e83a3beeb4213df4d7a /perl-install/printer
parent78dd1c5b452725709f60ea017882031a4cab38e5 (diff)
downloaddrakx-backup-do-not-use-0d5106d1fc7aed594dd31930583fe7f62a3ec966.tar
drakx-backup-do-not-use-0d5106d1fc7aed594dd31930583fe7f62a3ec966.tar.gz
drakx-backup-do-not-use-0d5106d1fc7aed594dd31930583fe7f62a3ec966.tar.bz2
drakx-backup-do-not-use-0d5106d1fc7aed594dd31930583fe7f62a3ec966.tar.xz
drakx-backup-do-not-use-0d5106d1fc7aed594dd31930583fe7f62a3ec966.zip
(gimp::pop_spaces): consolidate skipping of lines that are space ended
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/gimp.pm17
1 files changed, 9 insertions, 8 deletions
diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm
index dd36a514b..bb9f00b31 100644
--- a/perl-install/printer/gimp.pm
+++ b/perl-install/printer/gimp.pm
@@ -257,8 +257,7 @@ sub addentry {
my ($section, $entry, $filecontent) = @_;
my $sectionfound = 0;
my $entryinserted = 0;
- my @lines = split("\n", $filecontent);
- while ($lines[-1] !~ /\S/) { pop @lines; }
+ my @lines = pop_spaces(split("\n", $filecontent));
foreach (@lines) {
if (!$sectionfound) {
$sectionfound = 1 if /^\s*Printer\s*:\s*($section)\s*$/;
@@ -276,8 +275,7 @@ sub addentry {
sub addprinter {
my ($section, $filecontent) = @_;
- my @lines = split("\n", $filecontent);
- while ($lines[-1] !~ /\S/) { pop @lines; }
+ my @lines = pop_spaces(split("\n", $filecontent));
foreach (@lines) {
# section already there, nothing to be done
return $filecontent if /^\s*Printer\s*:\s*($section)\s*$/;
@@ -285,11 +283,15 @@ sub addprinter {
return $filecontent . "\nPrinter: $section\n";
}
+sub pop_spaces {
+ my @lines = @_;
+ pop @lines while $lines[-1] !~ /\S/;
+}
+
sub removeentry {
my ($section, $entry, $filecontent) = @_;
my $sectionfound;
- my @lines = split(/^/, $filecontent);
- while ($lines[-1] !~ /\S/) { pop @lines; }
+ my @lines = pop_spaces(split(/^/, $filecontent));
foreach (@lines) {
if (!$sectionfound) {
$sectionfound = /^\s*Printer\s*:\s*($section)\s*$/;
@@ -307,8 +309,7 @@ sub removeentry {
sub removeprinter {
my ($section, $filecontent) = @_;
my $sectionfound;
- my @lines = split(/^/, $filecontent);
- while ($lines[-1] !~ /\S/) { pop @lines; }
+ my @lines = pop_spaces(split(/^/, $filecontent));
foreach (@lines) {
if (!$sectionfound) {
if (/^\s*Printer\s*:\s*($section)\s*$/) {