SOURCES: fixconfig.pl - added configdo function for finding config...
sparky
sparky at pld-linux.org
Sun Oct 23 15:58:11 CEST 2005
Author: sparky Date: Sun Oct 23 13:58:11 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- added configdo function for finding config option
- much nicer select
---- Files affected:
SOURCES:
fixconfig.pl (1.1 -> 1.2)
---- Diffs:
================================================================
Index: SOURCES/fixconfig.pl
diff -u SOURCES/fixconfig.pl:1.1 SOURCES/fixconfig.pl:1.2
--- SOURCES/fixconfig.pl:1.1 Sun Oct 23 02:05:21 2005
+++ SOURCES/fixconfig.pl Sun Oct 23 15:58:06 2005
@@ -8,7 +8,6 @@
#
# TODO:
# - write some doc
-# - better 'select'
# - finish TODO
use strict;
@@ -221,6 +220,22 @@
my $menu = mkmenu("");
undef @source;
+sub configdo($$);
+sub configdo($$) {
+ my ($current, $name) = @_;
+ do {
+ if ( ( $$current{type} eq "config" ) and ( $$current{name} eq $name ) ) {
+ return $current;
+ }
+ if ( defined $$current{body} ) {
+ my $exit;
+ $exit = configdo($$current{body}, $name);
+ return $exit if defined $exit;
+ }
+ } while ( (defined $$current{next}) and ($current = $$current{next}) );
+ return undef;
+}
+
# read config file
my %orig;
my @orig;
@@ -384,7 +399,13 @@
}
}
if ( defined $$current{select} ) {
- print $B . $step . $ns . "$e`- SELECTS: $$current{select}\n";
+ print $B . $step . $ns . "$e`- SELECTS: ";
+ foreach my $select ( split /\s+/, $$current{select} ) {
+ my $c = $g;
+ $c = $r if (not defined $config{$select} ) or ($config{$select} eq "n");
+ print $c . $select . $e . " ";
+ }
+ print "\n";
}
my $opt;
@@ -417,23 +438,24 @@
} while ($more);
if ( $opt ne "\033" ) {
$orig{$$current{name}} = $opt;
- if ( defined $$current{select} ) {
- unless ( $opt =~ /^(n|0|0x0)$/ ) {
- $opt = "y" unless $opt eq "m";
- my $warn = 0;
- foreach my $option (split /\s+/, $$current{select}) {
- if ( (not defined $config{$option} ) or ($config{$option} eq "n") ) {
- print $B . $step . $ns . "$e`- $r${B}WARNING:$e selecting `$option' (=$opt)\n";
- $warn = 1;
- $orig{$option} = $opt;
- }
- }
- if ($warn) {
- sleep 3;
+ if ( ( defined $$current{select} ) and ( $opt !~ /^(n|0|0x0)$/ ) ) {
+ my $warn = 0;
+ foreach my $option (split /\s+/, $$current{select}) {
+ if ( (not defined $config{$option} ) or ($config{$option} eq "n") ) {
+ my $conf = configdo($menu, $option);
+ my $mark = "y";
+ $mark = "m" if $$conf{chtype} eq "tristate";
+
+ print $B . $step . $ns . "$e`- $r${B}WARNING:$e selecting `$option' (=$mark)\n";
+ $warn = 1;
+ $orig{$option} = $mark;
}
}
+ if ($warn) {
+ sleep 3;
+ }
}
- %config = ( %orig, %add);
+ %config = (%orig, %add);
}
}
}
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/fixconfig.pl?r1=1.1&r2=1.2&f=u
More information about the pld-cvs-commit
mailing list