Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 00:46: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: r220174 - in vendor/NetBSD/libedit: . dist dist/TEST
Message-ID:  <201103310046.p2V0kR7e085873@svn.freebsd.org>

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

Log:
  Vendor import NetBSD's libedit of "1997-06-25 01:14:45 -0700".
  
  Obtained from:	NetBSD

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

Added: vendor/NetBSD/libedit/dist/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/Makefile	Thu Mar 31 00:46:27 2011	(r220174)
@@ -0,0 +1,63 @@
+#	$NetBSD: Makefile,v 1.8 1997/05/09 07:50:14 mycroft Exp $
+#	@(#)Makefile	8.1 (Berkeley) 6/4/93
+
+LIB=	edit
+
+OSRCS=	chared.c common.c el.c emacs.c fcns.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_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
+# For protection
+SRCS=	editline.c tokenizer.c history.c
+
+SRCS+=	common.h emacs.h fcns.h help.h vi.h
+
+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
+
+AHDR=vi.h emacs.h common.h 
+ASRC=${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c
+
+vi.h: vi.c makelist
+	sh ${.CURDIR}/makelist -h ${.CURDIR}/vi.c > ${.TARGET}
+
+emacs.h: emacs.c makelist
+	sh ${.CURDIR}/makelist -h ${.CURDIR}/emacs.c > ${.TARGET}
+
+common.h: common.c makelist
+	sh ${.CURDIR}/makelist -h ${.CURDIR}/common.c > ${.TARGET}
+
+fcns.h: ${AHDR} makelist
+	sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET}
+
+fcns.c: ${AHDR} fcns.h makelist
+	sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET}
+
+help.c: ${ASRC} makelist 
+	sh ${.CURDIR}/makelist -bc ${ASRC} > ${.TARGET}
+
+help.h: ${ASRC} makelist
+	sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET}
+
+editline.c: ${OSRCS}
+	sh ${.CURDIR}/makelist -e ${.ALLSRC:T} > ${.TARGET}
+
+test:	libedit.a test.o 
+	${CC} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap
+
+.include <bsd.lib.mk>

Added: vendor/NetBSD/libedit/dist/TEST/test.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/TEST/test.c	Thu Mar 31 00:46:27 2011	(r220174)
@@ -0,0 +1,250 @@
+/*	$NetBSD	*/
+
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#ifndef lint
+static char 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";
+#endif
+#endif /* not lint && not SCCSID */
+
+/*
+ * test.c: A little test program
+ */
+#include "sys.h"
+#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"
+#include "tokenizer.h"
+
+static int continuation = 0;
+static EditLine *el = NULL;
+
+static char *
+/*ARGSUSED*/
+prompt(el)
+    EditLine *el;
+{
+    static char a[] = "Edit$";
+    static char b[] = "Edit>";
+    return continuation ? b : a;
+}
+
+static void
+sig(i)
+    int i;
+{
+    (void) fprintf(stderr, "Got signal %d.\n", i);
+    el_reset(el);
+}
+
+static unsigned char
+/*ARGSUSED*/
+complete(el, ch)
+    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;
+	}
+    }
+
+    closedir(dd);
+    return CC_ERROR;
+}
+
+int
+/*ARGSUSED*/
+main(argc, argv)
+    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;
+#ifdef DEBUG
+	(void) fprintf(stderr, "got %d %s", num, buf);
+#endif
+	if (!continuation && num == 1)
+	    continue;
+
+	if (tok_line(tok, buf, &ac, &av) > 0) {
+	    history(hist, continuation ? H_ADD : H_ENTER, buf);
+	    continuation = 1;
+	    continue;
+	}
+
+	history(hist, continuation ? H_ADD : H_ENTER, buf);
+
+	continuation = 0;
+
+	if (strcmp(av[0], "history") == 0) {
+	    const struct HistEvent *he;
+
+	    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;
+	    }
+	}
+	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);
+
+    return 0;
+}

Added: vendor/NetBSD/libedit/dist/chared.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/chared.c	Thu Mar 31 00:46:27 2011	(r220174)
@@ -0,0 +1,645 @@
+/*	$NetBSD: chared.c,v 1.2 1997/01/11 06:47:48 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#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 $";
+#endif
+#endif /* not lint && not SCCSID */
+
+/* 
+ * chared.c: Character editor utilities
+ */
+#include "sys.h"
+
+#include <stdlib.h>
+#include "el.h"
+
+/* 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);
+#ifdef DEBUG_UNDO
+    (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
+		   vu->ptr, vu->isize, vu->dsize);
+#endif
+}
+
+
+/* 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_delafter():
+ *	Delete num characters after the cursor
+ */
+protected void
+c_delafter(el, num)	
+    EditLine *el;
+    int num;
+{
+
+    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 (el->el_map.current != el->el_map.emacs) 
+	    cv_undo(el, INSERT, num, el->el_line.cursor);
+
+	for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
+	    *cp = cp[num];
+
+	el->el_line.lastchar -= num;
+    }
+}
+
+
+/* c_delbefore():
+ *	Delete num characters before the cursor
+ */
+protected void
+c_delbefore(el, num)
+    EditLine *el;
+    int num;
+{
+
+    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 (el->el_map.current != el->el_map.emacs) 
+	    cv_undo(el, INSERT, num, el->el_line.cursor - num);
+
+	for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; cp++)
+	    *cp = cp[num];
+
+	el->el_line.lastchar -= num;
+    }
+}
+
+
+/* ce__isword():
+ *	Return if p is part of a word according to emacs
+ */
+protected int
+ce__isword(p) 
+    int p;
+{
+    return isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL;
+}
+
+
+/* cv__isword():
+ *	Return if p is part of a word according to vi
+ */
+protected int
+cv__isword(p) 
+    int p;
+{
+    return !isspace(p);
+}
+
+
+/* c__prev_word():
+ *	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__next_word():
+ *	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;
+}
+
+/* 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++;
+    }
+
+    /* 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(el, p, low, n, wtest)
+    EditLine *el;
+    register char *p, *low;
+    register int n;
+    int (*wtest) __P((int));
+{
+    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)) 
+		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;
+}
+
+
+#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(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;
+}
+#endif
+
+/* cv_delfini():
+ *	Finish vi delete action
+ */
+protected void
+cv_delfini(el)		
+    EditLine *el;
+{
+    register int size;
+    int oaction;
+
+    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:
+	abort();
+	break;
+    }
+	
+
+    el->el_chared.c_undo.ptr = el->el_line.cursor;
+    el->el_chared.c_undo.dsize = size;
+}
+
+
+#ifdef notdef
+/* ce__endword():
+ *	Go to the end of this word according to emacs
+ */
+protected char *
+ce__endword(p, high, n)
+    char *p, *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(p, high, n)
+    char *p, *high;
+    int n;
+{
+    p++;
+
+    while (n--) {
+	while ((p < high) && isspace((unsigned char) *p)) 
+	    p++;
+
+	if (isalnum((unsigned char) *p))
+	    while ((p < high) && isalnum((unsigned char) *p)) 
+		p++;
+	else
+	    while ((p < high) && !(isspace((unsigned char) *p) || 
+				   isalnum((unsigned char) *p)))
+		p++;
+    }
+    p--;
+    return p;
+}
+
+/* ch_init():
+ *	Initialize the character editor
+ */
+protected int
+ch_init(el)
+    EditLine *el;
+{
+    el->el_line.buffer              = (char *)  el_malloc(EL_BUFSIZ);
+    (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 - 2];
+
+    el->el_chared.c_undo.buf        = (char *)  el_malloc(EL_BUFSIZ);
+    (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
+    el->el_chared.c_undo.action     = NOP;
+    el->el_chared.c_undo.isize      = 0;
+    el->el_chared.c_undo.dsize      = 0;
+    el->el_chared.c_undo.ptr        = el->el_line.buffer;
+
+    el->el_chared.c_vcmd.action     = NOP;
+    el->el_chared.c_vcmd.pos        = el->el_line.buffer;
+    el->el_chared.c_vcmd.ins        = el->el_line.buffer;
+
+    el->el_chared.c_kill.buf        = (char *)  el_malloc(EL_BUFSIZ);
+    (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;
+
+    el->el_chared.c_macro.nline     = NULL;
+    el->el_chared.c_macro.level     = -1;
+    el->el_chared.c_macro.macro     = (char **) el_malloc(EL_MAXMACRO * 
+						          sizeof(char *));
+    return 0;
+}
+
+/* ch_reset():
+ *	Reset the character editor
+ */
+protected void
+ch_reset(el)
+    EditLine *el;
+{
+    el->el_line.cursor              = el->el_line.buffer;
+    el->el_line.lastchar            = el->el_line.buffer;
+
+    el->el_chared.c_undo.action     = NOP;
+    el->el_chared.c_undo.isize      = 0;
+    el->el_chared.c_undo.dsize      = 0;
+    el->el_chared.c_undo.ptr        = el->el_line.buffer;
+
+    el->el_chared.c_vcmd.action     = NOP;
+    el->el_chared.c_vcmd.pos        = el->el_line.buffer;
+    el->el_chared.c_vcmd.ins        = 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;
+
+    el->el_chared.c_macro.level     = -1;
+
+    el->el_history.eventno = 0;
+}
+
+
+/* ch_end():
+ *	Free the data structures used by the editor
+ */
+protected void
+ch_end(el)
+    EditLine *el;
+{
+    el_free((ptr_t) el->el_line.buffer);
+    el->el_line.buffer = NULL;
+    el->el_line.limit = NULL;
+    el_free((ptr_t) el->el_chared.c_undo.buf);
+    el->el_chared.c_undo.buf = NULL;
+    el_free((ptr_t) el->el_chared.c_kill.buf);
+    el->el_chared.c_kill.buf = NULL;
+    el_free((ptr_t) el->el_chared.c_macro.macro);
+    el->el_chared.c_macro.macro = NULL;
+    ch_reset(el);
+}
+
+
+/* el_insertstr():
+ *	Insert string at cursorI
+ */
+public int
+el_insertstr(el, s)
+    EditLine *el;
+    char   *s;
+{
+    int len;
+
+    if ((len = strlen(s)) == 0)
+	return -1;
+    if (el->el_line.lastchar + len >= el->el_line.limit)
+	return -1;
+
+    c_insert(el, len);
+    while (*s)
+	*el->el_line.cursor++ = *s++;
+    return 0;
+}
+
+
+/* el_deletestr():
+ *	Delete num characters before the cursor
+ */
+public void
+el_deletestr(el, n)
+    EditLine *el;
+    int     n;
+{
+    if (n <= 0)
+	return;
+
+    if (el->el_line.cursor < &el->el_line.buffer[n]) 
+	return;
+
+    c_delbefore(el, n);		/* delete before dot */
+    el->el_line.cursor -= n;
+    if (el->el_line.cursor < el->el_line.buffer)
+	el->el_line.cursor = el->el_line.buffer;
+}
+
+/* c_gets():
+ *	Get a string
+ */
+protected int
+c_gets(el, buf)
+    EditLine *el;
+    char *buf;
+{
+    char ch;
+    int len = 0;
+
+    for (ch = 0; ch == 0;) {
+	if (el_getc(el, &ch) != 1)
+	    return ed_end_of_file(el, 0);
+	switch (ch) {
+	case 0010:	/* Delete and backspace */
+	case 0177:
+	    if (len > 1) {
+		*el->el_line.cursor-- = '\0';
+		el->el_line.lastchar = el->el_line.cursor;
+		buf[len--] = '\0';
+	    }
+	    else {
+		el->el_line.buffer[0] = '\0';
+		el->el_line.lastchar = el->el_line.buffer;
+		el->el_line.cursor = el->el_line.buffer;
+		return CC_REFRESH;
+	    }
+	    re_refresh(el);
+	    ch = 0;
+	    break;
+
+	case 0033:	/* ESC */
+	case '\r':	/* Newline */
+	case '\n':
+	    break;
+
+	default:
+	    if (len >= EL_BUFSIZ)
+		term_beep(el);
+	    else {
+		buf[len++] = ch;
+		*el->el_line.cursor++ = ch;
+		el->el_line.lastchar = el->el_line.cursor;
+	    }
+	    re_refresh(el);
+	    ch = 0;
+	    break;
+	}
+    }
+    buf[len] = ch;
+    return len;
+}
+
+
+/* c_hpos():
+ *	Return the current horizontal position of the cursor
+ */
+protected int
+c_hpos(el)
+    EditLine *el;
+{
+    char *ptr;
+
+    /*
+     * Find how many characters till the beginning of this line.
+     */
+    if (el->el_line.cursor == el->el_line.buffer)
+	return 0;
+    else {
+	for (ptr = el->el_line.cursor - 1; 
+	     ptr >= el->el_line.buffer && *ptr != '\n';
+	     ptr--)
+	    continue;
+	return el->el_line.cursor - ptr - 1;
+    }
+}

Added: vendor/NetBSD/libedit/dist/chared.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/NetBSD/libedit/dist/chared.h	Thu Mar 31 00:46:27 2011	(r220174)
@@ -0,0 +1,160 @@
+/*	$NetBSD: chared.h,v 1.2 1997/01/11 06:47:49 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. 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

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



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