Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 18:31:27 +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: r220218 - in vendor/NetBSD/libedit/dist: . TEST readline
Message-ID:  <201103311831.p2VIVRBR015109@svn.freebsd.org>

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

Log:
  Vendor import NetBSD's libedit of "2007/01/12 16:31:13 UTC".
  
  Obtained from:	NetBSD

Added:
  vendor/NetBSD/libedit/dist/TEST/tc1.c   (contents, props changed)
Deleted:
  vendor/NetBSD/libedit/dist/TEST/test.c
Modified:
  vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/dist/TEST/Makefile
  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/filecomplete.c
  vendor/NetBSD/libedit/dist/filecomplete.h
  vendor/NetBSD/libedit/dist/histedit.h
  vendor/NetBSD/libedit/dist/history.c
  vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/dist/read.h
  vendor/NetBSD/libedit/dist/readline.c
  vendor/NetBSD/libedit/dist/readline/readline.h
  vendor/NetBSD/libedit/dist/shlib_version
  vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/dist/term.h
  vendor/NetBSD/libedit/dist/vi.c

Modified: vendor/NetBSD/libedit/dist/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $
+#	$NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=	yes
@@ -37,7 +37,7 @@ 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
+CLEANFILES+=tc1.o tc1
 CPPFLAGS+=-I. -I${LIBEDITDIR} 
 CPPFLAGS+=-I. -I${.CURDIR}
 CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
@@ -94,9 +94,9 @@ editline.c: ${OSRCS} makelist Makefile
 	${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \
 	    mv ${.TARGET}.tmp ${.TARGET}
 
-test.o:	${LIBEDITDIR}/TEST/test.c
+tc1.o:	${LIBEDITDIR}/TEST/tc1.c
 	
-test:	libedit.a test.o 
+tc1:	libedit.a tc1.o 
 	${_MKTARGET_LINK}
 	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap
 

Modified: vendor/NetBSD/libedit/dist/TEST/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/TEST/Makefile	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/TEST/Makefile	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $
+# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $
 
 NOMAN=1
-PROG=test
+PROG=tc1
 CPPFLAGS=-I${.CURDIR}/..
 LDADD+=-ledit -ltermcap
 DPADD+=${LIBEDIT} ${LIBTERMCAP}

Added: vendor/NetBSD/libedit/dist/TEST/tc1.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/TEST/tc1.c	Thu Mar 31 18:31:27 2011	(r220218)
@@ -0,0 +1,301 @@
+/*	$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo 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.1 2006/08/31 20:20:38 rpaulo 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);
+}

Modified: vendor/NetBSD/libedit/dist/editline.3
==============================================================================
--- vendor/NetBSD/libedit/dist/editline.3	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/editline.3	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: editline.3,v 1.50 2005/10/12 09:29:43 wiz Exp $
+.\"	$NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $
 .\"
 .\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -13,11 +13,7 @@
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"        This product includes software developed by the NetBSD
-.\"        Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" 3. Neither the name of The NetBSD Foundation nor the names of its
 .\"    contributors may be used to endorse or promote products derived
 .\"    from this software without specific prior written permission.
 .\"
@@ -33,7 +29,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 9, 2005
+.Dd January 12, 2007
 .Os
 .Dt EDITLINE 3
 .Sh NAME
@@ -82,7 +78,7 @@
 .Ft int
 .Fn el_set "EditLine *e" "int op" "..."
 .Ft int
-.Fn el_get "EditLine *e" "int op" "void *result"
+.Fn el_get "EditLine *e" "int op" "..."
 .Ft int
 .Fn el_source "EditLine *e" "const char *file"
 .Ft void
@@ -402,6 +398,25 @@ to be associated with this EditLine stru
 It can be retrieved with the corresponding
 .Fn el_get
 call.
+.It Dv EL_SETFP , Fa "int fd" , Fa "FILE *fp"
+Set the current
+.Nm editline
+file pointer for
+.Dq input
+.Fa fd
+=
+.Dv 0 ,
+.Dq output
+.Fa fd
+=
+.Dv 1 ,
+or
+.Dq error
+.Fa fd
+=
+.Dv 2
+from
+.Fa fp .
 .El
 .It Fn el_get
 Get
@@ -426,15 +441,24 @@ Return the name of the editor, which wil
 .Dq emacs
 or
 .Dq vi .
+.It Dv EL_GETTC , Fa "const char *name" , Fa "void *value"
+Return non-zero if
+.Fa name
+is a valid
+.Xr termcap 5
+capability
+and set
+.Fa value
+to the current value of that capability.
 .It Dv EL_SIGNAL , Fa "int *"
 Return non-zero if
 .Nm
 has installed private signal handlers (see
 .Fn el_get
 above).
-.It Dv EL_EDITMODE, Fa "int *"
+.It Dv EL_EDITMODE , Fa "int *"
 Return non-zero if editing is enabled.
-.It Dv EL_GETCFN, Fa "int (**f)(EditLine *, char *)"
+.It Dv EL_GETCFN , Fa "int (**f)(EditLine *, char *)"
 Return a pointer to the function that read characters, which is equal to
 ``EL_BUILTIN_GETCFN'' in the case of the default builtin function.
 .It Dv EL_CLIENTDATA , Fa "void **data"
@@ -443,13 +467,32 @@ Retrieve
 previously registered with the corresponding
 .Fn el_set
 call.
-.It Dv EL_UNBUFFERED, Fa "int"
+.It Dv EL_UNBUFFERED , Fa "int"
 Sets or clears unbuffered mode.
 In this mode,
 .Fn el_gets
 will return immediately after processing a single character.
-.It Dv EL_PREP_TERM, Fa "int"
+.It Dv EL_PREP_TERM , Fa "int"
 Sets or clears terminal editing mode.
+.It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp"
+Return in
+.Fa fp
+the current
+.Nm editline
+file pointer for
+.Dq input
+.Fa fd
+=
+.Dv 0 ,
+.Dq output
+.Fa fd
+=
+.Dv 1 ,
+or
+.Dq error
+.Fa fd
+=
+.Dv 2 .
 .El
 .It Fn el_source
 Initialise
@@ -511,7 +554,7 @@ Returns \-1 if
 is empty or won't fit, and 0 otherwise.
 .It Fn el_deletestr
 Delete
-.Fa num
+.Fa count
 characters before the cursor.
 .El
 .Sh HISTORY LIST FUNCTIONS
@@ -635,7 +678,7 @@ into the history.
 .It Dv H_GETUNIQUE
 Retrieve the current setting if adjacent identical elements should
 be entered into the history.
-.It Dv H_DEL , Fa "int num"
+.It Dv H_DEL , Fa "int e"
 Delete the event numbered
 .Fa e .
 This function is only provided for
@@ -731,7 +774,8 @@ is a NUL terminated string to tokenize.
 .Xr sh 1 ,
 .Xr signal 3 ,
 .Xr termcap 3 ,
-.Xr editrc 5
+.Xr editrc 5 ,
+.Xr termcap 5
 .Sh HISTORY
 The
 .Nm

Modified: vendor/NetBSD/libedit/dist/editrc.5
==============================================================================
--- vendor/NetBSD/libedit/dist/editrc.5	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/editrc.5	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp $
+.\"	$NetBSD: editrc.5,v 1.20 2006/08/21 12:45:30 christos Exp $
 .\"
 .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -13,11 +13,7 @@
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"        This product includes software developed by the NetBSD
-.\"        Foundation, Inc. and its contributors.
-.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" 3. Neither the name of The NetBSD Foundation nor the names of its
 .\"    contributors may be used to endorse or promote products derived
 .\"    from this software without specific prior written permission.
 .\"

Modified: vendor/NetBSD/libedit/dist/el.c
==============================================================================
--- vendor/NetBSD/libedit/dist/el.c	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/el.c	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $	*/
+/*	$NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c	8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.41 2005/08/19 04:21:47 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -65,9 +65,12 @@ el_init(const char *prog, FILE *fin, FIL
 
 	memset(el, 0, sizeof(EditLine));
 
-	el->el_infd = fileno(fin);
+	el->el_infile = fin;
 	el->el_outfile = fout;
 	el->el_errfile = ferr;
+
+	el->el_infd = fileno(fin);
+
 	if ((el->el_prog = el_strdup(prog)) == NULL) {
 		el_free(el);
 		return NULL;
@@ -143,29 +146,29 @@ el_reset(EditLine *el)
 public int
 el_set(EditLine *el, int op, ...)
 {
-	va_list va;
+	va_list ap;
 	int rv = 0;
 
 	if (el == NULL)
 		return (-1);
-	va_start(va, op);
+	va_start(ap, op);
 
 	switch (op) {
 	case EL_PROMPT:
 	case EL_RPROMPT:
-		rv = prompt_set(el, va_arg(va, el_pfunc_t), op);
+		rv = prompt_set(el, va_arg(ap, el_pfunc_t), op);
 		break;
 
 	case EL_TERMINAL:
-		rv = term_set(el, va_arg(va, char *));
+		rv = term_set(el, va_arg(ap, char *));
 		break;
 
 	case EL_EDITOR:
-		rv = map_set_editor(el, va_arg(va, char *));
+		rv = map_set_editor(el, va_arg(ap, char *));
 		break;
 
 	case EL_SIGNAL:
-		if (va_arg(va, int))
+		if (va_arg(ap, int))
 			el->el_flags |= HANDLE_SIGNALS;
 		else
 			el->el_flags &= ~HANDLE_SIGNALS;
@@ -174,6 +177,7 @@ el_set(EditLine *el, int op, ...)
 	case EL_BIND:
 	case EL_TELLTC:
 	case EL_SETTC:
+	case EL_GETTC:
 	case EL_ECHOTC:
 	case EL_SETTY:
 	{
@@ -181,7 +185,7 @@ el_set(EditLine *el, int op, ...)
 		int i;
 
 		for (i = 1; i < 20; i++)
-			if ((argv[i] = va_arg(va, char *)) == NULL)
+			if ((argv[i] = va_arg(ap, char *)) == NULL)
 				break;
 
 		switch (op) {
@@ -220,9 +224,9 @@ el_set(EditLine *el, int op, ...)
 
 	case EL_ADDFN:
 	{
-		char *name = va_arg(va, char *);
-		char *help = va_arg(va, char *);
-		el_func_t func = va_arg(va, el_func_t);
+		char *name = va_arg(ap, char *);
+		char *help = va_arg(ap, char *);
+		el_func_t func = va_arg(ap, el_func_t);
 
 		rv = map_addfunc(el, name, help, func);
 		break;
@@ -230,15 +234,15 @@ el_set(EditLine *el, int op, ...)
 
 	case EL_HIST:
 	{
-		hist_fun_t func = va_arg(va, hist_fun_t);
-		ptr_t ptr = va_arg(va, char *);
+		hist_fun_t func = va_arg(ap, hist_fun_t);
+		ptr_t ptr = va_arg(ap, char *);
 
 		rv = hist_set(el, func, ptr);
 		break;
 	}
 
 	case EL_EDITMODE:
-		if (va_arg(va, int))
+		if (va_arg(ap, int))
 			el->el_flags &= ~EDIT_DISABLED;
 		else
 			el->el_flags |= EDIT_DISABLED;
@@ -247,17 +251,17 @@ el_set(EditLine *el, int op, ...)
 
 	case EL_GETCFN:
 	{
-		el_rfunc_t rc = va_arg(va, el_rfunc_t);
+		el_rfunc_t rc = va_arg(ap, el_rfunc_t);
 		rv = el_read_setfn(el, rc);
 		break;
 	}
 
 	case EL_CLIENTDATA:
-		el->el_data = va_arg(va, void *);
+		el->el_data = va_arg(ap, void *);
 		break;
 
 	case EL_UNBUFFERED:
-		rv = va_arg(va, int);
+		rv = va_arg(ap, int);
 		if (rv && !(el->el_flags & UNBUFFERED)) {
 			el->el_flags |= UNBUFFERED;
 			read_prepare(el);
@@ -269,7 +273,7 @@ el_set(EditLine *el, int op, ...)
 		break;
 
 	case EL_PREP_TERM:
-		rv = va_arg(va, int);
+		rv = va_arg(ap, int);
 		if (rv)
 			(void) tty_rawmode(el);
 		else
@@ -277,12 +281,39 @@ el_set(EditLine *el, int op, ...)
 		rv = 0;
 		break;
 
+	case EL_SETFP:
+	{
+		FILE *fp;
+		int what;
+
+		what = va_arg(ap, int);
+		fp = va_arg(ap, FILE *);
+
+		rv = 0;
+		switch (what) {
+		case 0:
+			el->el_infile = fp;
+			el->el_infd = fileno(fp);
+			break;
+		case 1:
+			el->el_outfile = fp;
+			break;
+		case 2:
+			el->el_errfile = fp;
+			break;
+		default:
+			rv = -1;
+			break;
+		}
+		break;
+	}
+
 	default:
 		rv = -1;
 		break;
 	}
 
-	va_end(va);
+	va_end(ap);
 	return (rv);
 }
 
@@ -291,90 +322,71 @@ el_set(EditLine *el, int op, ...)
  *	retrieve the editline parameters
  */
 public int
-el_get(EditLine *el, int op, void *ret)
+el_get(EditLine *el, int op, ...)
 {
+	va_list ap;
 	int rv;
 
-	if (el == NULL || ret == NULL)
-		return (-1);
+	if (el == NULL)
+		return -1;
+
+	va_start(ap, op);
+
 	switch (op) {
 	case EL_PROMPT:
 	case EL_RPROMPT:
-		rv = prompt_get(el, (el_pfunc_t *) ret, op);
+		rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op);
 		break;
 
 	case EL_EDITOR:
-		rv = map_get_editor(el, (const char **)ret);
+		rv = map_get_editor(el, va_arg(ap, const char **));
 		break;
 
 	case EL_SIGNAL:
-		*((int *) ret) = (el->el_flags & HANDLE_SIGNALS);
+		*va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS);
 		rv = 0;
 		break;
 
 	case EL_EDITMODE:
-		*((int *) ret) = (!(el->el_flags & EDIT_DISABLED));
+		*va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED);
 		rv = 0;
 		break;
 
 	case EL_TERMINAL:
-		term_get(el, (const char **)ret);
+		term_get(el, va_arg(ap, const char **));
 		rv = 0;
 		break;
 
-#if 0				/* XXX */
-	case EL_BIND:
-	case EL_TELLTC:
-	case EL_SETTC:
-	case EL_ECHOTC:
-	case EL_SETTY:
+	case EL_GETTC:
 	{
-		const char *argv[20];
+		static char name[] = "gettc";
+		char *argv[20];
 		int i;
 
  		for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
-			if ((argv[i] = va_arg(va, char *)) == NULL)
+			if ((argv[i] = va_arg(ap, char *)) == NULL)
 				break;
 
 		switch (op) {
-		case EL_BIND:
-			argv[0] = "bind";
-			rv = map_bind(el, i, argv);
-			break;
-
-		case EL_TELLTC:
-			argv[0] = "telltc";
-			rv = term_telltc(el, i, argv);
-			break;
-
-		case EL_SETTC:
-			argv[0] = "settc";
-			rv = term_settc(el, i, argv);
-			break;
-
-		case EL_ECHOTC:
-			argv[0] = "echotc";
-			rv = term_echotc(el, i, argv);
-			break;
-
-		case EL_SETTY:
-			argv[0] = "setty";
-			rv = tty_stty(el, i, argv);
+		case EL_GETTC:
+			argv[0] = name;
+			rv = term_gettc(el, i, argv);
 			break;
 
 		default:
 			rv = -1;
-			EL_ABORT((el->errfile, "Bad op %d\n", op));
+			EL_ABORT((el->el_errfile, "Bad op %d\n", op));
 			break;
 		}
 		break;
 	}
 
+#if 0 /* XXX */
 	case EL_ADDFN:
 	{
-		char *name = va_arg(va, char *);
-		char *help = va_arg(va, char *);
-		el_func_t func = va_arg(va, el_func_t);
+		char *name = va_arg(ap, char *);
+		char *help = va_arg(ap, char *);
+		el_func_t func = va_arg(ap, el_func_t);
 
 		rv = map_addfunc(el, name, help, func);
 		break;
@@ -382,31 +394,57 @@ el_get(EditLine *el, int op, void *ret)
 
 	case EL_HIST:
 		{
-			hist_fun_t func = va_arg(va, hist_fun_t);
-			ptr_t ptr = va_arg(va, char *);
+			hist_fun_t func = va_arg(ap, hist_fun_t);
+			ptr_t ptr = va_arg(ap, char *);
 			rv = hist_set(el, func, ptr);
 		}
 		break;
 #endif /* XXX */
 
 	case EL_GETCFN:
-		*((el_rfunc_t *)ret) = el_read_getfn(el);
+		*va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
 		rv = 0;
 		break;
 
 	case EL_CLIENTDATA:
-		*((void **)ret) = el->el_data;
+		*va_arg(ap, void **) = el->el_data;
 		rv = 0;
 		break;
 
 	case EL_UNBUFFERED:
-		*((int *) ret) = (!(el->el_flags & UNBUFFERED));
+		*va_arg(ap, int *) = (!(el->el_flags & UNBUFFERED));
 		rv = 0;
 		break;
 
+	case EL_GETFP:
+	{
+		int what;
+		FILE **fpp;
+
+		what = va_arg(ap, int);
+		fpp = va_arg(ap, FILE **);
+		rv = 0;
+		switch (what) {
+		case 0:
+			*fpp = el->el_infile;
+			break;
+		case 1:
+			*fpp = el->el_outfile;
+			break;
+		case 2:
+			*fpp = el->el_errfile;
+			break;
+		default:
+			rv = -1;
+			break;
+		}
+		break;
+	}
 	default:
 		rv = -1;
+		break;
 	}
+	va_end(ap);
 
 	return (rv);
 }

Modified: vendor/NetBSD/libedit/dist/el.h
==============================================================================
--- vendor/NetBSD/libedit/dist/el.h	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/el.h	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $	*/
+/*	$NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -110,6 +110,7 @@ typedef struct el_state_t {
 
 struct editline {
 	char		 *el_prog;	/* the program name		*/
+	FILE		 *el_infile;	/* Stdio stuff			*/
 	FILE		 *el_outfile;	/* Stdio stuff			*/
 	FILE		 *el_errfile;	/* Stdio stuff			*/
 	int		  el_infd;	/* Input file descriptor	*/

Modified: vendor/NetBSD/libedit/dist/filecomplete.c
==============================================================================
--- vendor/NetBSD/libedit/dist/filecomplete.c	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/filecomplete.c	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-/*	$NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $	*/
+/*	$NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -15,11 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * 3. Neither the name of The NetBSD Foundation nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
@@ -38,7 +34,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.8 2005/08/03 13:41:38 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -398,6 +394,7 @@ fn_complete(EditLine *el,
 	const char *ctemp;
 	size_t len;
 	int what_to_do = '\t';
+	int retval = CC_NORM;
 
 	if (el->el_state.lastcmd == el->el_state.thiscmd)
 		what_to_do = '?';
@@ -420,7 +417,11 @@ fn_complete(EditLine *el,
 		ctemp--;
 
 	len = li->cursor - ctemp;
+#if defined(__SSP__) || defined(__SSP_ALL__)
+	temp = malloc(len + 1);
+#else
 	temp = alloca(len + 1);
+#endif
 	(void)strncpy(temp, ctemp, len);
 	temp[len] = '\0';
 
@@ -445,9 +446,10 @@ fn_complete(EditLine *el,
 		*over = 0;
 
 	if (matches) {
-		int i, retval = CC_REFRESH;
+		int i;
 		int matches_num, maxlen, match_len, match_display=1;
 
+		retval = CC_REFRESH;
 		/*
 		 * Only replace the completed string with common part of
 		 * possible matches if there is possible completion.
@@ -519,11 +521,13 @@ fn_complete(EditLine *el,
 		/* free elements of array and the array itself */
 		for (i = 0; matches[i]; i++)
 			free(matches[i]);
-		free(matches), matches = NULL;
-
-		return (retval);
+		free(matches);
+		matches = NULL;
 	}
-	return (CC_NORM);
+#if defined(__SSP__) || defined(__SSP_ALL__)
+	free(temp);
+#endif
+	return retval;
 }
 
 /*

Modified: vendor/NetBSD/libedit/dist/filecomplete.h
==============================================================================
--- vendor/NetBSD/libedit/dist/filecomplete.h	Thu Mar 31 18:29:20 2011	(r220217)
+++ vendor/NetBSD/libedit/dist/filecomplete.h	Thu Mar 31 18:31:27 2011	(r220218)
@@ -1,4 +1,4 @@
-/*	$NetBSD: filecomplete.h,v 1.4 2005/06/11 18:18:59 christos Exp $	*/
+/*	$NetBSD: filecomplete.h,v 1.5 2006/08/21 12:45:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -15,11 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * 3. Neither the name of The NetBSD Foundation nor the names of its

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



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