Patch for lftp 3.7.14

"Ganael LAPLANCHE" <[email protected]> Mon, 20 Jul 2009 14:43:31 +0200 (CEST)
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
Hi everybody,

(originally posted to lftp@, but lftp-devel@ seems to be better, so this is a
kind of repost)

On FreeBSD, the 'help' command makes lftp 3.7.14 dump core. Here is a patch to
fix that issue. My previous patch (sent to lftp@) was missing a final endline
character.

Best regards,

Ganaƫl LAPLANCHE
[email protected]
http://www.martymac.com
patch-lftp3.txt (text/plain, 1.1 KB)
--- src/commands.cc.orig	2009-03-20 13:27:03.000000000 +0100
+++ src/commands.cc	2009-07-20 13:37:42.000000000 +0200
@@ -2524,27 +2524,23 @@
 void CmdExec::print_cmd_index()
 {
    int i=0;
-   const char *c1;
+   int j=0;
    const cmd_rec *cmd_table=dyn_cmd_table?dyn_cmd_table.get():static_cmd_table;
    const int count=dyn_cmd_table?dyn_cmd_table.count():1024;
    while(i<count && cmd_table[i].name)
    {
       while(cmd_table[i].name && !cmd_table[i].short_desc)
-	 i++;
-      if(!cmd_table[i].name)
-	 break;
-      c1=cmd_table[i].short_desc;
-      i++;
-      while(cmd_table[i].name && !cmd_table[i].short_desc)
-	 i++;
-      if(cmd_table[i].name)
-      {
-	 printf("\t%-35s %s\n",gettext(c1),gettext(cmd_table[i].short_desc));
-	 i++;
-      }
+	     i++;
+      if(i>=count || !cmd_table[i].name)
+	     break;
+      if(j%2 == 0)
+         printf("\t%-35s ",gettext(cmd_table[i].short_desc));
       else
-	 printf("\t%s\n",_(c1));
+         printf("%s\n",gettext(cmd_table[i].short_desc));
+      i++;
+      j++;
    }
+   if(j%2 == 1) printf("\n");
 }
 
 CMD(help)