summaryrefslogtreecommitdiffstats
path: root/perl-install/modparm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-09-07 16:04:35 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-09-07 16:04:35 +0000
commitb8f3f1d37183e4ba45a173f1c9800e56daa1fa3a (patch)
tree040821895050aa4365c9e9e72a142dcc5fa3de87 /perl-install/modparm.pm
parent5d31c65a29a5be64fe46946651108e0e13242037 (diff)
downloaddrakx-backup-do-not-use-b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a.tar
drakx-backup-do-not-use-b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a.tar.gz
drakx-backup-do-not-use-b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a.tar.bz2
drakx-backup-do-not-use-b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a.tar.xz
drakx-backup-do-not-use-b8f3f1d37183e4ba45a173f1c9800e56daa1fa3a.zip
no_comment
Diffstat (limited to 'perl-install/modparm.pm')
-rw-r--r--perl-install/modparm.pm65
1 files changed, 20 insertions, 45 deletions
diff --git a/perl-install/modparm.pm b/perl-install/modparm.pm
index a630cdd5c..cfbd063b5 100644
--- a/perl-install/modparm.pm
+++ b/perl-install/modparm.pm
@@ -1,14 +1,20 @@
package modparm;
+use diagnostics;
+use strict;
+
+use common qw(:common);
use log;
+
my %modparm_hash;
sub read_modparm_file($) {
my ($file) = @_;
my @line;
- open F, $file;
+ local *F;
+ open F, $file or log::l("missing $file: $!"), return;
while (<F>) {
chomp;
@line = split ':';
@@ -19,60 +25,29 @@ sub read_modparm_file($) {
desc => $line [4],
};
}
- close F;
}
-sub get_options_result($;$) {
- my ($module,$value) = @_;
- my @names = keys %{$modparm_hash{$module}};
- my $options;
- my $result;
- my $i;
+sub get_options_result($@) {
+ my ($module, @value) = @_;
- for $i (0..$#$value) {
- $result = $ {$value->[$i]};
-
- if ($result != "") {
- $options .= "$names[$i]=$result ";
- }
- }
-
- return $options;
+ mapn {
+ my ($a, $b) = @_;
+ $a ? "$b=$a" : ()
+ } \@value, [ keys %{$modparm_hash{$module}} ];
}
sub get_options_name($) {
my ($module) = @_;
- my @names = keys %{$modparm_hash{$module}};
- my @result;
- my $opttype;
- my $default;
+ my @names;
- foreach (@names) {
- $opttype = $modparm_hash{$module}{$_}{type};
- $default = $modparm_hash{$module}{$_}{default};
+ %modparm_hash or return;
- if (defined($default)) {
- push @result, _("$_ ($opttype)[$default]");
- } else {
- push @result, _("$_ ($opttype)");
- }
+ while (my ($k, $v) = each %{$modparm_hash{$module} || {}}) {
+ my $opttype = $v->{type};
+ my $default = $v->{default};
+ push @names, "$k ($v->{type})" . (defined($v->{default}) && "[$v->{default}]");
}
-
- return \@result;
-}
-
-sub get_options_value($) {
- my ($module) = @_;
- my @names = keys %{$modparm_hash{$module}};
- my @result;
-
- for $i (0..$#names) {
- my $value = "";
-
- $result[$i] = \$value;
- }
-
- return \@result;
+ @names;
}
read_modparm_file("/tmp/modparm.txt");