fix apropos command
authorminima <minima>
Sun, 16 Jan 2005 22:21:44 +0000 (22:21 +0000)
committerminima <minima>
Sun, 16 Jan 2005 22:21:44 +0000 (22:21 +0000)
Changes
cmd/Commands_en.hlp
cmd/Commands_es.hlp
cmd/apropos.pl

diff --git a/Changes b/Changes
index c57d115a3668bb4bcb80c3112cb0873c373a0b2c..ef60788860d912deee841c4ace0947111d82eadc 100644 (file)
--- 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
index dfdf929213b9c0290cb5b256af1c81b979dc1e3b..6c6cdb90fe4baa1af321fefd35cca2461b82182d 100644 (file)
@@ -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
index d7147319fef85abeb9bf524a35fa4d086a17155c..aad73293f66eaea149c437d63ec19e42a89210a1 100644 (file)
@@ -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 <Indicativo> 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 <Indicativo>^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 <Indicativo> 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 <Indicativo> 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 <Indicativo>^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 <Indicativo> 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 <Indicativo>^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 <nombre> [<horas> <intervalo>]^Muestra datos de seguimiento
index ac1d0f609a9ea792e429b5351f8bbe66170803ca..20775dd9bf9ca29f77b54ab2e470bbb19fc24fe9 100644 (file)
@@ -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;