Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 18:35:44 +0000 (UTC)
From:      "David E. O'Brien" <obrien@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r220221 - in vendor/NetBSD/libedit/2010-06-01: . TEST readline
Message-ID:  <201103311835.p2VIZim5015367@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: obrien
Date: Thu Mar 31 18:35:44 2011
New Revision: 220221
URL: http://svn.freebsd.org/changeset/base/220221

Log:
  "Tag" the "2010/06/01 18:20:26 UTC" import.

Added:
  vendor/NetBSD/libedit/2010-06-01/
     - copied from r220218, vendor/NetBSD/libedit/dist/
  vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c
  vendor/NetBSD/libedit/2010-06-01/chartype.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chartype.c
  vendor/NetBSD/libedit/2010-06-01/chartype.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chartype.h
  vendor/NetBSD/libedit/2010-06-01/eln.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/eln.c
Replaced:
  vendor/NetBSD/libedit/2010-06-01/Makefile
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/2010-06-01/TEST/Makefile
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/Makefile
  vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c
  vendor/NetBSD/libedit/2010-06-01/chared.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chared.c
  vendor/NetBSD/libedit/2010-06-01/chared.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/chared.h
  vendor/NetBSD/libedit/2010-06-01/common.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/common.c
  vendor/NetBSD/libedit/2010-06-01/config.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/config.h
  vendor/NetBSD/libedit/2010-06-01/editline.3
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/2010-06-01/editrc.5
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/editrc.5
  vendor/NetBSD/libedit/2010-06-01/el.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/2010-06-01/el.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/el.h
  vendor/NetBSD/libedit/2010-06-01/emacs.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/emacs.c
  vendor/NetBSD/libedit/2010-06-01/filecomplete.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/filecomplete.c
  vendor/NetBSD/libedit/2010-06-01/filecomplete.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/filecomplete.h
  vendor/NetBSD/libedit/2010-06-01/hist.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/hist.c
  vendor/NetBSD/libedit/2010-06-01/hist.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/2010-06-01/histedit.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/histedit.h
  vendor/NetBSD/libedit/2010-06-01/history.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/history.c
  vendor/NetBSD/libedit/2010-06-01/key.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/key.c
  vendor/NetBSD/libedit/2010-06-01/key.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/key.h
  vendor/NetBSD/libedit/2010-06-01/makelist
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/makelist
  vendor/NetBSD/libedit/2010-06-01/map.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/2010-06-01/map.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/map.h
  vendor/NetBSD/libedit/2010-06-01/parse.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/parse.c
  vendor/NetBSD/libedit/2010-06-01/parse.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/parse.h
  vendor/NetBSD/libedit/2010-06-01/prompt.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/prompt.c
  vendor/NetBSD/libedit/2010-06-01/prompt.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/prompt.h
  vendor/NetBSD/libedit/2010-06-01/read.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/read.c
  vendor/NetBSD/libedit/2010-06-01/read.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/read.h
  vendor/NetBSD/libedit/2010-06-01/readline.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/2010-06-01/readline/readline.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/2010-06-01/refresh.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/refresh.c
  vendor/NetBSD/libedit/2010-06-01/refresh.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/refresh.h
  vendor/NetBSD/libedit/2010-06-01/search.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/2010-06-01/search.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/search.h
  vendor/NetBSD/libedit/2010-06-01/shlib_version
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/shlib_version
  vendor/NetBSD/libedit/2010-06-01/sig.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sig.c
  vendor/NetBSD/libedit/2010-06-01/sig.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sig.h
  vendor/NetBSD/libedit/2010-06-01/sys.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/sys.h
  vendor/NetBSD/libedit/2010-06-01/term.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/2010-06-01/term.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/term.h
  vendor/NetBSD/libedit/2010-06-01/tokenizer.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/2010-06-01/tty.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/2010-06-01/tty.h
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/tty.h
  vendor/NetBSD/libedit/2010-06-01/vi.c
     - copied unchanged from r220220, vendor/NetBSD/libedit/dist/vi.c

Copied: vendor/NetBSD/libedit/2010-06-01/Makefile (from r220220, vendor/NetBSD/libedit/dist/Makefile)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2010-06-01/Makefile	Thu Mar 31 18:35:44 2011	(r220221, copy of r220220, vendor/NetBSD/libedit/dist/Makefile)
@@ -0,0 +1,122 @@
+#	$NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $
+#	@(#)Makefile	8.1 (Berkeley) 6/4/93
+
+USE_SHLIBDIR=	yes
+
+WIDECHAR ?= yes
+WARNS=	4
+LIB=	edit
+
+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 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
+
+MLINKS=	editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \
+	editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \
+	editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \
+	editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \
+	editline.3 el_insertstr.3 editline.3 el_deletestr.3 \
+	editline.3 history_init.3 editline.3 history_end.3 \
+	editline.3 history.3 \
+	editline.3 tok_init.3 editline.3 tok_end.3 editline.3 tok_reset.3 \
+	editline.3 tok_line.3 editline.3 tok_str.3
+
+# For speed and debugging
+#SRCS=   ${OSRCS} readline.c tokenizer.c history.c
+# For protection
+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}
+
+INCS= histedit.h
+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 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
+CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT
+
+AHDR=vi.h emacs.h common.h 
+ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
+
+DPSRCS+=	${AHDR} fcns.h help.h fcns.c help.c
+CLEANFILES+=	${AHDR} fcns.h help.h fcns.c help.c
+
+SUBDIR=	readline
+
+vi.h: vi.c makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \
+	    > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+emacs.h: emacs.c makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c \
+	    > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+common.h: common.c makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c \
+	    > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+fcns.h: ${AHDR} makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+fcns.c: ${AHDR} fcns.h help.h makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+help.c: ${ASRC} makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+help.h: ${ASRC} makelist Makefile
+	${_MKTARGET_CREATE}
+	${HOST_SH} ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
+
+editline.c: ${OSRCS} makelist Makefile
+	${_MKTARGET_CREATE}
+	${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} -ltermlib
+
+.include <bsd.lib.mk>
+.include <bsd.subdir.mk>

Copied: vendor/NetBSD/libedit/2010-06-01/TEST/Makefile (from r220220, vendor/NetBSD/libedit/dist/TEST/Makefile)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2010-06-01/TEST/Makefile	Thu Mar 31 18:35:44 2011	(r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/Makefile)
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.5 2010/02/03 15:34:43 roy Exp $
+
+NOMAN=1
+PROG=wtc1
+CPPFLAGS=-I${.CURDIR}/..
+LDADD+=-ledit -ltermlib
+DPADD+=${LIBEDIT} ${LIBTERMLIB}
+
+.ifdef DEBUG
+CPPFLAGS+=-DDEBUG
+.endif
+
+.include <bsd.prog.mk>

Copied: vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c (from r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2010-06-01/TEST/tc1.c	Thu Mar 31 18:35:44 2011	(r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/tc1.c)
@@ -0,0 +1,304 @@
+/*	$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Christos Zoulas of Cornell University.
+ *
+ * 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. Neither the name of the University 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 REGENTS 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 REGENTS 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 "config.h"
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n");
+#endif /* not lint */
+
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)test.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: tc1.c,v 1.5 2010/04/18 21:17:47 christos Exp $");
+#endif
+#endif /* not lint && not SCCSID */
+
+/*
+ * test.c: A little test program
+ */
+#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 <locale.h>
+
+#include "histedit.h"
+
+static int continuation = 0;
+volatile sig_atomic_t gotsig = 0;
+
+static	unsigned char	complete(EditLine *, int);
+	int	main(int, char **);
+static	char   *prompt(EditLine *);
+static	void	sig(int);
+
+static char *
+prompt(EditLine *el)
+{
+	static char a[] = "\1\033[7m\1Edit$\1\033[0m\1 ";
+	static char b[] = "Edit> ";
+
+	return (continuation ? b : a);
+}
+
+static void
+sig(int i)
+{
+	gotsig = i;
+}
+
+static unsigned char
+complete(EditLine *el, int ch)
+{
+	DIR *dd = opendir(".");
+	struct dirent *dp;
+	const char* ptr;
+	const LineInfo *lf = el_line(el);
+	int len;
+	int res = CC_ERROR;
+
+	/*
+	 * Find the last word
+	 */
+	for (ptr = lf->cursor - 1;
+	    !isspace((unsigned char)*ptr) && ptr > lf->buffer; ptr--)
+		continue;
+	len = lf->cursor - ++ptr;
+
+	for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
+		if (len > strlen(dp->d_name))
+			continue;
+		if (strncmp(dp->d_name, ptr, len) == 0) {
+			if (el_insertstr(el, &dp->d_name[len]) == -1)
+				res = CC_ERROR;
+			else
+				res = CC_REFRESH;
+			break;
+		}
+	}
+
+	closedir(dd);
+	return res;
+}
+
+int
+main(int argc, char *argv[])
+{
+	EditLine *el = NULL;
+	int num;
+	const char *buf;
+	Tokenizer *tok;
+#if 0
+	int lastevent = 0;
+#endif
+	int ncontinuation;
+	History *hist;
+	HistEvent ev;
+
+	(void) setlocale(LC_CTYPE, "");
+	(void) signal(SIGINT, sig);
+	(void) signal(SIGQUIT, sig);
+	(void) signal(SIGHUP, sig);
+	(void) signal(SIGTERM, sig);
+
+	hist = history_init();		/* Init the builtin history	*/
+					/* Remember 100 events		*/
+	history(hist, &ev, H_SETSIZE, 100);
+
+	tok  = tok_init(NULL);		/* Initialize the tokenizer	*/
+
+					/* Initialize editline		*/
+	el = el_init(*argv, stdin, stdout, stderr);
+
+	el_set(el, EL_EDITOR, "vi");	/* Default editor is vi		*/
+	el_set(el, EL_SIGNAL, 1);	/* Handle signals gracefully	*/
+	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);
+
+					/* Add a user-defined function	*/
+	el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
+
+					/* Bind tab to it 		*/
+	el_set(el, EL_BIND, "^I", "ed-complete", NULL);
+
+	/*
+	 * Bind j, k in vi command mode to previous and next line, instead
+	 * of previous and next history.
+	 */
+	el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL);
+	el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL);
+
+	/*
+	 * Source the user's defaults file.
+	 */
+	el_source(el, NULL);
+
+	while ((buf = el_gets(el, &num)) != NULL && num != 0)  {
+		int ac, cc, co;
+#ifdef DEBUG
+		int i;
+#endif
+		const char **av;
+		const LineInfo *li;
+		li = el_line(el);
+#ifdef DEBUG
+		(void) fprintf(stderr, "==> got %d %s", num, buf);
+		(void) fprintf(stderr, "  > li `%.*s_%.*s'\n",
+		    (li->cursor - li->buffer), li->buffer,
+		    (li->lastchar - 1 - li->cursor),
+		    (li->cursor >= li->lastchar) ? "" : li->cursor);
+
+#endif
+		if (gotsig) {
+			(void) fprintf(stderr, "Got signal %d.\n", gotsig);
+			gotsig = 0;
+			el_reset(el);
+		}
+
+		if (!continuation && num == 1)
+			continue;
+
+		ac = cc = co = 0;
+		ncontinuation = tok_line(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
+#if 0
+		if (continuation) {
+			/*
+			 * Append to the right event in case the user
+			 * moved around in history.
+			 */
+			if (history(hist, &ev, H_SET, lastevent) == -1)
+				err(1, "%d: %s", lastevent, ev.str);
+			history(hist, &ev, H_ADD , buf);
+		} else {
+			history(hist, &ev, H_ENTER, buf);
+			lastevent = ev.num;
+		}
+#else
+				/* Simpler */
+		history(hist, &ev, continuation ? H_APPEND : H_ENTER, buf);
+#endif
+
+		continuation = ncontinuation;
+		ncontinuation = 0;
+		if (continuation)
+			continue;
+#ifdef DEBUG
+		for (i = 0; i < ac; i++) {
+			(void) fprintf(stderr, "  > arg# %2d ", i);
+			if (i != cc)
+				(void) fprintf(stderr, "`%s'\n", av[i]);
+			else
+				(void) fprintf(stderr, "`%.*s_%s'\n",
+				    co, av[i], av[i] + co);
+		}
+#endif
+
+		if (strcmp(av[0], "history") == 0) {
+			int rv;
+
+			switch (ac) {
+			case 1:
+				for (rv = history(hist, &ev, H_LAST); rv != -1;
+				    rv = history(hist, &ev, H_PREV))
+					(void) fprintf(stdout, "%4d %s",
+					    ev.num, ev.str);
+				break;
+
+			case 2:
+				if (strcmp(av[1], "clear") == 0)
+					 history(hist, &ev, H_CLEAR);
+				else
+					 goto badhist;
+				break;
+
+			case 3:
+				if (strcmp(av[1], "load") == 0)
+					 history(hist, &ev, H_LOAD, av[2]);
+				else if (strcmp(av[1], "save") == 0)
+					 history(hist, &ev, H_SAVE, av[2]);
+				break;
+
+			badhist:
+			default:
+				(void) fprintf(stderr,
+				    "Bad history arguments\n");
+				break;
+			}
+		} else if (el_parse(el, ac, av) == -1) {
+			switch (fork()) {
+			case 0:
+				execvp(av[0], (char *const *)__UNCONST(av));
+				perror(av[0]);
+				_exit(1);
+				/*NOTREACHED*/
+				break;
+
+			case -1:
+				perror("fork");
+				break;
+
+			default:
+				if (wait(&num) == -1)
+					perror("wait");
+				(void) fprintf(stderr, "Exit %x\n", num);
+				break;
+			}
+		}
+
+		tok_reset(tok);
+	}
+
+	el_end(el);
+	tok_end(tok);
+	history_end(hist);
+
+	return (0);
+}

Copied: vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c (from r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2010-06-01/TEST/wtc1.c	Thu Mar 31 18:35:44 2011	(r220221, copy of r220220, vendor/NetBSD/libedit/dist/TEST/wtc1.c)
@@ -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;
+}
+
+

Copied: vendor/NetBSD/libedit/2010-06-01/chared.c (from r220220, vendor/NetBSD/libedit/dist/chared.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2010-06-01/chared.c	Thu Mar 31 18:35:44 2011	(r220221, copy of r220220, vendor/NetBSD/libedit/dist/chared.c)
@@ -0,0 +1,784 @@
+/*	$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Christos Zoulas of Cornell University.
+ *
+ * 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. Neither the name of the University 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 REGENTS 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 REGENTS 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 "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#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 $");
+#endif
+#endif /* not lint && not SCCSID */
+
+/*
+ * chared.c: Character editor utilities
+ */
+#include <stdlib.h>
+#include "el.h"
+
+private void ch__clearmacro (EditLine *);
+
+/* value to leave unused in line buffer */
+#define	EL_LEAVE	2
+
+/* cv_undo():
+ *	Handle state for the vi undo command
+ */
+protected void
+cv_undo(EditLine *el)
+{
+	c_undo_t *vu = &el->el_chared.c_undo;
+	c_redo_t *r = &el->el_chared.c_redo;
+	size_t size;
+
+	/* Save entire line for undo */
+	size = el->el_line.lastchar - el->el_line.buffer;
+	vu->len = 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;
+	r->action = el->el_chared.c_vcmd.action;
+	r->pos = r->buf;
+	r->cmd = el->el_state.thiscmd;
+	r->ch = el->el_state.thisch;
+}
+
+/* cv_yank():
+ *	Save yank/delete data for paste
+ */
+protected void
+cv_yank(EditLine *el, const Char *ptr, int size)
+{
+	c_kill_t *k = &el->el_chared.c_kill;
+
+	(void)memcpy(k->buf, ptr, size * sizeof(*k->buf));
+	k->last = k->buf + size;
+}
+
+
+/* c_insert():
+ *	Insert num characters
+ */
+protected void
+c_insert(EditLine *el, int num)
+{
+	Char *cp;
+
+	if (el->el_line.lastchar + num >= el->el_line.limit) {
+		if (!ch_enlargebufs(el, (size_t)num))
+			return;		/* can't go past end of buffer */
+	}
+
+	if (el->el_line.cursor < el->el_line.lastchar) {
+		/* if I must move chars */
+		for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
+			cp[num] = *cp;
+	}
+	el->el_line.lastchar += num;
+}
+
+
+/* c_delafter():
+ *	Delete num characters after the cursor
+ */
+protected void
+c_delafter(EditLine *el, int num)
+{
+
+	if (el->el_line.cursor + num > el->el_line.lastchar)
+		num = (int)(el->el_line.lastchar - el->el_line.cursor);
+
+	if (el->el_map.current != el->el_map.emacs) {
+		cv_undo(el);
+		cv_yank(el, el->el_line.cursor, num);
+	}
+
+	if (num > 0) {
+		Char *cp;
+
+		for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
+			*cp = cp[num];
+
+		el->el_line.lastchar -= num;
+	}
+}
+
+
+/* c_delafter1():
+ *	Delete the character after the cursor, do not yank
+ */
+protected void
+c_delafter1(EditLine *el)
+{
+	Char *cp;
+
+	for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
+		*cp = cp[1];
+
+	el->el_line.lastchar--;
+}
+
+
+/* c_delbefore():
+ *	Delete num characters before the cursor
+ */
+protected void
+c_delbefore(EditLine *el, int num)
+{
+
+	if (el->el_line.cursor - num < 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);
+		cv_yank(el, el->el_line.cursor - num, num);
+	}
+
+	if (num > 0) {
+		Char *cp;
+
+		for (cp = el->el_line.cursor - num;
+		    cp <= el->el_line.lastchar;
+		    cp++)
+			*cp = cp[num];
+
+		el->el_line.lastchar -= num;
+	}
+}
+
+
+/* c_delbefore1():
+ *	Delete the character before the cursor, do not yank
+ */
+protected void
+c_delbefore1(EditLine *el)
+{
+	Char *cp;
+
+	for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
+		*cp = cp[1];
+
+	el->el_line.lastchar--;
+}
+
+
+/* ce__isword():
+ *	Return if p is part of a word according to emacs
+ */
+protected int
+ce__isword(Int p)
+{
+	return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL);
+}
+
+
+/* cv__isword():
+ *	Return if p is part of a word according to vi
+ */
+protected int
+cv__isword(Int p)
+{
+	if (Isalnum(p) || p == '_')
+		return 1;
+	if (Isgraph(p))
+		return 2;
+	return 0;
+}
+
+
+/* cv__isWord():
+ *	Return if p is part of a big word according to vi
+ */
+protected int
+cv__isWord(Int 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))
+{
+	p--;
+
+	while (n--) {
+		while ((p >= low) && !(*wtest)(*p))
+			p--;
+		while ((p >= low) && (*wtest)(*p))
+			p--;
+	}
+
+	/* cp now points to one character before the word */
+	p++;
+	if (p < low)
+		p = low;
+	/* cp now points where we want it */
+	return (p);
+}
+
+
+/* c__next_word():
+ *	Find the next word
+ */
+protected Char *
+c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
+{
+	while (n--) {
+		while ((p < high) && !(*wtest)(*p))
+			p++;
+		while ((p < high) && (*wtest)(*p))
+			p++;
+	}
+	if (p > high)
+		p = high;
+	/* p now points where we want it */
+	return (p);
+}
+
+/* cv_next_word():
+ *	Find the next word vi style
+ */
+protected Char *

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



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