svn commit: r220220 - in vendor/NetBSD/libedit/dist: . TEST readline

David E. O'Brien obrien at FreeBSD.org
Thu Mar 31 18:34:50 UTC 2011


Author: obrien
Date: Thu Mar 31 18:34:50 2011
New Revision: 220220
URL: http://svn.freebsd.org/changeset/base/220220

Log:
  Vendor import NetBSD's libedit of "2010/06/01 18:20:26 UTC".
  
  Obtained from:	NetBSD

Added:
  vendor/NetBSD/libedit/dist/TEST/wtc1.c   (contents, props changed)
  vendor/NetBSD/libedit/dist/chartype.c   (contents, props changed)
  vendor/NetBSD/libedit/dist/chartype.h   (contents, props changed)
  vendor/NetBSD/libedit/dist/eln.c   (contents, props changed)
Modified:
  vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/dist/TEST/Makefile
  vendor/NetBSD/libedit/dist/TEST/tc1.c
  vendor/NetBSD/libedit/dist/chared.c
  vendor/NetBSD/libedit/dist/chared.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/emacs.c
  vendor/NetBSD/libedit/dist/filecomplete.c
  vendor/NetBSD/libedit/dist/filecomplete.h
  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/key.c
  vendor/NetBSD/libedit/dist/key.h
  vendor/NetBSD/libedit/dist/makelist
  vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/dist/map.h
  vendor/NetBSD/libedit/dist/parse.c
  vendor/NetBSD/libedit/dist/parse.h
  vendor/NetBSD/libedit/dist/prompt.c
  vendor/NetBSD/libedit/dist/prompt.h
  vendor/NetBSD/libedit/dist/read.c
  vendor/NetBSD/libedit/dist/read.h
  vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/dist/refresh.c
  vendor/NetBSD/libedit/dist/refresh.h
  vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/dist/search.h
  vendor/NetBSD/libedit/dist/shlib_version
  vendor/NetBSD/libedit/dist/sig.c
  vendor/NetBSD/libedit/dist/sig.h
  vendor/NetBSD/libedit/dist/sys.h
  vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/dist/term.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	Thu Mar 31 18:32:01 2011	(r220219)
+++ vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 18:34:50 2011	(r220220)
@@ -1,15 +1,16 @@
-#	$NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $
+#	$NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
 
-WARNS=	3
+WIDECHAR ?= yes
+WARNS=	4
 LIB=	edit
 
-LIBDPLIBS=     termcap ${.CURDIR}/../libterm
+LIBDPLIBS+=     terminfo ${.CURDIR}/../libterminfo
 
-OSRCS=	chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \
-	key.c map.c \
+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
 
 MAN=	editline.3 editrc.5
@@ -25,9 +26,16 @@ MLINKS=	editline.3 el_init.3 editline.3 
 	editline.3 tok_line.3 editline.3 tok_str.3
 
 # For speed and debugging
-#SRCS=   ${OSRCS} tokenizer.c history.c readline.c
+#SRCS=   ${OSRCS} readline.c tokenizer.c history.c
 # For protection
-SRCS=	editline.c tokenizer.c history.c readline.c
+SRCS=	editline.c readline.c tokenizer.c history.c
+
+.if ${WIDECHAR} == "yes"
+OSRCS += eln.c
+SRCS += tokenizern.c historyn.c
+CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
+CPPFLAGS+=-DWIDECHAR
+.endif
 
 LIBEDITDIR?=${.CURDIR}
 
@@ -36,8 +44,8 @@ INCSDIR=/usr/include
 
 CLEANFILES+=editline.c
 CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp
-CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp
-CLEANFILES+=tc1.o tc1
+CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1
+CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
 CPPFLAGS+=-I. -I${LIBEDITDIR} 
 CPPFLAGS+=-I. -I${.CURDIR}
 CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
@@ -94,11 +102,21 @@ editline.c: ${OSRCS} makelist Makefile
 	${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \
 	    mv ${.TARGET}.tmp ${.TARGET}
 
+tokenizern.c: makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+historyn.c: makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \
+	    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} -ltermcap
+	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib
 
 .include <bsd.lib.mk>
 .include <bsd.subdir.mk>

Modified: vendor/NetBSD/libedit/dist/TEST/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/TEST/Makefile	Thu Mar 31 18:32:01 2011	(r220219)
+++ vendor/NetBSD/libedit/dist/TEST/Makefile	Thu Mar 31 18:34:50 2011	(r220220)
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $
+# $NetBSD: Makefile,v 1.5 2010/02/03 15:34:43 roy Exp $
 
 NOMAN=1
-PROG=tc1
+PROG=wtc1
 CPPFLAGS=-I${.CURDIR}/..
-LDADD+=-ledit -ltermcap
-DPADD+=${LIBEDIT} ${LIBTERMCAP}
+LDADD+=-ledit -ltermlib
+DPADD+=${LIBEDIT} ${LIBTERMLIB}
 
 .ifdef DEBUG
 CPPFLAGS+=-DDEBUG

Modified: vendor/NetBSD/libedit/dist/TEST/tc1.c
==============================================================================
--- vendor/NetBSD/libedit/dist/TEST/tc1.c	Thu Mar 31 18:32:01 2011	(r220219)
+++ vendor/NetBSD/libedit/dist/TEST/tc1.c	Thu Mar 31 18:34:50 2011	(r220220)
@@ -1,4 +1,4 @@
-/*	$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $	*/
+/*	$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)test.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $");
+__RCSID("$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31
 #include <stdlib.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <locale.h>
 
 #include "histedit.h"
 
@@ -71,7 +72,7 @@ static	void	sig(int);
 static char *
 prompt(EditLine *el)
 {
-	static char a[] = "Edit$ ";
+	static char a[] = "\1\033[7m\1Edit$\1\033[0m\1 ";
 	static char b[] = "Edit> ";
 
 	return (continuation ? b : a);
@@ -91,6 +92,7 @@ complete(EditLine *el, int ch)
 	const char* ptr;
 	const LineInfo *lf = el_line(el);
 	int len;
+	int res = CC_ERROR;
 
 	/*
 	 * Find the last word
@@ -104,16 +106,16 @@ complete(EditLine *el, int ch)
 		if (len > strlen(dp->d_name))
 			continue;
 		if (strncmp(dp->d_name, ptr, len) == 0) {
-			closedir(dd);
 			if (el_insertstr(el, &dp->d_name[len]) == -1)
-				return (CC_ERROR);
+				res = CC_ERROR;
 			else
-				return (CC_REFRESH);
+				res = CC_REFRESH;
+			break;
 		}
 	}
 
 	closedir(dd);
-	return (CC_ERROR);
+	return res;
 }
 
 int
@@ -130,6 +132,7 @@ main(int argc, char *argv[])
 	History *hist;
 	HistEvent ev;
 
+	(void) setlocale(LC_CTYPE, "");
 	(void) signal(SIGINT, sig);
 	(void) signal(SIGQUIT, sig);
 	(void) signal(SIGHUP, sig);
@@ -146,7 +149,7 @@ main(int argc, char *argv[])
 
 	el_set(el, EL_EDITOR, "vi");	/* Default editor is vi		*/
 	el_set(el, EL_SIGNAL, 1);	/* Handle signals gracefully	*/
-	el_set(el, EL_PROMPT, prompt);	/* Set the prompt function	*/
+	el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */
 
 			/* Tell editline to use this history interface	*/
 	el_set(el, EL_HIST, history, hist);

Added: vendor/NetBSD/libedit/dist/TEST/wtc1.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/TEST/wtc1.c	Thu Mar 31 18:34:50 2011	(r220220)
@@ -0,0 +1,269 @@
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <limits.h>
+#include <locale.h>
+
+#include "../histedit.h"
+
+
+static int continuation;
+volatile sig_atomic_t gotsig;
+
+static wchar_t *
+prompt(EditLine *el)
+{
+	static wchar_t a[] = L"\1\033[7m\1Edit$\1\033[0m\1 ";
+	static wchar_t b[] = L"Edit> ";
+
+	return continuation ? b : a;
+}
+
+
+static void
+sig(int i)
+{
+	gotsig = i;
+}
+
+const char *
+my_wcstombs(const wchar_t *wstr)
+{
+	static struct {
+		char *str;
+		int len;
+	} buf;
+
+	int needed = wcstombs(0, wstr, 0) + 1;
+	if (needed > buf.len) {
+		buf.str = malloc(needed);
+		buf.len = needed;
+	}
+	wcstombs(buf.str, wstr, needed);
+	buf.str[needed - 1] = 0;
+
+	return buf.str;
+}
+
+
+static unsigned char
+complete(EditLine *el, int ch)
+{
+	DIR *dd = opendir(".");
+	struct dirent *dp;
+	const wchar_t *ptr;
+	char *buf, *bptr;
+	const LineInfoW *lf = el_wline(el);
+	int len, mblen, i;
+	unsigned char res;
+
+	/* Find the last word */
+	for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr)
+		continue;
+	len = lf->cursor - ++ptr;
+
+	/* 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);
+	for (i = 0; i < len; ++i) {
+		/* Note: really should test for -1 return from wctomb */
+		bptr += wctomb(bptr, ptr[i]);
+	}
+	*bptr = 0; /* Terminate multibyte string */
+	mblen = bptr - buf;
+
+	/* Scan directory for matching name */
+	for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
+		if (mblen > strlen(dp->d_name))
+			continue;
+		if (strncmp(dp->d_name, buf, mblen) == 0) {
+			if (el_insertstr(el, &dp->d_name[mblen]) == -1)
+				res = CC_ERROR;
+			else
+				res = CC_REFRESH;
+			break;
+		}
+	}
+
+	closedir(dd);
+	free(buf);
+	return res;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+	EditLine *el = NULL;
+	int numc, ncontinuation;
+	const wchar_t *line;
+	TokenizerW *tok;
+	HistoryW *hist;
+	HistEventW ev;
+#ifdef DEBUG
+	int i;
+#endif
+
+	setlocale(LC_ALL, "");
+
+	(void)signal(SIGINT,  sig);
+	(void)signal(SIGQUIT, sig);
+	(void)signal(SIGHUP,  sig);
+	(void)signal(SIGTERM, sig);
+
+	hist = history_winit();		/* Init built-in history     */
+	history_w(hist, &ev, H_SETSIZE, 100);	/* Remember 100 events	     */
+
+	tok = tok_winit(NULL);			/* Init the tokenizer	     */
+
+	el = el_init(argv[0], stdin, stdout, stderr);
+
+	el_wset(el, EL_EDITOR, L"vi");		/* Default editor is vi	     */
+	el_wset(el, EL_SIGNAL, 1);		/* Handle signals gracefully */
+	el_wset(el, EL_PROMPT_ESC, prompt, '\1'); /* Set the prompt function */
+
+	el_wset(el, EL_HIST, history_w, hist);	/* FIXME - history_w? */
+
+					/* Add a user-defined function	*/
+	el_wset(el, EL_ADDFN, L"ed-complete", L"Complete argument", complete);
+
+					/* Bind <tab> to it */
+	el_wset(el, EL_BIND, L"^I", L"ed-complete", NULL);
+
+	/*
+	* Bind j, k in vi command mode to previous and next line, instead
+	* of previous and next history.
+	*/
+	el_wset(el, EL_BIND, L"-a", L"k", L"ed-prev-line", NULL);
+	el_wset(el, EL_BIND, L"-a", L"j", L"ed-next-line", NULL);
+
+	/* Source the user's defaults file. */
+	el_source(el, NULL);
+
+	while((line = el_wgets(el, &numc)) != NULL && numc != 0) {
+		int ac, cc, co, rc;
+		const wchar_t **av;
+
+		const LineInfoW *li;
+		li = el_wline(el);
+
+#ifdef DEBUG
+		(void)fwprintf(stderr, L"==> got %d %ls", numc, line);
+		(void)fwprintf(stderr, L"  > li `%.*ls_%.*ls'\n",
+		    (li->cursor - li->buffer), li->buffer,
+		    (li->lastchar - 1 - li->cursor),
+		    (li->cursor >= li->lastchar) ? L"" : li->cursor);
+#endif
+
+		if (gotsig) {
+			(void)fprintf(stderr, "Got signal %d.\n", gotsig);
+			gotsig = 0;
+			el_reset(el);
+		}
+
+		if(!continuation && numc == 1)
+			continue;	/* Only got a linefeed */
+
+		ac = cc = co = 0;
+		ncontinuation = tok_wline(tok, li, &ac, &av, &cc, &co);
+		if (ncontinuation < 0) {
+			(void) fprintf(stderr, "Internal error\n");
+			continuation = 0;
+			continue;
+		}
+
+#ifdef DEBUG
+		(void)fprintf(stderr, "  > nc %d ac %d cc %d co %d\n",
+			ncontinuation, ac, cc, co);
+#endif
+		history_w(hist, &ev, continuation ? H_APPEND : H_ENTER, line);
+
+		continuation = ncontinuation;
+		ncontinuation = 0;
+		if(continuation)
+			continue;
+
+#ifdef DEBUG
+		for (i = 0; i < ac; ++i) {
+			(void)fwprintf(stderr, L"  > arg# %2d ", i);
+			if (i != cc)
+				(void)fwprintf(stderr, L"`%ls'\n", av[i]);
+			else
+				(void)fwprintf(stderr, L"`%.*ls_%ls'\n",
+				    co, av[i], av[i] + co);
+		}
+#endif
+
+		if (wcscmp (av[0], L"history") == 0) {
+			switch(ac) {
+			case 1:
+				for(rc = history_w(hist, &ev, H_LAST);
+				     rc != -1;
+				     rc = history_w(hist, &ev, H_PREV))
+					(void)fwprintf(stdout, L"%4d %ls",
+					     ev.num, ev.str);
+				break;
+			case 2:
+				if (wcscmp(av[1], L"clear") == 0)
+					history_w(hist, &ev, H_CLEAR);
+				else
+					goto badhist;
+				break;
+			case 3:
+				if (wcscmp(av[1], L"load") == 0)
+					history_w(hist, &ev, H_LOAD,
+					    my_wcstombs(av[2]));
+				else if (wcscmp(av[1], L"save") == 0)
+					history_w(hist, &ev, H_SAVE,
+					    my_wcstombs(av[2]));
+				else
+					goto badhist;
+				break;
+			badhist:
+			default:
+				(void)fprintf(stderr,
+				    "Bad history arguments\n");
+				break;
+			}
+		} else if (el_wparse(el, ac, av) == -1) {
+			switch (fork()) {
+			case 0: {
+				Tokenizer *ntok = tok_init(NULL);
+				int nargc;
+				const char **nav;
+				tok_str(ntok, my_wcstombs(line), &nargc, &nav);
+				execvp(nav[0],(char **)nav);
+				perror(nav[0]);
+				_exit(1);
+				/* NOTREACHED */
+				break;
+			}
+			case -1:
+				perror("fork");
+				break;
+			default:
+				if (wait(&rc) == -1)
+					perror("wait");
+				(void)fprintf(stderr, "Exit %x\n", rc);
+				break;
+			}
+		}
+
+		tok_wreset(tok);
+	}
+
+	el_end(el);
+	tok_wend(tok);
+	history_wend(hist);
+
+	fprintf(stdout, "\n");
+	return 0;
+}
+
+

Modified: vendor/NetBSD/libedit/dist/chared.c
==============================================================================
--- vendor/NetBSD/libedit/dist/chared.c	Thu Mar 31 18:32:01 2011	(r220219)
+++ vendor/NetBSD/libedit/dist/chared.c	Thu Mar 31 18:34:50 2011	(r220220)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $	*/
+/*	$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 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.25 2005/08/08 01:41:30 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -47,7 +47,7 @@ __RCSID("$NetBSD: chared.c,v 1.25 2005/0
 #include <stdlib.h>
 #include "el.h"
 
-private void ch__clearmacro __P((EditLine *));
+private void ch__clearmacro (EditLine *);
 
 /* value to leave unused in line buffer */
 #define	EL_LEAVE	2
@@ -60,13 +60,13 @@ cv_undo(EditLine *el)
 {
 	c_undo_t *vu = &el->el_chared.c_undo;
 	c_redo_t *r = &el->el_chared.c_redo;
-	unsigned int size;
+	size_t size;
 
 	/* Save entire line for undo */
 	size = el->el_line.lastchar - el->el_line.buffer;
 	vu->len = size;
-	vu->cursor = el->el_line.cursor - el->el_line.buffer;
-	memcpy(vu->buf, el->el_line.buffer, size);
+	vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer);
+	(void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf));
 
 	/* save command info for redo */
 	r->count = el->el_state.doingarg ? el->el_state.argument : 0;
@@ -80,11 +80,11 @@ cv_undo(EditLine *el)
  *	Save yank/delete data for paste
  */
 protected void
-cv_yank(EditLine *el, const char *ptr, int size)
+cv_yank(EditLine *el, const Char *ptr, int size)
 {
 	c_kill_t *k = &el->el_chared.c_kill;
 
-	memcpy(k->buf, ptr, size +0u);
+	(void)memcpy(k->buf, ptr, size * sizeof(*k->buf));
 	k->last = k->buf + size;
 }
 
@@ -95,10 +95,10 @@ cv_yank(EditLine *el, const char *ptr, i
 protected void
 c_insert(EditLine *el, int num)
 {
-	char *cp;
+	Char *cp;
 
 	if (el->el_line.lastchar + num >= el->el_line.limit) {
-		if (!ch_enlargebufs(el, num +0u))
+		if (!ch_enlargebufs(el, (size_t)num))
 			return;		/* can't go past end of buffer */
 	}
 
@@ -119,7 +119,7 @@ c_delafter(EditLine *el, int num)
 {
 
 	if (el->el_line.cursor + num > el->el_line.lastchar)
-		num = el->el_line.lastchar - el->el_line.cursor;
+		num = (int)(el->el_line.lastchar - el->el_line.cursor);
 
 	if (el->el_map.current != el->el_map.emacs) {
 		cv_undo(el);
@@ -127,7 +127,7 @@ c_delafter(EditLine *el, int num)
 	}
 
 	if (num > 0) {
-		char *cp;
+		Char *cp;
 
 		for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
 			*cp = cp[num];
@@ -143,7 +143,7 @@ c_delafter(EditLine *el, int num)
 protected void
 c_delafter1(EditLine *el)
 {
-	char *cp;
+	Char *cp;
 
 	for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
 		*cp = cp[1];
@@ -160,7 +160,7 @@ c_delbefore(EditLine *el, int num)
 {
 
 	if (el->el_line.cursor - num < el->el_line.buffer)
-		num = el->el_line.cursor - el->el_line.buffer;
+		num = (int)(el->el_line.cursor - el->el_line.buffer);
 
 	if (el->el_map.current != el->el_map.emacs) {
 		cv_undo(el);
@@ -168,7 +168,7 @@ c_delbefore(EditLine *el, int num)
 	}
 
 	if (num > 0) {
-		char *cp;
+		Char *cp;
 
 		for (cp = el->el_line.cursor - num;
 		    cp <= el->el_line.lastchar;
@@ -186,7 +186,7 @@ c_delbefore(EditLine *el, int num)
 protected void
 c_delbefore1(EditLine *el)
 {
-	char *cp;
+	Char *cp;
 
 	for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
 		*cp = cp[1];
@@ -199,9 +199,9 @@ c_delbefore1(EditLine *el)
  *	Return if p is part of a word according to emacs
  */
 protected int
-ce__isword(int p)
+ce__isword(Int p)
 {
-	return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
+	return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL);
 }
 
 
@@ -209,11 +209,11 @@ ce__isword(int p)
  *	Return if p is part of a word according to vi
  */
 protected int
-cv__isword(int p)
+cv__isword(Int p)
 {
-	if (isalnum(p) || p == '_')
+	if (Isalnum(p) || p == '_')
 		return 1;
-	if (isgraph(p))
+	if (Isgraph(p))
 		return 2;
 	return 0;
 }
@@ -223,24 +223,24 @@ cv__isword(int p)
  *	Return if p is part of a big word according to vi
  */
 protected int
-cv__isWord(int p)
+cv__isWord(Int p)
 {
-	return (!isspace(p));
+	return (!Isspace(p));
 }
 
 
 /* c__prev_word():
  *	Find the previous word
  */
-protected char *
-c__prev_word(char *p, char *low, int n, int (*wtest)(int))
+protected Char *
+c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
 {
 	p--;
 
 	while (n--) {
-		while ((p >= low) && !(*wtest)((unsigned char) *p))
+		while ((p >= low) && !(*wtest)(*p))
 			p--;
-		while ((p >= low) && (*wtest)((unsigned char) *p))
+		while ((p >= low) && (*wtest)(*p))
 			p--;
 	}
 
@@ -256,13 +256,13 @@ c__prev_word(char *p, char *low, int n, 
 /* c__next_word():
  *	Find the next word
  */
-protected char *
-c__next_word(char *p, char *high, int n, int (*wtest)(int))
+protected Char *
+c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
 {
 	while (n--) {
-		while ((p < high) && !(*wtest)((unsigned char) *p))
+		while ((p < high) && !(*wtest)(*p))
 			p++;
-		while ((p < high) && (*wtest)((unsigned char) *p))
+		while ((p < high) && (*wtest)(*p))
 			p++;
 	}
 	if (p > high)
@@ -274,21 +274,21 @@ c__next_word(char *p, char *high, int n,
 /* cv_next_word():
  *	Find the next word vi style
  */
-protected char *
-cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
+protected Char *
+cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
 {
 	int test;
 
 	while (n--) {
-		test = (*wtest)((unsigned char) *p);
-		while ((p < high) && (*wtest)((unsigned char) *p) == test)
+		test = (*wtest)(*p);
+		while ((p < high) && (*wtest)(*p) == test)
 			p++;
 		/*
 		 * vi historically deletes with cw only the word preserving the
 		 * trailing whitespace! This is not what 'w' does..
 		 */
 		if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
-			while ((p < high) && isspace((unsigned char) *p))
+			while ((p < high) && Isspace(*p))
 				p++;
 	}
 
@@ -303,17 +303,17 @@ cv_next_word(EditLine *el, char *p, char
 /* cv_prev_word():
  *	Find the previous word vi style
  */
-protected char *
-cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
+protected Char *
+cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
 {
 	int test;
 
 	p--;
 	while (n--) {
-		while ((p > low) && isspace((unsigned char) *p))
+		while ((p > low) && Isspace(*p))
 			p--;
-		test = (*wtest)((unsigned char) *p);
-		while ((p >= low) && (*wtest)((unsigned char) *p) == test)
+		test = (*wtest)(*p);
+		while ((p >= low) && (*wtest)(*p) == test)
 			p--;
 	}
 	p++;
@@ -332,9 +332,9 @@ cv_prev_word(char *p, char *low, int n, 
  * 	A '$' by itself means a big number; "$-" is for negative; '^' means 1.
  * 	Return p pointing to last char used.
  */
-protected char *
+protected Char *
 c__number(
-    char *p,	/* character position */
+    Char *p,	/* character position */
     int *num,	/* Return value	*/
     int dval)	/* dval is the number to subtract from like $-3 */
 {
@@ -353,7 +353,8 @@ c__number(
 		sign = -1;			/* Handle $- */
 		++p;
 	}
-	for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
+    /* 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);
@@ -376,7 +377,7 @@ cv_delfini(EditLine *el)
 		/* sanity */
 		return;
 
-	size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
+	size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos);
 	if (size == 0)
 		size = 1;
 	el->el_line.cursor = el->el_chared.c_vcmd.pos;
@@ -402,15 +403,15 @@ cv_delfini(EditLine *el)
 /* ce__endword():
  *	Go to the end of this word according to emacs
  */
-protected char *
-ce__endword(char *p, char *high, int n)
+protected Char *
+ce__endword(Char *p, Char *high, int n)
 {
 	p++;
 
 	while (n--) {
-		while ((p < high) && isspace((unsigned char) *p))
+		while ((p < high) && Isspace(*p))
 			p++;
-		while ((p < high) && !isspace((unsigned char) *p))
+		while ((p < high) && !Isspace(*p))
 			p++;
 	}
 
@@ -423,19 +424,19 @@ ce__endword(char *p, char *high, int n)
 /* cv__endword():
  *	Go to the end of this word according to vi
  */
-protected char *
-cv__endword(char *p, char *high, int n, int (*wtest)(int))
+protected Char *
+cv__endword(Char *p, Char *high, int n, int (*wtest)(Int))
 {
 	int test;
 
 	p++;
 
 	while (n--) {
-		while ((p < high) && isspace((unsigned char) *p))
+		while ((p < high) && Isspace(*p))
 			p++;
 
-		test = (*wtest)((unsigned char) *p);
-		while ((p < high) && (*wtest)((unsigned char) *p) == test)
+		test = (*wtest)(*p);
+		while ((p < high) && (*wtest)(*p) == test)
 			p++;
 	}
 	p--;
@@ -450,22 +451,27 @@ ch_init(EditLine *el)
 {
 	c_macro_t *ma = &el->el_chared.c_macro;
 
-	el->el_line.buffer		= (char *) el_malloc(EL_BUFSIZ);
+	el->el_line.buffer		= el_malloc(EL_BUFSIZ *
+	    sizeof(*el->el_line.buffer));
 	if (el->el_line.buffer == NULL)
 		return (-1);
 
-	(void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
+	(void) memset(el->el_line.buffer, 0, EL_BUFSIZ *
+	    sizeof(*el->el_line.buffer));
 	el->el_line.cursor		= el->el_line.buffer;
 	el->el_line.lastchar		= el->el_line.buffer;
 	el->el_line.limit		= &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE];
 
-	el->el_chared.c_undo.buf	= (char *) el_malloc(EL_BUFSIZ);
+	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);
-	(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
+	(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;
 	el->el_chared.c_undo.cursor	= 0;
-	el->el_chared.c_redo.buf	= (char *) el_malloc(EL_BUFSIZ);
+	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);
 	el->el_chared.c_redo.pos	= el->el_chared.c_redo.buf;
@@ -475,10 +481,12 @@ ch_init(EditLine *el)
 	el->el_chared.c_vcmd.action	= NOP;
 	el->el_chared.c_vcmd.pos	= el->el_line.buffer;
 
-	el->el_chared.c_kill.buf	= (char *) el_malloc(EL_BUFSIZ);
+	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);
-	(void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
+	(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;
 
@@ -492,7 +500,7 @@ ch_init(EditLine *el)
 
 	ma->level	= -1;
 	ma->offset	= 0;
-	ma->macro	= (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
+	ma->macro	= el_malloc(EL_MAXMACRO * sizeof(*ma->macro));
 	if (ma->macro == NULL)
 		return (-1);
 	return (0);
@@ -530,8 +538,7 @@ ch_reset(EditLine *el, int mclear)
 }
 
 private void
-ch__clearmacro(el)
-	EditLine *el;
+ch__clearmacro(EditLine *el)
 {
 	c_macro_t *ma = &el->el_chared.c_macro;
 	while (ma->level >= 0)
@@ -543,12 +550,10 @@ ch__clearmacro(el)
  *	Returns 1 if successful, 0 if not.
  */
 protected int
-ch_enlargebufs(el, addlen)
-	EditLine *el;
-	size_t addlen;
+ch_enlargebufs(EditLine *el, size_t addlen)
 {
 	size_t sz, newsz;
-	char *newbuffer, *oldbuf, *oldkbuf;
+	Char *newbuffer, *oldbuf, *oldkbuf;
 
 	sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
 	newsz = sz * 2;
@@ -564,12 +569,12 @@ ch_enlargebufs(el, addlen)
 	/*
 	 * Reallocate line buffer.
 	 */
-	newbuffer = el_realloc(el->el_line.buffer, newsz);
+	newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer));
 	if (!newbuffer)
 		return 0;
 
 	/* zero the newly added memory, leave old data in */
-	(void) memset(&newbuffer[sz], 0, newsz - sz);
+	(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
 	    
 	oldbuf = el->el_line.buffer;
 
@@ -582,12 +587,12 @@ ch_enlargebufs(el, addlen)
 	/*
 	 * Reallocate kill buffer.
 	 */
-	newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
+	newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * sizeof(*newbuffer));
 	if (!newbuffer)
 		return 0;
 
 	/* zero the newly added memory, leave old data in */
-	(void) memset(&newbuffer[sz], 0, newsz - sz);
+	(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
 
 	oldkbuf = el->el_chared.c_kill.buf;
 
@@ -600,15 +605,17 @@ ch_enlargebufs(el, addlen)
 	/*
 	 * Reallocate undo buffer.
 	 */
-	newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
+	newbuffer = el_realloc(el->el_chared.c_undo.buf,
+	    newsz * sizeof(*newbuffer));
 	if (!newbuffer)
 		return 0;
 
 	/* zero the newly added memory, leave old data in */
-	(void) memset(&newbuffer[sz], 0, newsz - sz);
+	(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
 	el->el_chared.c_undo.buf = newbuffer;
 
-	newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
+	newbuffer = el_realloc(el->el_chared.c_redo.buf,
+	    newsz * sizeof(*newbuffer));
 	if (!newbuffer)
 		return 0;
 	el->el_chared.c_redo.pos = newbuffer +
@@ -653,11 +660,11 @@ ch_end(EditLine *el)
  *	Insert string at cursorI
  */
 public int
-el_insertstr(EditLine *el, const char *s)
+FUN(el,insertstr)(EditLine *el, const Char *s)
 {
 	size_t len;
 
-	if ((len = strlen(s)) == 0)
+	if ((len = Strlen(s)) == 0)
 		return (-1);
 	if (el->el_line.lastchar + len >= el->el_line.limit) {
 		if (!ch_enlargebufs(el, len))
@@ -693,15 +700,15 @@ el_deletestr(EditLine *el, int n)
  *	Get a string
  */
 protected int
-c_gets(EditLine *el, char *buf, const char *prompt)
+c_gets(EditLine *el, Char *buf, const Char *prompt)
 {
-	char ch;
-	int len;
-	char *cp = el->el_line.buffer;
+	Char ch;
+	ssize_t len;
+	Char *cp = el->el_line.buffer;
 
 	if (prompt) {
-		len = strlen(prompt);
-		memcpy(cp, prompt, len + 0u);
+		len = Strlen(prompt);
+		(void)memcpy(cp, prompt, len * sizeof(*cp));
 		cp += len;
 	}
 	len = 0;
@@ -712,7 +719,7 @@ c_gets(EditLine *el, char *buf, const ch
 		el->el_line.lastchar = cp + 1;
 		re_refresh(el);
 
-		if (el_getc(el, &ch) != 1) {
+		if (FUN(el,getc)(el, &ch) != 1) {
 			ed_end_of_file(el, 0);
 			len = -1;
 			break;
@@ -722,7 +729,7 @@ c_gets(EditLine *el, char *buf, const ch
 
 		case 0010:	/* Delete and backspace */
 		case 0177:
-			if (len <= 0) {
+			if (len == 0) {
 				len = -1;
 				break;
 			}
@@ -750,7 +757,7 @@ c_gets(EditLine *el, char *buf, const ch
 	el->el_line.buffer[0] = '\0';
 	el->el_line.lastchar = el->el_line.buffer;
 	el->el_line.cursor = el->el_line.buffer;
-	return len;
+	return (int)len;
 }
 
 
@@ -760,7 +767,7 @@ c_gets(EditLine *el, char *buf, const ch
 protected int
 c_hpos(EditLine *el)
 {
-	char *ptr;
+	Char *ptr;
 
 	/*
 	 * Find how many characters till the beginning of this line.
@@ -772,6 +779,6 @@ c_hpos(EditLine *el)
 		     ptr >= el->el_line.buffer && *ptr != '\n';
 		     ptr--)
 			continue;
-		return (el->el_line.cursor - ptr - 1);
+		return (int)(el->el_line.cursor - ptr - 1);
 	}
 }

Modified: vendor/NetBSD/libedit/dist/chared.h
==============================================================================
--- vendor/NetBSD/libedit/dist/chared.h	Thu Mar 31 18:32:01 2011	(r220219)
+++ vendor/NetBSD/libedit/dist/chared.h	Thu Mar 31 18:34:50 2011	(r220220)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $	*/
+/*	$NetBSD: chared.h,v 1.20 2010/04/15 00:57:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -63,25 +63,25 @@
 typedef struct c_macro_t {
 	int	  level;
 	int	  offset;
-	char	**macro;
+	Char	**macro;
 } c_macro_t;

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


More information about the svn-src-all mailing list