summaryrefslogtreecommitdiffstats
path: root/MDK/Common
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-02-16 13:15:57 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-02-16 13:15:57 +0000
commit96a33323d9fa207c767a28cb6323b7e2e6f7855d (patch)
treee39edfc376cd8f67a796dd8d83e16f563ca4437f /MDK/Common
parentcc7b8085cd234c4e8478a2f0d459c4fa922cfc28 (diff)
downloadperl-MDK-Common-96a33323d9fa207c767a28cb6323b7e2e6f7855d.tar
perl-MDK-Common-96a33323d9fa207c767a28cb6323b7e2e6f7855d.tar.gz
perl-MDK-Common-96a33323d9fa207c767a28cb6323b7e2e6f7855d.tar.bz2
perl-MDK-Common-96a33323d9fa207c767a28cb6323b7e2e6f7855d.tar.xz
perl-MDK-Common-96a33323d9fa207c767a28cb6323b7e2e6f7855d.zip
(update_gnomekderc): rework it, make it work in all possible case
Diffstat (limited to 'MDK/Common')
-rw-r--r--MDK/Common/System.pm45
1 files changed, 26 insertions, 19 deletions
diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm
index 4bbedba..b01a523 100644
--- a/MDK/Common/System.pm
+++ b/MDK/Common/System.pm
@@ -155,7 +155,6 @@ package MDK::Common::System;
use MDK::Common::Math;
use MDK::Common::File;
-use MDK::Common::Func qw(map_each);
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK %compat_arch $printable_chars $sizeof_int $bitof_int); #);
@ISA = qw(Exporter);
@@ -325,25 +324,33 @@ sub template2userfile {
}
}
sub update_gnomekderc {
- my ($file, $category, %subst) = @_;
-
- MDK::Common::File::output($file,
- (map {
- my $l = $_;
- s/^\s*//;
- if (my $i = /^\[$category\]/i ... /^\[/) {
- if ($i =~ /E/) { #- for last line of category
- $l = join('', map_each { "$::a=$::b\n" } %subst) . $l;
- %subst = ();
- } elsif (/^(\w*?)=/) {
- if (my $e = delete $subst{lc($1)}) {
- $l = "$1=$e\n";
- }
+ my ($file, $category, %subst_) = @_;
+
+ my %subst = map { lc($_) => [ $_, $subst_{$_} ] } keys %subst_;
+
+ my $s;
+ foreach (MDK::Common::File::cat_($file), "[NOCATEGORY]\n") {
+ if (my $i = /^\s*\[$category\]/i ... /^\[/) {
+ if ($i =~ /E/) { #- for last line of category
+ $s .= "$_->[0]=$_->[1]\n" foreach values %subst;
+ %subst = ();
+ } elsif (/^\s*(\w*?)=/) {
+ if (my $e = delete $subst{lc($1)}) {
+ $_ = "$1=$e->[1]\n";
+ }
}
- }
- $l;
- } MDK::Common::File::cat_($file)),
- (%subst && "[$category]\n", map_each { "$::a=$::b\n" } %subst)); #- if category has not been found above.
+ }
+ $s .= $_ if !/^\Q[NOCATEGORY]/;
+ }
+
+ #- if category has not been found above.
+ if (%subst) {
+ $s .= "[$category]\n";
+ $s .= "$_->[0]=$_->[1]\n" foreach values %subst;
+ }
+
+ MDK::Common::File::output($file, $s);
+
}
1;