Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 01:14:06 +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: r220179 - in vendor/NetBSD/libedit/2005-08-02: . TEST readline
Message-ID:  <201103310114.p2V1E6Zo086675@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: obrien
Date: Thu Mar 31 01:14:06 2011
New Revision: 220179
URL: http://svn.freebsd.org/changeset/base/220179

Log:
  "Tag" the "2005/08/02 12:11:14 UTC" import.

Added:
  vendor/NetBSD/libedit/2005-08-02/
     - copied from r220176, vendor/NetBSD/libedit/dist/
  vendor/NetBSD/libedit/2005-08-02/TEST/Makefile
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/TEST/Makefile
  vendor/NetBSD/libedit/2005-08-02/config.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/config.h
  vendor/NetBSD/libedit/2005-08-02/filecomplete.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/filecomplete.c
  vendor/NetBSD/libedit/2005-08-02/filecomplete.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/filecomplete.h
Replaced:
  vendor/NetBSD/libedit/2005-08-02/Makefile
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/2005-08-02/TEST/test.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/TEST/test.c
  vendor/NetBSD/libedit/2005-08-02/chared.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/chared.c
  vendor/NetBSD/libedit/2005-08-02/chared.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/chared.h
  vendor/NetBSD/libedit/2005-08-02/common.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/common.c
  vendor/NetBSD/libedit/2005-08-02/editline.3
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/2005-08-02/editrc.5
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/editrc.5
  vendor/NetBSD/libedit/2005-08-02/el.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/2005-08-02/el.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/el.h
  vendor/NetBSD/libedit/2005-08-02/emacs.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/emacs.c
  vendor/NetBSD/libedit/2005-08-02/hist.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/hist.c
  vendor/NetBSD/libedit/2005-08-02/hist.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/2005-08-02/histedit.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/histedit.h
  vendor/NetBSD/libedit/2005-08-02/history.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/history.c
  vendor/NetBSD/libedit/2005-08-02/key.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/key.c
  vendor/NetBSD/libedit/2005-08-02/key.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/key.h
  vendor/NetBSD/libedit/2005-08-02/makelist
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/makelist
  vendor/NetBSD/libedit/2005-08-02/map.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/2005-08-02/map.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/map.h
  vendor/NetBSD/libedit/2005-08-02/parse.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/parse.c
  vendor/NetBSD/libedit/2005-08-02/parse.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/parse.h
  vendor/NetBSD/libedit/2005-08-02/prompt.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/prompt.c
  vendor/NetBSD/libedit/2005-08-02/prompt.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/prompt.h
  vendor/NetBSD/libedit/2005-08-02/read.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/read.c
  vendor/NetBSD/libedit/2005-08-02/read.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/read.h
  vendor/NetBSD/libedit/2005-08-02/readline.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/2005-08-02/readline/Makefile
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline/Makefile
  vendor/NetBSD/libedit/2005-08-02/readline/readline.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/2005-08-02/refresh.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/refresh.c
  vendor/NetBSD/libedit/2005-08-02/refresh.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/refresh.h
  vendor/NetBSD/libedit/2005-08-02/search.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/2005-08-02/search.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/search.h
  vendor/NetBSD/libedit/2005-08-02/shlib_version
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/shlib_version
  vendor/NetBSD/libedit/2005-08-02/sig.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sig.c
  vendor/NetBSD/libedit/2005-08-02/sig.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sig.h
  vendor/NetBSD/libedit/2005-08-02/sys.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/sys.h
  vendor/NetBSD/libedit/2005-08-02/term.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/2005-08-02/term.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/term.h
  vendor/NetBSD/libedit/2005-08-02/tokenizer.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/2005-08-02/tty.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/2005-08-02/tty.h
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/tty.h
  vendor/NetBSD/libedit/2005-08-02/vi.c
     - copied unchanged from r220178, vendor/NetBSD/libedit/dist/vi.c
Deleted:
  vendor/NetBSD/libedit/2005-08-02/tokenizer.h

Copied: vendor/NetBSD/libedit/2005-08-02/Makefile (from r220178, vendor/NetBSD/libedit/dist/Makefile)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2005-08-02/Makefile	Thu Mar 31 01:14:06 2011	(r220179, copy of r220178, vendor/NetBSD/libedit/dist/Makefile)
@@ -0,0 +1,104 @@
+#	$NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $
+#	@(#)Makefile	8.1 (Berkeley) 6/4/93
+
+USE_SHLIBDIR=	yes
+
+WARNS=	3
+LIB=	edit
+
+LIBDPLIBS=     termcap ${.CURDIR}/../libterm
+
+OSRCS=	chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \
+	key.c map.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} tokenizer.c history.c readline.c
+# For protection
+SRCS=	editline.c tokenizer.c history.c readline.c
+
+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
+CLEANFILES+=test.o test
+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}
+
+test.o:	${LIBEDITDIR}/TEST/test.c
+	
+test:	libedit.a test.o 
+	${_MKTARGET_LINK}
+	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap
+
+.include <bsd.lib.mk>
+.include <bsd.subdir.mk>

Copied: vendor/NetBSD/libedit/2005-08-02/TEST/Makefile (from r220178, vendor/NetBSD/libedit/dist/TEST/Makefile)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2005-08-02/TEST/Makefile	Thu Mar 31 01:14:06 2011	(r220179, copy of r220178, vendor/NetBSD/libedit/dist/TEST/Makefile)
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $
+
+NOMAN=1
+PROG=test
+CPPFLAGS=-I${.CURDIR}/..
+LDADD+=-ledit -ltermcap
+DPADD+=${LIBEDIT} ${LIBTERMCAP}
+
+.ifdef DEBUG
+CPPFLAGS+=-DDEBUG
+.endif
+
+.include <bsd.prog.mk>

Copied: vendor/NetBSD/libedit/2005-08-02/TEST/test.c (from r220178, vendor/NetBSD/libedit/dist/TEST/test.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2005-08-02/TEST/test.c	Thu Mar 31 01:14:06 2011	(r220179, copy of r220178, vendor/NetBSD/libedit/dist/TEST/test.c)
@@ -0,0 +1,301 @@
+/*	$NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem 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: test.c,v 1.18 2005/06/01 11:37:52 lukem 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 "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[] = "Edit$ ";
+	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;
+
+	/*
+	 * 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) {
+			closedir(dd);
+			if (el_insertstr(el, &dp->d_name[len]) == -1)
+				return (CC_ERROR);
+			else
+				return (CC_REFRESH);
+		}
+	}
+
+	closedir(dd);
+	return (CC_ERROR);
+}
+
+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) 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, prompt);	/* 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/2005-08-02/chared.c (from r220178, vendor/NetBSD/libedit/dist/chared.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/2005-08-02/chared.c	Thu Mar 31 01:14:06 2011	(r220179, copy of r220178, vendor/NetBSD/libedit/dist/chared.c)
@@ -0,0 +1,775 @@
+/*	$NetBSD: chared.c,v 1.24 2005/08/01 23:00:15 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.24 2005/08/01 23:00:15 christos Exp $");
+#endif
+#endif /* not lint && not SCCSID */
+
+/*
+ * chared.c: Character editor utilities
+ */
+#include <stdlib.h>
+#include "el.h"
+
+private void ch__clearmacro __P((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;
+	unsigned int 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);
+
+	/* 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;
+
+	memcpy(k->buf, ptr, size +0u);
+	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, num +0u))
+			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 = 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 = 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("*?_-.[]~=", 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)((unsigned char) *p))
+			p--;
+		while ((p >= low) && (*wtest)((unsigned char) *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)((unsigned char) *p))
+			p++;
+		while ((p < high) && (*wtest)((unsigned char) *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 *
+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)
+			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))
+				p++;
+	}
+
+	/* p now points where we want it */
+	if (p > high)
+		return (high);
+	else
+		return (p);
+}
+
+
+/* cv_prev_word():
+ *	Find the previous word vi style
+ */
+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))
+			p--;
+		test = (*wtest)((unsigned char) *p);
+		while ((p >= low) && (*wtest)((unsigned char) *p) == test)
+			p--;
+	}
+	p++;
+
+	/* p now points where we want it */
+	if (p < low)
+		return (low);
+	else
+		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;
+	}
+	for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
+		continue;
+	*num = (sign < 0 ? dval - i : i);
+	return (--p);
+}
+#endif
+
+/* cv_delfini():
+ *	Finish vi delete action
+ */
+protected void
+cv_delfini(EditLine *el)
+{
+	int size;
+	int action = el->el_chared.c_vcmd.action;
+
+	if (action & INSERT)
+		el->el_map.current = el->el_map.key;
+
+	if (el->el_chared.c_vcmd.pos == 0)
+		/* sanity */
+		return;
+
+	size = 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;
+	if (action & YANK) {
+		if (size > 0)
+			cv_yank(el, el->el_line.cursor, size);
+		else
+			cv_yank(el, el->el_line.cursor + size, -size);
+	} else {
+		if (size > 0) {
+			c_delafter(el, size);
+			re_refresh_cursor(el);
+		} else  {
+			c_delbefore(el, -size);
+			el->el_line.cursor += size;
+		}
+	}
+	el->el_chared.c_vcmd.action = NOP;
+}
+
+
+#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((unsigned char) *p))
+			p++;
+		while ((p < high) && !isspace((unsigned char) *p))
+			p++;
+	}
+
+	p--;
+	return (p);
+}
+#endif
+
+
+/* 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))
+{
+	int test;
+
+	p++;
+
+	while (n--) {
+		while ((p < high) && isspace((unsigned char) *p))
+			p++;
+
+		test = (*wtest)((unsigned char) *p);
+		while ((p < high) && (*wtest)((unsigned char) *p) == test)
+			p++;
+	}
+	p--;
+	return (p);
+}
+
+/* ch_init():
+ *	Initialize the character editor
+ */
+protected int
+ch_init(EditLine *el)
+{
+	c_macro_t *ma = &el->el_chared.c_macro;
+
+	el->el_line.buffer		= (char *) el_malloc(EL_BUFSIZ);
+	if (el->el_line.buffer == NULL)
+		return (-1);
+
+	(void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
+	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);
+	if (el->el_chared.c_undo.buf == NULL)
+		return (-1);
+	(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
+	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);
+	if (el->el_chared.c_redo.buf == NULL)
+		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;
+
+	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);
+	if (el->el_chared.c_kill.buf == NULL)
+		return (-1);
+	(void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
+	el->el_chared.c_kill.mark	= el->el_line.buffer;
+	el->el_chared.c_kill.last	= el->el_chared.c_kill.buf;
+
+	el->el_map.current		= el->el_map.key;
+
+	el->el_state.inputmode		= MODE_INSERT; /* XXX: save a default */
+	el->el_state.doingarg		= 0;
+	el->el_state.metanext		= 0;
+	el->el_state.argument		= 1;
+	el->el_state.lastcmd		= ED_UNASSIGNED;
+
+	ma->level	= -1;
+	ma->offset	= 0;
+	ma->macro	= (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
+	if (ma->macro == NULL)
+		return (-1);
+	return (0);
+}
+
+/* ch_reset():
+ *	Reset the character editor
+ */
+protected void
+ch_reset(EditLine *el, int mclear)
+{
+	el->el_line.cursor		= el->el_line.buffer;
+	el->el_line.lastchar		= el->el_line.buffer;
+
+	el->el_chared.c_undo.len	= -1;
+	el->el_chared.c_undo.cursor	= 0;
+
+	el->el_chared.c_vcmd.action	= NOP;
+	el->el_chared.c_vcmd.pos	= el->el_line.buffer;
+
+	el->el_chared.c_kill.mark	= el->el_line.buffer;
+
+	el->el_map.current		= el->el_map.key;
+
+	el->el_state.inputmode		= MODE_INSERT; /* XXX: save a default */
+	el->el_state.doingarg		= 0;
+	el->el_state.metanext		= 0;
+	el->el_state.argument		= 1;
+	el->el_state.lastcmd		= ED_UNASSIGNED;
+
+	if (mclear)
+		ch__clearmacro(el);
+}
+
+private void
+ch__clearmacro(el)
+	EditLine *el;
+{
+	c_macro_t *ma = &el->el_chared.c_macro;
+	while (ma->level >= 0)
+		el_free((ptr_t)ma->macro[ma->level--]);
+}
+
+/* ch_enlargebufs():
+ *	Enlarge line buffer to be able to hold twice as much characters.
+ *	Returns 1 if successful, 0 if not.
+ */
+protected int
+ch_enlargebufs(el, addlen)
+	EditLine *el;
+	size_t addlen;
+{
+	size_t sz, newsz;
+	char *newbuffer, *oldbuf, *oldkbuf;
+
+	sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
+	newsz = sz * 2;
+	/*
+	 * If newly required length is longer than current buffer, we need
+	 * to make the buffer big enough to hold both old and new stuff.
+	 */
+	if (addlen > sz) {
+		while(newsz - sz < addlen)
+			newsz *= 2;
+	}
+
+	/*
+	 * Reallocate line buffer.
+	 */
+	newbuffer = el_realloc(el->el_line.buffer, newsz);
+	if (!newbuffer)
+		return 0;
+
+	/* zero the newly added memory, leave old data in */
+	(void) memset(&newbuffer[sz], 0, newsz - sz);

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



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