Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 01:00:31 +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: r220176 - in vendor/NetBSD/libedit/dist: . TEST readline
Message-ID:  <201103310100.p2V10V6s086267@svn.freebsd.org>

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

Log:
  Vendor import NetBSD's libedit of "2001/09/29 17:52:10 UTC".
  
  Obtained from:	NetBSD

Added:
  vendor/NetBSD/libedit/dist/read.h   (contents, props changed)
  vendor/NetBSD/libedit/dist/readline/
  vendor/NetBSD/libedit/dist/readline.c   (contents, props changed)
  vendor/NetBSD/libedit/dist/readline/Makefile   (contents, props changed)
  vendor/NetBSD/libedit/dist/readline/readline.h   (contents, props changed)
Deleted:
  vendor/NetBSD/libedit/dist/termcap.h
Modified:
  vendor/NetBSD/libedit/dist/Makefile
  vendor/NetBSD/libedit/dist/TEST/test.c
  vendor/NetBSD/libedit/dist/chared.c
  vendor/NetBSD/libedit/dist/chared.h
  vendor/NetBSD/libedit/dist/common.c
  vendor/NetBSD/libedit/dist/editline.3
  vendor/NetBSD/libedit/dist/editrc.5
  vendor/NetBSD/libedit/dist/el.c
  vendor/NetBSD/libedit/dist/el.h
  vendor/NetBSD/libedit/dist/emacs.c
  vendor/NetBSD/libedit/dist/hist.c
  vendor/NetBSD/libedit/dist/hist.h
  vendor/NetBSD/libedit/dist/histedit.h
  vendor/NetBSD/libedit/dist/history.c
  vendor/NetBSD/libedit/dist/key.c
  vendor/NetBSD/libedit/dist/key.h
  vendor/NetBSD/libedit/dist/makelist
  vendor/NetBSD/libedit/dist/map.c
  vendor/NetBSD/libedit/dist/map.h
  vendor/NetBSD/libedit/dist/parse.c
  vendor/NetBSD/libedit/dist/parse.h
  vendor/NetBSD/libedit/dist/prompt.c
  vendor/NetBSD/libedit/dist/prompt.h
  vendor/NetBSD/libedit/dist/read.c
  vendor/NetBSD/libedit/dist/refresh.c
  vendor/NetBSD/libedit/dist/refresh.h
  vendor/NetBSD/libedit/dist/search.c
  vendor/NetBSD/libedit/dist/search.h
  vendor/NetBSD/libedit/dist/shlib_version
  vendor/NetBSD/libedit/dist/sig.c
  vendor/NetBSD/libedit/dist/sig.h
  vendor/NetBSD/libedit/dist/sys.h
  vendor/NetBSD/libedit/dist/term.c
  vendor/NetBSD/libedit/dist/term.h
  vendor/NetBSD/libedit/dist/tokenizer.c
  vendor/NetBSD/libedit/dist/tokenizer.h
  vendor/NetBSD/libedit/dist/tty.c
  vendor/NetBSD/libedit/dist/tty.h
  vendor/NetBSD/libedit/dist/vi.c

Modified: vendor/NetBSD/libedit/dist/Makefile
==============================================================================
--- vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 00:47:16 2011	(r220175)
+++ vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 01:00:31 2011	(r220176)
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 1997/05/09 07:50:14 mycroft Exp $
+#	$NetBSD: Makefile,v 1.20 2001/01/05 21:15:49 jdolecek Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/4/93
 
 LIB=	edit
@@ -10,54 +10,78 @@ 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_source.3 \
-	editline.3 el_resize.3 editline.3 el_line.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
 
 # For speed and debugging
-#SRCS=   ${OSRCS} tokenizer.c history.c
+#SRCS=   ${OSRCS} tokenizer.c history.c readline.c
 # For protection
-SRCS=	editline.c tokenizer.c history.c
+SRCS=	editline.c tokenizer.c history.c readline.c
 
 SRCS+=	common.h emacs.h fcns.h help.h vi.h
 
+LIBEDITDIR?=${.CURDIR}
+
 INCS= histedit.h
 INCSDIR=/usr/include
 
 CLEANFILES+=common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
-CFLAGS+=-I. -I${.CURDIR} 
-CFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
-CFLAGS+=#-DDEBUG_PASTE
+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
+CPPFLAGS+=-I. -I${LIBEDITDIR} 
+CPPFLAGS+=-I. -I${.CURDIR}
+CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
+CPPFLAGS+=#-DDEBUG_PASTE
 
 AHDR=vi.h emacs.h common.h 
-ASRC=${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c
+ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
+
+SUBDIR=	readline
 
 vi.h: vi.c makelist
-	sh ${.CURDIR}/makelist -h ${.CURDIR}/vi.c > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 emacs.h: emacs.c makelist
-	sh ${.CURDIR}/makelist -h ${.CURDIR}/emacs.c > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/emacs.c > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 common.h: common.c makelist
-	sh ${.CURDIR}/makelist -h ${.CURDIR}/common.c > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/common.c > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 fcns.h: ${AHDR} makelist
-	sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -fh ${AHDR} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 fcns.c: ${AHDR} fcns.h makelist
-	sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -fc ${AHDR} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 help.c: ${ASRC} makelist 
-	sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -bc ${ASRC} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 help.h: ${ASRC} makelist
-	sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -bh ${ASRC} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
 editline.c: ${OSRCS}
-	sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}
+	sh ${LIBEDITDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}.tmp && \
+	    mv ${.TARGET}.tmp ${.TARGET}
 
+test.o:	${LIBEDITDIR}/TEST/test.c
+	
 test:	libedit.a test.o 
-	${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap
+	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap
+
+# minimal dependency to make "make depend" optional
+editline.o editline.po editline.so editline.ln:	\
+	common.h emacs.h fcns.c fcns.h help.c help.h vi.h
+readline.o readline.po readline.so readline.ln:	\
+	common.h emacs.h fcns.h help.h vi.h
 
 .include <bsd.lib.mk>
+.include <bsd.subdir.mk>

Modified: vendor/NetBSD/libedit/dist/TEST/test.c
==============================================================================
--- vendor/NetBSD/libedit/dist/TEST/test.c	Thu Mar 31 00:47:16 2011	(r220175)
+++ vendor/NetBSD/libedit/dist/TEST/test.c	Thu Mar 31 01:00:31 2011	(r220176)
@@ -1,4 +1,4 @@
-/*	$NetBSD	*/
+/*	$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -36,17 +36,17 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
-	The Regents of the University of California.  All rights reserved.\n";
+__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
-static char rcsid[] = "$NetBSD";
+__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -69,182 +69,200 @@ static char rcsid[] = "$NetBSD";
 static int continuation = 0;
 static EditLine *el = NULL;
 
+static	u_char	complete(EditLine *, int);
+	int	main(int, char **);
+static	char   *prompt(EditLine *);
+static	void	sig(int);
+
 static char *
-/*ARGSUSED*/
-prompt(el)
-    EditLine *el;
+prompt(EditLine *el)
 {
-    static char a[] = "Edit$";
-    static char b[] = "Edit>";
-    return continuation ? b : a;
+	static char a[] = "Edit$";
+	static char b[] = "Edit>";
+
+	return (continuation ? b : a);
 }
 
 static void
-sig(i)
-    int i;
+sig(int i)
 {
-    (void) fprintf(stderr, "Got signal %d.\n", i);
-    el_reset(el);
+
+	(void) fprintf(stderr, "Got signal %d.\n", i);
+	el_reset(el);
 }
 
 static unsigned char
-/*ARGSUSED*/
-complete(el, ch)
-    EditLine *el;
-    int ch;
+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(*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;
+	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(*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;
+	closedir(dd);
+	return (CC_ERROR);
 }
 
 int
-/*ARGSUSED*/
-main(argc, argv)
-    int argc;
-    char *argv[];
+main(int argc, char *argv[])
 {
-    int num;
-    const char *buf;
-    Tokenizer *tok;
-    History *hist;
-
-    (void) signal(SIGINT, sig);
-    (void) signal(SIGQUIT, sig);
-    (void) signal(SIGHUP, sig);
-    (void) signal(SIGTERM, sig);
-
-    hist = history_init();		/* Init the builtin history	*/
-    history(hist, H_EVENT, 100);	/* Remember 100 events		*/
-
-    tok  = tok_init(NULL);		/* Initialize the tokenizer	*/
-
-    el = el_init(*argv, stdin, stdout);	/* Initialize editline		*/
-
-    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);
-
-    el_set(el, EL_BIND, "^I", "ed-complete", NULL);/* Bind tab to it 	*/
-
-    /*
-     * 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;
-	char **av;
+	int num;
+	const char *buf;
+	Tokenizer *tok;
+	int lastevent = 0, 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;
+		char **av;
 #ifdef DEBUG
-	(void) fprintf(stderr, "got %d %s", num, buf);
+		(void) fprintf(stderr, "got %d %s", num, buf);
 #endif
-	if (!continuation && num == 1)
-	    continue;
+		if (!continuation && num == 1)
+			continue;
 
-	if (tok_line(tok, buf, &ac, &av) > 0) {
-	    history(hist, continuation ? H_ADD : H_ENTER, buf);
-	    continuation = 1;
-	    continue;
-	}
+		if (tok_line(tok, buf, &ac, &av) > 0)
+			ncontinuation = 1;
+
+#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\n", 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
 
-	history(hist, continuation ? H_ADD : H_ENTER, buf);
+		continuation = ncontinuation;
+		ncontinuation = 0;
 
-	continuation = 0;
+		if (strcmp(av[0], "history") == 0) {
+			int rv;
 
-	if (strcmp(av[0], "history") == 0) {
-	    const struct HistEvent *he;
+			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], 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;
+			}
+		}
 
-	    switch (ac) {
-	    case 1:
-		for (he = history(hist, H_LAST); he;
-		     he = history(hist, H_PREV))
-		    (void) fprintf(stdout, "%4d %s", he->num, he->str);
-		break;
-
-	    case 2:
-		if (strcmp(av[1], "clear") == 0)
-		     history(hist, H_CLEAR);
-		else
-		     goto badhist;
-		break;
-
-	    case 3:
-		if (strcmp(av[1], "load") == 0)
-		     history(hist, H_LOAD, av[2]);
-		else if (strcmp(av[1], "save") == 0)
-		     history(hist, H_SAVE, av[2]);
-		break;
-
-	    badhist:
-	    default:
-		(void) fprintf(stderr, "Bad history arguments\n");
-		break;
-	    }
+		tok_reset(tok);
 	}
-	else if (el_parse(el, ac, av) == -1) {
-	    switch (fork()) {
-	    case 0:
-		execvp(av[0], 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);
+	el_end(el);
+	tok_end(tok);
+	history_end(hist);
 
-    return 0;
+	return (0);
 }

Modified: vendor/NetBSD/libedit/dist/chared.c
==============================================================================
--- vendor/NetBSD/libedit/dist/chared.c	Thu Mar 31 00:47:16 2011	(r220175)
+++ vendor/NetBSD/libedit/dist/chared.c	Thu Mar 31 01:00:31 2011	(r220176)
@@ -1,4 +1,4 @@
-/*	$NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $	*/
+/*	$NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -36,15 +36,16 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #if !defined(lint) && !defined(SCCSID)
 #if 0
 static char sccsid[] = "@(#)chared.c	8.1 (Berkeley) 6/4/93";
 #else
-static char rcsid[] = "$NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 lukem Exp $";
+__RCSID("$NetBSD: chared.c,v 1.14 2001/05/17 01:02:17 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
-/* 
+/*
  * chared.c: Character editor utilities
  */
 #include "sys.h"
@@ -52,72 +53,68 @@ static char rcsid[] = "$NetBSD: chared.c
 #include <stdlib.h>
 #include "el.h"
 
+/* value to leave unused in line buffer */
+#define	EL_LEAVE	2
+
 /* cv_undo():
  *	Handle state for the vi undo command
  */
 protected void
-cv_undo(el, action, size, ptr)
-    EditLine *el;
-    int action, size;
-    char *ptr;
-{
-    c_undo_t *vu = &el->el_chared.c_undo;
-    vu->action = action;
-    vu->ptr    = ptr;
-    vu->isize  = size;
-    (void) memcpy(vu->buf, vu->ptr, size);
+cv_undo(EditLine *el,int action, size_t size, char *ptr)
+{
+	c_undo_t *vu = &el->el_chared.c_undo;
+	vu->action = action;
+	vu->ptr    = ptr;
+	vu->isize  = size;
+	(void) memcpy(vu->buf, vu->ptr, size);
 #ifdef DEBUG_UNDO
-    (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
-		   vu->ptr, vu->isize, vu->dsize);
+	(void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
+	       vu->ptr, vu->isize, vu->dsize);
 #endif
 }
 
 
-/* c_insert(): 
+/* c_insert():
  *	Insert num characters
  */
 protected void
-c_insert(el, num)
-    EditLine *el;
-    int num;
-{
-    char *cp;
-
-    if (el->el_line.lastchar + num >= el->el_line.limit)
-	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;
-} /* end c_insert */
+c_insert(EditLine *el, int num)
+{
+	char *cp;
+
+	if (el->el_line.lastchar + num >= el->el_line.limit)
+		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(el, num)	
-    EditLine *el;
-    int num;
+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_line.cursor + num > el->el_line.lastchar)
+		num = el->el_line.lastchar - el->el_line.cursor;
 
-    if (num > 0) {			
-	char *cp;
+	if (num > 0) {
+		char *cp;
 
-	if (el->el_map.current != el->el_map.emacs) 
-	    cv_undo(el, INSERT, num, el->el_line.cursor);
+		if (el->el_map.current != el->el_map.emacs)
+			cv_undo(el, INSERT, (size_t)num, el->el_line.cursor);
 
-	for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
-	    *cp = cp[num];
+		for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
+			*cp = cp[num];
 
-	el->el_line.lastchar -= num;
-    }
+		el->el_line.lastchar -= num;
+	}
 }
 
 
@@ -125,25 +122,26 @@ c_delafter(el, num)	
  *	Delete num characters before the cursor
  */
 protected void
-c_delbefore(el, num)
-    EditLine *el;
-    int num;
+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_line.cursor - num < el->el_line.buffer)
+		num = el->el_line.cursor - el->el_line.buffer;
 
-    if (num > 0) {		
-	char *cp;
+	if (num > 0) {
+		char *cp;
 
-	if (el->el_map.current != el->el_map.emacs) 
-	    cv_undo(el, INSERT, num, el->el_line.cursor - num);
+		if (el->el_map.current != el->el_map.emacs)
+			cv_undo(el, INSERT, (size_t)num,
+			    el->el_line.cursor - num);
 
-	for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; cp++)
-	    *cp = cp[num];
+		for (cp = el->el_line.cursor - num;
+		    cp <= el->el_line.lastchar;
+		    cp++)
+			*cp = cp[num];
 
-	el->el_line.lastchar -= num;
-    }
+		el->el_line.lastchar -= num;
+	}
 }
 
 
@@ -151,10 +149,9 @@ c_delbefore(el, num)
  *	Return if p is part of a word according to emacs
  */
 protected int
-ce__isword(p) 
-    int p;
+ce__isword(int p)
 {
-    return isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL;
+	return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL);
 }
 
 
@@ -162,10 +159,9 @@ ce__isword(p) 
  *	Return if p is part of a word according to vi
  */
 protected int
-cv__isword(p) 
-    int p;
+cv__isword(int p)
 {
-    return !isspace(p);
+	return (!isspace(p));
 }
 
 
@@ -173,26 +169,23 @@ cv__isword(p) 
  *	Find the previous word
  */
 protected char *
-c__prev_word(p, low, n, wtest) 
-    register char *p, *low;
-    register int n;
-    int (*wtest) __P((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__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);
 }
 
 
@@ -200,53 +193,46 @@ c__prev_word(p, low, n, wtest) 
  *	Find the next word
  */
 protected char *
-c__next_word(p, high, n, wtest)
-    register char *p, *high;
-    register int n;
-    int (*wtest) __P((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;
+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(el, p, high, n, wtest)
-    EditLine *el;
-    register char *p, *high;
-    register int n;
-    int (*wtest) __P((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 (el->el_chared.c_vcmd.action != (DELETE|INSERT)) 
-	    while ((p < high) && isspace((unsigned char) *p)) 
-		p++;
-    }
+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 (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;
+	/* p now points where we want it */
+	if (p > high)
+		return (high);
+	else
+		return (p);
 }
 
 
@@ -254,36 +240,32 @@ cv_next_word(el, p, high, n, wtest)
  *	Find the previous word vi style
  */
 protected char *
-cv_prev_word(el, p, low, n, wtest)
-    EditLine *el;
-    register char *p, *low;
-    register int n;
-    int (*wtest) __P((int));
+cv_prev_word(EditLine *el, char *p, char *low, int n, int (*wtest)(int))
 {
-    int test;
+	int test;
 
-    while (n--) {
-	p--;
-	/*
-	 * vi historically deletes with cb only the word preserving the
-	 * leading whitespace! This is not what 'b' does..
-	 */
-	if (el->el_chared.c_vcmd.action != (DELETE|INSERT)) 
-	    while ((p > low) && isspace((unsigned char) *p)) 
+	while (n--) {
 		p--;
-	test = (*wtest)((unsigned char) *p);
-	while ((p >= low) && (*wtest)((unsigned char) *p) == test) 
-	    p--;
-	p++;
-	while (isspace((unsigned char) *p)) 
+		/*
+		 * vi historically deletes with cb only the word preserving the
+		 * leading whitespace! This is not what 'b' does..
+		 */
+		if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
+			while ((p > low) && isspace((unsigned char) *p))
+				p--;
+		test = (*wtest)((unsigned char) *p);
+		while ((p >= low) && (*wtest)((unsigned char) *p) == test)
+			p--;
 		p++;
-    }
+		while (isspace((unsigned char) *p))
+			p++;
+	}
 
-    /* p now points where we want it */
-    if (p < low)
-	return low;
-    else
-	return p;
+	/* p now points where we want it */
+	if (p < low)
+		return (low);
+	else
+		return (p);
 }
 
 
@@ -294,30 +276,30 @@ cv_prev_word(el, p, low, n, wtest)
  * 	Return p pointing to last char used.
  */
 protected char *
-c__number(p, num, dval)
-    char *p;	/* character position */
-    int *num;	/* Return value	*/
-    int dval;	/* dval is the number to subtract from like $-3 */
-{
-    register int i;
-    register 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;
+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
 
@@ -325,53 +307,50 @@ c__number(p, num, dval)
  *	Finish vi delete action
  */
 protected void
-cv_delfini(el)		
-    EditLine *el;
+cv_delfini(EditLine *el)
 {
-    register int size;
-    int oaction;
+	int size;
+	int oaction;
 
-    if (el->el_chared.c_vcmd.action & INSERT)
-	el->el_map.current = el->el_map.key;
+	if (el->el_chared.c_vcmd.action & INSERT)
+		el->el_map.current = el->el_map.key;
+
+	oaction = el->el_chared.c_vcmd.action;
+	el->el_chared.c_vcmd.action = NOP;
+
+	if (el->el_chared.c_vcmd.pos == 0)
+		return;
+
+
+	if (el->el_line.cursor > el->el_chared.c_vcmd.pos) {
+		size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos);
+		c_delbefore(el, size);
+		el->el_line.cursor = el->el_chared.c_vcmd.pos;
+		re_refresh_cursor(el);
+	} else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) {
+		size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor);
+		c_delafter(el, size);
+	} else {
+		size = 1;
+		c_delafter(el, size);
+	}
+	switch (oaction) {
+	case DELETE|INSERT:
+		el->el_chared.c_undo.action = DELETE|INSERT;
+		break;
+	case DELETE:
+		el->el_chared.c_undo.action = INSERT;
+		break;
+	case NOP:
+	case INSERT:
+	default:
+		EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction));
+		break;
+	}
 
-    oaction = el->el_chared.c_vcmd.action;
-    el->el_chared.c_vcmd.action = NOP;
-
-    if (el->el_chared.c_vcmd.pos == 0) 
-	return;
-
-
-    if (el->el_line.cursor > el->el_chared.c_vcmd.pos) {
-	size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos);
-	c_delbefore(el, size); 
-	el->el_line.cursor = el->el_chared.c_vcmd.pos;
-	re_refresh_cursor(el);
-    }
-    else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) {

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



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