From 27e78b3812d39874a6db249fda63f0e7b20dce71 Mon Sep 17 00:00:00 2001 From: minima Date: Sun, 16 Jan 2005 22:21:44 +0000 Subject: [PATCH] fix apropos command --- Changes | 3 +++ cmd/Commands_en.hlp | 2 ++ cmd/Commands_es.hlp | 18 ++++++++---------- cmd/apropos.pl | 43 +++++++++++++++++++++++-------------------- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Changes b/Changes index c57d115a..ef607888 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,9 @@ 1. Added the changes to Canadian Prefixes so that usdbraw.gz from Charlie K1XX's website (http://dxc.k1xx.com/download) dated after 1Jan05 will include Canadian city and province data as well the existing US data. +2. Improve the apropos command to take better account of language and do +a better job of only showing english stuff for commands where there really is +no local language version. 15Jan05======================================================================= 1. knocked over a few possible ways of people annoying other people thru the use of scripts diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index dfdf9292..6c6cdb90 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -9,6 +9,8 @@ # if the command ends in a - then that line isn't printed, but any # subsequent lines are # +# $Id$ +# # Comment lines are indented before printing # === 0^ACCEPT^Set a filter to accept something diff --git a/cmd/Commands_es.hlp b/cmd/Commands_es.hlp index d7147319..aad73293 100644 --- a/cmd/Commands_es.hlp +++ b/cmd/Commands_es.hlp @@ -9,6 +9,8 @@ # if the command ends in a - then that line isn't printed, but any # subsequent lines are # +# $Id$ +# # Comment lines are indented before printing # === 0^ACCEPT^Define un filtro para aceptar algo @@ -1739,8 +1741,8 @@ en modo de SOLO-RECIBIR no pudiendo usar los comandos DX, ANN, etc. La única excepción que se le hace a un usuario no registrado es la de poder enviar un TALK o un mensaje al sysop. -=== 6^SET/STARTUP Crea un fichero de inicio de conexión para un usuario. -=== 0^SET/STARTUP Crea tu propio fichero de inicio de conexión. +=== 6^SET/STARTUP ^Crea un fichero de inicio de conexión para un usuario. +=== 0^SET/STARTUP^Crea tu propio fichero de inicio de conexión. Crea un fichero de conexión con los comandos del cluster que se ejecutarán cada vez que conectes. Sólo se puede crear el fichero completo, no pudiéndolo editar parcialmente. Hacer un fichero @@ -1755,12 +1757,8 @@ m Puedes borrar tu fichero de conexión con el comando UNSET/STARTUP. -SHOW/STARTUP Ver el fichero de inicio de conexión de un usuario. -SHOW/STARTUP Ver tu propio fichero de inicio de conexión - Para ver el contenido del fichero de conexión creado con SET/STARTUP. - -=== 6^UNSET/STARTUP Borra el fichero de inicio de conexión de un usuario -=== 0^UNSET/STARTUP Borra tu fichero de inicio de conexión. +=== 6^UNSET/STARTUP ^Borra el fichero de inicio de conexión de un usuario +=== 0^UNSET/STARTUP^Borra tu fichero de inicio de conexión. Puedes borrar tu fichero de conexión con el comando UNSET/STARTUP. === 0^SET/TALK^Acepta mensajes TALK @@ -2142,8 +2140,8 @@ especifiques. podr sh/route n2tly -=== 6^SHOW/STARTUP Ver el fichero de inicio de conexión de un usuario. -=== 0^SHOW/STARTUP Ver tu propio fichero de inicio de conexión +=== 6^SHOW/STARTUP ^Ver el fichero de inicio de conexión de un usuario. +=== 0^SHOW/STARTUP^Ver tu propio fichero de inicio de conexión Para ver el contenido del fichero de conexión creado con SET/STARTUP. === 0^SHOW/SATELLITE [ ]^Muestra datos de seguimiento diff --git a/cmd/apropos.pl b/cmd/apropos.pl index ac1d0f60..20775dd9 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 @@ -15,11 +14,13 @@ my @out; my $lang = $self->lang; $lang = 'en' if !$lang; +print "$line\n"; my $in; $line = 'help' unless $line; $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; @@ -40,25 +41,22 @@ if ($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 @@ -69,23 +67,28 @@ if ($h) { 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; -- 2.34.1