Searching for a command in help output is much simpler when sorted.
The strings can be inlined into the struct while staying under 80 chars.

Now manual and help output are in the same order, except help folded
into ? in the manual to avoid duplicate text there.

Or should help appear at the same spot to make manual and help output
an exact match order-wise?

Feedback? OK?


Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/tftp/main.c,v
retrieving revision 1.43
diff -u -p -r1.43 main.c
--- main.c      20 Sep 2018 11:42:42 -0000      1.43
+++ main.c      1 Oct 2022 19:18:12 -0000
@@ -109,23 +109,6 @@ int                         opt_tsize = 0;
 int                     opt_tout = 0;
 int                     opt_blksize = 0;
 
-char   vhelp[] = "toggle verbose mode";
-char   thelp[] = "toggle packet tracing";
-char   chelp[] = "connect to remote tftp";
-char   qhelp[] = "exit tftp";
-char   hhelp[] = "print help information";
-char   shelp[] = "send file";
-char   rhelp[] = "receive file";
-char   mhelp[] = "set file transfer mode";
-char   sthelp[] = "show current status";
-char   xhelp[] = "set per-packet retransmission timeout";
-char   ihelp[] = "set total retransmission timeout";
-char   ashelp[] = "set mode to netascii";
-char   bnhelp[] = "set mode to octet";
-char   oshelp[] = "toggle tsize option";
-char   othelp[] = "toggle timeout option";
-char   obhelp[] = "set alternative blksize option";
-
 struct cmd {
        char    *name;
        char    *help;
@@ -133,23 +116,23 @@ struct cmd {
 };
 
 struct cmd cmdtab[] = {
-       { "connect",    chelp,  parsearg },
-       { "mode",       mhelp,  modecmd },
-       { "put",        shelp,  put },
-       { "get",        rhelp,  get },
-       { "quit",       qhelp,  quit },
-       { "verbose",    vhelp,  setverbose },
-       { "trace",      thelp,  settrace },
-       { "status",     sthelp, status },
-       { "binary",     bnhelp, setbinary },
-       { "ascii",      ashelp, setascii },
-       { "rexmt",      xhelp,  setrexmt },
-       { "timeout",    ihelp,  settimeout },
-       { "tsize",      oshelp, settsize },
-       { "tout",       othelp, settout },
-       { "blksize",    obhelp, setblksize },
-       { "help",       hhelp,  help },
-       { "?",          hhelp,  help },
+       { "?",          "print help information",       help },
+       { "ascii",      "set mode to netascii", setascii },
+       { "binary",     "set mode to octet",    setbinary },
+       { "blksize",    "set alternative blksize option",       setblksize },
+       { "connect",    "connect to remote tftp",       parsearg },
+       { "get",        "receive file", get },
+       { "help",       "print help information",       help },
+       { "mode",       "set file transfer mode",       modecmd },
+       { "put",        "send file",    put },
+       { "quit",       "exit tftp",    quit },
+       { "rexmt",      "set per-packet retransmission timeout", setrexmt },
+       { "status",     "show current status",  status },
+       { "timeout",    "set total retransmission timeout",     settimeout },
+       { "tout",       "toggle timeout option",        settout },
+       { "trace",      "toggle packet tracing",        settrace },
+       { "tsize",      "toggle tsize option",  settsize },
+       { "verbose",    "toggle verbose mode",  setverbose },
        { NULL,         NULL,   NULL }
 };
 
Index: tftp.1
===================================================================
RCS file: /cvs/src/usr.bin/tftp/tftp.1,v
retrieving revision 1.20
diff -u -p -r1.20 tftp.1
--- tftp.1      1 May 2012 04:23:21 -0000       1.20
+++ tftp.1      1 Oct 2022 19:18:14 -0000
@@ -62,7 +62,7 @@ is running, it issues the prompt
 and recognizes the following commands:
 .Pp
 .Bl -tag -width verbose -compact
-.It Ic \&? Ar command-name ...
+.It Ic \&? Ns | Ns Ic help Ar command-name ...
 Print help information.
 .Pp
 .It Ic ascii

Reply via email to