Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Feb 2016 01:38:50 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r295360 - in vendor/NetBSD/libedit/dist: . readline
Message-ID:  <201602070138.u171coMp061951@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun Feb  7 01:38:50 2016
New Revision: 295360
URL: https://svnweb.freebsd.org/changeset/base/295360

Log:
  Import libedit 2016-01-16
  
  Obtained from:	NetBSD

Modified:
  vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/dist/chartype.c
  vendor/NetBSD/libedit/dist/chartype.h
  vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/dist/eln.c
  vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/dist/keymacro.h
  vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/dist/vi.c

Modified: vendor/NetBSD/libedit/dist/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/Makefile	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/Makefile	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.52 2014/06/14 20:49:37 mrg Exp $
+#	$NetBSD: Makefile,v 1.53 2015/01/29 20:30:02 joerg Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -13,6 +13,7 @@ LIBDPLIBS+=     terminfo ${.CURDIR}/../l
 
 COPTS+=	-Wunused-parameter
 CWARNFLAGS.gcc+=	-Wconversion
+CWARNFLAGS.clang+=	-Wno-cast-qual
 
 OSRCS=	chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
 	hist.c keymacro.c map.c chartype.c \

Modified: vendor/NetBSD/libedit/dist/chartype.c
==============================================================================
--- vendor/NetBSD/libedit/dist/chartype.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/chartype.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $	*/
+/*	$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
 #endif /* not lint && not SCCSID */
 #include "el.h"
 #include <stdlib.h>
@@ -46,31 +46,46 @@ __RCSID("$NetBSD: chartype.c,v 1.10 2011
 #define CT_BUFSIZ ((size_t)1024)
 
 #ifdef WIDECHAR
-protected void
-ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize)
+protected int
+ct_conv_cbuff_resize(ct_buffer_t *conv, size_t csize)
 {
 	void *p;
-	if (mincsize > conv->csize) {
-		conv->csize = mincsize;
-		p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
-		if (p == NULL) {
-			conv->csize = 0;
-			el_free(conv->cbuff);
-			conv->cbuff = NULL;
-		} else 
-			conv->cbuff = p;
+
+	if (csize <= conv->csize)
+		return 0;
+
+	conv->csize = csize;
+
+	p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
+	if (p == NULL) {
+		conv->csize = 0;
+		el_free(conv->cbuff);
+		conv->cbuff = NULL;
+		return -1;
 	}
+	conv->cbuff = p;
+	return 0;
+}
 
-	if (minwsize > conv->wsize) {
-		conv->wsize = minwsize;
-		p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
-		if (p == NULL) {
-			conv->wsize = 0;
-			el_free(conv->wbuff);
-			conv->wbuff = NULL;
-		} else
-			conv->wbuff = p;
+protected int
+ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
+{
+	void *p;
+
+	if (wsize <= conv->wsize) 
+		return 0;
+
+	conv->wsize = wsize;
+
+	p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
+	if (p == NULL) {
+		conv->wsize = 0;
+		el_free(conv->wbuff);
+		conv->wbuff = NULL;
+		return -1;
 	}
+	conv->wbuff = p;
+	return 0;
 }
 
 
@@ -78,26 +93,22 @@ public char *
 ct_encode_string(const Char *s, ct_buffer_t *conv)
 {
 	char *dst;
-	ssize_t used = 0;
+	ssize_t used;
 
 	if (!s)
 		return NULL;
-	if (!conv->cbuff)
-		ct_conv_buff_resize(conv, CT_BUFSIZ, (size_t)0);
-	if (!conv->cbuff)
-		return NULL;
 
 	dst = conv->cbuff;
-	while (*s) {
-		used = (ssize_t)(conv->csize - (size_t)(dst - conv->cbuff));
-		if (used < 5) {
-			used = dst - conv->cbuff;
-			ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ,
-			    (size_t)0);
-			if (!conv->cbuff)
+	for (;;) {
+		used = (ssize_t)(dst - conv->cbuff);
+		if ((conv->csize - (size_t)used) < 5) {
+			if (ct_conv_cbuff_resize(conv,
+			    conv->csize + CT_BUFSIZ) == -1)
 				return NULL;
 			dst = conv->cbuff + used;
 		}
+		if (!*s)
+			break;
 		used = ct_encode_char(dst, (size_t)5, *s);
 		if (used == -1) /* failed to encode, need more buffer space */
 			abort();
@@ -111,22 +122,19 @@ ct_encode_string(const Char *s, ct_buffe
 public Char *
 ct_decode_string(const char *s, ct_buffer_t *conv)
 {
-	size_t len = 0;
+	size_t len;
 
 	if (!s)
 		return NULL;
-	if (!conv->wbuff)
-		ct_conv_buff_resize(conv, (size_t)0, CT_BUFSIZ);
-	if (!conv->wbuff)
-		return NULL;
 
 	len = ct_mbstowcs(NULL, s, (size_t)0);
 	if (len == (size_t)-1)
 		return NULL;
-	if (len > conv->wsize)
-		ct_conv_buff_resize(conv, (size_t)0, len + 1);
-	if (!conv->wbuff)
-		return NULL;
+
+	if (conv->wsize < ++len)
+		if (ct_conv_wbuff_resize(conv, len + CT_BUFSIZ) == -1)
+			return NULL;
+
 	ct_mbstowcs(conv->wbuff, s, conv->wsize);
 	return conv->wbuff;
 }
@@ -145,9 +153,9 @@ ct_decode_argv(int argc, const char *arg
 	 * the argv strings. */
 	for (i = 0, bufspace = 0; i < argc; ++i)
 		bufspace += argv[i] ? strlen(argv[i]) + 1 : 0;
-	ct_conv_buff_resize(conv, (size_t)0, bufspace);
-	if (!conv->wsize)
-		return NULL;
+	if (conv->wsize < ++bufspace)
+		if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
+			return NULL;
 
 	wargv = el_malloc((size_t)argc * sizeof(*wargv));
 

Modified: vendor/NetBSD/libedit/dist/chartype.h
==============================================================================
--- vendor/NetBSD/libedit/dist/chartype.h	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/chartype.h	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chartype.h,v 1.10 2011/11/16 01:45:10 christos Exp $	*/
+/*	$NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  * supports non-BMP code points without requiring UTF-16, but nothing
  * seems to actually advertise this properly, despite Unicode 3.1 having
  * been around since 2001... */
-#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__))
+#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
 #ifndef __STDC_ISO_10646__
 /* In many places it is assumed that the first 127 code points are ASCII
  * compatible, so ensure wchar_t indeed does ISO 10646 and not some other
@@ -72,6 +72,7 @@
 #define FUN(prefix,rest)	prefix ## _w ## rest
 #define FUNW(type)		type ## _w
 #define TYPE(type)		type ## W
+#define FCHAR			"%lc"
 #define FSTR			"%ls"
 #define STR(x) 			L ## x
 #define UC(c)			c
@@ -126,6 +127,7 @@ Width(wchar_t c)
 #define FUN(prefix,rest)	prefix ## _ ## rest
 #define FUNW(type)		type
 #define TYPE(type)		type
+#define FCHAR			"%c"
 #define FSTR			"%s"
 #define STR(x) 			x
 #define UC(c)			(unsigned char)(c)
@@ -189,7 +191,8 @@ public Char *ct_decode_string(const char
 protected Char **ct_decode_argv(int, const char *[],  ct_buffer_t *);
 
 /* Resizes the conversion buffer(s) if needed. */
-protected void ct_conv_buff_resize(ct_buffer_t *, size_t, size_t);
+protected int ct_conv_cbuff_resize(ct_buffer_t *, size_t);
+protected int ct_conv_wbuff_resize(ct_buffer_t *, size_t);
 protected ssize_t ct_encode_char(char *, size_t, Char);
 protected size_t ct_enc_width(Char);
 
@@ -199,7 +202,8 @@ protected size_t ct_enc_width(Char);
 #define	ct_encode_string(s, b)	(s)
 #define ct_decode_string(s, b)	(s)
 #define ct_decode_argv(l, s, b)	(s)
-#define ct_conv_buff_resize(b, os, ns)
+#define ct_conv_cbuff_resize(b, s) ((s) == (0))
+#define ct_conv_wbuff_resize(b, s) ((s) == (0))
 #define ct_encode_char(d, l, s)	(*d = s, 1)
 #define ct_free_argv(s)
 #endif

Modified: vendor/NetBSD/libedit/dist/editline.3
==============================================================================
--- vendor/NetBSD/libedit/dist/editline.3	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/editline.3	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: editline.3,v 1.84 2014/12/25 13:39:41 wiz Exp $
+.\"	$NetBSD: editline.3,v 1.85 2015/11/03 21:36:59 christos Exp $
 .\"
 .\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 25, 2014
+.Dd November 3, 2015
 .Dt EDITLINE 3
 .Os
 .Sh NAME
@@ -189,7 +189,7 @@ counterparts.
 The following functions are available:
 .Bl -tag -width 4n
 .It Fn el_init
-Initialise the line editor, and return a data structure
+Initialize the line editor, and return a data structure
 to be used by all other line editing functions, or
 .Dv NULL
 on failure.
@@ -519,61 +519,68 @@ are supported, along with actual type of
 .Fa result :
 .Bl -tag -width 4n
 .It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
-Return a pointer to the function that displays the prompt in
+Set
 .Fa f .
+to a pointer to the function that displays the prompt.
 If
 .Fa c
 is not
 .Dv NULL ,
-return the start/stop literal prompt character in it.
+set it to the start/stop literal prompt character.
 .It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)" , Fa "char *c"
-Return a pointer to the function that displays the prompt in
+Set
 .Fa f .
+to a pointer to the function that displays the prompt.
 If
 .Fa c
 is not
 .Dv NULL ,
-return the start/stop literal prompt character in it.
-.It Dv EL_EDITOR , Fa "const char **"
-Return the name of the editor, which will be one of
+set it to the start/stop literal prompt character.
+.It Dv EL_EDITOR , Fa "const char **n"
+Set the name of the editor in
+.Fa n ,
+which will be one of
 .Dq emacs
 or
 .Dq vi .
 .It Dv EL_GETTC , Fa "const char *name" , Fa "void *value"
-Return non-zero if
+If
 .Fa name
 is a valid
 .Xr termcap 5
-capability
-and set
+capability set
 .Fa value
 to the current value of that capability.
-.It Dv EL_SIGNAL , Fa "int *"
-Return non-zero if
+.It Dv EL_SIGNAL , Fa "int *s"
+Set
+.Fa s
+to non zero if
 .Nm
 has installed private signal handlers (see
 .Fn el_get
 above).
-.It Dv EL_EDITMODE , Fa "int *"
-Return non-zero if editing is enabled.
+.It Dv EL_EDITMODE , Fa "int *c"
+Set
+.Fa c
+to non-zero if editing is enabled.
 .It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)"
 Return a pointer to the function that read characters, which is equal to
 .Dq Dv EL_BUILTIN_GETCFN
 in the case of the default builtin function.
 .It Dv EL_CLIENTDATA , Fa "void **data"
-Retrieve
+Set
 .Fa data
-previously registered with the corresponding
+to the previously registered client data set by an
 .Fn el_set
 call.
-.It Dv EL_UNBUFFERED , Fa "int"
-Return non-zero if unbuffered mode is enabled.
-.It Dv EL_PREP_TERM , Fa "int"
-Sets or clears terminal editing mode.
+.It Dv EL_UNBUFFERED , Fa "int *c"
+Set
+.Fa c
+to non-zero if unbuffered mode is enabled.
 .It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp"
-Return in
+Set
 .Fa fp
-the current
+to the current
 .Nm editline
 file pointer for
 .Dq input
@@ -591,7 +598,7 @@ or
 .Dv 2 .
 .El
 .It Fn el_source
-Initialise
+Initialize
 .Nm
 by reading the contents of
 .Fa file .
@@ -669,7 +676,7 @@ and freed by
 The following functions are available:
 .Bl -tag -width 4n
 .It Fn history_init
-Initialise the history list, and return a data structure
+Initialize the history list, and return a data structure
 to be used by all other history list functions, or
 .Dv NULL
 on failure.
@@ -808,7 +815,7 @@ and freed by
 The following functions are available:
 .Bl -tag -width 4n
 .It Fn tok_init
-Initialise the tokenizer, and return a data structure
+Initialize the tokenizer, and return a data structure
 to be used by all other tokenizer functions.
 .Fa IFS
 contains the Input Field Separators, which defaults to

Modified: vendor/NetBSD/libedit/dist/el.c
==============================================================================
--- vendor/NetBSD/libedit/dist/el.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/el.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.c,v 1.73 2014/06/18 18:12:28 christos Exp $	*/
+/*	$NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c	8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.73 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -135,7 +135,8 @@ el_end(EditLine *el)
 	terminal_end(el);
 	keymacro_end(el);
 	map_end(el);
-	tty_end(el);
+	if (!(el->el_flags & NO_TTY))
+		tty_end(el);
 	ch_end(el);
 	search_end(el);
 	hist_end(el);

Modified: vendor/NetBSD/libedit/dist/eln.c
==============================================================================
--- vendor/NetBSD/libedit/dist/eln.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/eln.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $	*/
+/*	$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -76,9 +76,17 @@ el_gets(EditLine *el, int *nread)
 {
 	const wchar_t *tmp;
 
-	el->el_flags |= IGNORE_EXTCHARS;
+	if (!(el->el_flags & CHARSET_IS_UTF8))
+		el->el_flags |= IGNORE_EXTCHARS;
 	tmp = el_wgets(el, nread);
-	el->el_flags &= ~IGNORE_EXTCHARS;
+	if (tmp != NULL) {
+	    size_t nwread = 0;
+	    for (int i = 0; i < *nread; i++)
+		nwread += ct_enc_width(tmp[i]);
+	    *nread = (int)nwread;
+	}
+	if (!(el->el_flags & CHARSET_IS_UTF8))
+		el->el_flags &= ~IGNORE_EXTCHARS;
 	return ct_encode_string(tmp, &el->el_lgcyconv);
 }
 

Modified: vendor/NetBSD/libedit/dist/hist.h
==============================================================================
--- vendor/NetBSD/libedit/dist/hist.h	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/hist.h	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: hist.h,v 1.14 2014/05/11 01:05:17 christos Exp $	*/
+/*	$NetBSD: hist.h,v 1.15 2016/01/30 15:05:27 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -46,10 +46,10 @@ typedef int (*hist_fun_t)(void *, TYPE(H
 
 typedef struct el_history_t {
 	Char		*buf;		/* The history buffer		*/
-	size_t		sz;		/* Size of history buffer	*/
+	size_t		 sz;		/* Size of history buffer	*/
 	Char		*last;		/* The last character		*/
 	int		 eventno;	/* Event we are looking for	*/
-	void *		 ref;		/* Argument for history fcns	*/
+	void		*ref;		/* Argument for history fcns	*/
 	hist_fun_t	 fun;		/* Event access			*/
 	TYPE(HistEvent)	 ev;		/* Event cookie			*/
 } el_history_t;

Modified: vendor/NetBSD/libedit/dist/keymacro.h
==============================================================================
--- vendor/NetBSD/libedit/dist/keymacro.h	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/keymacro.h	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: keymacro.h,v 1.2 2011/07/28 03:44:36 christos Exp $	*/
+/*	$NetBSD: keymacro.h,v 1.3 2016/01/29 19:59:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -47,7 +47,7 @@ typedef union keymacro_value_t {
 
 typedef struct keymacro_node_t keymacro_node_t;
 
-typedef struct el_keymacromacro_t {
+typedef struct el_keymacro_t {
 	Char		*buf;	/* Key print buffer		*/
 	keymacro_node_t	*map;	/* Key map			*/
 	keymacro_value_t val;	/* Local conversion buffer	*/

Modified: vendor/NetBSD/libedit/dist/map.c
==============================================================================
--- vendor/NetBSD/libedit/dist/map.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/map.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $	*/
+/*	$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)map.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -1300,8 +1300,8 @@ map_bind(EditLine *el, int argc, const C
 				return 0;
 			default:
 				(void) fprintf(el->el_errfile,
-				    "" FSTR ": Invalid switch `%c'.\n",
-				    argv[0], p[1]);
+				    "" FSTR ": Invalid switch `" FCHAR "'.\n",
+				    argv[0], (Int)p[1]);
 			}
 		else
 			break;

Modified: vendor/NetBSD/libedit/dist/readline.c
==============================================================================
--- vendor/NetBSD/libedit/dist/readline.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/readline.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.c,v 1.113 2014/10/18 08:33:23 snj Exp $	*/
+/*	$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 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.113 2014/10/18 08:33:23 snj Exp $");
+__RCSID("$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -78,7 +78,7 @@ FILE *rl_outstream = NULL;
 int rl_point = 0;
 int rl_end = 0;
 char *rl_line_buffer = NULL;
-VCPFunction *rl_linefunc = NULL;
+rl_vcpfunc_t *rl_linefunc = NULL;
 int rl_done = 0;
 VFunction *rl_event_hook = NULL;
 KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
@@ -107,9 +107,9 @@ int rl_attempted_completion_over = 0;
 char *rl_basic_word_break_characters = break_chars;
 char *rl_completer_word_break_characters = NULL;
 char *rl_completer_quote_characters = NULL;
-Function *rl_completion_entry_function = NULL;
+rl_compentry_func_t *rl_completion_entry_function = NULL;
 char *(*rl_completion_word_break_hook)(void) = NULL;
-CPPFunction *rl_attempted_completion_function = NULL;
+rl_completion_func_t *rl_attempted_completion_function = NULL;
 Function *rl_pre_input_hook = NULL;
 Function *rl_startup1_hook = NULL;
 int (*rl_getc_function)(FILE *) = NULL;
@@ -160,7 +160,7 @@ int rl_completion_append_character = ' '
 
 static History *h = NULL;
 static EditLine *e = NULL;
-static Function *map[256];
+static rl_command_func_t *map[256];
 static jmp_buf topbuf;
 
 /* internal functions */
@@ -362,6 +362,37 @@ rl_initialize(void)
 	    _el_rl_tstp);
 	el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
 		
+	/*
+	 * Set some readline compatible key-bindings.
+	 */
+	el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL);
+
+	/*
+	 * Allow the use of Home/End keys.
+	 */
+	el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
+	el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
+	el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL);
+	el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL);
+	el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL);
+	el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL);
+
+	/*
+	 * Allow the use of the Delete/Insert keys.
+	 */
+	el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
+	el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL);
+
+	/*
+	 * Ctrl-left-arrow and Ctrl-right-arrow for word moving.
+	 */
+	el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL);
+	el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL);
+	el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL);
+	el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL);
+	el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL);
+	el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL);
+
 	/* read settings from configuration file */
 	el_source(e, NULL);
 
@@ -948,7 +979,8 @@ loop:
 		for (; str[j]; j++) {
 			if (str[j] == '\\' &&
 			    str[j + 1] == history_expansion_char) {
-				(void)strcpy(&str[j], &str[j + 1]);
+				len = strlen(&str[j + 1]) + 1;
+				memmove(&str[j], &str[j + 1], len);
 				continue;
 			}
 			if (!loop_again) {
@@ -1795,9 +1827,11 @@ rl_complete(int ignore __attribute__((__
 	else
 		breakchars = rl_basic_word_break_characters;
 
+	_rl_update_pos();
+
 	/* Just look at how many global variables modify this operation! */
 	return fn_complete(e,
-	    (CPFunction *)rl_completion_entry_function,
+	    (rl_compentry_func_t *)rl_completion_entry_function,
 	    rl_attempted_completion_function,
 	    ct_decode_string(rl_basic_word_break_characters, &wbreak_conv),
 	    ct_decode_string(breakchars, &sprefix_conv),
@@ -1926,7 +1960,7 @@ rl_bind_wrapper(EditLine *el __attribute
 
 	_rl_update_pos();
 
-	(*map[c])(NULL, c);
+	(*map[c])(1, c);
 
 	/* If rl_done was set by the above call, deal with it here */
 	if (rl_done)
@@ -1936,7 +1970,7 @@ rl_bind_wrapper(EditLine *el __attribute
 }
 
 int
-rl_add_defun(const char *name, Function *fun, int c)
+rl_add_defun(const char *name, rl_command_func_t *fun, int c)
 {
 	char dest[8];
 	if ((size_t)c >= sizeof(map) / sizeof(map[0]) || c < 0)
@@ -1975,7 +2009,7 @@ rl_callback_read_char(void)
 }
 
 void 
-rl_callback_handler_install(const char *prompt, VCPFunction *linefunc)
+rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
 {
 	if (e == NULL) {
 		rl_initialize();

Modified: vendor/NetBSD/libedit/dist/readline/readline.h
==============================================================================
--- vendor/NetBSD/libedit/dist/readline/readline.h	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/readline/readline.h	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.h,v 1.34 2013/05/28 00:10:34 christos Exp $	*/
+/*	$NetBSD: readline.h,v 1.37 2015/06/02 15:36:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -39,9 +39,8 @@
 /* typedefs */
 typedef int	  Function(const char *, int);
 typedef void	  VFunction(void);
-typedef void	  VCPFunction(char *);
-typedef char	 *CPFunction(const char *, int);
-typedef char	**CPPFunction(const char *, int, int);
+typedef void	  rl_vcpfunc_t(char *);
+typedef char	**rl_completion_func_t(const char *, int, int);
 typedef char     *rl_compentry_func_t(const char *, int);
 typedef int	  rl_command_func_t(int, int);
 
@@ -108,9 +107,9 @@ extern int		 max_input_history;
 extern char		*rl_basic_word_break_characters;
 extern char		*rl_completer_word_break_characters;
 extern char		*rl_completer_quote_characters;
-extern Function		*rl_completion_entry_function;
+extern rl_compentry_func_t *rl_completion_entry_function;
 extern char		*(*rl_completion_word_break_hook)(void);
-extern CPPFunction	*rl_attempted_completion_function;
+extern rl_completion_func_t *rl_attempted_completion_function;
 extern int		 rl_attempted_completion_over;
 extern int		rl_completion_type;
 extern int		rl_completion_query_items;
@@ -175,7 +174,7 @@ char		*filename_completion_function(cons
 char		*username_completion_function(const char *, int);
 int		 rl_complete(int, int);
 int		 rl_read_key(void);
-char	       **completion_matches(const char *, CPFunction *);
+char	       **completion_matches(const char *, rl_compentry_func_t *);
 void		 rl_display_match_list(char **, int, int);
 
 int		 rl_insert(int, int);
@@ -184,7 +183,7 @@ void		 rl_reset_terminal(const char *);
 int		 rl_bind_key(int, rl_command_func_t *);
 int		 rl_newline(int, int);
 void		 rl_callback_read_char(void);
-void		 rl_callback_handler_install(const char *, VCPFunction *);
+void		 rl_callback_handler_install(const char *, rl_vcpfunc_t *);
 void		 rl_callback_handler_remove(void);
 void		 rl_redisplay(void);
 int		 rl_get_previous_history(int, int);
@@ -194,7 +193,7 @@ int		 rl_read_init_file(const char *);
 int		 rl_parse_and_bind(const char *);
 int		 rl_variable_bind(const char *, const char *);
 void		 rl_stuff_char(int);
-int		 rl_add_defun(const char *, Function *, int);
+int		 rl_add_defun(const char *, rl_command_func_t *, int);
 HISTORY_STATE	*history_get_history_state(void);
 void		 rl_get_screen_size(int *, int *);
 void		 rl_set_screen_size(int, int);

Modified: vendor/NetBSD/libedit/dist/search.c
==============================================================================
--- vendor/NetBSD/libedit/dist/search.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/search.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: search.c,v 1.30 2011/10/04 15:27:04 christos Exp $	*/
+/*	$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)search.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: search.c,v 1.30 2011/10/04 15:27:04 christos Exp $");
+__RCSID("$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -147,7 +147,7 @@ el_match(const Char *str, const Char *pa
 	if (re_comp(ct_encode_string(pat, &conv)) != NULL)
 		return 0;
 	else
-		return re_exec(ct_encode_string(str, &conv) == 1);
+		return re_exec(ct_encode_string(str, &conv)) == 1;
 #endif
 }
 

Modified: vendor/NetBSD/libedit/dist/tokenizer.c
==============================================================================
--- vendor/NetBSD/libedit/dist/tokenizer.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/tokenizer.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: tokenizer.c,v 1.21 2011/08/16 16:25:15 christos Exp $	*/
+/*	$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)tokenizer.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tokenizer.c,v 1.21 2011/08/16 16:25:15 christos Exp $");
+__RCSID("$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -446,5 +446,5 @@ FUN(tok,str)(TYPE(Tokenizer) *tok, const
 	memset(&li, 0, sizeof(li));
 	li.buffer = line;
 	li.cursor = li.lastchar = Strchr(line, '\0');
-	return FUN(tok,line(tok, &li, argc, argv, NULL, NULL));
+	return FUN(tok,line)(tok, &li, argc, argv, NULL, NULL);
 }

Modified: vendor/NetBSD/libedit/dist/tty.c
==============================================================================
--- vendor/NetBSD/libedit/dist/tty.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/tty.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.46 2014/06/18 18:52:49 christos Exp $	*/
+/*	$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)tty.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tty.c,v 1.46 2014/06/18 18:52:49 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -580,6 +580,9 @@ protected void
 /*ARGSUSED*/
 tty_end(EditLine *el)
 {
+	if (el->el_flags & EDIT_DISABLED)
+		return;
+
 	if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
 #ifdef DEBUG_TTY
 		(void) fprintf(el->el_errfile,
@@ -1171,8 +1174,8 @@ tty_stty(EditLine *el, int argc __attrib
 			break;
 		default:
 			(void) fprintf(el->el_errfile,
-			    "%s: Unknown switch `%c'.\n",
-			    name, argv[0][1]);
+			    "%s: Unknown switch `" FCHAR "'.\n",
+			    name, (Int)argv[0][1]);
 			return -1;
 		}
 

Modified: vendor/NetBSD/libedit/dist/vi.c
==============================================================================
--- vendor/NetBSD/libedit/dist/vi.c	Sun Feb  7 01:09:38 2016	(r295359)
+++ vendor/NetBSD/libedit/dist/vi.c	Sun Feb  7 01:38:50 2016	(r295360)
@@ -1,4 +1,4 @@
-/*	$NetBSD: vi.c,v 1.45 2014/06/18 18:12:28 christos Exp $	*/
+/*	$NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)vi.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vi.c,v 1.45 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -1038,12 +1038,12 @@ vi_histedit(EditLine *el, Int c __attrib
 		while (waitpid(pid, &status, 0) != pid)
 			continue;
 		lseek(fd, (off_t)0, SEEK_SET);
-		st = read(fd, cp, TMP_BUFSIZ);
+		st = read(fd, cp, TMP_BUFSIZ - 1);
 		if (st > 0) {
-			len = (size_t)(el->el_line.lastchar -
-			    el->el_line.buffer);
+			cp[st] = '\0';
+			len = (size_t)(el->el_line.limit - el->el_line.buffer);
 			len = ct_mbstowcs(el->el_line.buffer, cp, len);
-			if (len > 0 && el->el_line.buffer[len -1] == '\n')
+			if (len > 0 && el->el_line.buffer[len - 1] == '\n')
 				--len;
 		}
 		else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602070138.u171coMp061951>