bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] ftp 1.5 open - arguments too long?


From: Barry deFreese
Subject: Re: [bug-inetutils] ftp 1.5 open - arguments too long?
Date: Tue, 27 Mar 2007 18:41:22 -0400
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)



Alfred M. Szmidt wrote:
<snip>
This is incorrect. It will change the prompt for all callers for
another().  And you only change the caller at one place, for the
`(to)' prompt.  You should use sprintf and make a new string that
looks like it should in the HAVE_READLINE case.
Is this any better? It still segfaults for me though after connecting to the host.. :-(

Barry


diff -urN inetutils-20070322/ftp/cmds.c 
ftp_readline/inetutils-20070322/ftp/cmds.c
--- inetutils-20070322/ftp/cmds.c       2007-03-21 21:44:58.000000000 -0400
+++ ftp_readline/inetutils-20070322/ftp/cmds.c  2007-03-27 18:30:28.000000000 
-0400
@@ -69,6 +69,10 @@
    system headers on some platforms. */
 #include <glob.h>
 
+#if HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#endif
+
 #include "ftp_var.h"
 
 /* Returns true if STR is entirely lower case.  */
@@ -136,20 +140,48 @@
      char ***pargv;
      char *prompt;
 {
-  int len = strlen (line), ret;
+  int ret, len;
+
+#if HAVE_LIBREADLINE
+  char *l;
+
+/* Add brackets () and space to prompt */
+       char *newprmpt = xmalloc (strlen (prompt) + strlen ("() "));
+  sprintf (newprmpt, "(%s) ", prompt);
+  l = readline (newprmpt);
+  if (!l)
+    quit(0, 0);
+
+  line = strcat (line, " ");
+  line = strcat (line, l);
+
+       if (l)
+    free (l);
+
+  if (newprmpt)
+    free (newprmpt);
+
+  if (line && *line)
+    add_history (line);
+
+  len = strlen (line);
+#else
+  len = strlen (line);
 
   if (len >= sizeof (line) - 3)
     {
       printf ("sorry, arguments too long\n");
       intr ();
     }
-  printf ("(%s) ", prompt);
+  printf ("%s", prompt);
   line[len++] = ' ';
   if (fgets (&line[len], sizeof (line) - len, stdin) == NULL)
     intr ();
   len += strlen (&line[len]);
   if (len > 0 && line[len - 1] == '\n')
     line[len - 1] = '\0';
+#endif
+
   makeargv ();
   ret = margc > *pargc;
   *pargc = margc;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]