Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Sep 2012 10:41:30 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r240915 - in vendor/NetBSD/libedit/dist: . TEST readline
Message-ID:  <201209251041.q8PAfUW6014969@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Tue Sep 25 10:41:30 2012
New Revision: 240915
URL: http://svn.freebsd.org/changeset/base/240915

Log:
  Vendor import NetBSD's libedit of "2012/09/25 10:41:11 UTC".
  
  Obtained from:	NetBSD

Added:
  vendor/NetBSD/libedit/dist/TEST/rl1.c
  vendor/NetBSD/libedit/dist/keymacro.c
  vendor/NetBSD/libedit/dist/keymacro.h
  vendor/NetBSD/libedit/dist/terminal.c
  vendor/NetBSD/libedit/dist/terminal.h
Deleted:
  vendor/NetBSD/libedit/dist/key.c
  vendor/NetBSD/libedit/dist/key.h
  vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/dist/term.h
Modified:
  vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/dist/TEST/wtc1.c
  vendor/NetBSD/libedit/dist/chared.c
  vendor/NetBSD/libedit/dist/chared.h
  vendor/NetBSD/libedit/dist/chartype.c
  vendor/NetBSD/libedit/dist/chartype.h
  vendor/NetBSD/libedit/dist/common.c
  vendor/NetBSD/libedit/dist/config.h
  vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/dist/editrc.5
  vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/dist/el.h
  vendor/NetBSD/libedit/dist/eln.c
  vendor/NetBSD/libedit/dist/emacs.c
  vendor/NetBSD/libedit/dist/filecomplete.c
  vendor/NetBSD/libedit/dist/hist.c
  vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/dist/histedit.h
  vendor/NetBSD/libedit/dist/history.c
  vendor/NetBSD/libedit/dist/makelist
  vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/dist/parse.c
  vendor/NetBSD/libedit/dist/prompt.c
  vendor/NetBSD/libedit/dist/read.c
  vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/dist/refresh.c
  vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/dist/sig.c
  vendor/NetBSD/libedit/dist/sys.h
  vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/dist/tty.h
  vendor/NetBSD/libedit/dist/vi.c

Modified: vendor/NetBSD/libedit/dist/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/Makefile	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/Makefile	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,17 +1,22 @@
-#	$NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $
+#	$NetBSD: Makefile,v 1.51 2012/08/10 12:20:10 joerg Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
 
 WIDECHAR ?= yes
-WARNS=	4
+WARNS?=	5
 LIB=	edit
 
 LIBDPLIBS+=     terminfo ${.CURDIR}/../libterminfo
 
+.include "bsd.own.mk"
+
+COPTS+=	-Wunused-parameter
+CWARNFLAGS.gcc+=	-Wconversion
+
 OSRCS=	chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
-	hist.c key.c map.c chartype.c \
-	parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c
+	hist.c keymacro.c map.c chartype.c \
+	parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
 
 MAN=	editline.3 editrc.5
 
@@ -113,10 +118,17 @@ historyn.c: makelist Makefile
 	    mv ${.TARGET}.tmp ${.TARGET}
 
 tc1.o:	${LIBEDITDIR}/TEST/tc1.c
-	
+
 tc1:	libedit.a tc1.o 
 	${_MKTARGET_LINK}
 	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib
 
 .include <bsd.lib.mk>
 .include <bsd.subdir.mk>
+
+# XXX
+.if defined(HAVE_GCC) && ${HAVE_GCC} >= 45
+COPTS.editline.c+=	-Wno-cast-qual
+COPTS.tokenizer.c+=	-Wno-cast-qual
+COPTS.tokenizern.c+=	-Wno-cast-qual
+.endif

Added: vendor/NetBSD/libedit/dist/TEST/rl1.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/TEST/rl1.c	Tue Sep 25 10:41:30 2012	(r240915)
@@ -0,0 +1,59 @@
+/*	$NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if !defined(lint)
+__RCSID("$NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $");
+#endif /* not lint  */
+
+/*
+ * test.c: A little test program
+ */
+#include <stdio.h>
+#include <readline/readline.h>
+
+int
+main(int argc, char *argv[])
+{
+	char *p;
+	while ((p = readline("hi$")) != NULL) {
+		add_history(p);
+		printf("%d %s\n", history_length, p);
+	}
+	return 0;
+}

Modified: vendor/NetBSD/libedit/dist/TEST/wtc1.c
==============================================================================
--- vendor/NetBSD/libedit/dist/TEST/wtc1.c	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/TEST/wtc1.c	Tue Sep 25 10:41:30 2012	(r240915)
@@ -2,6 +2,7 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/wait.h>
+#include <err.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -14,6 +15,7 @@
 
 static int continuation;
 volatile sig_atomic_t gotsig;
+static const char hfile[] = ".whistory";
 
 static wchar_t *
 prompt(EditLine *el)
@@ -60,7 +62,8 @@ complete(EditLine *el, int ch)
 	char *buf, *bptr;
 	const LineInfoW *lf = el_wline(el);
 	int len, mblen, i;
-	unsigned char res;
+	unsigned char res = 0;
+	wchar_t dir[1024];
 
 	/* Find the last word */
 	for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr)
@@ -70,7 +73,9 @@ complete(EditLine *el, int ch)
 	/* Convert last word to multibyte encoding, so we can compare to it */
 	wctomb(NULL, 0); /* Reset shift state */
 	mblen = MB_LEN_MAX * len + 1;
-	buf = bptr =(char *)malloc(mblen);
+	buf = bptr = malloc(mblen);
+	if (buf == NULL)
+		err(1, "malloc");
 	for (i = 0; i < len; ++i) {
 		/* Note: really should test for -1 return from wctomb */
 		bptr += wctomb(bptr, ptr[i]);
@@ -83,7 +88,9 @@ complete(EditLine *el, int ch)
 		if (mblen > strlen(dp->d_name))
 			continue;
 		if (strncmp(dp->d_name, buf, mblen) == 0) {
-			if (el_insertstr(el, &dp->d_name[mblen]) == -1)
+			mbstowcs(dir, &dp->d_name[mblen],
+			    sizeof(dir) / sizeof(*dir));
+			if (el_winsertstr(el, dir) == -1)
 				res = CC_ERROR;
 			else
 				res = CC_REFRESH;
@@ -119,6 +126,7 @@ main(int argc, char *argv[])
 
 	hist = history_winit();		/* Init built-in history     */
 	history_w(hist, &ev, H_SETSIZE, 100);	/* Remember 100 events	     */
+	history_w(hist, &ev, H_LOAD, hfile);
 
 	tok = tok_winit(NULL);			/* Init the tokenizer	     */
 
@@ -260,6 +268,7 @@ main(int argc, char *argv[])
 
 	el_end(el);
 	tok_wend(tok);
+	history_w(hist, &ev, H_SAVE, hfile);
 	history_wend(hist);
 
 	fprintf(stdout, "\n");

Modified: vendor/NetBSD/libedit/dist/chared.c
==============================================================================
--- vendor/NetBSD/libedit/dist/chared.c	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/chared.c	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $	*/
+/*	$NetBSD: chared.c,v 1.37 2012/07/18 17:12:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)chared.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.37 2012/07/18 17:12:39 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -63,8 +63,8 @@ cv_undo(EditLine *el)
 	size_t size;
 
 	/* Save entire line for undo */
-	size = el->el_line.lastchar - el->el_line.buffer;
-	vu->len = size;
+	size = (size_t)(el->el_line.lastchar - el->el_line.buffer);
+	vu->len = (ssize_t)size;
 	vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer);
 	(void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf));
 
@@ -84,7 +84,7 @@ cv_yank(EditLine *el, const Char *ptr, i
 {
 	c_kill_t *k = &el->el_chared.c_kill;
 
-	(void)memcpy(k->buf, ptr, size * sizeof(*k->buf));
+	(void)memcpy(k->buf, ptr, (size_t)size * sizeof(*k->buf));
 	k->last = k->buf + size;
 }
 
@@ -201,7 +201,7 @@ c_delbefore1(EditLine *el)
 protected int
 ce__isword(Int p)
 {
-	return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL);
+	return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
 }
 
 
@@ -225,7 +225,7 @@ cv__isword(Int p)
 protected int
 cv__isWord(Int p)
 {
-	return (!Isspace(p));
+	return !Isspace(p);
 }
 
 
@@ -249,7 +249,7 @@ c__prev_word(Char *p, Char *low, int n, 
 	if (p < low)
 		p = low;
 	/* cp now points where we want it */
-	return (p);
+	return p;
 }
 
 
@@ -268,7 +268,7 @@ c__next_word(Char *p, Char *high, int n,
 	if (p > high)
 		p = high;
 	/* p now points where we want it */
-	return (p);
+	return p;
 }
 
 /* cv_next_word():
@@ -294,9 +294,9 @@ cv_next_word(EditLine *el, Char *p, Char
 
 	/* p now points where we want it */
 	if (p > high)
-		return (high);
+		return high;
 	else
-		return (p);
+		return p;
 }
 
 
@@ -320,47 +320,12 @@ cv_prev_word(Char *p, Char *low, int n, 
 
 	/* p now points where we want it */
 	if (p < low)
-		return (low);
+		return low;
 	else
-		return (p);
+		return p;
 }
 
 
-#ifdef notdef
-/* c__number():
- *	Ignore character p points to, return number appearing after that.
- * 	A '$' by itself means a big number; "$-" is for negative; '^' means 1.
- * 	Return p pointing to last char used.
- */
-protected Char *
-c__number(
-    Char *p,	/* character position */
-    int *num,	/* Return value	*/
-    int dval)	/* dval is the number to subtract from like $-3 */
-{
-	int i;
-	int sign = 1;
-
-	if (*++p == '^') {
-		*num = 1;
-		return (p);
-	}
-	if (*p == '$') {
-		if (*++p != '-') {
-			*num = 0x7fffffff;	/* Handle $ */
-			return (--p);
-		}
-		sign = -1;			/* Handle $- */
-		++p;
-	}
-    /* XXX: this assumes ASCII compatible digits */
-	for (i = 0; Isdigit(*p); i = 10 * i + *p++ - '0')
-		continue;
-	*num = (sign < 0 ? dval - i : i);
-	return (--p);
-}
-#endif
-
 /* cv_delfini():
  *	Finish vi delete action
  */
@@ -399,28 +364,6 @@ cv_delfini(EditLine *el)
 }
 
 
-#ifdef notdef
-/* ce__endword():
- *	Go to the end of this word according to emacs
- */
-protected Char *
-ce__endword(Char *p, Char *high, int n)
-{
-	p++;
-
-	while (n--) {
-		while ((p < high) && Isspace(*p))
-			p++;
-		while ((p < high) && !Isspace(*p))
-			p++;
-	}
-
-	p--;
-	return (p);
-}
-#endif
-
-
 /* cv__endword():
  *	Go to the end of this word according to vi
  */
@@ -440,7 +383,7 @@ cv__endword(Char *p, Char *high, int n, 
 			p++;
 	}
 	p--;
-	return (p);
+	return p;
 }
 
 /* ch_init():
@@ -454,7 +397,7 @@ ch_init(EditLine *el)
 	el->el_line.buffer		= el_malloc(EL_BUFSIZ *
 	    sizeof(*el->el_line.buffer));
 	if (el->el_line.buffer == NULL)
-		return (-1);
+		return -1;
 
 	(void) memset(el->el_line.buffer, 0, EL_BUFSIZ *
 	    sizeof(*el->el_line.buffer));
@@ -465,7 +408,7 @@ ch_init(EditLine *el)
 	el->el_chared.c_undo.buf	= el_malloc(EL_BUFSIZ *
 	    sizeof(*el->el_chared.c_undo.buf));
 	if (el->el_chared.c_undo.buf == NULL)
-		return (-1);
+		return -1;
 	(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ *
 	    sizeof(*el->el_chared.c_undo.buf));
 	el->el_chared.c_undo.len	= -1;
@@ -473,7 +416,7 @@ ch_init(EditLine *el)
 	el->el_chared.c_redo.buf	= el_malloc(EL_BUFSIZ *
 	    sizeof(*el->el_chared.c_redo.buf));
 	if (el->el_chared.c_redo.buf == NULL)
-		return (-1);
+		return -1;
 	el->el_chared.c_redo.pos	= el->el_chared.c_redo.buf;
 	el->el_chared.c_redo.lim	= el->el_chared.c_redo.buf + EL_BUFSIZ;
 	el->el_chared.c_redo.cmd	= ED_UNASSIGNED;
@@ -484,11 +427,13 @@ ch_init(EditLine *el)
 	el->el_chared.c_kill.buf	= el_malloc(EL_BUFSIZ *
 	    sizeof(*el->el_chared.c_kill.buf));
 	if (el->el_chared.c_kill.buf == NULL)
-		return (-1);
+		return -1;
 	(void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ *
 	    sizeof(*el->el_chared.c_kill.buf));
 	el->el_chared.c_kill.mark	= el->el_line.buffer;
 	el->el_chared.c_kill.last	= el->el_chared.c_kill.buf;
+	el->el_chared.c_resizefun	= NULL;
+	el->el_chared.c_resizearg	= NULL;
 
 	el->el_map.current		= el->el_map.key;
 
@@ -502,8 +447,8 @@ ch_init(EditLine *el)
 	ma->offset	= 0;
 	ma->macro	= el_malloc(EL_MAXMACRO * sizeof(*ma->macro));
 	if (ma->macro == NULL)
-		return (-1);
-	return (0);
+		return -1;
+	return 0;
 }
 
 /* ch_reset():
@@ -542,7 +487,7 @@ ch__clearmacro(EditLine *el)
 {
 	c_macro_t *ma = &el->el_chared.c_macro;
 	while (ma->level >= 0)
-		el_free((ptr_t)ma->macro[ma->level--]);
+		el_free(ma->macro[ma->level--]);
 }
 
 /* ch_enlargebufs():
@@ -555,7 +500,7 @@ ch_enlargebufs(EditLine *el, size_t addl
 	size_t sz, newsz;
 	Char *newbuffer, *oldbuf, *oldkbuf;
 
-	sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
+	sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE);
 	newsz = sz * 2;
 	/*
 	 * If newly required length is longer than current buffer, we need
@@ -587,7 +532,8 @@ ch_enlargebufs(EditLine *el, size_t addl
 	/*
 	 * Reallocate kill buffer.
 	 */
-	newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * sizeof(*newbuffer));
+	newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz *
+	    sizeof(*newbuffer));
 	if (!newbuffer)
 		return 0;
 
@@ -629,6 +575,8 @@ ch_enlargebufs(EditLine *el, size_t addl
 
 	/* Safe to set enlarged buffer size */
 	el->el_line.limit  = &el->el_line.buffer[newsz - EL_LEAVE];
+	if (el->el_chared.c_resizefun)
+		(*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg);
 	return 1;
 }
 
@@ -638,20 +586,20 @@ ch_enlargebufs(EditLine *el, size_t addl
 protected void
 ch_end(EditLine *el)
 {
-	el_free((ptr_t) el->el_line.buffer);
+	el_free(el->el_line.buffer);
 	el->el_line.buffer = NULL;
 	el->el_line.limit = NULL;
-	el_free((ptr_t) el->el_chared.c_undo.buf);
+	el_free(el->el_chared.c_undo.buf);
 	el->el_chared.c_undo.buf = NULL;
-	el_free((ptr_t) el->el_chared.c_redo.buf);
+	el_free(el->el_chared.c_redo.buf);
 	el->el_chared.c_redo.buf = NULL;
 	el->el_chared.c_redo.pos = NULL;
 	el->el_chared.c_redo.lim = NULL;
 	el->el_chared.c_redo.cmd = ED_UNASSIGNED;
-	el_free((ptr_t) el->el_chared.c_kill.buf);
+	el_free(el->el_chared.c_kill.buf);
 	el->el_chared.c_kill.buf = NULL;
 	ch_reset(el, 1);
-	el_free((ptr_t) el->el_chared.c_macro.macro);
+	el_free(el->el_chared.c_macro.macro);
 	el->el_chared.c_macro.macro = NULL;
 }
 
@@ -664,17 +612,17 @@ FUN(el,insertstr)(EditLine *el, const Ch
 {
 	size_t len;
 
-	if ((len = Strlen(s)) == 0)
-		return (-1);
+	if (s == NULL || (len = Strlen(s)) == 0)
+		return -1;
 	if (el->el_line.lastchar + len >= el->el_line.limit) {
 		if (!ch_enlargebufs(el, len))
-			return (-1);
+			return -1;
 	}
 
 	c_insert(el, (int)len);
 	while (*s)
 		*el->el_line.cursor++ = *s++;
-	return (0);
+	return 0;
 }
 
 
@@ -707,8 +655,8 @@ c_gets(EditLine *el, Char *buf, const Ch
 	Char *cp = el->el_line.buffer;
 
 	if (prompt) {
-		len = Strlen(prompt);
-		(void)memcpy(cp, prompt, len * sizeof(*cp));
+		len = (ssize_t)Strlen(prompt);
+		(void)memcpy(cp, prompt, (size_t)len * sizeof(*cp));
 		cp += len;
 	}
 	len = 0;
@@ -743,8 +691,8 @@ c_gets(EditLine *el, Char *buf, const Ch
 			break;
 
 		default:
-			if (len >= EL_BUFSIZ - 16)
-				term_beep(el);
+			if (len >= (ssize_t)(EL_BUFSIZ - 16))
+				terminal_beep(el);
 			else {
 				buf[len++] = ch;
 				*cp++ = ch;
@@ -773,7 +721,7 @@ c_hpos(EditLine *el)
 	 * Find how many characters till the beginning of this line.
 	 */
 	if (el->el_line.cursor == el->el_line.buffer)
-		return (0);
+		return 0;
 	else {
 		for (ptr = el->el_line.cursor - 1;
 		     ptr >= el->el_line.buffer && *ptr != '\n';
@@ -782,3 +730,11 @@ c_hpos(EditLine *el)
 		return (int)(el->el_line.cursor - ptr - 1);
 	}
 }
+
+protected int
+ch_resizefun(EditLine *el, el_zfunc_t f, void *a)
+{
+	el->el_chared.c_resizefun = f;
+	el->el_chared.c_resizearg = a;
+	return 0;
+}

Modified: vendor/NetBSD/libedit/dist/chared.h
==============================================================================
--- vendor/NetBSD/libedit/dist/chared.h	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/chared.h	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chared.h,v 1.20 2010/04/15 00:57:33 christos Exp $	*/
+/*	$NetBSD: chared.h,v 1.21 2010/08/28 15:44:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -103,6 +103,8 @@ typedef struct c_kill_t {
 	Char	*mark;
 } c_kill_t;
 
+typedef void (*el_zfunc_t)(EditLine *, void *);
+
 /*
  * Note that we use both data structures because the user can bind
  * commands from both editors!
@@ -113,6 +115,8 @@ typedef struct el_chared_t {
 	c_redo_t	c_redo;
 	c_vcmd_t	c_vcmd;
 	c_macro_t	c_macro;
+	el_zfunc_t	c_resizefun;
+	void *		c_resizearg;
 } el_chared_t;
 
 
@@ -160,6 +164,7 @@ protected int	 c_hpos(EditLine *);
 
 protected int	 ch_init(EditLine *);
 protected void	 ch_reset(EditLine *, int);
+protected int	 ch_resizefun(EditLine *, el_zfunc_t, void *);
 protected int	 ch_enlargebufs(EditLine *, size_t);
 protected void	 ch_end(EditLine *);
 

Modified: vendor/NetBSD/libedit/dist/chartype.c
==============================================================================
--- vendor/NetBSD/libedit/dist/chartype.c	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/chartype.c	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $	*/
+/*	$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,12 +38,12 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $");
 #endif /* not lint && not SCCSID */
 #include "el.h"
 #include <stdlib.h>
 
-#define CT_BUFSIZ 1024
+#define CT_BUFSIZ ((size_t)1024)
 
 #ifdef WIDECHAR
 protected void
@@ -52,7 +52,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, s
 	void *p;
 	if (mincsize > conv->csize) {
 		conv->csize = mincsize;
-		p = el_realloc(conv->cbuff, conv->csize);
+		p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
 		if (p == NULL) {
 			conv->csize = 0;
 			el_free(conv->cbuff);
@@ -63,7 +63,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, s
 
 	if (minwsize > conv->wsize) {
 		conv->wsize = minwsize;
-		p = el_realloc(conv->wbuff, conv->wsize);
+		p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
 		if (p == NULL) {
 			conv->wsize = 0;
 			el_free(conv->wbuff);
@@ -83,33 +83,27 @@ ct_encode_string(const Char *s, ct_buffe
 	if (!s)
 		return NULL;
 	if (!conv->cbuff)
-		ct_conv_buff_resize(conv, CT_BUFSIZ, 0);
+		ct_conv_buff_resize(conv, CT_BUFSIZ, (size_t)0);
 	if (!conv->cbuff)
 		return NULL;
 
 	dst = conv->cbuff;
 	while (*s) {
-		used = ct_encode_char(dst, (int)(conv->csize -
-		    (dst - conv->cbuff)), *s);
-		if (used == -1) { /* failed to encode, need more buffer space */
+		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, 0);
+			ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ,
+			    (size_t)0);
 			if (!conv->cbuff)
 				return NULL;
 			dst = conv->cbuff + used;
-			/* don't increment s here - we want to retry it! */
 		}
-		else
-			++s;
+		used = ct_encode_char(dst, (size_t)5, *s);
+		if (used == -1) /* failed to encode, need more buffer space */
+			abort();
+		++s;
 		dst += used;
 	}
-	if (dst >= (conv->cbuff + conv->csize)) {
-		used = dst - conv->cbuff;
-		ct_conv_buff_resize(conv, conv->csize + 1, 0);
-		if (!conv->cbuff)
-			return NULL;
-		dst = conv->cbuff + used;
-	}
 	*dst = '\0';
 	return conv->cbuff;
 }
@@ -122,13 +116,15 @@ ct_decode_string(const char *s, ct_buffe
 	if (!s)
 		return NULL;
 	if (!conv->wbuff)
-		ct_conv_buff_resize(conv, 0, CT_BUFSIZ);
+		ct_conv_buff_resize(conv, (size_t)0, CT_BUFSIZ);
 	if (!conv->wbuff)
 		return NULL;
 
-	len = ct_mbstowcs(0, s, 0);
+	len = ct_mbstowcs(NULL, s, (size_t)0);
+	if (len == (size_t)-1)
+		return NULL;
 	if (len > conv->wsize)
-		ct_conv_buff_resize(conv, 0, len + 1);
+		ct_conv_buff_resize(conv, (size_t)0, len + 1);
 	if (!conv->wbuff)
 		return NULL;
 	ct_mbstowcs(conv->wbuff, s, conv->wsize);
@@ -149,11 +145,11 @@ 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, 0, bufspace);
+	ct_conv_buff_resize(conv, (size_t)0, bufspace);
 	if (!conv->wsize)
 		return NULL;
 
-	wargv = el_malloc(argc * sizeof(*wargv));
+	wargv = el_malloc((size_t)argc * sizeof(*wargv));
 
 	for (i = 0, p = conv->wbuff; i < argc; ++i) {
 		if (!argv[i]) {   /* don't pass null pointers to mbstowcs */
@@ -161,14 +157,14 @@ ct_decode_argv(int argc, const char *arg
 			continue;
 		} else {
 			wargv[i] = p;
-			bytes = mbstowcs(p, argv[i], bufspace);
+			bytes = (ssize_t)mbstowcs(p, argv[i], bufspace);
 		}
 		if (bytes == -1) {
 			el_free(wargv);
 			return NULL;
 		} else
 			bytes++;  /* include '\0' in the count */
-		bufspace -= bytes;
+		bufspace -= (size_t)bytes;
 		p += bytes;
 	}
 
@@ -225,7 +221,7 @@ ct_visual_string(const Char *s)
 	}
 	dst = buff;
 	while (*s) {
-		used = ct_visual_char(dst, buffsize - (dst - buff), *s);
+		used = ct_visual_char(dst, buffsize - (size_t)(dst - buff), *s);
 		if (used == -1) { /* failed to encode, need more buffer space */
 			used = dst - buff;
 			buffsize += CT_BUFSIZ;
@@ -326,7 +322,7 @@ ct_visual_char(Char *dst, size_t len, Ch
 		*dst++ = tohexdigit(((unsigned int) c >>  8) & 0xf);
 		*dst++ = tohexdigit(((unsigned int) c >>  4) & 0xf);
 		*dst   = tohexdigit(((unsigned int) c      ) & 0xf);
-		return (c > 0xffff) ? 8 : 7;
+		return c > 0xffff ? 8 : 7;
 #else
 		*dst++ = '\\';
 #define tooctaldigit(v) ((v) + '0')

Modified: vendor/NetBSD/libedit/dist/chartype.h
==============================================================================
--- vendor/NetBSD/libedit/dist/chartype.h	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/chartype.h	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chartype.h,v 1.6 2010/04/20 02:01:13 christos Exp $	*/
+/*	$NetBSD: chartype.h,v 1.10 2011/11/16 01:45:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
 #endif
 
 #define ct_mbtowc            mbtowc
-#define ct_mbtowc_reset      mbtowc(0,0,0)
+#define ct_mbtowc_reset      mbtowc(0,0,(size_t)0)
 #define ct_wctomb            wctomb
 #define ct_wctomb_reset      wctomb(0,0)
 #define ct_wcstombs          wcstombs
@@ -105,7 +105,12 @@
 
 #define Strtol(p,e,b)   wcstol(p,e,b)
 
-#define Width(c)	wcwidth(c)
+static inline int
+Width(wchar_t c)
+{
+	int w = wcwidth(c);
+	return w < 0 ? 0 : w;
+}
 
 #else /* NARROW */
 
@@ -172,11 +177,11 @@ typedef struct ct_buffer_t {
 } ct_buffer_t;
 
 #define ct_encode_string __ct_encode_string
-/* Encode a wide character string and return the UTF-8 encoded result. */
+/* Encode a wide-character string and return the UTF-8 encoded result. */
 public char *ct_encode_string(const Char *, ct_buffer_t *);
 
 #define ct_decode_string __ct_decode_string
-/* Decode a (multi)?byte string and return the wide character string result. */
+/* Decode a (multi)?byte string and return the wide-character string result. */
 public Char *ct_decode_string(const char *, ct_buffer_t *);
 
 /* Decode a (multi)?byte argv string array.
@@ -206,7 +211,7 @@ protected size_t ct_enc_width(Char);
 
 /* The maximum buffer size to hold the most unwieldly visual representation,
  * in this case \U+nnnnn. */
-#define VISUAL_WIDTH_MAX 8
+#define VISUAL_WIDTH_MAX ((size_t)8)
 
 /* The terminal is thought of in terms of X columns by Y lines. In the cases
  * where a wide character takes up more than one column, the adjacent 

Modified: vendor/NetBSD/libedit/dist/common.c
==============================================================================
--- vendor/NetBSD/libedit/dist/common.c	Tue Sep 25 05:56:59 2012	(r240914)
+++ vendor/NetBSD/libedit/dist/common.c	Tue Sep 25 10:41:30 2012	(r240915)
@@ -1,4 +1,4 @@
-/*	$NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $	*/
+/*	$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)common.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -57,7 +57,7 @@ ed_end_of_file(EditLine *el, Int c __att
 
 	re_goto_bottom(el);
 	*el->el_line.lastchar = '\0';
-	return (CC_EOF);
+	return CC_EOF;
 }
 
 
@@ -71,7 +71,7 @@ ed_insert(EditLine *el, Int c)
 	int count = el->el_state.argument;
 
 	if (c == '\0')
-		return (CC_ERROR);
+		return CC_ERROR;
 
 	if (el->el_line.lastchar + el->el_state.argument >=
 	    el->el_line.limit) {
@@ -99,7 +99,7 @@ ed_insert(EditLine *el, Int c)
 	if (el->el_state.inputmode == MODE_REPLACE_1)
 		return vi_command_mode(el, 0);
 
-	return (CC_NORM);
+	return CC_NORM;
 }
 
 
@@ -114,7 +114,7 @@ ed_delete_prev_word(EditLine *el, Int c 
 	Char *cp, *p, *kp;
 
 	if (el->el_line.cursor == el->el_line.buffer)
-		return (CC_ERROR);
+		return CC_ERROR;
 
 	cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
 	    el->el_state.argument, ce__isword);
@@ -127,7 +127,7 @@ ed_delete_prev_word(EditLine *el, Int c 
 	el->el_line.cursor = cp;
 	if (el->el_line.cursor < el->el_line.buffer)
 		el->el_line.cursor = el->el_line.buffer; /* bounds check */
-	return (CC_REFRESH);
+	return CC_REFRESH;
 }
 
 
@@ -137,9 +137,9 @@ ed_delete_prev_word(EditLine *el, Int c 
  */
 protected el_action_t
 /*ARGSUSED*/
-ed_delete_next_char(EditLine *el, Int c)
+ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
 {
-#ifdef notdef			/* XXX */
+#ifdef DEBUG_EDIT
 #define	EL	el->el_line
 	(void) fprintf(el->el_errlfile,
 	    "\nD(b: %x(%s)  c: %x(%s) last: %x(%s) limit: %x(%s)\n",
@@ -152,32 +152,29 @@ ed_delete_next_char(EditLine *el, Int c)
 			if (el->el_line.cursor == el->el_line.buffer) {
 				/* if I'm also at the beginning */
 #ifdef KSHVI
-				return (CC_ERROR);
+				return CC_ERROR;
 #else
 				/* then do an EOF */
-				term_writec(el, c);
-				return (CC_EOF);
+				terminal_writec(el, c);
+				return CC_EOF;
 #endif
 			} else {
 #ifdef KSHVI
 				el->el_line.cursor--;
 #else
-				return (CC_ERROR);
+				return CC_ERROR;
 #endif
 			}
-		} else {
-			if (el->el_line.cursor != el->el_line.buffer)
-				el->el_line.cursor--;
-			else
-				return (CC_ERROR);
-		}
+		} else
+				return CC_ERROR;
 	}
 	c_delafter(el, el->el_state.argument);	/* delete after dot */
-	if (el->el_line.cursor >= el->el_line.lastchar &&
+	if (el->el_map.type == MAP_VI &&
+	    el->el_line.cursor >= el->el_line.lastchar &&
 	    el->el_line.cursor > el->el_line.buffer)
 			/* bounds check */
 		el->el_line.cursor = el->el_line.lastchar - 1;
-	return (CC_REFRESH);
+	return CC_REFRESH;
 }
 
 
@@ -198,7 +195,7 @@ ed_kill_line(EditLine *el, Int c __attri
 	el->el_chared.c_kill.last = kp;
 			/* zap! -- delete to end */
 	el->el_line.lastchar = el->el_line.cursor;
-	return (CC_REFRESH);
+	return CC_REFRESH;
 }
 
 
@@ -215,13 +212,13 @@ ed_move_to_end(EditLine *el, Int c __att
 	if (el->el_map.type == MAP_VI) {
 		if (el->el_chared.c_vcmd.action != NOP) {
 			cv_delfini(el);
-			return (CC_REFRESH);
+			return CC_REFRESH;
 		}
 #ifdef VI_MOVE
 		el->el_line.cursor--;
 #endif
 	}
-	return (CC_CURSOR);
+	return CC_CURSOR;
 }
 
 
@@ -242,10 +239,10 @@ ed_move_to_beg(EditLine *el, Int c __att
 			el->el_line.cursor++;
 		if (el->el_chared.c_vcmd.action != NOP) {
 			cv_delfini(el);
-			return (CC_REFRESH);
+			return CC_REFRESH;
 		}
 	}
-	return (CC_CURSOR);
+	return CC_CURSOR;
 }
 
 
@@ -259,7 +256,7 @@ ed_transpose_chars(EditLine *el, Int c)
 
 	if (el->el_line.cursor < el->el_line.lastchar) {
 		if (el->el_line.lastchar <= &el->el_line.buffer[1])
-			return (CC_ERROR);
+			return CC_ERROR;
 		else
 			el->el_line.cursor++;
 	}
@@ -268,9 +265,9 @@ ed_transpose_chars(EditLine *el, Int c)
 		c = el->el_line.cursor[-2];
 		el->el_line.cursor[-2] = el->el_line.cursor[-1];
 		el->el_line.cursor[-1] = c;
-		return (CC_REFRESH);
+		return CC_REFRESH;
 	} else
-		return (CC_ERROR);
+		return CC_ERROR;
 }
 
 
@@ -288,7 +285,7 @@ ed_next_char(EditLine *el, Int c __attri
 	    (el->el_line.cursor == lim - 1 &&
 	    el->el_map.type == MAP_VI &&
 	    el->el_chared.c_vcmd.action == NOP))
-		return (CC_ERROR);
+		return CC_ERROR;
 
 	el->el_line.cursor += el->el_state.argument;
 	if (el->el_line.cursor > lim)
@@ -297,9 +294,9 @@ ed_next_char(EditLine *el, Int c __attri
 	if (el->el_map.type == MAP_VI)
 		if (el->el_chared.c_vcmd.action != NOP) {
 			cv_delfini(el);
-			return (CC_REFRESH);
+			return CC_REFRESH;
 		}
-	return (CC_CURSOR);
+	return CC_CURSOR;
 }
 
 
@@ -313,7 +310,7 @@ ed_prev_word(EditLine *el, Int c __attri
 {
 
 	if (el->el_line.cursor == el->el_line.buffer)
-		return (CC_ERROR);
+		return CC_ERROR;
 
 	el->el_line.cursor = c__prev_word(el->el_line.cursor,
 	    el->el_line.buffer,
@@ -323,9 +320,9 @@ ed_prev_word(EditLine *el, Int c __attri
 	if (el->el_map.type == MAP_VI)
 		if (el->el_chared.c_vcmd.action != NOP) {
 			cv_delfini(el);
-			return (CC_REFRESH);
+			return CC_REFRESH;
 		}
-	return (CC_CURSOR);
+	return CC_CURSOR;
 }
 
 
@@ -346,11 +343,11 @@ ed_prev_char(EditLine *el, Int c __attri
 		if (el->el_map.type == MAP_VI)
 			if (el->el_chared.c_vcmd.action != NOP) {
 				cv_delfini(el);
-				return (CC_REFRESH);
+				return CC_REFRESH;
 			}
-		return (CC_CURSOR);
+		return CC_CURSOR;
 	} else
-		return (CC_ERROR);
+		return CC_ERROR;
 }

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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