X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fapropos.pl;h=1d6ac6bf5ab73b80715fc41098f81f1e9edea55c;hb=refs%2Fheads%2Fspider;hp=8e4d4eb24fff17d4943e3db394bb13b3038b5771;hpb=d0e9787ea8e709d8cbd91e87e363812e669c0ca6;p=spider.git diff --git a/cmd/apropos.pl b/cmd/apropos.pl index 8e4d4eb2..1d6ac6bf 100644 --- a/cmd/apropos.pl +++ b/cmd/apropos.pl @@ -1,4 +1,3 @@ -# # the help subsystem # # apropos - this does a grep on the command file and returns the commands @@ -6,7 +5,7 @@ # # Copyright (c) 1998 - Dirk Koopman G1TLH # -# $Id$ +# # my ($self, $line) = @_; @@ -15,11 +14,14 @@ my @out; my $lang = $self->lang; $lang = 'en' if !$lang; +#print "$line\n"; my $in; $line = 'help' unless $line; +$line =~ s/\ball\b/.*/; $line =~ s/\W//g; # remove dubious characters +print "$line\n"; -my ($priv, $cmd, $desc); +my ($priv, $cmd, $param, $desc); my %cmd; my $defh = new IO::File; @@ -30,7 +32,7 @@ unless ($defh->open("$main::localcmd/Commands_en.hlp")) { } my $h; -unless ($lang ne 'en') { +if ($lang ne 'en') { $h = new IO::File; unless ($h->open("$main::localcmd/Commands_$lang.hlp")) { unless($h->open("$main::cmd/Commands_$lang.hlp")) { @@ -40,24 +42,22 @@ unless ($lang ne 'en') { } # do english help -my $include; foreach $in (<$defh>) { next if $in =~ /^\#/; chomp $in; + $in =~ s/\r$//; if ($in =~ /^===/) { - $cmd{$cmd} = "$cmd $desc" if $include; - $include = 0; - $in =~ s/=== //; - ($priv, $cmd, $desc) = split /\^/, $in; +# print "$in\n"; + ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)}; + $param ||= ''; + $desc ||= ''; next if $priv > $self->priv; # ignore subcommands that are of no concern - next unless $cmd =~ /$line/i || $desc =~ /$line/i; + next unless $in =~ /$line/i; next if $cmd =~ /-$/o; - $include = 1; + push @{$cmd{$cmd}->{en}}, "$cmd$param $desc"; next; } - $include =~ 1 if $cmd =~ /$line/i; } -$cmd{$cmd} = "$cmd $desc" if $include; $defh->close; # override with any not english help @@ -66,24 +66,30 @@ if ($h) { foreach $in (<$h>) { next if $in =~ /^\#/; chomp $in; + $in =~ s/\r$//; if ($in =~ /^===/) { - $cmd{$cmd} = "$cmd $desc" if $include; - $include = 0; - $in =~ s/=== //; - ($priv, $cmd, $desc) = split /\^/, $in; +# print "$in\n"; + ($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)}; + $param ||= ''; + $desc ||= ''; next if $priv > $self->priv; # ignore subcommands that are of no concern - next unless $cmd =~ /$line/i || $desc =~ /$line/i; + next unless $in =~ /$line/i; next if $cmd =~ /-$/o; - $include = 1; + push @{$cmd{$cmd}->{$lang}}, "$cmd$param $desc"; next; } - $include =~ 1 if $cmd =~ /$line/i; } - $cmd{$cmd} = "$cmd $desc" if $include; $h->close; } -push @out, map {$cmd{$_}} sort keys %cmd; +foreach my $k (sort keys %cmd) { + my $v; + if ($v = $cmd{$k}->{$lang}) { + push @out, @$v; + } elsif ($v = $cmd{$k}->{en}) { + push @out, @$v; + } +} push @out, $self->msg('helpe2', $line) if @out == 0;