commit-inetutils
[Top][All Lists]
Advanced

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

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-197-gd94aa


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-197-gd94aaf6
Date: Thu, 01 Nov 2012 21:02:18 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d94aaf66915ccc93e913368bc7382c6fda6630bd (commit)
       via  78b2623dd4cdf4f66397ee6a68b6661b7ffde2ce (commit)
       via  1c6c243965ba2e2e795105ff0fc78aea2742e8a8 (commit)
      from  e1c5c5849a6a26e52d32cfd5c9d75d881a9c497f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d94aaf66915ccc93e913368bc7382c6fda6630bd


commit d94aaf66915ccc93e913368bc7382c6fda6630bd
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Nov 1 21:52:23 2012 +0100

    ftp: Building with readline is optional.

diff --git a/ChangeLog b/ChangeLog
index 38e771e..ffc7b76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2012-10-01  Mats Erik Andersson  <address@hidden>
+
+       ftp: Build without readline support.
+
+       * configure.ac <enable_ftp>: Remove test for disabling
+       FTP client based on `$gl_cv_lib_readline = no'.
+       * am/readline.m4 (gl_FUNC_READLINE): Create option
+       `--disable-readline' using AC_ARG_ENABLE([readline]).
+       (HAVE_READLINE): Demand also `$enable_readline = yes`.
+       * ftp/cmds.c [HAVE_READLINE_READLINE_H]: Inclusion guard
+       for <readline/readline.h>.
+       [HAVE_READLINE_HISTORY_H]: Guard <readline/history.h>.
+       (another) [HAVE_READLINE]: Conditional use of readline()
+       and of add_history().
+       * ftp/main.c [HAVE_READLINE_READLINE_H]: Inclusion guard
+       for <readline/readline.h>.
+       [HAVE_READLINE_HISTORY_H]: Guard <readline/history.h>.
+       (argp_options) [!HAVE_READLINE]: Alternate description
+       for `-e/--no-edit'.
+       (cmdscanner) [HAVE_READLINE]: Conditional use of readline()
+       and of add_history().
+
 2012-10-30  Mats Erik Andersson  <address@hidden>
 
        * tests/readutmp.c: New file.
diff --git a/NEWS b/NEWS
index 6631509..b29896e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ Please send inetutils bug reports to <address@hidden>.
 
 * New tool 'dnsdomainname'.
 
+* ftp
+
+Called as `pftp', passive mode is preset.  New switch `-e/--no-edit'
+for compatibility with other implementations.  Can now be built
+without readline ability: configure using `--disable-readline'.
+
 
 January 6, 2012
 Version 1.9.1:
diff --git a/am/readline.m4 b/am/readline.m4
index e8704bc..be4ce86 100644
--- a/am/readline.m4
+++ b/am/readline.m4
@@ -14,6 +14,12 @@ AC_DEFUN([gl_FUNC_READLINE],
   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
   AC_REQUIRE([AC_LIB_RPATH])
 
+  dnl Allow disabling the use of libreadline.
+  AC_ARG_ENABLE([readline],
+    AC_HELP_STRING([--disable-readline],
+                  [do not build against libreadline]), ,
+    [enable_readline=yes])
+
   dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
   dnl INCREADLINE accordingly.
   AC_LIB_LINKFLAGS_BODY([readline])
@@ -68,7 +74,8 @@ AC_DEFUN([gl_FUNC_READLINE],
     LIBREADLINE=-ledit
   fi
 
-  if test "$gl_cv_lib_readline" != no; then
+  if test "$enable_readline" = "yes" \
+     && test "$gl_cv_lib_readline" != no; then
     AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.])
     extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'`
     if test -n "$extra_lib"; then
diff --git a/configure.ac b/configure.ac
index 11f23d0..c37b828 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,13 +161,10 @@ AC_SEARCH_LIBS([getpeername], [socket])
 # See if a termcap library is available (under one of several names)
 IU_LIB_TERMCAP
 
-# Find libreadline -- disable the ftp client if not found.
+# Find libreadline -- the ftp client will be built without
+# command editing and history capability if readline() cannot
+# be found, neither in libreadline, nor in libedit.
 gl_FUNC_READLINE
-if test "$gl_cv_lib_readline" = no; then
-  enable_ftp=no
-  ftp_BUILD=''
-  ftp_INSTALL_HOOK=''
-fi
 
 # See if there's a separate libcrypt (many systems put crypt there).
 AC_CHECK_LIB(crypt, crypt, LIBCRYPT=-lcrypt)
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 6121c7a..9886fd2 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -78,8 +78,12 @@
    system headers on some platforms. */
 #include <glob.h>
 
-#include <readline/readline.h>
-#include <readline/history.h>
+#ifdef HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#endif
+#ifdef HAVE_READLINE_HISTORY_H
+# include <readline/history.h>
+#endif
 
 #include "ftp_var.h"
 #include "unused-parameter.h"
@@ -151,9 +155,11 @@ another (int *pargc, char ***pargv, const char *prompt)
 
   sprintf (buffer, "(%s) ", prompt);
 
+#if HAVE_READLINE
   if (usereadline)
     arg = readline (buffer);
   else
+#endif /* HAVE_READLINE */
     {
       char *nl;
 
@@ -174,8 +180,10 @@ another (int *pargc, char ***pargv, const char *prompt)
 
   free (buffer);
 
+#if HAVE_READLINE
   if (usereadline && arg && *arg)
     add_history (arg);
+#endif /* HAVE_READLINE */
 
   if (!arg)
     intr (0);
diff --git a/ftp/main.c b/ftp/main.c
index a15c92e..7ccb967 100644
--- a/ftp/main.c
+++ b/ftp/main.c
@@ -77,8 +77,12 @@
 #include "libinetutils.h"
 #include "unused-parameter.h"
 
-#include <readline/readline.h>
-#include <readline/history.h>
+#ifdef HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#endif
+#ifdef HAVE_READLINE_HISTORY_H
+# include <readline/history.h>
+#endif
 
 
 #define DEFAULT_PROMPT "ftp> "
@@ -94,7 +98,13 @@ enum {
 static struct argp_option argp_options[] = {
 #define GRP 0
   {"debug", 'd', NULL, 0, "set the SO_DEBUG option", GRP+1},
-  {"no-edit", 'e', NULL, 0, "disable command line editing", GRP+1},
+  {"no-edit", 'e', NULL, 0,
+#if HAVE_READLINE
+         "disable command line editing",
+#else /* !HAVE_READLINE */
+         "(ignored)",
+#endif /* !HAVE_READLINE */
+         GRP+1},
   {"no-glob", 'g', NULL, 0, "turn off file name globbing", GRP+1},
   {"no-prompt", 'i', NULL, 0, "do not prompt during multiple file transfers",
    GRP+1},
@@ -351,9 +361,11 @@ cmdscanner (int top)
          len = 0;
        }
 
+#if HAVE_READLINE
       if (usereadline)
        line = readline (prompt);
       else
+#endif /* HAVE_READLINE */
        {
          if (prompt)
            {
@@ -389,8 +401,10 @@ cmdscanner (int top)
          break;
        }
 
+#if HAVE_READLINE
       if (usereadline && line && *line)
        add_history (line);
+#endif /* HAVE_READLINE */
 
       if (l == 0)
        break;

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=78b2623dd4cdf4f66397ee6a68b6661b7ffde2ce


commit 78b2623dd4cdf4f66397ee6a68b6661b7ffde2ce
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Oct 30 11:30:51 2012 +0100

    Test script for read_utmp.

diff --git a/ChangeLog b/ChangeLog
index 02d3ee7..38e771e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-10-30  Mats Erik Andersson  <address@hidden>
+
+       * tests/readutmp.c: New file.
+       * tests/utmp.sh: New file.
+       * tests/Makefile.am (check_PROGRAMS): Add readutmp.
+       (dist_check_SCRIPTS): Add utmp.sh.
+       * tests/.gitignore: Add readutmp to list.
+
 2012-10-29  Mats Erik Andersson  <address@hidden>
 
        ftp: Increase universality by recognizing the alias
diff --git a/tests/.gitignore b/tests/.gitignore
index 51bb74c..fbf984c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,3 +1,4 @@
 localhost
+readutmp
 addrpeek
 tools.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f26247d..b827bf5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,12 +21,12 @@ AM_CPPFLAGS = $(iu_INCLUDES)
 
 LDADD = $(iu_LIBRARIES)
 
-check_PROGRAMS = localhost
+check_PROGRAMS = localhost readutmp
 if ENABLE_inetd
 check_PROGRAMS += addrpeek
 endif
 
-dist_check_SCRIPTS =
+dist_check_SCRIPTS = utmp.sh
 if ENABLE_ping
 dist_check_SCRIPTS += ping-localhost.sh
 endif
diff --git a/tests/readutmp.c b/tests/readutmp.c
new file mode 100644
index 0000000..07d29ad
--- /dev/null
+++ b/tests/readutmp.c
@@ -0,0 +1,90 @@
+/* readutmp - Basic test of existing utmp/utmpx access.
+  Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
+
+  This file is part of GNU Inetutils.
+
+  GNU Inetutils is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or (at
+  your option) any later version.
+
+  GNU Inetutils is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see `http://www.gnu.org/licenses/'. */
+
+/* Written by Mats Erik Andersson.  */
+
+/* Readutmp reads the system's standard UTMP or UTMPX file
+ * and verifies that a spcific user is logged in.
+ *
+ * Invocation:
+ *
+ *    readutmp
+ *    readutmp name
+ *
+ * The first mode investigates the present user.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#include <pwd.h>
+
+#include <progname.h>
+#include <readutmp.h>
+#include <xalloc.h>
+
+int
+main (int argc, char *argv[])
+{
+  STRUCT_UTMP *utmpp, *uptr;
+  struct passwd *pw;
+  char *name;
+  size_t count;
+  int found = 0;
+
+  set_program_name (argv[0]);
+
+  if (argc > 1)
+    pw = getpwnam (argv[1]);
+  else
+    pw = getpwuid (getuid ());
+
+  if (pw)
+    name = xstrdup (pw->pw_name);
+  else
+    {
+      fprintf (stderr, "Unknown user '%s'.\n",
+              (argc > 1) ? argv[1] : "my own UID");
+      return EXIT_FAILURE;
+    }
+
+  if (read_utmp (UTMP_FILE, &count, &utmpp, READ_UTMP_USER_PROCESS))
+    {
+      perror ("read_utmp:");
+      return EXIT_FAILURE;
+    }
+
+  for (uptr = utmpp; uptr < utmpp + count; uptr++)
+    if (!strncmp (name, UT_USER (uptr), sizeof (UT_USER (uptr))))
+      {
+       found = 1;
+       break;
+      }
+
+  if (found)
+    return EXIT_SUCCESS;
+
+  fprintf (stderr, "User '%s' is not logged in.\n", name);
+  return EXIT_FAILURE;
+}
diff --git a/tests/utmp.sh b/tests/utmp.sh
new file mode 100755
index 0000000..f19e467
--- /dev/null
+++ b/tests/utmp.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Inetutils.
+#
+# GNU Inetutils is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Inetutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see `http://www.gnu.org/licenses/'.
+
+# Test to establish functionality of read_utmp() from Gnulib.
+# The functionality is needed by our services syslog and talkd.
+#
+
+. ./tools.sh
+
+READUTMP=${READUTMP:-./readutmp$EXEEXT}
+
+if test ! -x $READUTMP; then
+    echo >&2 "No executable '$READUTMP' present.  Skipping test."
+    exit 77
+fi
+
+if test -n "$VERBOSE"; then
+    set -x
+fi
+
+# Execute READUTMP once without argument, and once with
+# ourself as argument.  Both should succeed, but if either
+# fails report only a skipped test, giving some complimentary
+# explanations.
+
+errno=0
+
+$READUTMP || errno=77
+
+$READUTMP `func_id_user` || errno=77
+
+if test $errno -ne 0; then
+    cat >&2 <<-EOT
+       NOTICE: read_utmp() from Gnulib just failed.  This can be
+       due to running this test in sudo mode, or using a role.
+       Should this script fail while running it as a logged in
+       user, then read_utmp() is indeed broken on this system.
+       Then the present syslog and talkd are not fully functional.
+       You are then welcome to report this failure.
+       EOT
+fi
+
+exit $errno

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=1c6c243965ba2e2e795105ff0fc78aea2742e8a8


commit 1c6c243965ba2e2e795105ff0fc78aea2742e8a8
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Oct 29 22:23:44 2012 +0100

    ftp: Support standard options.
    
    Add alias `pftp' and option `-e' for better
    prospects as drop-in replacement.

diff --git a/ChangeLog b/ChangeLog
index 489f5a4..02d3ee7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2012-10-29  Mats Erik Andersson  <address@hidden>
+
+       ftp: Increase universality by recognizing the alias
+       name `pftp' and the option `-e'.
+
+       * ftp/cmds.c (another): New variable SIZE.  Use LEN
+       typed as size_t.  Condition readline() on `usereadline'
+       not `fromatty', otherwise read input based on getline().
+       Likewise, condition add_history() on `usereadline'.
+       (dotrans): Use type size_t for I, OSTOP, FOUND.
+       * ftp/ftp_var.h (usereadline): New variable.
+       * ftp/main.c (argp_options): New option `-e/--no-edit'.
+       (parse_opt) <'e'>: New case.
+       (main): Check if invoked as `pftp', setting passive mode.
+       Clear `usereadline' without a TTY.
+       (cmdscanner): Change L to ssize_t.  New variable LEN.
+       Condition readline() and add_history() on `usereadline',
+       else use a getline() block for input.
+
 2012-10-28  Mats Erik Andersson  <address@hidden>
 
        * ftpd/popen.c (ftpd_popen): Prevent null deference
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 7edf426..626f297 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -903,8 +903,14 @@ network site.  Synopsis:
 
 @example
 ftp address@hidden@dots{}] address@hidden address@hidden
+pftp address@hidden@dots{}] address@hidden address@hidden
 @end example
 
address@hidden
+The alternate name @command{pftp} is starting in passive mode,
+but is otherwise identical to @command{ftp}.
+The available command line options are as follows:
+
 @table @option
 @item -4
 @itemx --ipv4
@@ -922,19 +928,27 @@ Initially set addressing to IPv6 only.
 @itemx --active
 @opindex -A
 @opindex --active
-Enable active mode transfer.
+Enable active mode transfer.  Default mode for @command{ftp}.
 
 @item -p
 @itemx --passive
 @opindex -p
 @opindex --passive
-Enable passive mode transfer.
+Enable passive mode transfer.  Default mode when invoked
+as @command{pftp}.
 
 @item -d
 @itemx --debug
 @opindex -d
 @opindex --debug
-Enables debugging.
+Enables socket debugging.
+
address@hidden -e
address@hidden --no-edit
address@hidden -e
address@hidden --no-edit
+Disables the editing of commands.  This is default setting
+for batch mode, without a TTY.
 
 @item -g
 @itemx --no-glob
@@ -968,10 +982,17 @@ supplied, its value is used instead of the default 
@samp{ftp> }.
 Notice, that the argument is optional.
 
 @item -t
address@hidden --trace
address@hidden --trace
 @opindex -t
 @opindex --trace
 Enable packet tracing.
+
address@hidden -v
address@hidden --verbose
address@hidden -v
address@hidden --verbose
+Start in verbose mode, printing informational messages.
+This is default for interactive mode.
 @end table
 
 @menu
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 3e1328f..6121c7a 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -140,9 +140,10 @@ char *mapout = 0;
 int
 another (int *pargc, char ***pargv, const char *prompt)
 {
-  char *arg;
+  char *arg = NULL;
   char *buffer;
-  int len = strlen (line), ret;
+  size_t size = 0, len = strlen (line);
+  int ret;
 
   buffer = (char *) malloc (sizeof (char) * (strlen (prompt) + 4));
   if (!buffer)
@@ -150,10 +151,30 @@ another (int *pargc, char ***pargv, const char *prompt)
 
   sprintf (buffer, "(%s) ", prompt);
 
-  arg = readline (buffer);
+  if (usereadline)
+    arg = readline (buffer);
+  else
+    {
+      char *nl;
+
+      fprintf (stdout, "%s", buffer);
+      fflush (stdout);
+
+      if (getline (&arg, &size, stdin) <= 0)
+       {
+         free (buffer);
+         free (arg);
+         intr (0);
+       }
+
+      nl = strchr (arg, '\n');
+      if (nl)
+       *nl = '\0';
+    }
+
   free (buffer);
 
-  if (fromatty && arg && *arg)
+  if (usereadline && arg && *arg)
     add_history (arg);
 
   if (!arg)
@@ -2080,7 +2101,7 @@ dotrans (char *name)
 {
   char *new = xmalloc (strlen (name) + 1);
   char *cp1, *cp2 = new;
-  int i, ostop, found;
+  size_t i, ostop, found;
 
   for (ostop = 0; *(ntout + ostop) && ostop < sizeof (ntout) - 1; ostop++)
     continue;
diff --git a/ftp/ftp_var.h b/ftp/ftp_var.h
index 6afa945..224669a 100644
--- a/ftp/ftp_var.h
+++ b/ftp/ftp_var.h
@@ -89,6 +89,7 @@ FTP_EXTERN char pasv[64];     /* passive port for proxy data 
connection */
 FTP_EXTERN int passivemode;    /* passive mode enabled */
 FTP_EXTERN int doepsv4;                /* EPSV/EPRT for IPv4 enabled */
 FTP_EXTERN int usefamily;      /* Precondition on an adress family */
+FTP_EXTERN int usereadline;    /* Use readline support, given a TTY.  */
 FTP_EXTERN char *altarg;       /* argv[1] with no shell-like preprocessing  */
 FTP_EXTERN char ntin[17];      /* input translation table */
 FTP_EXTERN char ntout[17];     /* output translation table */
diff --git a/ftp/main.c b/ftp/main.c
index 1c0cdec..a15c92e 100644
--- a/ftp/main.c
+++ b/ftp/main.c
@@ -82,7 +82,7 @@
 
 
 #define DEFAULT_PROMPT "ftp> "
-static char *prompt = 0;
+static char *prompt = NULL;
 
 const char args_doc[] = "[HOST [PORT]]";
 const char doc[] = "Remote file transfer.";
@@ -94,13 +94,15 @@ enum {
 static struct argp_option argp_options[] = {
 #define GRP 0
   {"debug", 'd', NULL, 0, "set the SO_DEBUG option", GRP+1},
+  {"no-edit", 'e', NULL, 0, "disable command line editing", GRP+1},
   {"no-glob", 'g', NULL, 0, "turn off file name globbing", GRP+1},
   {"no-prompt", 'i', NULL, 0, "do not prompt during multiple file transfers",
    GRP+1},
   {"no-login", 'n', NULL, 0, "do not automatically login to the remote system",
    GRP+1},
   {"trace", 't', NULL, 0, "enable packet tracing", GRP+1},
-  {"passive", 'p', NULL, 0, "enable passive mode transfer", GRP+1},
+  {"passive", 'p', NULL, 0,
+   "enable passive mode transfer, default for `pftp'", GRP+1},
   {"active", 'A', NULL, 0, "enable active mode transfer", GRP+1},
   {"prompt", OPT_PROMPT, "PROMPT", OPTION_ARG_OPTIONAL, "print a command line 
PROMPT "
    "(optionally), even if not on a tty", GRP+1},
@@ -121,6 +123,10 @@ parse_opt (int key, char *arg, struct argp_state *state 
_GL_UNUSED_PARAMETER)
       debug++;
       break;
 
+    case 'e':
+      usereadline = 0; /* No editing.  */
+      break;
+
     case 'g':          /* No glob.  */
       doglob = 0;
       break;
@@ -188,6 +194,16 @@ main (int argc, char *argv[])
   passivemode = 0;             /* passive mode not active */
   doepsv4 = 0;                 /* use EPRT/EPSV for IPv4 */
   usefamily = AF_UNSPEC;       /* allow any address family */
+  usereadline = 1;             /* normally using readline */
+
+  /* Invoked as `pftp'?  Then set passive mode.  */
+  cp = strrchr (argv[0], '/');
+  if (cp)
+    cp++;
+  else
+    cp = argv[0];
+  if (!strcmp ("pftp", cp))
+    passivemode = 1;
 
   /* Parse command line */
   iu_argp_init ("ftp", default_program_authors);
@@ -203,6 +219,8 @@ main (int argc, char *argv[])
       if (!prompt)
        prompt = DEFAULT_PROMPT;
     }
+  else
+    usereadline = 0;
 
   cpend = 0;                   /* no pending replies */
   proxy = 0;                   /* proxy not active */
@@ -319,7 +337,8 @@ void
 cmdscanner (int top)
 {
   struct cmd *c;
-  int l;
+  ssize_t l;
+  size_t len;
 
   if (!top)
     putchar ('\n');
@@ -329,10 +348,40 @@ cmdscanner (int top)
        {
          free (line);
          line = NULL;
+         len = 0;
+       }
+
+      if (usereadline)
+       line = readline (prompt);
+      else
+       {
+         if (prompt)
+           {
+             fprintf (stdout, "%s", prompt);
+             fflush (stdout);
+           }
+
+         l = getline (&line, &len, stdin);
+         if ((l > 0) && line)
+           {
+             char *nl = strchr (line, '\n');
+
+             if (nl)
+               *nl = '\0';
+           }
+         else
+           {
+             free (line);      /* EOF, et cetera */
+             line = NULL;
+           }
+
+         if (!fromatty && prompt)
+           fprintf (stdout, "%s\n", line ? line : "");
        }
-      line = readline (prompt);
+
       if (!line)
        quit (0, 0);
+
       l = strlen (line);
       if (l >= MAXLINE)
        {
@@ -340,7 +389,7 @@ cmdscanner (int top)
          break;
        }
 
-      if (fromatty && line && *line)
+      if (usereadline && line && *line)
        add_history (line);
 
       if (l == 0)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   49 ++++++++++++++++++++++++++++
 NEWS               |    6 +++
 am/readline.m4     |    9 +++++-
 configure.ac       |    9 ++---
 doc/inetutils.texi |   29 ++++++++++++++--
 ftp/cmds.c         |   43 +++++++++++++++++++++----
 ftp/ftp_var.h      |    1 +
 ftp/main.c         |   77 ++++++++++++++++++++++++++++++++++++++++----
 tests/.gitignore   |    1 +
 tests/Makefile.am  |    4 +-
 tests/readutmp.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/utmp.sh      |   59 ++++++++++++++++++++++++++++++++++
 12 files changed, 350 insertions(+), 27 deletions(-)
 create mode 100644 tests/readutmp.c
 create mode 100755 tests/utmp.sh


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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