Imported Upstream version 20170329 83/135383/1 upstream upstream/20170329
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 22 Jun 2017 06:54:39 +0000 (15:54 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 22 Jun 2017 06:54:46 +0000 (15:54 +0900)
Change-Id: Ic610563318a1f3148754aa2e75b11039e1e18fc8
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
ChangeLog
configure
configure.ac
src/chartype.c
src/editline/readline.h
src/filecomplete.c
src/hist.c
src/read.c
src/readline.c
src/vis.c

index e29d699..390a251 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
    * See also NetBSD changelog:
        http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit
 
+2017-03-29 Jess Thrysoee
+
+   * version-info: 0:56:0
+
+   * all: sync with upstream source
+
 2016-09-03 Jess Thrysoee
 
    * version-info: 0:55:0
index fe1977e..e2733fb 100755 (executable)
--- a/configure
+++ b/configure
@@ -586,7 +586,7 @@ MAKEFLAGS=
 
 # Identity of this package.
 PACKAGE_NAME='libedit'
-PACKAGE_TARNAME='libedit-20160903'
+PACKAGE_TARNAME='libedit-20170329'
 PACKAGE_VERSION='3.1'
 PACKAGE_STRING='libedit 3.1'
 PACKAGE_BUGREPORT=''
@@ -1374,7 +1374,7 @@ Fine tuning of the installation directories:
   --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
   --mandir=DIR            man documentation [DATAROOTDIR/man]
   --docdir=DIR            documentation root
-                          [DATAROOTDIR/doc/libedit-20160903]
+                          [DATAROOTDIR/doc/libedit-20170329]
   --htmldir=DIR           html documentation [DOCDIR]
   --dvidir=DIR            dvi documentation [DOCDIR]
   --pdfdir=DIR            pdf documentation [DOCDIR]
@@ -4223,7 +4223,7 @@ fi
 
 
 # Define the identity of the package.
- PACKAGE='libedit-20160903'
+ PACKAGE='libedit-20170329'
  VERSION='3.1'
 
 
@@ -12118,7 +12118,7 @@ CC=$lt_save_CC
 
 
 # libtool -version-info
-LT_VERSION=0:55:0
+LT_VERSION=0:56:0
 
 
 # Check whether --enable-silent-rules was given.
index 2a5affa..9a571b2 100644 (file)
@@ -35,7 +35,7 @@ AM_INIT_AUTOMAKE
 AC_PROG_LIBTOOL
 
 # libtool -version-info
-AC_SUBST(LT_VERSION, [0:55:0])
+AC_SUBST(LT_VERSION, [0:56:0])
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
index f350dfd..9288e6b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $   */
+/*     $NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <ctype.h>
@@ -156,7 +156,7 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
                if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
                        return NULL;
 
-       wargv = el_malloc((size_t)argc * sizeof(*wargv));
+       wargv = el_malloc((size_t)(argc + 1) * sizeof(*wargv));
 
        for (i = 0, p = conv->wbuff; i < argc; ++i) {
                if (!argv[i]) {   /* don't pass null pointers to mbstowcs */
@@ -174,6 +174,7 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
                bufspace -= (size_t)bytes;
                p += bytes;
        }
+       wargv[i] = NULL;
 
        return wargv;
 }
index 5d2a17f..777a4c6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.h,v 1.40 2016/08/24 13:10:59 christos Exp $   */
+/*     $NetBSD: readline.h,v 1.41 2016/10/28 18:32:35 christos Exp $   */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -121,6 +121,7 @@ extern Function             *rl_startup_hook;
 extern char            *rl_terminal_name;
 extern int             rl_already_prompted;
 extern char            *rl_prompt;
+extern int             rl_done;
 /*
  * The following is not implemented
  */
index 9cb8de8..a115525 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.43 2016/04/11 00:50:13 christos Exp $       */
+/*     $NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "config.h"
 
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.43 2016/04/11 00:50:13 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -477,8 +477,6 @@ fn_complete(EditLine *el,
                            ct_decode_string(matches[0], &el->el_scratch));
                }
 
-               if (what_to_do == '?')
-                       goto display_matches;
 
                if (matches[2] == NULL &&
                    (matches[1] == NULL || strcmp(matches[0], matches[1]) == 0)) {
@@ -490,8 +488,7 @@ fn_complete(EditLine *el,
                        el_winsertstr(el,
                            ct_decode_string((*app_func)(matches[0]),
                            &el->el_scratch));
-               } else if (what_to_do == '!') {
-    display_matches:
+               } else if (what_to_do == '!' || what_to_do == '?') {
                        /*
                         * More than one match and requested to list possible
                         * matches.
index 9664f9b..3c9db7d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: hist.c,v 1.29 2016/05/09 21:46:56 christos Exp $       */
+/*     $NetBSD: hist.c,v 1.32 2017/03/05 19:23:58 christos Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)hist.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: hist.c,v 1.29 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: hist.c,v 1.32 2017/03/05 19:23:58 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: hist.c,v 1.29 2016/05/09 21:46:56 christos Exp $");
  */
 #include <stdlib.h>
 #include <string.h>
+#include <vis.h>
 
 #include "el.h"
 
@@ -101,6 +102,7 @@ hist_get(EditLine *el)
 {
        const wchar_t *hp;
        int h;
+       size_t blen, hlen;
 
        if (el->el_history.eventno == 0) {      /* if really the current line */
                (void) wcsncpy(el->el_line.buffer, el->el_history.buf,
@@ -126,14 +128,16 @@ hist_get(EditLine *el)
                return CC_ERROR;
 
        for (h = 1; h < el->el_history.eventno; h++)
-               if ((hp = HIST_NEXT(el)) == NULL) {
-                       el->el_history.eventno = h;
-                       return CC_ERROR;
-               }
-       (void) wcsncpy(el->el_line.buffer, hp,
-                       (size_t)(el->el_line.limit - el->el_line.buffer));
-       el->el_line.buffer[el->el_line.limit - el->el_line.buffer - 1] = '\0';
-       el->el_line.lastchar = el->el_line.buffer + wcslen(el->el_line.buffer);
+               if ((hp = HIST_NEXT(el)) == NULL)
+                       goto out;
+
+       hlen = wcslen(hp) + 1;
+       blen = (size_t)(el->el_line.limit - el->el_line.buffer);
+       if (hlen > blen && !ch_enlargebufs(el, hlen))
+               goto out;
+
+       memcpy(el->el_line.buffer, hp, hlen * sizeof(*hp));
+       el->el_line.lastchar = el->el_line.buffer + hlen - 1;
 
        if (el->el_line.lastchar > el->el_line.buffer
            && el->el_line.lastchar[-1] == '\n')
@@ -149,6 +153,10 @@ hist_get(EditLine *el)
                el->el_line.cursor = el->el_line.lastchar;
 
        return CC_REFRESH;
+out:
+       el->el_history.eventno = h;
+       return CC_ERROR;
+
 }
 
 
@@ -166,11 +174,32 @@ hist_command(EditLine *el, int argc, const wchar_t **argv)
                return -1;
 
        if (argc == 1 || wcscmp(argv[1], L"list") == 0) {
+               size_t maxlen = 0;
+               char *buf = NULL;
+               int hno = 1;
                 /* List history entries */
 
-               for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
-                       (void) fprintf(el->el_outfile, "%d %s",
-                           el->el_history.ev.num, ct_encode_string(str, &el->el_scratch));
+               for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el)) {
+                       char *ptr =
+                           ct_encode_string(str, &el->el_scratch);
+                       size_t len = strlen(ptr);
+                       if (len > 0 && ptr[len - 1] == '\n') 
+                               ptr[--len] = '\0';
+                       len = len * 4 + 1;
+                       if (len >= maxlen) {
+                               maxlen = len + 1024;
+                               char *nbuf = el_realloc(buf, maxlen);
+                               if (nbuf == NULL) {
+                                       el_free(buf);
+                                       return -1;
+                               }
+                               buf = nbuf;
+                       }
+                       strvis(buf, ptr, VIS_NL);
+                       (void) fprintf(el->el_outfile, "%d\t%s\n",
+                           hno++, buf);
+               }
+               el_free(buf);
                return 0;
        }
 
index cfab820..ec10be7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.101 2016/05/25 13:01:11 christos Exp $      */
+/*     $NetBSD: read.c,v 1.102 2016/12/11 15:47:06 christos Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)read.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: read.c,v 1.101 2016/05/25 13:01:11 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.102 2016/12/11 15:47:06 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -111,6 +111,7 @@ read_end(struct el_read_t *el_read)
        read_clearmacros(&el_read->macros);
        el_free(el_read->macros.macro);
        el_read->macros.macro = NULL;
+       el_free(el_read);
 }
 
 /* el_read_setfn():
index 27e2ff2..2e0e2c4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.138 2016/09/01 13:23:44 mbalmer Exp $   */
+/*     $NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $  */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.138 2016/09/01 13:23:44 mbalmer Exp $");
+__RCSID("$NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -200,7 +200,7 @@ _getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
 {
        int i;
 
-       i = (*rl_getc_function)(NULL);
+       i = (*rl_getc_function)(rl_instream);
        if (i == -1)
                return 0;
        *c = (wchar_t)i;
@@ -560,7 +560,7 @@ get_history_event(const char *cmd, int *cindex, int qchar)
                        idx++;
                }
                if (sign)
-                       num = history_length - num + 1;
+                       num = history_length - num + history_base;
 
                if (!(he = history_get(num)))
                        return NULL;
index cf08375..914e7b1 100644 (file)
--- a/src/vis.c
+++ b/src/vis.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $        */
+/*     $NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $        */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -58,7 +58,7 @@
 #include "config.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 #ifdef __FBSDID
 __FBSDID("$FreeBSD$");
@@ -407,6 +407,14 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
        _DIAGASSERT(mbsrc != NULL || mblength == 0);
        _DIAGASSERT(mbextra != NULL);
 
+       mbslength = (ssize_t)mblength;
+       /*
+        * When inputing a single character, must also read in the
+        * next character for nextc, the look-ahead character.
+        */
+       if (mbslength == 1)
+               mbslength++;
+
        /*
         * Input (mbsrc) is a char string considered to be multibyte
         * characters.  The input loop will read this string pulling
@@ -423,12 +431,12 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
        /* Allocate space for the wide char strings */
        psrc = pdst = extra = NULL;
        mdst = NULL;
-       if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
+       if ((psrc = calloc(mbslength + 1, sizeof(*psrc))) == NULL)
                return -1;
-       if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
+       if ((pdst = calloc((4 * mbslength) + 1, sizeof(*pdst))) == NULL)
                goto out;
        if (*mbdstp == NULL) {
-               if ((mdst = calloc((4 * mblength) + 1, sizeof(*mdst))) == NULL)
+               if ((mdst = calloc((4 * mbslength) + 1, sizeof(*mdst))) == NULL)
                        goto out;
                *mbdstp = mdst;
        }
@@ -451,13 +459,6 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
         * stop at NULs because we may be processing a block of data
         * that includes NULs.
         */
-       mbslength = (ssize_t)mblength;
-       /*
-        * When inputing a single character, must also read in the
-        * next character for nextc, the look-ahead character.
-        */
-       if (mbslength == 1)
-               mbslength++;
        while (mbslength > 0) {
                /* Convert one multibyte character to wchar_t. */
                if (!cerr)
@@ -483,6 +484,7 @@ istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
        }
        len = src - psrc;
        src = psrc;
+
        /*
         * In the single character input case, we will have actually
         * processed two characters, c and nextc.  Reset len back to