SVN: vfmg/trunk/vfmg

sparky sparky at pld-linux.org
Mon Dec 4 06:39:29 CET 2006


Author: sparky
Date: Mon Dec  4 06:39:28 2006
New Revision: 8057

Modified:
   vfmg/trunk/vfmg
Log:
- save rc-config sections, for future use


Modified: vfmg/trunk/vfmg
==============================================================================
--- vfmg/trunk/vfmg	(original)
+++ vfmg/trunk/vfmg	Mon Dec  4 06:39:28 2006
@@ -212,23 +212,34 @@
 my @rcFiles = ("/etc/vfmgrc", "$ENV{'HOME'}/.vfmgrc");
 push @rcFiles, "$ENV{'HOME_ETC'}/.vfmgrc" if exists $ENV{'HOME_ETC'};
 
+our %rcSect = ( global => [] );
 my @rcBody;
 foreach my $rc (grep -r, @rcFiles) {
 	open F_IN, $rc or next;
-	my $read = 1;
+	my $sect = "global";
 	while (<F_IN>) {
-		next if ( /^\s*#/ );
-		$_ .= <F_IN> while s/\\\n$//;
-		$read = 0 if /^\[/;
-		if ( /^\[$o_output\]/ ) {
-			$read = 1;
+		if ( /^\[(.*?)\](\s*#.*)?$/ ) {
+			$sect = $1;
+			$rcSect{$sect} = [] unless $sect eq "global";
 			next;
 		}
-		push @rcBody, $_ if $read;
+		push @{$rcSect{$sect}}, $_;
 	}
 	close F_IN;
-}
 
+	my $ll = ""; # last line
+	foreach (
+				@{$rcSect{global}},
+				exists $rcSect{$o_output} ? @{$rcSect{$o_output}} : ()
+			) {
+		next if /^\s*#/;
+		$ll .= $_;
+		unless ( s/\s*\\\n$// ) {
+			push @rcBody, $ll unless $ll =~ s/^\s*$//;
+			$ll = "";
+		}
+	}
+}
 my %rcopt = map { /^\s*(.*?)\s*=\s*(.*)\s*$/ } @rcBody;
 # }}}
 


More information about the pld-cvs-commit mailing list