summaryrefslogtreecommitdiffstats
path: root/perl-install/modparm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-04 22:06:41 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-04 22:06:41 +0000
commit285c6b23d68eb69dd6109637ce3e447ea434d21c (patch)
treed6148faba019cfae55628e675875bba99697fe2f /perl-install/modparm.pm
parent572d43287e28808396239180e04128908b95dfef (diff)
downloaddrakx-285c6b23d68eb69dd6109637ce3e447ea434d21c.tar
drakx-285c6b23d68eb69dd6109637ce3e447ea434d21c.tar.gz
drakx-285c6b23d68eb69dd6109637ce3e447ea434d21c.tar.bz2
drakx-285c6b23d68eb69dd6109637ce3e447ea434d21c.tar.xz
drakx-285c6b23d68eb69dd6109637ce3e447ea434d21c.zip
rework, cleanup, simplify and make it work
Diffstat (limited to 'perl-install/modparm.pm')
-rw-r--r--perl-install/modparm.pm90
1 files changed, 55 insertions, 35 deletions
diff --git a/perl-install/modparm.pm b/perl-install/modparm.pm
index 5432ea762..849cc40a1 100644
--- a/perl-install/modparm.pm
+++ b/perl-install/modparm.pm
@@ -2,57 +2,77 @@ package modparm; # $Id$
use diagnostics;
use strict;
-use modules;
#-######################################################################################
#- misc imports
#-######################################################################################
use common;
-use log;
-
+use modules;
-sub get_options_result($@) {
- my ($module, @value) = @_;
- mapn {
- my ($a, $b) = @_;
- $b =~ s/^(\w+).*/$1/;
- $a ? "$b=$a" : ();
- } \@value, [get_options_name($module)];
-}
-sub get_options_name($) {
+sub parameters {
my ($module) = @_;
- my @names;
- $modinfo = $::isStandalone ? '/sbin/modinfo' : '/usr/bin/modinfo';
- -e $modinfo or die _('modinfo is not available');
- my @line;
- if ($::isStandalone) {
- @line = `$modinfo -p $module`;
- } else {
+ my $modinfo = '/sbin/modinfo';
+ -x $modinfo or $modinfo = '/usr/bin/modinfo';
+ -x $modinfo or die _('modinfo is not available');
+
+ if (!$::isStandalone && !$::testing) {
modules::extract_modules('/tmp', $module);
- @line = `$modinfo -p /tmp/$module.o`;
+ $module = "/tmp/$module.o";
}
- foreach (@line) {
+
+ my @parameters;
+ foreach (join_lines(`$modinfo -p $module`)) {
chomp;
- s/int/: (integer/;
- s/string/: (string/;
- my ($f, $g) = /array \(min = (\d+), max = (\d+)\)/;
- my $c;
- if ($f == 1 && $g == 1) {
- $c = _('1 character)');
+ next if /^warning:/;
+ (my $name, $_) = /(\S+)\s+(.*)/s or warn "modparm::get_options_name($module): unknown line\n";
+
+ my $c_types = 'int|string|short|byte|char|long';
+ my ($is_a_number, $description, $min, $max) = (0, '', 1, 1);
+ if (/^($c_types) array \(min = (\d+), max = (\d+)\),?\s*(.*)/s) {
+ $_ = $4;
+ #- seems like "char" are buggy entries
+ ($is_a_number, $min, $max) = ($1 ne 'string', $2, $3) if $1 ne 'char';
+ } elsif (/^($c_types),?\s*(.*)/s) {
+ $_ = $2;
+ #- here "char" really are size-limited strings, modinfo doesn't display the size limit (but since we don't care about it, it doesn't matter :)
+ $is_a_number = $1 ne 'string' if $1 ne 'char';
} else {
- $c = sprintf("$f-$g %s)", _('characters'));
+ #- for things like "no format character" or "unknown format character"
}
- s/array \(min = \d+, max = \d+\)/$c/;
- if (/parm:\s+(.+)/) {
- local $_ = $1;
- s/\s+/ /;
- s/, description /TOOLTIP=>/;
- push @names, $_;
+ if (/^description "(.*)",?\s*/s) {
+ ($description, $_) = ($1, $2);
}
+ #- print "STILL HAVE ($_)\n" if $_;
+
+ my $format =
+ $min == 1 && $max == 1 ?
+ ($is_a_number ? _("a number") : '') :
+ $min == $max ?
+ ($is_a_number ? _("%d comma separated numbers", $min) : _("%d comma separated strings", $min)) :
+ $min == 1 ?
+ ($is_a_number ? _("comma separated numbers") : _("comma separated strings")) :
+ ''; #- to weird and buggy, do not display it
+
+ push @parameters, [ $format ? "$name ($format)" : $name, $description ];
}
- @names;
+ @parameters;
+}
+
+
+sub join_lines {
+ my @l;
+ my $s;
+ foreach (@_) {
+ if (/^\s/) {
+ $s .= $_;
+ } else {
+ push @l, $s if $s;
+ $s = $_;
+ }
+ }
+ @l, if_($s, $s);
}
1;