summaryrefslogtreecommitdiff
path: root/net/tnftp
diff options
context:
space:
mode:
authorlukem <lukem@pkgsrc.org>2005-05-11 08:11:55 +0000
committerlukem <lukem@pkgsrc.org>2005-05-11 08:11:55 +0000
commit0d6d28549944474712a1516543ac129e2e0b2d00 (patch)
tree713b60c4bfb874a35e18d177c34f44207b1fb5ff /net/tnftp
parente0317c5212695b5eda31810c1c609a09054ea2fc (diff)
downloadpkgsrc-0d6d28549944474712a1516543ac129e2e0b2d00.tar.gz
tnftp 20050511.
Notable changes: * Improve timeout handling during connection initiation * Prevent coredump with long command lines when editing is enabled.
Diffstat (limited to 'net/tnftp')
-rw-r--r--net/tnftp/files/Makefile.in2
-rw-r--r--net/tnftp/files/THANKS16
-rw-r--r--net/tnftp/files/aclocal.m42
-rw-r--r--net/tnftp/files/libedit/Makefile.in3
-rw-r--r--net/tnftp/files/libedit/chared.c321
-rw-r--r--net/tnftp/files/libedit/chared.h52
-rw-r--r--net/tnftp/files/libedit/common.c223
-rw-r--r--net/tnftp/files/libedit/editline.3165
-rw-r--r--net/tnftp/files/libedit/editrc.543
-rw-r--r--net/tnftp/files/libedit/el.c73
-rw-r--r--net/tnftp/files/libedit/el.h29
-rw-r--r--net/tnftp/files/libedit/emacs.c116
-rw-r--r--net/tnftp/files/libedit/hist.c71
-rw-r--r--net/tnftp/files/libedit/hist.h13
-rw-r--r--net/tnftp/files/libedit/histedit.h42
-rw-r--r--net/tnftp/files/libedit/history.c210
-rw-r--r--net/tnftp/files/libedit/key.c23
-rw-r--r--net/tnftp/files/libedit/key.h13
-rw-r--r--net/tnftp/files/libedit/makelist.in14
-rw-r--r--net/tnftp/files/libedit/map.c314
-rw-r--r--net/tnftp/files/libedit/map.h9
-rw-r--r--net/tnftp/files/libedit/parse.c36
-rw-r--r--net/tnftp/files/libedit/parse.h9
-rw-r--r--net/tnftp/files/libedit/prompt.c26
-rw-r--r--net/tnftp/files/libedit/prompt.h9
-rw-r--r--net/tnftp/files/libedit/read.c176
-rw-r--r--net/tnftp/files/libedit/read.h5
-rw-r--r--net/tnftp/files/libedit/readline.c2143
-rw-r--r--net/tnftp/files/libedit/readline/readline.h80
-rw-r--r--net/tnftp/files/libedit/refresh.c57
-rw-r--r--net/tnftp/files/libedit/refresh.h9
-rw-r--r--net/tnftp/files/libedit/search.c206
-rw-r--r--net/tnftp/files/libedit/search.h15
-rw-r--r--net/tnftp/files/libedit/sig.c26
-rw-r--r--net/tnftp/files/libedit/sig.h17
-rw-r--r--net/tnftp/files/libedit/sys.h86
-rw-r--r--net/tnftp/files/libedit/term.c57
-rw-r--r--net/tnftp/files/libedit/term.h11
-rw-r--r--net/tnftp/files/libedit/tokenizer.c124
-rw-r--r--net/tnftp/files/libedit/tty.c157
-rw-r--r--net/tnftp/files/libedit/tty.h9
-rw-r--r--net/tnftp/files/libedit/vi.c829
-rw-r--r--net/tnftp/files/libnetbsd/Makefile.in3
-rw-r--r--net/tnftp/files/libnetbsd/err.c2
-rw-r--r--net/tnftp/files/libnetbsd/fgetln.c2
-rw-r--r--net/tnftp/files/libnetbsd/fparseln.c4
-rw-r--r--net/tnftp/files/libnetbsd/fseeko.c2
-rw-r--r--net/tnftp/files/libnetbsd/ftpglob.h4
-rw-r--r--net/tnftp/files/libnetbsd/ftpvis.h3
-rw-r--r--net/tnftp/files/libnetbsd/getaddrinfo.c4
-rw-r--r--net/tnftp/files/libnetbsd/getnameinfo.c5
-rw-r--r--net/tnftp/files/libnetbsd/glob.c4
-rw-r--r--net/tnftp/files/libnetbsd/inet_ntop.c4
-rw-r--r--net/tnftp/files/libnetbsd/inet_pton.c4
-rw-r--r--net/tnftp/files/libnetbsd/mkstemp.c4
-rw-r--r--net/tnftp/files/libnetbsd/setprogname.c4
-rw-r--r--net/tnftp/files/libnetbsd/sl_init.c4
-rw-r--r--net/tnftp/files/libnetbsd/snprintf.c2
-rw-r--r--net/tnftp/files/libnetbsd/strdup.c4
-rw-r--r--net/tnftp/files/libnetbsd/strerror.c2
-rw-r--r--net/tnftp/files/libnetbsd/strlcat.c4
-rw-r--r--net/tnftp/files/libnetbsd/strlcpy.c4
-rw-r--r--net/tnftp/files/libnetbsd/strptime.c4
-rw-r--r--net/tnftp/files/libnetbsd/strsep.c4
-rw-r--r--net/tnftp/files/libnetbsd/strtoll.c4
-rw-r--r--net/tnftp/files/libnetbsd/strunvis.c4
-rw-r--r--net/tnftp/files/libnetbsd/strvis.c4
-rw-r--r--net/tnftp/files/libnetbsd/timegm.c3
-rw-r--r--net/tnftp/files/libnetbsd/usleep.c3
-rw-r--r--net/tnftp/files/src/Makefile.in3
-rw-r--r--net/tnftp/files/src/complete.c10
71 files changed, 4612 insertions, 1337 deletions
diff --git a/net/tnftp/files/Makefile.in b/net/tnftp/files/Makefile.in
index 50a5103ae09..4098824edb0 100644
--- a/net/tnftp/files/Makefile.in
+++ b/net/tnftp/files/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.1 2004/03/11 13:01:01 grant Exp $
+# NetBSD: Makefile.in,v 1.3 2005/05/11 03:03:42 lukem Exp
#
srcdir = @srcdir@
diff --git a/net/tnftp/files/THANKS b/net/tnftp/files/THANKS
index 677d9513187..93e12af5575 100644
--- a/net/tnftp/files/THANKS
+++ b/net/tnftp/files/THANKS
@@ -1,9 +1,10 @@
Whilst a lot of the work in tnftp (both the original sources in NetBSD
and this port) was done by Luke Mewburn, it would not be as usable
-without the enhancements, fixes, or input from the following people:
+without the enhancements, bug fixes, or input from the following people:
Amitai Schlair <schmonz@schmonz.com>
Anders Dinsen <anders@dinsen.net>
+Anders Magnusson <ragge@ltu.se>
Arkadiusz Miskiewicz <misiek@pld.org.pl>
Brian Stark <bstark1990@netscape.net>
Chris G. Demetriou <cgd@NetBSD.org>
@@ -14,6 +15,7 @@ David Brownlee <abs@mono.org>
David Carrel <carrel@NetBSD.org>
DervishD <raul@pleyades.net>
Douwe Kiela <virtus@wanadoo.nl>
+Eugene Kotlyarov <ekot@protek36.esoo.ru>
Geoff Wing <mason@primenet.com.au>
Giles Lean <giles@nemeton.com.au>
Havard Eidnes <Havard.Eidnes@runit.sintef.no>
@@ -28,18 +30,24 @@ Klaus Klein <kleink@NetBSD.org>
Launey Thomas <ljt@alum.mit.edu>
Luke Mewburn <lukem@NetBSD.org>
Marc Horowitz <marc@mit.edu>
+Mathieu Arnold <mat@FreeBSD.org>
Matthew R. Green <mrg@eterna.com.au>
Matthias Pfaller <leo@dachau.marco.de>
Matthias Scheler <tron@zhadum.de>
-Maxim Konovalov <maxim@freebsd.org>
+Maxim Konovalov <maxim@FreeBSD.org>
+Maxime Henrion <mux@FreeBSD.org>
Michael L. Hitch <osymh@terra.oscs.montana.edu>
-Mike Heffner <mikeh@freebsd.org>
+Mike Heffner <mikeh@FreeBSD.org>
+Onno van der Linden <o.vd.linden@quicknet.nl>
Ruslan Ermilov <ru@FreeBSD.org>
+Ryoji Kanai <rkanai@eeye.com>
Scott Aaron Bamford <sab@ansic.net>
Simon Burge <simonb@thistledown.com.au>
Steve McClellan <steve.mcclellan@radisys.com>
+TAMURA Kent <kent@NetBSD.org>
+Stoned Elipot <seb@NetBSD.org>
Todd C. Miller <Todd.Miller@courtesan.com>
YAMANO Yuji <yyamano@NetBSD.org>
-Yar Tikhiy <yar@freebsd.org>
+Yar Tikhiy <yar@FreeBSD.org>
Apologies to anyone missed.
diff --git a/net/tnftp/files/aclocal.m4 b/net/tnftp/files/aclocal.m4
index e38bebe4738..d5d12cdf16a 100644
--- a/net/tnftp/files/aclocal.m4
+++ b/net/tnftp/files/aclocal.m4
@@ -1,4 +1,4 @@
-dnl $Id: aclocal.m4,v 1.1 2004/03/11 13:01:01 grant Exp $
+dnl NetBSD: aclocal.m4,v 1.3 2005/05/11 03:03:42 lukem Exp
dnl
dnl
diff --git a/net/tnftp/files/libedit/Makefile.in b/net/tnftp/files/libedit/Makefile.in
index 4a334a53b36..85daedde427 100644
--- a/net/tnftp/files/libedit/Makefile.in
+++ b/net/tnftp/files/libedit/Makefile.in
@@ -1,5 +1,4 @@
-#
-# $Id: Makefile.in,v 1.1 2004/03/11 13:01:01 grant Exp $
+# NetBSD: Makefile.in,v 1.2 2005/05/11 01:17:39 lukem Exp
#
srcdir = @srcdir@
diff --git a/net/tnftp/files/libedit/chared.c b/net/tnftp/files/libedit/chared.c
index e04f2c359a7..23adb5fb9c0 100644
--- a/net/tnftp/files/libedit/chared.c
+++ b/net/tnftp/files/libedit/chared.c
@@ -1,4 +1,5 @@
-/* $NetBSD: chared.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: chared.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#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.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* chared.c: Character editor utilities
*/
@@ -52,17 +60,36 @@
* Handle state for the vi undo command
*/
protected void
-cv_undo(EditLine *el,int action, size_t size, char *ptr)
+cv_undo(EditLine *el)
{
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_redo_t *r = &el->el_chared.c_redo;
+ uint 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;
}
@@ -74,8 +101,10 @@ 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.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 */
@@ -96,12 +125,14 @@ 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;
- 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];
@@ -110,6 +141,21 @@ c_delafter(EditLine *el, int 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
*/
@@ -120,13 +166,14 @@ 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;
- 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++)
@@ -137,13 +184,28 @@ c_delbefore(EditLine *el, int 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 (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL);
+ return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
}
@@ -153,6 +215,20 @@ ce__isword(int p)
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));
}
@@ -215,7 +291,7 @@ cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
* 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))
+ if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
while ((p < high) && isspace((unsigned char) *p))
p++;
}
@@ -232,26 +308,19 @@ cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
* Find the previous word vi style
*/
protected char *
-cv_prev_word(EditLine *el, char *p, char *low, int n, int (*wtest)(int))
+cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
{
int test;
+ p--;
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--;
+ 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++;
/* p now points where we want it */
if (p < low)
@@ -302,47 +371,34 @@ protected void
cv_delfini(EditLine *el)
{
int size;
- int oaction;
+ int action = el->el_chared.c_vcmd.action;
- if (el->el_chared.c_vcmd.action & INSERT)
+ if (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)
+ /* sanity */
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 = el->el_line.cursor - el->el_chared.c_vcmd.pos;
+ if (size == 0)
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;
+ 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_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.dsize = size;
+ el->el_chared.c_vcmd.action = NOP;
}
@@ -372,21 +428,19 @@ ce__endword(char *p, char *high, int n)
* Go to the end of this word according to vi
*/
protected char *
-cv__endword(char *p, char *high, int n)
+cv__endword(char *p, char *high, int n, int (*wtest)(int))
{
+ int test;
+
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++;
+ test = (*wtest)((unsigned char) *p);
+ while ((p < high) && (*wtest)((unsigned char) *p) == test)
+ p++;
}
p--;
return (p);
@@ -405,20 +459,23 @@ ch_init(EditLine *el)
(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_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.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_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_vcmd.ins = el->el_line.buffer;
el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
if (el->el_chared.c_kill.buf == NULL)
@@ -435,8 +492,8 @@ ch_init(EditLine *el)
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.offset = 0;
el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
sizeof(char *));
if (el->el_chared.c_macro.macro == NULL)
@@ -453,14 +510,11 @@ ch_reset(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_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_vcmd.ins = el->el_line.buffer;
el->el_chared.c_kill.mark = el->el_line.buffer;
@@ -515,7 +569,8 @@ ch_enlargebufs(el, addlen)
el->el_line.buffer = newbuffer;
el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
- el->el_line.limit = &newbuffer[newsz - EL_LEAVE];
+ /* don't set new size until all buffers are enlarged */
+ el->el_line.limit = &newbuffer[sz - EL_LEAVE];
/*
* Reallocate kill buffer.
@@ -544,14 +599,22 @@ ch_enlargebufs(el, addlen)
/* zero the newly added memory, leave old data in */
(void) memset(&newbuffer[sz], 0, newsz - sz);
-
- el->el_chared.c_undo.ptr = el->el_line.buffer +
- (el->el_chared.c_undo.ptr - oldbuf);
el->el_chared.c_undo.buf = newbuffer;
+
+ newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
+ if (!newbuffer)
+ return 0;
+ el->el_chared.c_redo.pos = newbuffer +
+ (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
+ el->el_chared.c_redo.lim = newbuffer +
+ (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
+ el->el_chared.c_redo.buf = newbuffer;
if (!hist_enlargebuf(el, sz, newsz))
return 0;
+ /* Safe to set enlarged buffer size */
+ el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
return 1;
}
@@ -566,6 +629,11 @@ ch_end(EditLine *el)
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_redo.buf);
+ el->el_chared.c_redo.buf = NULL;
+ el->el_chared.c_redo.pos = NULL;
+ el->el_chared.c_redo.lim = NULL;
+ el->el_chared.c_redo.cmd = ED_UNASSIGNED;
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);
@@ -618,51 +686,64 @@ el_deletestr(EditLine *el, int n)
* Get a string
*/
protected int
-c_gets(EditLine *el, char *buf)
+c_gets(EditLine *el, char *buf, const char *prompt)
{
char ch;
- int len = 0;
+ int len;
+ char *cp = el->el_line.buffer;
+
+ if (prompt) {
+ len = strlen(prompt);
+ memcpy(cp, prompt, len + 0u);
+ cp += len;
+ }
+ len = 0;
+
+ for (;;) {
+ el->el_line.cursor = cp;
+ *cp = ' ';
+ el->el_line.lastchar = cp + 1;
+ re_refresh(el);
+
+ if (el_getc(el, &ch) != 1) {
+ ed_end_of_file(el, 0);
+ len = -1;
+ break;
+ }
- 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);
+ if (len <= 0) {
+ len = -1;
+ break;
}
- re_refresh(el);
- ch = 0;
- break;
+ cp--;
+ continue;
case 0033: /* ESC */
case '\r': /* Newline */
case '\n':
+ buf[len] = ch;
break;
default:
- if (len >= EL_BUFSIZ)
+ if (len >= EL_BUFSIZ - 16)
term_beep(el);
else {
buf[len++] = ch;
- *el->el_line.cursor++ = ch;
- el->el_line.lastchar = el->el_line.cursor;
+ *cp++ = ch;
}
- re_refresh(el);
- ch = 0;
- break;
+ continue;
}
+ break;
}
- buf[len] = ch;
- return (len);
+
+ el->el_line.buffer[0] = '\0';
+ el->el_line.lastchar = el->el_line.buffer;
+ el->el_line.cursor = el->el_line.buffer;
+ return len;
}
diff --git a/net/tnftp/files/libedit/chared.h b/net/tnftp/files/libedit/chared.h
index 0c9a65e95b5..963dc7a86d3 100644
--- a/net/tnftp/files/libedit/chared.h
+++ b/net/tnftp/files/libedit/chared.h
@@ -1,4 +1,5 @@
-/* $NetBSD: chared.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: chared.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -66,28 +63,36 @@
typedef struct c_macro_t {
int level;
+ int offset;
char **macro;
- char *nline;
} c_macro_t;
/*
- * Undo information for both vi and emacs
+ * Undo information for vi - no undo in emacs (yet)
*/
typedef struct c_undo_t {
- int action;
- size_t isize;
- size_t dsize;
- char *ptr;
- char *buf;
+ int len; /* length of saved line */
+ int cursor; /* position of saved cursor */
+ char *buf; /* full saved text */
} c_undo_t;
+/* redo for vi */
+typedef struct c_redo_t {
+ char *buf; /* redo insert key sequence */
+ char *pos;
+ char *lim;
+ el_action_t cmd; /* command to redo */
+ char ch; /* char that invoked it */
+ int count;
+ int action; /* from cv_action() */
+} c_redo_t;
+
/*
* Current action information for vi
*/
typedef struct c_vcmd_t {
int action;
char *pos;
- char *ins;
} c_vcmd_t;
/*
@@ -106,6 +111,7 @@ typedef struct c_kill_t {
typedef struct el_chared_t {
c_undo_t c_undo;
c_kill_t c_kill;
+ c_redo_t c_redo;
c_vcmd_t c_vcmd;
c_macro_t c_macro;
} el_chared_t;
@@ -120,10 +126,10 @@ typedef struct el_chared_t {
#define NOP 0x00
#define DELETE 0x01
#define INSERT 0x02
-#define CHANGE 0x04
+#define YANK 0x04
-#define CHAR_FWD 0
-#define CHAR_BACK 1
+#define CHAR_FWD (+1)
+#define CHAR_BACK (-1)
#define MODE_INSERT 0
#define MODE_REPLACE 1
@@ -137,18 +143,22 @@ typedef struct el_chared_t {
protected int cv__isword(int);
+protected int cv__isWord(int);
protected void cv_delfini(EditLine *);
-protected char *cv__endword(char *, char *, int);
+protected char *cv__endword(char *, char *, int, int (*)(int));
protected int ce__isword(int);
-protected void cv_undo(EditLine *, int, size_t, char *);
+protected void cv_undo(EditLine *);
+protected void cv_yank(EditLine *, const char *, int);
protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
-protected char *cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
+protected char *cv_prev_word(char *, char *, int, int (*)(int));
protected char *c__next_word(char *, char *, int, int (*)(int));
protected char *c__prev_word(char *, char *, int, int (*)(int));
protected void c_insert(EditLine *, int);
protected void c_delbefore(EditLine *, int);
+protected void c_delbefore1(EditLine *);
protected void c_delafter(EditLine *, int);
-protected int c_gets(EditLine *, char *);
+protected void c_delafter1(EditLine *);
+protected int c_gets(EditLine *, char *, const char *);
protected int c_hpos(EditLine *);
protected int ch_init(EditLine *);
diff --git a/net/tnftp/files/libedit/common.c b/net/tnftp/files/libedit/common.c
index 0fdf7cf805e..3344c3ebaa8 100644
--- a/net/tnftp/files/libedit/common.c
+++ b/net/tnftp/files/libedit/common.c
@@ -1,4 +1,5 @@
-/* $NetBSD: common.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: common.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: common.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* common.c: Common Editor functions
*/
@@ -50,7 +58,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_end_of_file(EditLine *el, int c)
+ed_end_of_file(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -66,7 +74,7 @@ ed_end_of_file(EditLine *el, int c)
protected el_action_t
ed_insert(EditLine *el, int c)
{
- int i;
+ int count = el->el_state.argument;
if (c == '\0')
return (CC_ERROR);
@@ -74,42 +82,28 @@ ed_insert(EditLine *el, int c)
if (el->el_line.lastchar + el->el_state.argument >=
el->el_line.limit) {
/* end of buffer space, try to allocate more */
- if (!ch_enlargebufs(el, (size_t) el->el_state.argument))
+ if (!ch_enlargebufs(el, (size_t) count))
return CC_ERROR; /* error allocating more */
}
- if (el->el_state.argument == 1) {
- if (el->el_state.inputmode != MODE_INSERT) {
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- *el->el_line.cursor;
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, 1);
- }
- c_insert(el, 1);
+ if (count == 1) {
+ if (el->el_state.inputmode == MODE_INSERT
+ || el->el_line.cursor >= el->el_line.lastchar)
+ c_insert(el, 1);
*el->el_line.cursor++ = c;
- el->el_state.doingarg = 0; /* just in case */
re_fastaddc(el); /* fast refresh for one char. */
} else {
- if (el->el_state.inputmode != MODE_INSERT) {
- for (i = 0; i < el->el_state.argument; i++)
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- el->el_line.cursor[i];
-
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, el->el_state.argument);
- }
- c_insert(el, el->el_state.argument);
+ if (el->el_state.inputmode != MODE_REPLACE_1)
+ c_insert(el, el->el_state.argument);
- while (el->el_state.argument--)
+ while (count-- && el->el_line.cursor < el->el_line.lastchar)
*el->el_line.cursor++ = c;
re_refresh(el);
}
if (el->el_state.inputmode == MODE_REPLACE_1)
- (void) vi_command_mode(el, 0);
+ return vi_command_mode(el, 0);
return (CC_NORM);
}
@@ -121,7 +115,7 @@ ed_insert(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_word(EditLine *el, int c)
+ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *p, *kp;
@@ -149,7 +143,7 @@ ed_delete_prev_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, int c)
+ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
{
#ifdef notdef /* XXX */
#define EL el->el_line
@@ -200,7 +194,7 @@ ed_delete_next_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_kill_line(EditLine *el, int c)
+ed_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -221,7 +215,7 @@ ed_kill_line(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_end(EditLine *el, int c)
+ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.lastchar;
@@ -229,7 +223,7 @@ ed_move_to_end(EditLine *el, int c)
#ifdef VI_MOVE
el->el_line.cursor--;
#endif
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -244,7 +238,7 @@ ed_move_to_end(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_beg(EditLine *el, int c)
+ed_move_to_beg(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -253,7 +247,7 @@ ed_move_to_beg(EditLine *el, int c)
/* We want FIRST non space character */
while (isspace((unsigned char) *el->el_line.cursor))
el->el_line.cursor++;
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -293,18 +287,22 @@ ed_transpose_chars(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_char(EditLine *el, int c)
+ed_next_char(EditLine *el, int c __attribute__((__unused__)))
{
+ char *lim = el->el_line.lastchar;
- if (el->el_line.cursor >= el->el_line.lastchar)
+ if (el->el_line.cursor >= lim ||
+ (el->el_line.cursor == lim - 1 &&
+ el->el_map.type == MAP_VI &&
+ el->el_chared.c_vcmd.action == NOP))
return (CC_ERROR);
el->el_line.cursor += el->el_state.argument;
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar;
+ if (el->el_line.cursor > lim)
+ el->el_line.cursor = lim;
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -318,7 +316,7 @@ ed_next_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_word(EditLine *el, int c)
+ed_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -330,7 +328,7 @@ ed_prev_word(EditLine *el, int c)
ce__isword);
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -344,7 +342,7 @@ ed_prev_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_char(EditLine *el, int c)
+ed_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor > el->el_line.buffer) {
@@ -353,7 +351,7 @@ ed_prev_char(EditLine *el, int c)
el->el_line.cursor = el->el_line.buffer;
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -405,25 +403,9 @@ ed_digit(EditLine *el, int c)
(el->el_state.argument * 10) + (c - '0');
}
return (CC_ARGHACK);
- } else {
- if (el->el_line.lastchar + 1 >= el->el_line.limit) {
- if (!ch_enlargebufs(el, 1))
- return (CC_ERROR);
- }
-
- if (el->el_state.inputmode != MODE_INSERT) {
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- *el->el_line.cursor;
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, 1);
- }
- c_insert(el, 1);
- *el->el_line.cursor++ = c;
- el->el_state.doingarg = 0;
- re_fastaddc(el);
}
- return (CC_NORM);
+
+ return ed_insert(el, c);
}
@@ -457,12 +439,10 @@ ed_argument_digit(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_unassigned(EditLine *el, int c)
+ed_unassigned(EditLine *el, int c __attribute__((__unused__)))
{
- term_beep(el);
- term__flush();
- return (CC_NORM);
+ return (CC_ERROR);
}
@@ -476,7 +456,8 @@ ed_unassigned(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigint(EditLine *el, int c)
+ed_tty_sigint(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -489,7 +470,8 @@ ed_tty_sigint(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_dsusp(EditLine *el, int c)
+ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -502,7 +484,8 @@ ed_tty_dsusp(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_flush_output(EditLine *el, int c)
+ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -515,7 +498,8 @@ ed_tty_flush_output(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigquit(EditLine *el, int c)
+ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -528,7 +512,8 @@ ed_tty_sigquit(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigtstp(EditLine *el, int c)
+ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -541,7 +526,8 @@ ed_tty_sigtstp(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_stop_output(EditLine *el, int c)
+ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -554,7 +540,8 @@ ed_tty_stop_output(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_start_output(EditLine *el, int c)
+ed_tty_start_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -567,14 +554,12 @@ ed_tty_start_output(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_newline(EditLine *el, int c)
+ed_newline(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
*el->el_line.lastchar++ = '\n';
*el->el_line.lastchar = '\0';
- if (el->el_map.type == MAP_VI)
- el->el_chared.c_vcmd.ins = el->el_line.buffer;
return (CC_NEWLINE);
}
@@ -585,7 +570,7 @@ ed_newline(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_char(EditLine *el, int c)
+ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
@@ -605,7 +590,7 @@ ed_delete_prev_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_clear_screen(EditLine *el, int c)
+ed_clear_screen(EditLine *el, int c __attribute__((__unused__)))
{
term_clear_screen(el); /* clear the whole real screen */
@@ -620,7 +605,8 @@ ed_clear_screen(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_redisplay(EditLine *el, int c)
+ed_redisplay(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_REDISPLAY);
@@ -633,7 +619,7 @@ ed_redisplay(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_start_over(EditLine *el, int c)
+ed_start_over(EditLine *el, int c __attribute__((__unused__)))
{
ch_reset(el);
@@ -647,7 +633,8 @@ ed_start_over(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_sequence_lead_in(EditLine *el, int c)
+ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -660,11 +647,12 @@ ed_sequence_lead_in(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_history(EditLine *el, int c)
+ed_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
char beep = 0;
+ int sv_event = el->el_history.eventno;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno == 0) { /* save the current buffer
@@ -677,15 +665,17 @@ ed_prev_history(EditLine *el, int c)
el->el_history.eventno += el->el_state.argument;
if (hist_get(el) == CC_ERROR) {
+ if (el->el_map.type == MAP_VI) {
+ el->el_history.eventno = sv_event;
+ return CC_ERROR;
+ }
beep = 1;
/* el->el_history.eventno was fixed by first call */
(void) hist_get(el);
}
- re_refresh(el);
if (beep)
- return (CC_ERROR);
- else
- return (CC_NORM); /* was CC_UP_HIST */
+ return CC_REFRESH_BEEP;
+ return CC_REFRESH;
}
@@ -695,19 +685,24 @@ ed_prev_history(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_history(EditLine *el, int c)
+ed_next_history(EditLine *el, int c __attribute__((__unused__)))
{
+ el_action_t beep = CC_REFRESH, rval;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
el->el_history.eventno -= el->el_state.argument;
if (el->el_history.eventno < 0) {
el->el_history.eventno = 0;
- return (CC_ERROR);/* make it beep */
+ beep = CC_REFRESH_BEEP;
}
- return (hist_get(el));
+ rval = hist_get(el);
+ if (rval == CC_REFRESH)
+ return beep;
+ return rval;
+
}
@@ -717,14 +712,14 @@ ed_next_history(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_prev_history(EditLine *el, int c)
+ed_search_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
bool_t found = 0;
el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno < 0) {
#ifdef DEBUG_EDIT
@@ -785,14 +780,14 @@ ed_search_prev_history(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_next_history(EditLine *el, int c)
+ed_search_next_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
bool_t found = 0;
el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno == 0)
@@ -839,7 +834,7 @@ ed_search_next_history(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_line(EditLine *el, int c)
+ed_prev_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -882,7 +877,7 @@ ed_prev_line(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_line(EditLine *el, int c)
+ed_next_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -916,30 +911,18 @@ ed_next_line(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_command(EditLine *el, int c)
+ed_command(EditLine *el, int c __attribute__((__unused__)))
{
char tmpbuf[EL_BUFSIZ];
int tmplen;
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
-
- c_insert(el, 3); /* prompt + ": " */
- *el->el_line.cursor++ = '\n';
- *el->el_line.cursor++ = ':';
- *el->el_line.cursor++ = ' ';
- re_refresh(el);
+ tmplen = c_gets(el, tmpbuf, "\n: ");
+ term__putc('\n');
- tmplen = c_gets(el, tmpbuf);
- tmpbuf[tmplen] = '\0';
-
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
+ if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
+ term_beep(el);
- if (parse_line(el, tmpbuf) == -1)
- return (CC_ERROR);
- else
- return (CC_REFRESH);
+ el->el_map.current = el->el_map.key;
+ re_clear_display(el);
+ return CC_REFRESH;
}
diff --git a/net/tnftp/files/libedit/editline.3 b/net/tnftp/files/libedit/editline.3
index 46e9dd5669c..7ed7c5bf977 100644
--- a/net/tnftp/files/libedit/editline.3
+++ b/net/tnftp/files/libedit/editline.3
@@ -1,6 +1,7 @@
-.\" $NetBSD: editline.3,v 1.1 2004/03/11 13:01:01 grant Exp $
+.\" NetBSD: editline.3,v 1.2 2005/05/11 01:17:39 lukem Exp
+.\" from NetBSD: editline.3,v 1.45 2004/04/15 08:13:29 wiz Exp
.\"
-.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
+.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
@@ -33,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 12, 1999
+.Dd December 5, 2003
.Os
.Dt EDITLINE 3
.Sh NAME
@@ -53,12 +54,17 @@
.Nm el_deletestr ,
.Nm history_init ,
.Nm history_end ,
-.Nm history
-.Nd line editor and history functions
+.Nm history ,
+.Nm tok_init ,
+.Nm tok_end ,
+.Nm tok_reset ,
+.Nm tok_line ,
+.Nm tok_str
+.Nd line editor, history and tokenization functions
.Sh LIBRARY
.Lb libedit
.Sh SYNOPSIS
-.Fd #include \*[Lt]histedit.h\*[Gt]
+.In histedit.h
.Ft EditLine *
.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
.Ft void
@@ -72,7 +78,7 @@
.Ft void
.Fn el_push "EditLine *e" "const char *str"
.Ft int
-.Fn el_parse "EditLine *e" "int argc" "char *argv[]"
+.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
.Ft int
.Fn el_set "EditLine *e" "int op" "..."
.Ft int
@@ -93,10 +99,20 @@
.Fn history_end "History *h"
.Ft int
.Fn history "History *h" "HistEvent *ev" "int op" "..."
+.Ft Tokenizer *
+.Fn tok_init "const char *IFS"
+.Ft void
+.Fn tok_end "Tokenizer *t"
+.Ft void
+.Fn tok_reset "Tokenizer *t"
+.Ft int
+.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char *argv[]" "int *cursorc" "int *cursoro"
+.Ft int
+.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char *argv[]"
.Sh DESCRIPTION
The
.Nm
-library provides generic line editing and history functions,
+library provides generic line editing, history and tokenization functions,
similar to those found in
.Xr sh 1 .
.Pp
@@ -152,7 +168,7 @@ if no characters were read or if an error occurred.
Read a character from the tty.
.Fa ch
is modified to contain the character read.
-Returns the number of characters read if successful, -1 otherwise.
+Returns the number of characters read if successful, \-1 otherwise.
.It Fn el_push
Pushes
.Fa str
@@ -184,7 +200,7 @@ matches the
argument supplied to
.Fn el_init .
The return value is
--1 if the command is unknown,
+\-1 if the command is unknown,
0 if there was no error or
.Dq prog
didn't match, or
@@ -362,7 +378,7 @@ is non-zero,
editing is enabled (the default).
Note that this is only an indication, and does not
affect the operation of
-.Nm "" .
+.Nm .
At this time, it is the caller's responsibility to
check this
(using
@@ -382,8 +398,8 @@ name ``EL_BUILTIN_GETCFN''.
.It Dv EL_CLIENTDATA , Fa "void *data"
Register
.Fa data
-to be associated with this EditLine structure. It can be retrieved with
-the corresponding
+to be associated with this EditLine structure.
+It can be retrieved with the corresponding
.Fn el_get
call.
.El
@@ -394,6 +410,7 @@ parameters.
.Fa op
determines which parameter to retrieve into
.Fa result .
+Returns 0 if successful, \-1 otherwise.
.Pp
The following values for
.Fa op
@@ -426,6 +443,13 @@ Retrieve
previously registered with the corresponding
.Fn el_set
call.
+.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"
+Sets or clears terminal editing mode.
.El
.It Fn el_source
Initialise
@@ -468,11 +492,21 @@ typedef struct lineinfo {
const char *lastchar; /* address of last character */
} LineInfo;
.Ed
+.Pp
+.Fa buffer
+is not NUL terminated.
+This function may be called after
+.Fn el_gets
+to obtain the
+.Fa LineInfo
+structure pertaining to line returned by that function,
+and from within user defined functions added with
+.Dv EL_ADDFN .
.It Fn el_insertstr
Insert
.Fa str
into the line at the cursor.
-Returns -1 if
+Returns \-1 if
.Fa str
is empty or won't fit, and 0 otherwise.
.It Fn el_deletestr
@@ -552,7 +586,11 @@ Set the cursor to point to the requested element.
.It Dv H_ADD , Fa "const char *str"
Append
.Fa str
-to the current element of the history, or create an element with
+to the current element of the history, or perform the
+.Dv H_ENTER
+operation with argument
+.Fa str
+if there is no current element.
.It Dv H_APPEND , Fa "const char *str"
Append
.Fa str
@@ -562,6 +600,17 @@ Add
.Fa str
as a new element to the history, and, if necessary,
removing the oldest entry to keep the list to the created size.
+If
+.Dv H_SETUNIQUE
+was has been called with a non-zero arguments, the element
+will not be entered into the history if its contents match
+the ones of the current history element.
+If the element is entered
+.Fn history
+returns 1, if it is ignored as a duplicate returns 0.
+Finally
+.Fn history
+returns \-1 if an error occurred.
.It Dv H_PREV_STR , Fa "const char *str"
Return the closest previous event that starts with
.Fa str .
@@ -580,15 +629,94 @@ Load the history list stored in
.It Dv H_SAVE , Fa "const char *file"
Save the history list to
.Fa file .
+.It Dv H_SETUNIQUE , Fa "int unique"
+Set if the adjacent identical event strings should not be entered into
+the history.
+.It Dv H_GETUNIQUE
+Retrieve the current setting if if adjacent elements should be entered into
+the history.
.El
.Pp
.Fn history
-returns 0 if the operation
+returns \*[Gt]= 0 if the operation
.Fa op
-succeeds. Otherwise, -1 is returned and
+succeeds.
+Otherwise, \-1 is returned and
.Fa ev
is updated to contain more details about the error.
.El
+.Sh TOKENIZATION FUNCTIONS
+The tokenization functions use a common data structure,
+.Fa Tokenizer ,
+which is created by
+.Fn tok_init
+and freed by
+.Fn tok_end .
+.Pp
+The following functions are available:
+.Bl -tag -width 4n
+.It Fn tok_init
+Initialise the tokenizer, and return a data structure
+to be used by all other tokenizer functions.
+.Fa IFS
+contains the Input Field Separators, which defaults to
+.Aq space ,
+.Aq tab ,
+and
+.Aq newline
+if
+.Dv NULL .
+.It Fn tok_end
+Clean up and finish with
+.Fa t ,
+assumed to have been created with
+.Fn tok_init .
+.It Fn tok_reset
+Reset the tokenizer state.
+Use after a line has been successfully tokenized
+by
+.Fn tok_line
+or
+.Fn tok_str
+and before a new line is to be tokenized.
+.It Fn tok_line
+Tokenize
+.Fa li ,
+If successful, modify:
+.Fa argv
+to contain the words,
+.Fa argc
+to contain the number of words,
+.Fa cursorc
+(if not
+.Dv NULL )
+to contain the index of the word containing the cursor,
+and
+.Fa cursoro
+(if not
+.Dv NULL )
+to contain the offset within
+.Fa argv[cursorc]
+of the cursor.
+.Pp
+Returns
+0 if successful,
+\-1 for an internal error,
+1 for an unmatched single quote,
+2 for an unmatched double quote,
+and
+3 for a backslash quoted
+.Aq newline .
+A positive exit code indicates that another line should be read
+and tokenization attempted again.
+.
+.It Fn tok_str
+A simpler form of
+.Fn tok_line ;
+.Fa str
+is a NUL terminated string to tokenize.
+.El
+.
.\"XXX.Sh EXAMPLES
.\"XXX: provide some examples
.Sh SEE ALSO
@@ -623,9 +751,6 @@ and
.Dv EL_RPROMPT .
Jaromir Dolecek implemented the readline emulation.
.Sh BUGS
-The tokenization functions are not publicly defined in
-.Fd \*[Lt]histedit.h\*[Gt] .
-.Pp
At this time, it is the responsibility of the caller to
check the result of the
.Dv EL_EDITMODE
diff --git a/net/tnftp/files/libedit/editrc.5 b/net/tnftp/files/libedit/editrc.5
index c0338e06b73..93879d6d2b7 100644
--- a/net/tnftp/files/libedit/editrc.5
+++ b/net/tnftp/files/libedit/editrc.5
@@ -1,4 +1,5 @@
-.\" $NetBSD: editrc.5,v 1.1 2004/03/11 13:01:01 grant Exp $
+.\" NetBSD: editrc.5,v 1.2 2005/05/11 01:17:39 lukem Exp
+.\" from NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp
.\"
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -33,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 8, 2000
+.Dd October 18, 2003
.Os
.Dt EDITRC 5
.Sh NAME
@@ -62,7 +63,7 @@ for more information.
.Ar prog
is the program name string that a program defines when it calls
.Xr el_init 3
-to setup
+to set up
.Xr editline 3 ,
which is usually
.Va argv[0] .
@@ -122,7 +123,7 @@ Options include:
Bind all keys to the standard GNU Emacs-like bindings.
.It Fl v
Bind all keys to the standard
-.Xr vi 1 -like
+.Xr vi 1 Ns -like
bindings.
.It Fl a
List or change key bindings in the
@@ -222,7 +223,7 @@ or
indicating that the terminal does or does not have that capability.
.Pp
.Fl s
-returns an emptry string for non-existent capabilities, rather than
+returns an empty string for non-existent capabilities, rather than
causing an error.
.Fl v
causes messages to be verbose.
@@ -230,8 +231,24 @@ causes messages to be verbose.
Enable or disable the
.Nm editline
functionality in a program.
-.It Ic history
-List the history.
+.It Ic history Ar list | Ar size Dv n | Ar unique Dv n
+The
+.Ar list
+command lists all entries in the history.
+The
+.Ar size
+command sets the history size to
+.Dv n
+entries.
+The
+.Ar unique
+command controls if history should keep duplicate entries.
+If
+.Dv n
+is non zero, only keep unique history entries.
+If
+.Dv n
+is zero, then keep all entries (the default).
.It Ic telltc
List the values of all the terminal capabilities (see
.Xr termcap 5 ) .
@@ -251,6 +268,7 @@ No sanity checking is done.
.Op Ar +mode
.Op Ar -mode
.Op Ar mode
+.Op Ar char=c
.Xc
Control which tty modes that
.Nm
@@ -291,6 +309,15 @@ fixes
on or off or removes control of
.Ar mode
in the chosen set.
+.Pp
+.Ic Setty
+can also be used to set tty characters to particular values using
+.Ar char=value .
+If
+.Ar value
+is empty
+then the character is set to
+.Dv _POSIX_VDISABLE .
.El
.Sh EDITOR COMMANDS
The following editor commands are available for use in key bindings:
@@ -380,7 +407,7 @@ Cut the entire line and save in cut buffer.
Cut area between mark and cursor and save in cut buffer.
.It Ic em-copy-region
Copy area between mark and cursor to cut buffer.
-.It Ic em-gosmacs-traspose
+.It Ic em-gosmacs-transpose
Exchange the two characters before the cursor.
.It Ic em-next-word
Move next to end of current word.
diff --git a/net/tnftp/files/libedit/el.c b/net/tnftp/files/libedit/el.c
index bb5f5dd035e..f6d819a07a0 100644
--- a/net/tnftp/files/libedit/el.c
+++ b/net/tnftp/files/libedit/el.c
@@ -1,4 +1,5 @@
-/* $NetBSD: el.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: el.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
+#else
+__RCSID("NetBSD: el.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* el.c: EditLine interface functions
*/
@@ -66,7 +74,10 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
el->el_infd = fileno(fin);
el->el_outfile = fout;
el->el_errfile = ferr;
- el->el_prog = strdup(prog);
+ if ((el->el_prog = el_strdup(prog)) == NULL) {
+ el_free(el);
+ return NULL;
+ }
/*
* Initialize all the modules. Order is important!!!
@@ -74,7 +85,7 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
el->el_flags = 0;
if (term_init(el) == -1) {
- free(el->el_prog);
+ el_free(el->el_prog);
el_free(el);
return NULL;
}
@@ -251,6 +262,27 @@ el_set(EditLine *el, int op, ...)
el->el_data = va_arg(va, void *);
break;
+ case EL_UNBUFFERED:
+ rv = va_arg(va, int);
+ if (rv && !(el->el_flags & UNBUFFERED)) {
+ el->el_flags |= UNBUFFERED;
+ read_prepare(el);
+ } else if (!rv && (el->el_flags & UNBUFFERED)) {
+ el->el_flags &= ~UNBUFFERED;
+ read_finish(el);
+ }
+ rv = 0;
+ break;
+
+ case EL_PREP_TERM:
+ rv = va_arg(va, int);
+ if (rv)
+ (void) tty_rawmode(el);
+ else
+ (void) tty_cookedmode(el);
+ rv = 0;
+ break;
+
default:
rv = -1;
break;
@@ -274,11 +306,11 @@ el_get(EditLine *el, int op, void *ret)
switch (op) {
case EL_PROMPT:
case EL_RPROMPT:
- rv = prompt_get(el, (el_pfunc_t *) & ret, op);
+ rv = prompt_get(el, (void *) &ret, op);
break;
case EL_EDITOR:
- rv = map_get_editor(el, (const char **) &ret);
+ rv = map_get_editor(el, (void *) &ret);
break;
case EL_SIGNAL:
@@ -291,21 +323,22 @@ el_get(EditLine *el, int op, void *ret)
rv = 0;
break;
-#if 0 /* XXX */
case EL_TERMINAL:
- rv = term_get(el, (const char *) &ret);
+ term_get(el, (const char **)ret);
+ rv = 0;
break;
+#if 0 /* XXX */
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
case EL_ECHOTC:
case EL_SETTY:
{
- char *argv[20];
+ const char *argv[20];
int i;
- for (i = 1; i < 20; i++)
+ for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
if ((argv[i] = va_arg(va, char *)) == NULL)
break;
@@ -372,6 +405,11 @@ el_get(EditLine *el, int op, void *ret)
rv = 0;
break;
+ case EL_UNBUFFERED:
+ *((int *) ret) = (!(el->el_flags & UNBUFFERED));
+ rv = 0;
+ break;
+
default:
rv = -1;
}
@@ -479,10 +517,13 @@ el_editmode(EditLine *el, int argc, const char **argv)
return (-1);
how = argv[1];
- if (strcmp(how, "on") == 0)
+ if (strcmp(how, "on") == 0) {
el->el_flags &= ~EDIT_DISABLED;
- else if (strcmp(how, "off") == 0)
+ tty_rawmode(el);
+ } else if (strcmp(how, "off") == 0) {
+ tty_cookedmode(el);
el->el_flags |= EDIT_DISABLED;
+ }
else {
(void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how);
return (-1);
diff --git a/net/tnftp/files/libedit/el.h b/net/tnftp/files/libedit/el.h
index bd3f9f966bd..6bc47e93c59 100644
--- a/net/tnftp/files/libedit/el.h
+++ b/net/tnftp/files/libedit/el.h
@@ -1,4 +1,5 @@
-/* $NetBSD: el.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: el.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -55,9 +52,10 @@
#define EL_BUFSIZ 1024 /* Maximum line size */
-#define HANDLE_SIGNALS 1<<0
-#define NO_TTY 1<<1
-#define EDIT_DISABLED 1<<2
+#define HANDLE_SIGNALS 0x01
+#define NO_TTY 0x02
+#define EDIT_DISABLED 0x04
+#define UNBUFFERED 0x08
typedef int bool_t; /* True or not */
@@ -72,7 +70,7 @@ typedef struct el_line_t {
char *buffer; /* Input line */
char *cursor; /* Cursor position */
char *lastchar; /* Last character */
- const char *limit; /* Max position */
+ const char *limit; /* Max position */
} el_line_t;
/*
@@ -84,11 +82,14 @@ typedef struct el_state_t {
int argument; /* Numeric argument */
int metanext; /* Is the next char a meta char */
el_action_t lastcmd; /* Previous command */
+ el_action_t thiscmd; /* this command */
+ char thisch; /* char that generated it */
} el_state_t;
/*
* Until we come up with something better...
*/
+#define el_strdup(a) strdup(a)
#define el_malloc(a) malloc(a)
#define el_realloc(a,b) realloc(a, b)
#define el_free(a) free(a)
@@ -137,8 +138,12 @@ struct editline {
protected int el_editmode(EditLine *, int, const char **);
#ifdef DEBUG
-#define EL_ABORT(a) (void) (fprintf(el->el_errfile, "%s, %d: ", \
- __FILE__, __LINE__), fprintf a, abort())
+#define EL_ABORT(a) do { \
+ fprintf(el->el_errfile, "%s, %d: ", \
+ __FILE__, __LINE__); \
+ fprintf a; \
+ abort(); \
+ } while( /*CONSTCOND*/0);
#else
#define EL_ABORT(a) abort()
#endif
diff --git a/net/tnftp/files/libedit/emacs.c b/net/tnftp/files/libedit/emacs.c
index 155c9192137..39bcced6f0d 100644
--- a/net/tnftp/files/libedit/emacs.c
+++ b/net/tnftp/files/libedit/emacs.c
@@ -1,4 +1,5 @@
-/* $NetBSD: emacs.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: emacs.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: emacs.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* emacs.c: Emacs functions
*/
@@ -50,7 +58,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_or_list(EditLine *el, int c)
+em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar) {
@@ -69,7 +77,10 @@ em_delete_or_list(EditLine *el, int c)
return (CC_ERROR);
}
} else {
- c_delafter(el, el->el_state.argument); /* delete after dot */
+ if (el->el_state.doingarg)
+ c_delafter(el, el->el_state.argument);
+ else
+ c_delafter1(el);
if (el->el_line.cursor > el->el_line.lastchar)
el->el_line.cursor = el->el_line.lastchar;
/* bounds check */
@@ -84,7 +95,7 @@ em_delete_or_list(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_next_word(EditLine *el, int c)
+em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *p, *kp;
@@ -113,14 +124,12 @@ em_delete_next_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_yank(EditLine *el, int c)
+em_yank(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
- if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) {
- if (!ch_enlargebufs(el, 1))
- return (CC_ERROR);
- }
+ if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
+ return (CC_NORM);
if (el->el_line.lastchar +
(el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
@@ -150,7 +159,7 @@ em_yank(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_line(EditLine *el, int c)
+em_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -172,7 +181,7 @@ em_kill_line(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_region(EditLine *el, int c)
+em_kill_region(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -205,11 +214,11 @@ em_kill_region(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_region(EditLine *el, int c)
+em_copy_region(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
- if (el->el_chared.c_kill.mark)
+ if (!el->el_chared.c_kill.mark)
return (CC_ERROR);
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
@@ -229,12 +238,12 @@ em_copy_region(EditLine *el, int c)
}
-/* em_gosmacs_traspose():
+/* em_gosmacs_transpose():
* Exchange the two characters before the cursor
* Gosling emacs transpose chars [^T]
*/
protected el_action_t
-em_gosmacs_traspose(EditLine *el, int c)
+em_gosmacs_transpose(EditLine *el, int c)
{
if (el->el_line.cursor > &el->el_line.buffer[1]) {
@@ -254,7 +263,7 @@ em_gosmacs_traspose(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_next_word(EditLine *el, int c)
+em_next_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
return (CC_ERROR);
@@ -265,7 +274,7 @@ em_next_word(EditLine *el, int c)
ce__isword);
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -279,7 +288,7 @@ em_next_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_upper_case(EditLine *el, int c)
+em_upper_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -287,8 +296,8 @@ em_upper_case(EditLine *el, int c)
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++)
- if (islower((unsigned char) *cp))
- *cp = toupper(*cp);
+ if (islower((unsigned char)*cp))
+ *cp = toupper((unsigned char)*cp);
el->el_line.cursor = ep;
if (el->el_line.cursor > el->el_line.lastchar)
@@ -303,7 +312,7 @@ em_upper_case(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_capitol_case(EditLine *el, int c)
+em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -311,16 +320,16 @@ em_capitol_case(EditLine *el, int c)
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++) {
- if (isalpha((unsigned char) *cp)) {
- if (islower((unsigned char) *cp))
- *cp = toupper(*cp);
+ if (isalpha((unsigned char)*cp)) {
+ if (islower((unsigned char)*cp))
+ *cp = toupper((unsigned char)*cp);
cp++;
break;
}
}
for (; cp < ep; cp++)
- if (isupper((unsigned char) *cp))
- *cp = tolower(*cp);
+ if (isupper((unsigned char)*cp))
+ *cp = tolower((unsigned char)*cp);
el->el_line.cursor = ep;
if (el->el_line.cursor > el->el_line.lastchar)
@@ -335,7 +344,7 @@ em_capitol_case(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_lower_case(EditLine *el, int c)
+em_lower_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -343,8 +352,8 @@ em_lower_case(EditLine *el, int c)
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++)
- if (isupper((unsigned char) *cp))
- *cp = tolower(*cp);
+ if (isupper((unsigned char)*cp))
+ *cp = tolower((unsigned char)*cp);
el->el_line.cursor = ep;
if (el->el_line.cursor > el->el_line.lastchar)
@@ -359,7 +368,7 @@ em_lower_case(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_set_mark(EditLine *el, int c)
+em_set_mark(EditLine *el, int c __attribute__((__unused__)))
{
el->el_chared.c_kill.mark = el->el_line.cursor;
@@ -373,7 +382,7 @@ em_set_mark(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_exchange_mark(EditLine *el, int c)
+em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
{
char *cp;
@@ -390,7 +399,7 @@ em_exchange_mark(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_universal_argument(EditLine *el, int c)
+em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
{ /* multiply current argument by 4 */
if (el->el_state.argument > 1000000)
@@ -407,7 +416,7 @@ em_universal_argument(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_meta_next(EditLine *el, int c)
+em_meta_next(EditLine *el, int c __attribute__((__unused__)))
{
el->el_state.metanext = 1;
@@ -420,7 +429,7 @@ em_meta_next(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_toggle_overwrite(EditLine *el, int c)
+em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
{
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
@@ -434,7 +443,7 @@ em_toggle_overwrite(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_prev_word(EditLine *el, int c)
+em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *oldc, *dp;
@@ -461,7 +470,7 @@ em_copy_prev_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_next(EditLine *el, int c)
+em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
@@ -474,9 +483,32 @@ em_inc_search_next(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_prev(EditLine *el, int c)
+em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
}
+
+
+/* em_delete_prev_char():
+ * Delete the character to the left of the cursor
+ * [^?]
+ */
+protected el_action_t
+/*ARGSUSED*/
+em_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
+{
+
+ if (el->el_line.cursor <= el->el_line.buffer)
+ return (CC_ERROR);
+
+ if (el->el_state.doingarg)
+ c_delbefore(el, el->el_state.argument);
+ else
+ c_delbefore1(el);
+ el->el_line.cursor -= el->el_state.argument;
+ if (el->el_line.cursor < el->el_line.buffer)
+ el->el_line.cursor = el->el_line.buffer;
+ return (CC_REFRESH);
+}
diff --git a/net/tnftp/files/libedit/hist.c b/net/tnftp/files/libedit/hist.c
index 657bb19dbc4..55adb3542aa 100644
--- a/net/tnftp/files/libedit/hist.c
+++ b/net/tnftp/files/libedit/hist.c
@@ -1,4 +1,5 @@
-/* $NetBSD: hist.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: hist.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: hist.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* hist.c: History access functions
*/
@@ -126,18 +134,16 @@ hist_get(EditLine *el)
el->el_history.eventno = h;
return (CC_ERROR);
}
- (void) strncpy(el->el_line.buffer, hp,
+ (void) strlcpy(el->el_line.buffer, hp,
(size_t)(el->el_line.limit - el->el_line.buffer));
el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer);
- if (el->el_line.lastchar > el->el_line.buffer) {
- if (el->el_line.lastchar[-1] == '\n')
- el->el_line.lastchar--;
- if (el->el_line.lastchar[-1] == ' ')
- el->el_line.lastchar--;
- if (el->el_line.lastchar < el->el_line.buffer)
- el->el_line.lastchar = el->el_line.buffer;
- }
+ if (el->el_line.lastchar > el->el_line.buffer
+ && el->el_line.lastchar[-1] == '\n')
+ el->el_line.lastchar--;
+ if (el->el_line.lastchar > el->el_line.buffer
+ && el->el_line.lastchar[-1] == ' ')
+ el->el_line.lastchar--;
#ifdef KSHVI
if (el->el_map.type == MAP_VI)
el->el_line.cursor = el->el_line.buffer;
@@ -149,21 +155,40 @@ hist_get(EditLine *el)
}
-/* hist_list()
- * List history entries
+/* hist_command()
+ * process a history command
*/
protected int
-/*ARGSUSED*/
-hist_list(EditLine *el, int argc, const char **argv)
+hist_command(EditLine *el, int argc, const char **argv)
{
const char *str;
+ int num;
+ HistEvent ev;
if (el->el_history.ref == NULL)
return (-1);
- for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
- (void) fprintf(el->el_outfile, "%d %s",
- el->el_history.ev.num, str);
- return (0);
+
+ if (argc == 1 || strcmp(argv[1], "list") == 0) {
+ /* List history entries */
+
+ for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
+ (void) fprintf(el->el_outfile, "%d %s",
+ el->el_history.ev.num, str);
+ return (0);
+ }
+
+ if (argc != 3)
+ return (-1);
+
+ num = (int)strtol(argv[2], NULL, 0);
+
+ if (strcmp(argv[1], "size") == 0)
+ return history(el->el_history.ref, &ev, H_SETSIZE, num);
+
+ if (strcmp(argv[1], "unique") == 0)
+ return history(el->el_history.ref, &ev, H_SETUNIQUE, num);
+
+ return -1;
}
/* hist_enlargebuf()
diff --git a/net/tnftp/files/libedit/hist.h b/net/tnftp/files/libedit/hist.h
index f44f3286fb0..3799ca1fb28 100644
--- a/net/tnftp/files/libedit/hist.h
+++ b/net/tnftp/files/libedit/hist.h
@@ -1,4 +1,5 @@
-/* $NetBSD: hist.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: hist.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -66,7 +63,7 @@ typedef struct el_history_t {
#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)
#define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL)
#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)
-#define HIST_EVENT(el, num) HIST_FUN(el, H_EVENT, num)
+#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)
#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
@@ -74,7 +71,7 @@ protected int hist_init(EditLine *);
protected void hist_end(EditLine *);
protected el_action_t hist_get(EditLine *);
protected int hist_set(EditLine *, hist_fun_t, ptr_t);
-protected int hist_list(EditLine *, int, const char **);
+protected int hist_command(EditLine *, int, const char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t);
#endif /* _h_el_hist */
diff --git a/net/tnftp/files/libedit/histedit.h b/net/tnftp/files/libedit/histedit.h
index 6a2cb78bab2..d984dd1e904 100644
--- a/net/tnftp/files/libedit/histedit.h
+++ b/net/tnftp/files/libedit/histedit.h
@@ -1,4 +1,5 @@
-/* $NetBSD: histedit.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: histedit.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: histedit.h,v 1.25 2003/12/05 13:37:48 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -45,7 +42,7 @@
#define _HISTEDIT_H_
#define LIBEDIT_MAJOR 2
-#define LIBEDIT_MINOR 6
+#define LIBEDIT_MINOR 9
#include <sys/types.h>
#include <stdio.h>
@@ -53,6 +50,7 @@
/*
* ==== Editing ====
*/
+
typedef struct editline EditLine;
/*
@@ -64,7 +62,6 @@ typedef struct lineinfo {
const char *lastchar;
} LineInfo;
-
/*
* EditLine editor function return codes.
* For user-defined function interface
@@ -84,9 +81,8 @@ typedef struct lineinfo {
* Initialization, cleanup, and resetting
*/
EditLine *el_init(const char *, FILE *, FILE *, FILE *);
-void el_reset(EditLine *);
void el_end(EditLine *);
-
+void el_reset(EditLine *);
/*
* Get a line, a character or push a string back in the input queue
@@ -131,6 +127,8 @@ int el_get(EditLine *, int, void *);
#define EL_RPROMPT 12 /* , el_pfunc_t); */
#define EL_GETCFN 13 /* , el_rfunc_t); */
#define EL_CLIENTDATA 14 /* , void *); */
+#define EL_UNBUFFERED 15 /* , int); */
+#define EL_PREP_TERM 16 /* , int); */
#define EL_BUILTIN_GETCFN (NULL)
@@ -146,7 +144,6 @@ int el_source(EditLine *, const char *);
*/
void el_resize(EditLine *);
-
/*
* User-defined function interface.
*/
@@ -154,6 +151,7 @@ const LineInfo *el_line(EditLine *);
int el_insertstr(EditLine *, const char *);
void el_deletestr(EditLine *, int);
+
/*
* ==== History ====
*/
@@ -181,7 +179,7 @@ int history(History *, HistEvent *, int, ...);
#define H_PREV 5 /* , void); */
#define H_NEXT 6 /* , void); */
#define H_CURR 8 /* , const int); */
-#define H_SET 7 /* , void); */
+#define H_SET 7 /* , int); */
#define H_ADD 9 /* , const char *); */
#define H_ENTER 10 /* , const char *); */
#define H_APPEND 11 /* , const char *); */
@@ -193,5 +191,25 @@ int history(History *, HistEvent *, int, ...);
#define H_LOAD 17 /* , const char *); */
#define H_SAVE 18 /* , const char *); */
#define H_CLEAR 19 /* , void); */
+#define H_SETUNIQUE 20 /* , int); */
+#define H_GETUNIQUE 21 /* , void); */
+
+
+/*
+ * ==== Tokenization ====
+ */
+
+typedef struct tokenizer Tokenizer;
+
+/*
+ * String tokenization functions, using simplified sh(1) quoting rules
+ */
+Tokenizer *tok_init(const char *);
+void tok_end(Tokenizer *);
+void tok_reset(Tokenizer *);
+int tok_line(Tokenizer *, const LineInfo *,
+ int *, const char ***, int *, int *);
+int tok_str(Tokenizer *, const char *,
+ int *, const char ***);
#endif /* _HISTEDIT_H_ */
diff --git a/net/tnftp/files/libedit/history.c b/net/tnftp/files/libedit/history.c
index 594d3a76f65..c88439d4483 100644
--- a/net/tnftp/files/libedit/history.c
+++ b/net/tnftp/files/libedit/history.c
@@ -1,4 +1,5 @@
-/* $NetBSD: history.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: history.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: history.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* hist.c: History access functions
*/
@@ -69,6 +77,7 @@ struct history {
history_efun_t h_enter; /* Add an element */
history_efun_t h_add; /* Append to an element */
};
+
#define HNEXT(h, ev) (*(h)->h_next)((h)->h_ref, ev)
#define HFIRST(h, ev) (*(h)->h_first)((h)->h_ref, ev)
#define HPREV(h, ev) (*(h)->h_prev)((h)->h_ref, ev)
@@ -79,6 +88,7 @@ struct history {
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
+#define h_strdup(a) strdup(a)
#define h_malloc(a) malloc(a)
#define h_realloc(a, b) realloc((a), (b))
#define h_free(a) free(a)
@@ -92,6 +102,8 @@ typedef struct {
private int history_setsize(History *, HistEvent *, int);
private int history_getsize(History *, HistEvent *);
+private int history_setunique(History *, HistEvent *, int);
+private int history_getunique(History *, HistEvent *);
private int history_set_fun(History *, History *);
private int history_load(History *, const char *);
private int history_save(History *, const char *);
@@ -110,15 +122,17 @@ typedef struct hentry_t {
HistEvent ev; /* What we return */
struct hentry_t *next; /* Next entry */
struct hentry_t *prev; /* Previous entry */
-} hentry_t;
+} hentry_t;
typedef struct history_t {
- hentry_t list; /* Fake list header element */
- hentry_t *cursor; /* Current element in the list */
- int max; /* Maximum number of events */
- int cur; /* Current number of events */
+ hentry_t list; /* Fake list header element */
+ hentry_t *cursor; /* Current element in the list */
+ int max; /* Maximum number of events */
+ int cur; /* Current number of events */
int eventid; /* For generation of unique event id */
-} history_t;
+ int flags; /* History flags */
+#define H_UNIQUE 1 /* Store only unique elements */
+} history_t;
private int history_def_first(ptr_t, HistEvent *);
private int history_def_last(ptr_t, HistEvent *);
@@ -128,13 +142,19 @@ private int history_def_curr(ptr_t, HistEvent *);
private int history_def_set(ptr_t, HistEvent *, const int n);
private int history_def_enter(ptr_t, HistEvent *, const char *);
private int history_def_add(ptr_t, HistEvent *, const char *);
-private void history_def_init(ptr_t *, HistEvent *, int);
+private int history_def_init(ptr_t *, HistEvent *, int);
private void history_def_clear(ptr_t, HistEvent *);
private int history_def_insert(history_t *, HistEvent *, const char *);
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
-#define history_def_setsize(p, num)(void) (((history_t *) p)->max = (num))
-#define history_def_getsize(p) (((history_t *) p)->cur)
+#define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
+#define history_def_getsize(p) (((history_t *)p)->cur)
+#define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0)
+#define history_def_setunique(p, uni) \
+ if (uni) \
+ (((history_t *)p)->flags) |= H_UNIQUE; \
+ else \
+ (((history_t *)p)->flags) &= ~H_UNIQUE
#define he_strerror(code) he_errlist[code]
#define he_seterrev(evp, code) {\
@@ -227,20 +247,19 @@ history_def_next(ptr_t p, HistEvent *ev)
{
history_t *h = (history_t *) p;
- if (h->cursor != &h->list)
- h->cursor = h->cursor->next;
- else {
+ if (h->cursor == &h->list) {
he_seterrev(ev, _HE_EMPTY_LIST);
return (-1);
}
- if (h->cursor != &h->list)
- *ev = h->cursor->ev;
- else {
+ if (h->cursor->next == &h->list) {
he_seterrev(ev, _HE_END_REACHED);
return (-1);
}
+ h->cursor = h->cursor->next;
+ *ev = h->cursor->ev;
+
return (0);
}
@@ -253,21 +272,20 @@ history_def_prev(ptr_t p, HistEvent *ev)
{
history_t *h = (history_t *) p;
- if (h->cursor != &h->list)
- h->cursor = h->cursor->prev;
- else {
+ if (h->cursor == &h->list) {
he_seterrev(ev,
(h->cur > 0) ? _HE_END_REACHED : _HE_EMPTY_LIST);
return (-1);
}
- if (h->cursor != &h->list)
- *ev = h->cursor->ev;
- else {
+ if (h->cursor->prev == &h->list) {
he_seterrev(ev, _HE_START_REACHED);
return (-1);
}
+ h->cursor = h->cursor->prev;
+ *ev = h->cursor->ev;
+
return (0);
}
@@ -334,13 +352,13 @@ history_def_add(ptr_t p, HistEvent *ev, const char *str)
return (history_def_enter(p, ev, str));
len = strlen(evp->str) + strlen(str) + 1;
s = (char *) h_malloc(len);
- if (!s) {
+ if (s == NULL) {
he_seterrev(ev, _HE_MALLOC_FAILED);
return (-1);
}
(void) strlcpy(s, h->cursor->ev.str, len);
(void) strlcat(s, str, len);
- h_free(evp->str);
+ h_free((ptr_t)evp->str);
evp->str = s;
*ev = h->cursor->ev;
return (0);
@@ -352,7 +370,8 @@ history_def_add(ptr_t p, HistEvent *ev, const char *str)
*/
/* ARGSUSED */
private void
-history_def_delete(history_t *h, HistEvent *ev, hentry_t *hp)
+history_def_delete(history_t *h,
+ HistEvent *ev __attribute__((__unused__)), hentry_t *hp)
{
HistEventPrivate *evp = (void *)&hp->ev;
if (hp == &h->list)
@@ -373,11 +392,11 @@ history_def_insert(history_t *h, HistEvent *ev, const char *str)
{
h->cursor = (hentry_t *) h_malloc(sizeof(hentry_t));
- if (h->cursor)
- h->cursor->ev.str = strdup(str);
- if (!h->cursor || !h->cursor->ev.str) {
- he_seterrev(ev, _HE_MALLOC_FAILED);
- return (-1);
+ if (h->cursor == NULL)
+ goto oomem;
+ if ((h->cursor->ev.str = h_strdup(str)) == NULL) {
+ h_free((ptr_t)h->cursor);
+ goto oomem;
}
h->cursor->ev.num = ++h->eventid;
h->cursor->next = h->list.next;
@@ -388,6 +407,9 @@ history_def_insert(history_t *h, HistEvent *ev, const char *str)
*ev = h->cursor->ev;
return (0);
+oomem:
+ he_seterrev(ev, _HE_MALLOC_FAILED);
+ return (-1);
}
@@ -399,6 +421,10 @@ history_def_enter(ptr_t p, HistEvent *ev, const char *str)
{
history_t *h = (history_t *) p;
+ if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list &&
+ strcmp(h->list.next->ev.str, str) == 0)
+ return (0);
+
if (history_def_insert(h, ev, str) == -1)
return (-1); /* error, keep error message */
@@ -409,7 +435,7 @@ history_def_enter(ptr_t p, HistEvent *ev, const char *str)
while (h->cur > h->max && h->cur > 0)
history_def_delete(h, ev, h->list.prev);
- return (0);
+ return (1);
}
@@ -417,10 +443,12 @@ history_def_enter(ptr_t p, HistEvent *ev, const char *str)
* Default history initialization function
*/
/* ARGSUSED */
-private void
-history_def_init(ptr_t *p, HistEvent *ev, int n)
+private int
+history_def_init(ptr_t *p, HistEvent *ev __attribute__((__unused__)), int n)
{
history_t *h = (history_t *) h_malloc(sizeof(history_t));
+ if (h == NULL)
+ return -1;
if (n <= 0)
n = 0;
@@ -431,7 +459,9 @@ history_def_init(ptr_t *p, HistEvent *ev, int n)
h->list.ev.str = NULL;
h->list.ev.num = 0;
h->cursor = &h->list;
+ h->flags = 0;
*p = (ptr_t) h;
+ return 0;
}
@@ -460,10 +490,15 @@ history_def_clear(ptr_t p, HistEvent *ev)
public History *
history_init(void)
{
- History *h = (History *) h_malloc(sizeof(History));
HistEvent ev;
+ History *h = (History *) h_malloc(sizeof(History));
+ if (h == NULL)
+ return NULL;
- history_def_init(&h->h_ref, &ev, 0);
+ if (history_def_init(&h->h_ref, &ev, 0) == -1) {
+ h_free((ptr_t)h);
+ return NULL;
+ }
h->h_ent = -1;
h->h_next = history_def_next;
h->h_first = history_def_first;
@@ -519,18 +554,46 @@ history_setsize(History *h, HistEvent *ev, int num)
private int
history_getsize(History *h, HistEvent *ev)
{
- int retval = 0;
-
if (h->h_next != history_def_next) {
he_seterrev(ev, _HE_NOT_ALLOWED);
return (-1);
}
- retval = history_def_getsize(h->h_ref);
- if (retval < -1) {
+ ev->num = history_def_getsize(h->h_ref);
+ if (ev->num < -1) {
he_seterrev(ev, _HE_SIZE_NEGATIVE);
return (-1);
}
- ev->num = retval;
+ return (0);
+}
+
+
+/* history_setunique():
+ * Set if adjacent equal events should not be entered in history.
+ */
+private int
+history_setunique(History *h, HistEvent *ev, int uni)
+{
+
+ if (h->h_next != history_def_next) {
+ he_seterrev(ev, _HE_NOT_ALLOWED);
+ return (-1);
+ }
+ history_def_setunique(h->h_ref, uni);
+ return (0);
+}
+
+
+/* history_getunique():
+ * Get if adjacent equal events should not be entered in history.
+ */
+private int
+history_getunique(History *h, HistEvent *ev)
+{
+ if (h->h_next != history_def_next) {
+ he_seterrev(ev, _HE_NOT_ALLOWED);
+ return (-1);
+ }
+ ev->num = history_def_getunique(h->h_ref);
return (0);
}
@@ -602,6 +665,8 @@ history_load(History *h, const char *fname)
goto done;
ptr = h_malloc(max_size = 1024);
+ if (ptr == NULL)
+ goto done;
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
char c = line[sz];
@@ -611,15 +676,24 @@ history_load(History *h, const char *fname)
line[sz] = '\0';
if (max_size < sz) {
- max_size = (sz + 1023) & ~1023;
- ptr = h_realloc(ptr, max_size);
+ char *nptr;
+ max_size = (sz + 1024) & ~1023;
+ nptr = h_realloc(ptr, max_size);
+ if (nptr == NULL) {
+ i = -1;
+ goto oomem;
+ }
+ ptr = nptr;
}
(void) strunvis(ptr, line);
line[sz] = c;
- HENTER(h, &ev, ptr);
+ if (HENTER(h, &ev, ptr) == -1) {
+ h_free((ptr_t)ptr);
+ return -1;
+ }
}
- h_free(ptr);
-
+oomem:
+ h_free((ptr_t)ptr);
done:
(void) fclose(fp);
return (i);
@@ -634,28 +708,40 @@ history_save(History *h, const char *fname)
{
FILE *fp;
HistEvent ev;
- int i = 0, retval;
+ int i = -1, retval;
size_t len, max_size;
char *ptr;
if ((fp = fopen(fname, "w")) == NULL)
return (-1);
- (void) fchmod(fileno(fp), S_IRUSR|S_IWUSR);
- (void) fputs(hist_cookie, fp);
+ if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
+ goto done;
+ if (fputs(hist_cookie, fp) == EOF)
+ goto done;
ptr = h_malloc(max_size = 1024);
- for (retval = HLAST(h, &ev);
+ if (ptr == NULL)
+ goto done;
+ for (i = 0, retval = HLAST(h, &ev);
retval != -1;
retval = HPREV(h, &ev), i++) {
len = strlen(ev.str) * 4;
if (len >= max_size) {
- max_size = (len + 1023) & 1023;
- ptr = h_realloc(ptr, max_size);
+ char *nptr;
+ max_size = (len + 1024) & ~1023;
+ nptr = h_realloc(ptr, max_size);
+ if (nptr == NULL) {
+ i = -1;
+ goto oomem;
+ }
+ ptr = nptr;
}
(void) strvis(ptr, ev.str, VIS_WHITE);
- (void) fprintf(fp, "%s\n", ev.str);
+ (void) fprintf(fp, "%s\n", ptr);
}
- h_free(ptr);
+oomem:
+ h_free((ptr_t)ptr);
+done:
(void) fclose(fp);
return (i);
}
@@ -754,6 +840,14 @@ history(History *h, HistEvent *ev, int fun, ...)
retval = history_setsize(h, ev, va_arg(va, int));
break;
+ case H_GETUNIQUE:
+ retval = history_getunique(h, ev);
+ break;
+
+ case H_SETUNIQUE:
+ retval = history_setunique(h, ev, va_arg(va, int));
+ break;
+
case H_ADD:
str = va_arg(va, const char *);
retval = HADD(h, ev, str);
diff --git a/net/tnftp/files/libedit/key.c b/net/tnftp/files/libedit/key.c
index 09641f84642..2babd0067bf 100644
--- a/net/tnftp/files/libedit/key.c
+++ b/net/tnftp/files/libedit/key.c
@@ -1,4 +1,5 @@
-/* $NetBSD: key.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: key.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: key.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* key.c: This module contains the procedures for maintaining
* the extended-key map.
@@ -350,7 +358,8 @@ node__try(EditLine *el, key_node_t *ptr, const char *str, key_value_t *val, int
break;
case XK_STR:
case XK_EXE:
- ptr->val.str = strdup(val->str);
+ if ((ptr->val.str = el_strdup(val->str)) == NULL)
+ return -1;
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
diff --git a/net/tnftp/files/libedit/key.h b/net/tnftp/files/libedit/key.h
index 1c4764096a7..71f84a48bf0 100644
--- a/net/tnftp/files/libedit/key.h
+++ b/net/tnftp/files/libedit/key.h
@@ -1,4 +1,5 @@
-/* $NetBSD: key.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: key.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -62,6 +59,10 @@ typedef struct el_key_t {
#define XK_NOD 2
#define XK_EXE 3
+#undef key_end
+#undef key_clear
+#undef key_print
+
protected int key_init(EditLine *);
protected void key_end(EditLine *);
protected key_value_t *key_map_cmd(EditLine *, int);
diff --git a/net/tnftp/files/libedit/makelist.in b/net/tnftp/files/libedit/makelist.in
index 7a7acafea5c..6c5321ae9e1 100644
--- a/net/tnftp/files/libedit/makelist.in
+++ b/net/tnftp/files/libedit/makelist.in
@@ -1,7 +1,7 @@
#!/bin/sh -
# @configure_input@
#
-# $NetBSD: makelist.in,v 1.1 2004/03/11 13:01:01 grant Exp $
+# NetBSD: makelist.in,v 1.2 2005/01/05 04:40:05 lukem Exp
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -93,7 +93,7 @@ case $FLAG in
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#include \"sys.h\"\n#include \"el.h\"\n");
- printf("private struct el_bindings_t el_func_help[] = {\n");
+ printf("private const struct el_bindings_t el_func_help[] = {\n");
low = "abcdefghijklmnopqrstuvwxyz_";
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
for (i = 1; i <= length(low); i++)
@@ -129,7 +129,7 @@ case $FLAG in
END {
printf(" { NULL, 0, NULL }\n");
printf("};\n");
- printf("\nprotected el_bindings_t* help__get()");
+ printf("\nprotected const el_bindings_t* help__get()");
printf("{ return el_func_help; }\n");
}'
;;
@@ -141,7 +141,7 @@ case $FLAG in
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#ifndef _h_help_c\n#define _h_help_c\n");
- printf("protected el_bindings_t *help__get(void);\n");
+ printf("protected const el_bindings_t *help__get(void);\n");
printf("#endif /* _h_help_c */\n");
}' /dev/null
;;
@@ -163,7 +163,7 @@ case $FLAG in
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
printf("typedef el_action_t (*el_func_t)(EditLine *, int);");
- printf("\nprotected el_func_t* func__get(void);\n");
+ printf("\nprotected const el_func_t* func__get(void);\n");
printf("#endif /* _h_fcns_c */\n");
}'
;;
@@ -175,7 +175,7 @@ case $FLAG in
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#include \"sys.h\"\n#include \"el.h\"\n");
- printf("private el_func_t el_func[] = {");
+ printf("private const el_func_t el_func[] = {");
maxlen = 80;
needn = 1;
len = 0;
@@ -195,7 +195,7 @@ case $FLAG in
}
END {
printf("\n};\n");
- printf("\nprotected el_func_t* func__get() { return el_func; }\n");
+ printf("\nprotected const el_func_t* func__get() { return el_func; }\n");
}'
;;
diff --git a/net/tnftp/files/libedit/map.c b/net/tnftp/files/libedit/map.c
index 764fa7280f1..584aaf15255 100644
--- a/net/tnftp/files/libedit/map.c
+++ b/net/tnftp/files/libedit/map.c
@@ -1,4 +1,5 @@
-/* $NetBSD: map.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: map.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: map.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* map.c: Editor function definitions
*/
@@ -65,7 +73,7 @@ private const el_action_t el_map_emacs[] = {
/* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_NEXT_CHAR, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */
- /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
+ /* 8 */ EM_DELETE_PREV_CHAR, /* ^H */
/* 9 */ ED_UNASSIGNED, /* ^I */
/* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */
@@ -184,7 +192,7 @@ private const el_action_t el_map_emacs[] = {
/* 124 */ ED_INSERT, /* | */
/* 125 */ ED_INSERT, /* } */
/* 126 */ ED_INSERT, /* ~ */
- /* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
+ /* 127 */ EM_DELETE_PREV_CHAR, /* ^? */
/* 128 */ ED_UNASSIGNED, /* M-^@ */
/* 129 */ ED_UNASSIGNED, /* M-^A */
/* 130 */ ED_UNASSIGNED, /* M-^B */
@@ -373,7 +381,7 @@ private const el_action_t el_map_vi_insert[] = {
/* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_NEXT_CHAR, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */
- /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
+ /* 8 */ VI_DELETE_PREV_CHAR, /* ^H */ /* BackSpace key */
/* 9 */ ED_UNASSIGNED, /* ^I */ /* Tab Key */
/* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */
@@ -493,135 +501,135 @@ private const el_action_t el_map_vi_insert[] = {
/* 124 */ ED_INSERT, /* | */
/* 125 */ ED_INSERT, /* } */
/* 126 */ ED_INSERT, /* ~ */
- /* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
- /* 128 */ ED_UNASSIGNED, /* M-^@ */
- /* 129 */ ED_UNASSIGNED, /* M-^A */
- /* 130 */ ED_UNASSIGNED, /* M-^B */
- /* 131 */ ED_UNASSIGNED, /* M-^C */
- /* 132 */ ED_UNASSIGNED, /* M-^D */
- /* 133 */ ED_UNASSIGNED, /* M-^E */
- /* 134 */ ED_UNASSIGNED, /* M-^F */
- /* 135 */ ED_UNASSIGNED, /* M-^G */
- /* 136 */ ED_UNASSIGNED, /* M-^H */
- /* 137 */ ED_UNASSIGNED, /* M-^I */
- /* 138 */ ED_UNASSIGNED, /* M-^J */
- /* 139 */ ED_UNASSIGNED, /* M-^K */
- /* 140 */ ED_UNASSIGNED, /* M-^L */
- /* 141 */ ED_UNASSIGNED, /* M-^M */
- /* 142 */ ED_UNASSIGNED, /* M-^N */
- /* 143 */ ED_UNASSIGNED, /* M-^O */
- /* 144 */ ED_UNASSIGNED, /* M-^P */
- /* 145 */ ED_UNASSIGNED, /* M-^Q */
- /* 146 */ ED_UNASSIGNED, /* M-^R */
- /* 147 */ ED_UNASSIGNED, /* M-^S */
- /* 148 */ ED_UNASSIGNED, /* M-^T */
- /* 149 */ ED_UNASSIGNED, /* M-^U */
- /* 150 */ ED_UNASSIGNED, /* M-^V */
- /* 151 */ ED_UNASSIGNED, /* M-^W */
- /* 152 */ ED_UNASSIGNED, /* M-^X */
- /* 153 */ ED_UNASSIGNED, /* M-^Y */
- /* 154 */ ED_UNASSIGNED, /* M-^Z */
- /* 155 */ ED_UNASSIGNED, /* M-^[ */
- /* 156 */ ED_UNASSIGNED, /* M-^\ */
- /* 157 */ ED_UNASSIGNED, /* M-^] */
- /* 158 */ ED_UNASSIGNED, /* M-^^ */
- /* 159 */ ED_UNASSIGNED, /* M-^_ */
- /* 160 */ ED_UNASSIGNED, /* M-SPACE */
- /* 161 */ ED_UNASSIGNED, /* M-! */
- /* 162 */ ED_UNASSIGNED, /* M-" */
- /* 163 */ ED_UNASSIGNED, /* M-# */
- /* 164 */ ED_UNASSIGNED, /* M-$ */
- /* 165 */ ED_UNASSIGNED, /* M-% */
- /* 166 */ ED_UNASSIGNED, /* M-& */
- /* 167 */ ED_UNASSIGNED, /* M-' */
- /* 168 */ ED_UNASSIGNED, /* M-( */
- /* 169 */ ED_UNASSIGNED, /* M-) */
- /* 170 */ ED_UNASSIGNED, /* M-* */
- /* 171 */ ED_UNASSIGNED, /* M-+ */
- /* 172 */ ED_UNASSIGNED, /* M-, */
- /* 173 */ ED_UNASSIGNED, /* M-- */
- /* 174 */ ED_UNASSIGNED, /* M-. */
- /* 175 */ ED_UNASSIGNED, /* M-/ */
- /* 176 */ ED_UNASSIGNED, /* M-0 */
- /* 177 */ ED_UNASSIGNED, /* M-1 */
- /* 178 */ ED_UNASSIGNED, /* M-2 */
- /* 179 */ ED_UNASSIGNED, /* M-3 */
- /* 180 */ ED_UNASSIGNED, /* M-4 */
- /* 181 */ ED_UNASSIGNED, /* M-5 */
- /* 182 */ ED_UNASSIGNED, /* M-6 */
- /* 183 */ ED_UNASSIGNED, /* M-7 */
- /* 184 */ ED_UNASSIGNED, /* M-8 */
- /* 185 */ ED_UNASSIGNED, /* M-9 */
- /* 186 */ ED_UNASSIGNED, /* M-: */
- /* 187 */ ED_UNASSIGNED, /* M-; */
- /* 188 */ ED_UNASSIGNED, /* M-< */
- /* 189 */ ED_UNASSIGNED, /* M-= */
- /* 190 */ ED_UNASSIGNED, /* M-> */
- /* 191 */ ED_UNASSIGNED, /* M-? */
- /* 192 */ ED_UNASSIGNED, /* M-@ */
- /* 193 */ ED_UNASSIGNED, /* M-A */
- /* 194 */ ED_UNASSIGNED, /* M-B */
- /* 195 */ ED_UNASSIGNED, /* M-C */
- /* 196 */ ED_UNASSIGNED, /* M-D */
- /* 197 */ ED_UNASSIGNED, /* M-E */
- /* 198 */ ED_UNASSIGNED, /* M-F */
- /* 199 */ ED_UNASSIGNED, /* M-G */
- /* 200 */ ED_UNASSIGNED, /* M-H */
- /* 201 */ ED_UNASSIGNED, /* M-I */
- /* 202 */ ED_UNASSIGNED, /* M-J */
- /* 203 */ ED_UNASSIGNED, /* M-K */
- /* 204 */ ED_UNASSIGNED, /* M-L */
- /* 205 */ ED_UNASSIGNED, /* M-M */
- /* 206 */ ED_UNASSIGNED, /* M-N */
- /* 207 */ ED_UNASSIGNED, /* M-O */
- /* 208 */ ED_UNASSIGNED, /* M-P */
- /* 209 */ ED_UNASSIGNED, /* M-Q */
- /* 210 */ ED_UNASSIGNED, /* M-R */
- /* 211 */ ED_UNASSIGNED, /* M-S */
- /* 212 */ ED_UNASSIGNED, /* M-T */
- /* 213 */ ED_UNASSIGNED, /* M-U */
- /* 214 */ ED_UNASSIGNED, /* M-V */
- /* 215 */ ED_UNASSIGNED, /* M-W */
- /* 216 */ ED_UNASSIGNED, /* M-X */
- /* 217 */ ED_UNASSIGNED, /* M-Y */
- /* 218 */ ED_UNASSIGNED, /* M-Z */
- /* 219 */ ED_UNASSIGNED, /* M-[ */
- /* 220 */ ED_UNASSIGNED, /* M-\ */
- /* 221 */ ED_UNASSIGNED, /* M-] */
- /* 222 */ ED_UNASSIGNED, /* M-^ */
- /* 223 */ ED_UNASSIGNED, /* M-_ */
- /* 224 */ ED_UNASSIGNED, /* M-` */
- /* 225 */ ED_UNASSIGNED, /* M-a */
- /* 226 */ ED_UNASSIGNED, /* M-b */
- /* 227 */ ED_UNASSIGNED, /* M-c */
- /* 228 */ ED_UNASSIGNED, /* M-d */
- /* 229 */ ED_UNASSIGNED, /* M-e */
- /* 230 */ ED_UNASSIGNED, /* M-f */
- /* 231 */ ED_UNASSIGNED, /* M-g */
- /* 232 */ ED_UNASSIGNED, /* M-h */
- /* 233 */ ED_UNASSIGNED, /* M-i */
- /* 234 */ ED_UNASSIGNED, /* M-j */
- /* 235 */ ED_UNASSIGNED, /* M-k */
- /* 236 */ ED_UNASSIGNED, /* M-l */
- /* 237 */ ED_UNASSIGNED, /* M-m */
- /* 238 */ ED_UNASSIGNED, /* M-n */
- /* 239 */ ED_UNASSIGNED, /* M-o */
- /* 240 */ ED_UNASSIGNED, /* M-p */
- /* 241 */ ED_UNASSIGNED, /* M-q */
- /* 242 */ ED_UNASSIGNED, /* M-r */
- /* 243 */ ED_UNASSIGNED, /* M-s */
- /* 244 */ ED_UNASSIGNED, /* M-t */
- /* 245 */ ED_UNASSIGNED, /* M-u */
- /* 246 */ ED_UNASSIGNED, /* M-v */
- /* 247 */ ED_UNASSIGNED, /* M-w */
- /* 248 */ ED_UNASSIGNED, /* M-x */
- /* 249 */ ED_UNASSIGNED, /* M-y */
- /* 250 */ ED_UNASSIGNED, /* M-z */
- /* 251 */ ED_UNASSIGNED, /* M-{ */
- /* 252 */ ED_UNASSIGNED, /* M-| */
- /* 253 */ ED_UNASSIGNED, /* M-} */
- /* 254 */ ED_UNASSIGNED, /* M-~ */
- /* 255 */ ED_UNASSIGNED /* M-^? */
+ /* 127 */ VI_DELETE_PREV_CHAR, /* ^? */
+ /* 128 */ ED_INSERT, /* M-^@ */
+ /* 129 */ ED_INSERT, /* M-^A */
+ /* 130 */ ED_INSERT, /* M-^B */
+ /* 131 */ ED_INSERT, /* M-^C */
+ /* 132 */ ED_INSERT, /* M-^D */
+ /* 133 */ ED_INSERT, /* M-^E */
+ /* 134 */ ED_INSERT, /* M-^F */
+ /* 135 */ ED_INSERT, /* M-^G */
+ /* 136 */ ED_INSERT, /* M-^H */
+ /* 137 */ ED_INSERT, /* M-^I */
+ /* 138 */ ED_INSERT, /* M-^J */
+ /* 139 */ ED_INSERT, /* M-^K */
+ /* 140 */ ED_INSERT, /* M-^L */
+ /* 141 */ ED_INSERT, /* M-^M */
+ /* 142 */ ED_INSERT, /* M-^N */
+ /* 143 */ ED_INSERT, /* M-^O */
+ /* 144 */ ED_INSERT, /* M-^P */
+ /* 145 */ ED_INSERT, /* M-^Q */
+ /* 146 */ ED_INSERT, /* M-^R */
+ /* 147 */ ED_INSERT, /* M-^S */
+ /* 148 */ ED_INSERT, /* M-^T */
+ /* 149 */ ED_INSERT, /* M-^U */
+ /* 150 */ ED_INSERT, /* M-^V */
+ /* 151 */ ED_INSERT, /* M-^W */
+ /* 152 */ ED_INSERT, /* M-^X */
+ /* 153 */ ED_INSERT, /* M-^Y */
+ /* 154 */ ED_INSERT, /* M-^Z */
+ /* 155 */ ED_INSERT, /* M-^[ */
+ /* 156 */ ED_INSERT, /* M-^\ */
+ /* 157 */ ED_INSERT, /* M-^] */
+ /* 158 */ ED_INSERT, /* M-^^ */
+ /* 159 */ ED_INSERT, /* M-^_ */
+ /* 160 */ ED_INSERT, /* M-SPACE */
+ /* 161 */ ED_INSERT, /* M-! */
+ /* 162 */ ED_INSERT, /* M-" */
+ /* 163 */ ED_INSERT, /* M-# */
+ /* 164 */ ED_INSERT, /* M-$ */
+ /* 165 */ ED_INSERT, /* M-% */
+ /* 166 */ ED_INSERT, /* M-& */
+ /* 167 */ ED_INSERT, /* M-' */
+ /* 168 */ ED_INSERT, /* M-( */
+ /* 169 */ ED_INSERT, /* M-) */
+ /* 170 */ ED_INSERT, /* M-* */
+ /* 171 */ ED_INSERT, /* M-+ */
+ /* 172 */ ED_INSERT, /* M-, */
+ /* 173 */ ED_INSERT, /* M-- */
+ /* 174 */ ED_INSERT, /* M-. */
+ /* 175 */ ED_INSERT, /* M-/ */
+ /* 176 */ ED_INSERT, /* M-0 */
+ /* 177 */ ED_INSERT, /* M-1 */
+ /* 178 */ ED_INSERT, /* M-2 */
+ /* 179 */ ED_INSERT, /* M-3 */
+ /* 180 */ ED_INSERT, /* M-4 */
+ /* 181 */ ED_INSERT, /* M-5 */
+ /* 182 */ ED_INSERT, /* M-6 */
+ /* 183 */ ED_INSERT, /* M-7 */
+ /* 184 */ ED_INSERT, /* M-8 */
+ /* 185 */ ED_INSERT, /* M-9 */
+ /* 186 */ ED_INSERT, /* M-: */
+ /* 187 */ ED_INSERT, /* M-; */
+ /* 188 */ ED_INSERT, /* M-< */
+ /* 189 */ ED_INSERT, /* M-= */
+ /* 190 */ ED_INSERT, /* M-> */
+ /* 191 */ ED_INSERT, /* M-? */
+ /* 192 */ ED_INSERT, /* M-@ */
+ /* 193 */ ED_INSERT, /* M-A */
+ /* 194 */ ED_INSERT, /* M-B */
+ /* 195 */ ED_INSERT, /* M-C */
+ /* 196 */ ED_INSERT, /* M-D */
+ /* 197 */ ED_INSERT, /* M-E */
+ /* 198 */ ED_INSERT, /* M-F */
+ /* 199 */ ED_INSERT, /* M-G */
+ /* 200 */ ED_INSERT, /* M-H */
+ /* 201 */ ED_INSERT, /* M-I */
+ /* 202 */ ED_INSERT, /* M-J */
+ /* 203 */ ED_INSERT, /* M-K */
+ /* 204 */ ED_INSERT, /* M-L */
+ /* 205 */ ED_INSERT, /* M-M */
+ /* 206 */ ED_INSERT, /* M-N */
+ /* 207 */ ED_INSERT, /* M-O */
+ /* 208 */ ED_INSERT, /* M-P */
+ /* 209 */ ED_INSERT, /* M-Q */
+ /* 210 */ ED_INSERT, /* M-R */
+ /* 211 */ ED_INSERT, /* M-S */
+ /* 212 */ ED_INSERT, /* M-T */
+ /* 213 */ ED_INSERT, /* M-U */
+ /* 214 */ ED_INSERT, /* M-V */
+ /* 215 */ ED_INSERT, /* M-W */
+ /* 216 */ ED_INSERT, /* M-X */
+ /* 217 */ ED_INSERT, /* M-Y */
+ /* 218 */ ED_INSERT, /* M-Z */
+ /* 219 */ ED_INSERT, /* M-[ */
+ /* 220 */ ED_INSERT, /* M-\ */
+ /* 221 */ ED_INSERT, /* M-] */
+ /* 222 */ ED_INSERT, /* M-^ */
+ /* 223 */ ED_INSERT, /* M-_ */
+ /* 224 */ ED_INSERT, /* M-` */
+ /* 225 */ ED_INSERT, /* M-a */
+ /* 226 */ ED_INSERT, /* M-b */
+ /* 227 */ ED_INSERT, /* M-c */
+ /* 228 */ ED_INSERT, /* M-d */
+ /* 229 */ ED_INSERT, /* M-e */
+ /* 230 */ ED_INSERT, /* M-f */
+ /* 231 */ ED_INSERT, /* M-g */
+ /* 232 */ ED_INSERT, /* M-h */
+ /* 233 */ ED_INSERT, /* M-i */
+ /* 234 */ ED_INSERT, /* M-j */
+ /* 235 */ ED_INSERT, /* M-k */
+ /* 236 */ ED_INSERT, /* M-l */
+ /* 237 */ ED_INSERT, /* M-m */
+ /* 238 */ ED_INSERT, /* M-n */
+ /* 239 */ ED_INSERT, /* M-o */
+ /* 240 */ ED_INSERT, /* M-p */
+ /* 241 */ ED_INSERT, /* M-q */
+ /* 242 */ ED_INSERT, /* M-r */
+ /* 243 */ ED_INSERT, /* M-s */
+ /* 244 */ ED_INSERT, /* M-t */
+ /* 245 */ ED_INSERT, /* M-u */
+ /* 246 */ ED_INSERT, /* M-v */
+ /* 247 */ ED_INSERT, /* M-w */
+ /* 248 */ ED_INSERT, /* M-x */
+ /* 249 */ ED_INSERT, /* M-y */
+ /* 250 */ ED_INSERT, /* M-z */
+ /* 251 */ ED_INSERT, /* M-{ */
+ /* 252 */ ED_INSERT, /* M-| */
+ /* 253 */ ED_INSERT, /* M-} */
+ /* 254 */ ED_INSERT, /* M-~ */
+ /* 255 */ ED_INSERT /* M-^? */
};
private const el_action_t el_map_vi_command[] = {
@@ -633,7 +641,7 @@ private const el_action_t el_map_vi_command[] = {
/* 5 */ ED_MOVE_TO_END, /* ^E */
/* 6 */ ED_UNASSIGNED, /* ^F */
/* 7 */ ED_UNASSIGNED, /* ^G */
- /* 8 */ ED_PREV_CHAR, /* ^H */
+ /* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
/* 9 */ ED_UNASSIGNED, /* ^I */
/* 10 */ ED_NEWLINE, /* ^J */
/* 11 */ ED_KILL_LINE, /* ^K */
@@ -660,9 +668,9 @@ private const el_action_t el_map_vi_command[] = {
/* 32 */ ED_NEXT_CHAR, /* SPACE */
/* 33 */ ED_UNASSIGNED, /* ! */
/* 34 */ ED_UNASSIGNED, /* " */
- /* 35 */ ED_UNASSIGNED, /* # */
+ /* 35 */ VI_COMMENT_OUT, /* # */
/* 36 */ ED_MOVE_TO_END, /* $ */
- /* 37 */ ED_UNASSIGNED, /* % */
+ /* 37 */ VI_MATCH, /* % */
/* 38 */ ED_UNASSIGNED, /* & */
/* 39 */ ED_UNASSIGNED, /* ' */
/* 40 */ ED_UNASSIGNED, /* ( */
@@ -671,7 +679,7 @@ private const el_action_t el_map_vi_command[] = {
/* 43 */ ED_NEXT_HISTORY, /* + */
/* 44 */ VI_REPEAT_PREV_CHAR, /* , */
/* 45 */ ED_PREV_HISTORY, /* - */
- /* 46 */ ED_UNASSIGNED, /* . */
+ /* 46 */ VI_REDO, /* . */
/* 47 */ VI_SEARCH_PREV, /* / */
/* 48 */ VI_ZERO, /* 0 */
/* 49 */ ED_ARGUMENT_DIGIT, /* 1 */
@@ -689,14 +697,14 @@ private const el_action_t el_map_vi_command[] = {
/* 61 */ ED_UNASSIGNED, /* = */
/* 62 */ ED_UNASSIGNED, /* > */
/* 63 */ VI_SEARCH_NEXT, /* ? */
- /* 64 */ ED_UNASSIGNED, /* @ */
+ /* 64 */ VI_ALIAS, /* @ */
/* 65 */ VI_ADD_AT_EOL, /* A */
- /* 66 */ VI_PREV_SPACE_WORD, /* B */
+ /* 66 */ VI_PREV_BIG_WORD, /* B */
/* 67 */ VI_CHANGE_TO_EOL, /* C */
/* 68 */ ED_KILL_LINE, /* D */
- /* 69 */ VI_TO_END_WORD, /* E */
+ /* 69 */ VI_END_BIG_WORD, /* E */
/* 70 */ VI_PREV_CHAR, /* F */
- /* 71 */ ED_UNASSIGNED, /* G */
+ /* 71 */ VI_TO_HISTORY_LINE, /* G */
/* 72 */ ED_UNASSIGNED, /* H */
/* 73 */ VI_INSERT_AT_BOL, /* I */
/* 74 */ ED_SEARCH_NEXT_HISTORY, /* J */
@@ -710,17 +718,17 @@ private const el_action_t el_map_vi_command[] = {
/* 82 */ VI_REPLACE_MODE, /* R */
/* 83 */ VI_SUBSTITUTE_LINE, /* S */
/* 84 */ VI_TO_PREV_CHAR, /* T */
- /* 85 */ ED_UNASSIGNED, /* U */
+ /* 85 */ VI_UNDO_LINE, /* U */
/* 86 */ ED_UNASSIGNED, /* V */
- /* 87 */ VI_NEXT_SPACE_WORD, /* W */
+ /* 87 */ VI_NEXT_BIG_WORD, /* W */
/* 88 */ ED_DELETE_PREV_CHAR, /* X */
- /* 89 */ ED_UNASSIGNED, /* Y */
+ /* 89 */ VI_YANK_END, /* Y */
/* 90 */ ED_UNASSIGNED, /* Z */
/* 91 */ ED_SEQUENCE_LEAD_IN, /* [ */
/* 92 */ ED_UNASSIGNED, /* \ */
/* 93 */ ED_UNASSIGNED, /* ] */
/* 94 */ ED_MOVE_TO_BEG, /* ^ */
- /* 95 */ ED_UNASSIGNED, /* _ */
+ /* 95 */ VI_HISTORY_WORD, /* _ */
/* 96 */ ED_UNASSIGNED, /* ` */
/* 97 */ VI_ADD, /* a */
/* 98 */ VI_PREV_WORD, /* b */
@@ -743,13 +751,13 @@ private const el_action_t el_map_vi_command[] = {
/* 115 */ VI_SUBSTITUTE_CHAR, /* s */
/* 116 */ VI_TO_NEXT_CHAR, /* t */
/* 117 */ VI_UNDO, /* u */
- /* 118 */ ED_UNASSIGNED, /* v */
+ /* 118 */ VI_HISTEDIT, /* v */
/* 119 */ VI_NEXT_WORD, /* w */
/* 120 */ ED_DELETE_NEXT_CHAR, /* x */
- /* 121 */ ED_UNASSIGNED, /* y */
+ /* 121 */ VI_YANK, /* y */
/* 122 */ ED_UNASSIGNED, /* z */
/* 123 */ ED_UNASSIGNED, /* { */
- /* 124 */ ED_UNASSIGNED, /* | */
+ /* 124 */ VI_TO_COLUMN, /* | */
/* 125 */ ED_UNASSIGNED, /* } */
/* 126 */ VI_CHANGE_CASE, /* ~ */
/* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
diff --git a/net/tnftp/files/libedit/map.h b/net/tnftp/files/libedit/map.h
index 1b4113d8e7d..372a11d12bc 100644
--- a/net/tnftp/files/libedit/map.h
+++ b/net/tnftp/files/libedit/map.h
@@ -1,4 +1,5 @@
-/* $NetBSD: map.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: map.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
diff --git a/net/tnftp/files/libedit/parse.c b/net/tnftp/files/libedit/parse.c
index 5bd31e49e2b..385b468ff23 100644
--- a/net/tnftp/files/libedit/parse.c
+++ b/net/tnftp/files/libedit/parse.c
@@ -1,4 +1,5 @@
-/* $NetBSD: parse.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: parse.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: parse.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* parse.c: parse an editline extended command
*
@@ -53,7 +61,6 @@
* setty
*/
#include "el.h"
-#include "tokenizer.h"
#include <stdlib.h>
private const struct {
@@ -63,7 +70,7 @@ private const struct {
{ "bind", map_bind },
{ "echotc", term_echotc },
{ "edit", el_editmode },
- { "history", hist_list },
+ { "history", hist_command },
{ "telltc", term_telltc },
{ "settc", term_settc },
{ "setty", tty_stty },
@@ -82,7 +89,7 @@ parse_line(EditLine *el, const char *line)
Tokenizer *tok;
tok = tok_init(NULL);
- tok_line(tok, line, &argc, &argv);
+ tok_str(tok, line, &argc, &argv);
argc = el_parse(el, argc, argv);
tok_end(tok);
return (argc);
@@ -200,7 +207,7 @@ parse__escape(const char **const ptr)
c = *p;
break;
}
- } else if (*p == '^' && isalpha((unsigned char) p[1])) {
+ } else if (*p == '^') {
p++;
c = (*p == '?') ? '\177' : (*p & 0237);
} else
@@ -208,6 +215,7 @@ parse__escape(const char **const ptr)
*ptr = ++p;
return (c);
}
+
/* parse__string():
* Parse the escapes from in and put the raw string out
*/
@@ -230,6 +238,14 @@ parse__string(char *out, const char *in)
*out++ = n;
break;
+ case 'M':
+ if (in[1] == '-' && in[2] != '\0') {
+ *out++ = '\033';
+ in += 2;
+ break;
+ }
+ /*FALLTHROUGH*/
+
default:
*out++ = *in++;
break;
diff --git a/net/tnftp/files/libedit/parse.h b/net/tnftp/files/libedit/parse.h
index bf6c172da9d..64da41c0977 100644
--- a/net/tnftp/files/libedit/parse.h
+++ b/net/tnftp/files/libedit/parse.h
@@ -1,4 +1,5 @@
-/* $NetBSD: parse.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: parse.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: parse.h,v 1.5 2003/08/07 16:44:32 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
diff --git a/net/tnftp/files/libedit/prompt.c b/net/tnftp/files/libedit/prompt.c
index a8492c04a85..6814ed81388 100644
--- a/net/tnftp/files/libedit/prompt.c
+++ b/net/tnftp/files/libedit/prompt.c
@@ -1,4 +1,5 @@
-/* $NetBSD: prompt.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: prompt.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: prompt.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* prompt.c: Prompt printing functions
*/
@@ -53,7 +61,7 @@ private char *prompt_default_r(EditLine *);
*/
private char *
/*ARGSUSED*/
-prompt_default(EditLine *el)
+prompt_default(EditLine *el __attribute__((__unused__)))
{
static char a[3] = {'?', ' ', '\0'};
@@ -66,7 +74,7 @@ prompt_default(EditLine *el)
*/
private char *
/*ARGSUSED*/
-prompt_default_r(EditLine *el)
+prompt_default_r(EditLine *el __attribute__((__unused__)))
{
static char a[1] = {'\0'};
@@ -121,7 +129,7 @@ prompt_init(EditLine *el)
*/
protected void
/*ARGSUSED*/
-prompt_end(EditLine *el)
+prompt_end(EditLine *el __attribute__((__unused__)))
{
}
diff --git a/net/tnftp/files/libedit/prompt.h b/net/tnftp/files/libedit/prompt.h
index 5ac87629984..6e30674b8b9 100644
--- a/net/tnftp/files/libedit/prompt.h
+++ b/net/tnftp/files/libedit/prompt.h
@@ -1,4 +1,5 @@
-/* $NetBSD: prompt.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: prompt.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
diff --git a/net/tnftp/files/libedit/read.c b/net/tnftp/files/libedit/read.c
index 237cfa5d09e..f8b8535844e 100644
--- a/net/tnftp/files/libedit/read.c
+++ b/net/tnftp/files/libedit/read.c
@@ -1,4 +1,5 @@
-/* $NetBSD: read.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: read.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: read.c,v 1.34 2004/07/08 00:51:36 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,11 +36,23 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: read.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* read.c: Clean this junk up! This is horrible code.
* Terminal read functions
*/
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include "el.h"
@@ -91,6 +100,10 @@ el_read_getfn(EditLine *el)
}
+#ifndef MIN
+#define MIN(A,B) ((A) < (B) ? (A) : (B))
+#endif
+
#ifdef DEBUG_EDIT
private void
read_debug(EditLine *el)
@@ -115,7 +128,7 @@ read_debug(EditLine *el)
*/
/* ARGSUSED */
private int
-read__fixio(int fd, int e)
+read__fixio(int fd __attribute__((__unused__)), int e)
{
switch (e) {
@@ -180,10 +193,6 @@ read_preread(EditLine *el)
{
int chrs = 0;
- if (el->el_chared.c_macro.nline) {
- el_free((ptr_t) el->el_chared.c_macro.nline);
- el->el_chared.c_macro.nline = NULL;
- }
if (el->el_tty.t_mode == ED_IO)
return (0);
@@ -196,8 +205,7 @@ read_preread(EditLine *el)
(size_t) MIN(chrs, EL_BUFSIZ - 1));
if (chrs > 0) {
buf[chrs] = '\0';
- el->el_chared.c_macro.nline = strdup(buf);
- el_push(el, el->el_chared.c_macro.nline);
+ el_push(el, buf);
}
}
#endif /* FIONREAD */
@@ -216,11 +224,12 @@ el_push(EditLine *el, char *str)
if (str != NULL && ma->level + 1 < EL_MAXMACRO) {
ma->level++;
- ma->macro[ma->level] = str;
- } else {
- term_beep(el);
- term__flush();
+ if ((ma->macro[ma->level] = el_strdup(str)) != NULL)
+ return;
+ ma->level--;
}
+ term_beep(el);
+ term__flush();
}
@@ -230,10 +239,10 @@ el_push(EditLine *el, char *str)
private int
read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch)
{
- el_action_t cmd = ED_UNASSIGNED;
+ el_action_t cmd;
int num;
- while (cmd == ED_UNASSIGNED || cmd == ED_SEQUENCE_LEAD_IN) {
+ do {
if ((num = el_getc(el, ch)) != 1) /* if EOF or error */
return (num);
@@ -272,7 +281,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch)
}
if (el->el_map.alt == NULL)
el->el_map.current = el->el_map.key;
- }
+ } while (cmd == ED_SEQUENCE_LEAD_IN);
*cmdnum = cmd;
return (OKCMD);
}
@@ -317,14 +326,16 @@ el_getc(EditLine *el, char *cp)
if (ma->level < 0)
break;
- if (*ma->macro[ma->level] == 0) {
- ma->level--;
+ if (ma->macro[ma->level][ma->offset] == '\0') {
+ el_free(ma->macro[ma->level--]);
+ ma->offset = 0;
continue;
}
- *cp = *ma->macro[ma->level]++ & 0377;
- if (*ma->macro[ma->level] == 0) { /* Needed for QuoteMode
- * On */
- ma->level--;
+ *cp = ma->macro[ma->level][ma->offset++] & 0377;
+ if (ma->macro[ma->level][ma->offset] == '\0') {
+ /* Needed for QuoteMode On */
+ el_free(ma->macro[ma->level--]);
+ ma->offset = 0;
}
return (1);
}
@@ -345,6 +356,32 @@ el_getc(EditLine *el, char *cp)
return (num_read);
}
+protected void
+read_prepare(EditLine *el)
+{
+ if (el->el_flags & HANDLE_SIGNALS)
+ sig_set(el);
+ if (el->el_flags & NO_TTY)
+ return;
+ if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
+ tty_rawmode(el);
+
+ /* This is relatively cheap, and things go terribly wrong if
+ we have the wrong size. */
+ el_resize(el);
+ re_clear_display(el); /* reset the display stuff */
+ ch_reset(el);
+ re_refresh(el); /* print the prompt */
+}
+
+protected void
+read_finish(EditLine *el)
+{
+ if ((el->el_flags & UNBUFFERED) == 0)
+ (void) tty_cookedmode(el);
+ if (el->el_flags & HANDLE_SIGNALS)
+ sig_clr(el);
+}
public const char *
el_gets(EditLine *el, int *nread)
@@ -353,13 +390,11 @@ el_gets(EditLine *el, int *nread)
el_action_t cmdnum = 0;
int num; /* how many chars we have read at NL */
char ch;
+ int crlf = 0;
#ifdef FIONREAD
c_macro_t *ma = &el->el_chared.c_macro;
#endif /* FIONREAD */
- if (el->el_flags & HANDLE_SIGNALS)
- sig_set(el);
-
if (el->el_flags & NO_TTY) {
char *cp = el->el_line.buffer;
size_t idx;
@@ -373,6 +408,8 @@ el_gets(EditLine *el, int *nread)
cp = &el->el_line.buffer[idx];
}
cp++;
+ if (el->el_flags & UNBUFFERED)
+ break;
if (cp[-1] == '\r' || cp[-1] == '\n')
break;
}
@@ -383,8 +420,7 @@ el_gets(EditLine *el, int *nread)
*nread = el->el_line.cursor - el->el_line.buffer;
return (el->el_line.buffer);
}
- re_clear_display(el); /* reset the display stuff */
- ch_reset(el);
+
#ifdef FIONREAD
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
@@ -401,11 +437,16 @@ el_gets(EditLine *el, int *nread)
}
#endif /* FIONREAD */
- re_refresh(el); /* print the prompt */
+ if ((el->el_flags & UNBUFFERED) == 0)
+ read_prepare(el);
if (el->el_flags & EDIT_DISABLED) {
- char *cp = el->el_line.buffer;
+ char *cp;
size_t idx;
+ if ((el->el_flags & UNBUFFERED) == 0)
+ cp = el->el_line.buffer;
+ else
+ cp = el->el_line.lastchar;
term__flush();
@@ -417,8 +458,13 @@ el_gets(EditLine *el, int *nread)
break;
cp = &el->el_line.buffer[idx];
}
+ if (*cp == 4) /* ought to be stty eof */
+ break;
cp++;
- if (cp[-1] == '\r' || cp[-1] == '\n')
+ crlf = cp[-1] == '\r' || cp[-1] == '\n';
+ if (el->el_flags & UNBUFFERED)
+ break;
+ if (crlf)
break;
}
@@ -428,6 +474,7 @@ el_gets(EditLine *el, int *nread)
*nread = el->el_line.cursor - el->el_line.buffer;
return (el->el_line.buffer);
}
+
for (num = OKCMD; num == OKCMD;) { /* while still editing this
* line */
#ifdef DEBUG_EDIT
@@ -441,7 +488,7 @@ el_gets(EditLine *el, int *nread)
#endif /* DEBUG_READ */
break;
}
- if ((int) cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
+ if ((uint)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
#ifdef DEBUG_EDIT
(void) fprintf(el->el_errfile,
"ERROR: illegal command from key 0%o\r\n", ch);
@@ -463,7 +510,24 @@ el_gets(EditLine *el, int *nread)
"Error command = %d\n", cmdnum);
}
#endif /* DEBUG_READ */
+ /* vi redo needs these way down the levels... */
+ el->el_state.thiscmd = cmdnum;
+ el->el_state.thisch = ch;
+ if (el->el_map.type == MAP_VI &&
+ el->el_map.current == el->el_map.key &&
+ el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) {
+ if (cmdnum == VI_DELETE_PREV_CHAR &&
+ el->el_chared.c_redo.pos != el->el_chared.c_redo.buf
+ && isprint((unsigned char)el->el_chared.c_redo.pos[-1]))
+ el->el_chared.c_redo.pos--;
+ else
+ *el->el_chared.c_redo.pos++ = ch;
+ }
retval = (*el->el_map.func[cmdnum]) (el, ch);
+#ifdef DEBUG_READ
+ (void) fprintf(el->el_errfile,
+ "Returned state %d\n", retval );
+#endif /* DEBUG_READ */
/* save the last command here */
el->el_state.lastcmd = cmdnum;
@@ -471,8 +535,6 @@ el_gets(EditLine *el, int *nread)
/* use any return value */
switch (retval) {
case CC_CURSOR:
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
re_refresh_cursor(el);
break;
@@ -482,29 +544,29 @@ el_gets(EditLine *el, int *nread)
/* FALLTHROUGH */
case CC_REFRESH:
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
re_refresh(el);
break;
case CC_REFRESH_BEEP:
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
re_refresh(el);
term_beep(el);
break;
case CC_NORM: /* normal char */
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
break;
case CC_ARGHACK: /* Suggested by Rich Salz */
/* <rsalz@pineapple.bbn.com> */
- break; /* keep going... */
+ continue; /* keep going... */
case CC_EOF: /* end of file typed */
- num = 0;
+ if ((el->el_flags & UNBUFFERED) == 0)
+ num = 0;
+ else if (num == -1) {
+ *el->el_line.lastchar++ = CONTROL('d');
+ el->el_line.cursor = el->el_line.lastchar;
+ num = 1;
+ }
break;
case CC_NEWLINE: /* normal end of line */
@@ -520,8 +582,6 @@ el_gets(EditLine *el, int *nread)
re_clear_display(el); /* reset the display stuff */
ch_reset(el); /* reset the input pointers */
re_refresh(el); /* print the prompt again */
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
break;
case CC_ERROR:
@@ -530,20 +590,26 @@ el_gets(EditLine *el, int *nread)
(void) fprintf(el->el_errfile,
"*** editor ERROR ***\r\n\n");
#endif /* DEBUG_READ */
- el->el_state.argument = 1;
- el->el_state.doingarg = 0;
term_beep(el);
term__flush();
break;
}
+ el->el_state.argument = 1;
+ el->el_state.doingarg = 0;
+ el->el_chared.c_vcmd.action = NOP;
+ if (el->el_flags & UNBUFFERED)
+ break;
}
- /* make sure the tty is set up correctly */
- (void) tty_cookedmode(el);
term__flush(); /* flush any buffered output */
- if (el->el_flags & HANDLE_SIGNALS)
- sig_clr(el);
- if (nread)
- *nread = num;
+ /* make sure the tty is set up correctly */
+ if ((el->el_flags & UNBUFFERED) == 0) {
+ read_finish(el);
+ if (nread)
+ *nread = num;
+ } else {
+ if (nread)
+ *nread = el->el_line.lastchar - el->el_line.buffer;
+ }
return (num ? el->el_line.buffer : NULL);
}
diff --git a/net/tnftp/files/libedit/read.h b/net/tnftp/files/libedit/read.h
index 2d9a76ade36..dc4bcff5274 100644
--- a/net/tnftp/files/libedit/read.h
+++ b/net/tnftp/files/libedit/read.h
@@ -1,4 +1,5 @@
-/* $NetBSD: read.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: read.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -49,6 +50,8 @@ typedef struct el_read_t {
} el_read_t;
protected int read_init(EditLine *);
+protected void read_prepare(EditLine *);
+protected void read_finish(EditLine *);
protected int el_read_setfn(EditLine *, el_rfunc_t);
protected el_rfunc_t el_read_getfn(EditLine *);
diff --git a/net/tnftp/files/libedit/readline.c b/net/tnftp/files/libedit/readline.c
new file mode 100644
index 00000000000..3cb57b5ee1e
--- /dev/null
+++ b/net/tnftp/files/libedit/readline.c
@@ -0,0 +1,2143 @@
+/* NetBSD: readline.c,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: readline.c,v 1.47 2004/09/08 18:15:57 christos Exp */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jaromir Dolecek.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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)
+__RCSID("NetBSD: readline.c,v 1.2 2005/05/11 01:17:39 lukem Exp");
+#endif /* not lint && not SCCSID */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <pwd.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
+#include "np/vis.h"
+#endif
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#include "el.h"
+#include "fcns.h" /* for EL_NUM_FCNS */
+#include "histedit.h"
+#include "readline/readline.h"
+
+/* for rl_complete() */
+#define TAB '\r'
+
+/* see comment at the #ifdef for sense of this */
+/* #define GDB_411_HACK */
+
+/* readline compatibility stuff - look at readline sources/documentation */
+/* to see what these variables mean */
+const char *rl_library_version = "EditLine wrapper";
+static char empty[] = { '\0' };
+static char expand_chars[] = { ' ', '\t', '\n', '=', '(', '\0' };
+static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
+ '>', '<', '=', ';', '|', '&', '{', '(', '\0' };
+char *rl_readline_name = empty;
+FILE *rl_instream = NULL;
+FILE *rl_outstream = NULL;
+int rl_point = 0;
+int rl_end = 0;
+char *rl_line_buffer = NULL;
+VFunction *rl_linefunc = NULL;
+int rl_done = 0;
+VFunction *rl_event_hook = NULL;
+
+int history_base = 1; /* probably never subject to change */
+int history_length = 0;
+int max_input_history = 0;
+char history_expansion_char = '!';
+char history_subst_char = '^';
+char *history_no_expand_chars = expand_chars;
+Function *history_inhibit_expansion_function = NULL;
+char *history_arg_extract(int start, int end, const char *str);
+
+int rl_inhibit_completion = 0;
+int rl_attempted_completion_over = 0;
+char *rl_basic_word_break_characters = break_chars;
+char *rl_completer_word_break_characters = NULL;
+char *rl_completer_quote_characters = NULL;
+Function *rl_completion_entry_function = NULL;
+CPPFunction *rl_attempted_completion_function = NULL;
+Function *rl_pre_input_hook = NULL;
+Function *rl_startup1_hook = NULL;
+Function *rl_getc_function = NULL;
+char *rl_terminal_name = NULL;
+int rl_already_prompted = 0;
+int rl_filename_completion_desired = 0;
+int rl_ignore_completion_duplicates = 0;
+int rl_catch_signals = 1;
+VFunction *rl_redisplay_function = NULL;
+Function *rl_startup_hook = NULL;
+VFunction *rl_completion_display_matches_hook = NULL;
+VFunction *rl_prep_term_function = NULL;
+VFunction *rl_deprep_term_function = NULL;
+
+/*
+ * The current prompt string.
+ */
+char *rl_prompt = NULL;
+/*
+ * This is set to character indicating type of completion being done by
+ * rl_complete_internal(); this is available for application completion
+ * functions.
+ */
+int rl_completion_type = 0;
+
+/*
+ * If more than this number of items results from query for possible
+ * completions, we ask user if they are sure to really display the list.
+ */
+int rl_completion_query_items = 100;
+
+/*
+ * List of characters which are word break characters, but should be left
+ * in the parsed text when it is passed to the completion function.
+ * Shell uses this to help determine what kind of completing to do.
+ */
+char *rl_special_prefixes = (char *)NULL;
+
+/*
+ * This is the character appended to the completed words if at the end of
+ * the line. Default is ' ' (a space).
+ */
+int rl_completion_append_character = ' ';
+
+/* stuff below is used internally by libedit for readline emulation */
+
+/* if not zero, non-unique completions always show list of possible matches */
+static int _rl_complete_show_all = 0;
+
+static History *h = NULL;
+static EditLine *e = NULL;
+static Function *map[256];
+static int el_rl_complete_cmdnum = 0;
+
+/* internal functions */
+static unsigned char _el_rl_complete(EditLine *, int);
+static unsigned char _el_rl_tstp(EditLine *, int);
+static char *_get_prompt(EditLine *);
+static HIST_ENTRY *_move_history(int);
+static int _history_expand_command(const char *, size_t, size_t,
+ char **);
+static char *_rl_compat_sub(const char *, const char *,
+ const char *, int);
+static int rl_complete_internal(int);
+static int _rl_qsort_string_compare(const void *, const void *);
+static int _rl_event_read_char(EditLine *, char *);
+
+
+/* ARGSUSED */
+static char *
+_get_prompt(EditLine *el __attribute__((__unused__)))
+{
+ rl_already_prompted = 1;
+ return (rl_prompt);
+}
+
+
+/*
+ * generic function for moving around history
+ */
+static HIST_ENTRY *
+_move_history(int op)
+{
+ HistEvent ev;
+ static HIST_ENTRY rl_he;
+
+ if (history(h, &ev, op) != 0)
+ return (HIST_ENTRY *) NULL;
+
+ rl_he.line = ev.str;
+ rl_he.data = NULL;
+
+ return (&rl_he);
+}
+
+
+/*
+ * READLINE compatibility stuff
+ */
+
+/*
+ * initialize rl compat stuff
+ */
+int
+rl_initialize(void)
+{
+ HistEvent ev;
+ const LineInfo *li;
+ int i;
+ int editmode = 1;
+ struct termios t;
+
+ if (e != NULL)
+ el_end(e);
+ if (h != NULL)
+ history_end(h);
+
+ if (!rl_instream)
+ rl_instream = stdin;
+ if (!rl_outstream)
+ rl_outstream = stdout;
+
+ /*
+ * See if we don't really want to run the editor
+ */
+ if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0)
+ editmode = 0;
+
+ e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr);
+
+ if (!editmode)
+ el_set(e, EL_EDITMODE, 0);
+
+ h = history_init();
+ if (!e || !h)
+ return (-1);
+
+ history(h, &ev, H_SETSIZE, INT_MAX); /* unlimited */
+ history_length = 0;
+ max_input_history = INT_MAX;
+ el_set(e, EL_HIST, history, h);
+
+ /* for proper prompt printing in readline() */
+ rl_prompt = strdup("");
+ if (rl_prompt == NULL) {
+ history_end(h);
+ el_end(e);
+ return -1;
+ }
+ el_set(e, EL_PROMPT, _get_prompt);
+ el_set(e, EL_SIGNAL, rl_catch_signals);
+
+ /* set default mode to "emacs"-style and read setting afterwards */
+ /* so this can be overriden */
+ el_set(e, EL_EDITOR, "emacs");
+ if (rl_terminal_name != NULL)
+ el_set(e, EL_TERMINAL, rl_terminal_name);
+ else
+ el_get(e, EL_TERMINAL, &rl_terminal_name);
+
+ /*
+ * Word completion - this has to go AFTER rebinding keys
+ * to emacs-style.
+ */
+ el_set(e, EL_ADDFN, "rl_complete",
+ "ReadLine compatible completion function",
+ _el_rl_complete);
+ el_set(e, EL_BIND, "^I", "rl_complete", NULL);
+
+ /*
+ * Send TSTP when ^Z is pressed.
+ */
+ el_set(e, EL_ADDFN, "rl_tstp",
+ "ReadLine compatible suspend function",
+ _el_rl_tstp);
+ el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
+
+ /*
+ * Find out where the rl_complete function was added; this is
+ * used later to detect that lastcmd was also rl_complete.
+ */
+ for(i=EL_NUM_FCNS; i < e->el_map.nfunc; i++) {
+ if (e->el_map.func[i] == _el_rl_complete) {
+ el_rl_complete_cmdnum = i;
+ break;
+ }
+ }
+
+ /* read settings from configuration file */
+ el_source(e, NULL);
+
+ /*
+ * Unfortunately, some applications really do use rl_point
+ * and rl_line_buffer directly.
+ */
+ li = el_line(e);
+ /* a cheesy way to get rid of const cast. */
+ rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
+ rl_point = rl_end = 0;
+
+ if (rl_startup_hook)
+ (*rl_startup_hook)(NULL, 0);
+
+ return (0);
+}
+
+
+/*
+ * read one line from input stream and return it, chomping
+ * trailing newline (if there is any)
+ */
+char *
+readline(const char *prompt)
+{
+ HistEvent ev;
+ int count;
+ const char *ret;
+ char *buf;
+ static int used_event_hook;
+
+ if (e == NULL || h == NULL)
+ rl_initialize();
+
+ rl_done = 0;
+
+ /* update prompt accordingly to what has been passed */
+ if (!prompt)
+ prompt = "";
+ if (strcmp(rl_prompt, prompt) != 0) {
+ free(rl_prompt);
+ rl_prompt = strdup(prompt);
+ if (rl_prompt == NULL)
+ return NULL;
+ }
+
+ if (rl_pre_input_hook)
+ (*rl_pre_input_hook)(NULL, 0);
+
+ if (rl_event_hook && !(e->el_flags&NO_TTY)) {
+ el_set(e, EL_GETCFN, _rl_event_read_char);
+ used_event_hook = 1;
+ }
+
+ if (!rl_event_hook && used_event_hook) {
+ el_set(e, EL_GETCFN, EL_BUILTIN_GETCFN);
+ used_event_hook = 0;
+ }
+
+ rl_already_prompted = 0;
+
+ /* get one line from input stream */
+ ret = el_gets(e, &count);
+
+ if (ret && count > 0) {
+ int lastidx;
+
+ buf = strdup(ret);
+ if (buf == NULL)
+ return NULL;
+ lastidx = count - 1;
+ if (buf[lastidx] == '\n')
+ buf[lastidx] = '\0';
+ } else
+ buf = NULL;
+
+ history(h, &ev, H_GETSIZE);
+ history_length = ev.num;
+
+ return buf;
+}
+
+/*
+ * history functions
+ */
+
+/*
+ * is normally called before application starts to use
+ * history expansion functions
+ */
+void
+using_history(void)
+{
+ if (h == NULL || e == NULL)
+ rl_initialize();
+}
+
+
+/*
+ * substitute ``what'' with ``with'', returning resulting string; if
+ * globally == 1, substitutes all occurrences of what, otherwise only the
+ * first one
+ */
+static char *
+_rl_compat_sub(const char *str, const char *what, const char *with,
+ int globally)
+{
+ const char *s;
+ char *r, *result;
+ size_t len, with_len, what_len;
+
+ len = strlen(str);
+ with_len = strlen(with);
+ what_len = strlen(what);
+
+ /* calculate length we need for result */
+ s = str;
+ while (*s) {
+ if (*s == *what && !strncmp(s, what, what_len)) {
+ len += with_len - what_len;
+ if (!globally)
+ break;
+ s += what_len;
+ } else
+ s++;
+ }
+ r = result = malloc(len + 1);
+ if (result == NULL)
+ return NULL;
+ s = str;
+ while (*s) {
+ if (*s == *what && !strncmp(s, what, what_len)) {
+ (void)strncpy(r, with, with_len);
+ r += with_len;
+ s += what_len;
+ if (!globally) {
+ (void)strcpy(r, s);
+ return(result);
+ }
+ } else
+ *r++ = *s++;
+ }
+ *r = 0;
+ return(result);
+}
+
+static char *last_search_pat; /* last !?pat[?] search pattern */
+static char *last_search_match; /* last !?pat[?] that matched */
+
+const char *
+get_history_event(const char *cmd, int *cindex, int qchar)
+{
+ int idx, sign, sub, num, begin, ret;
+ size_t len;
+ char *pat;
+ const char *rptr;
+ HistEvent ev;
+
+ idx = *cindex;
+ if (cmd[idx++] != history_expansion_char)
+ return(NULL);
+
+ /* find out which event to take */
+ if (cmd[idx] == history_expansion_char || cmd[idx] == 0) {
+ if (history(h, &ev, H_FIRST) != 0)
+ return(NULL);
+ *cindex = cmd[idx]? (idx + 1):idx;
+ return(ev.str);
+ }
+ sign = 0;
+ if (cmd[idx] == '-') {
+ sign = 1;
+ idx++;
+ }
+
+ if ('0' <= cmd[idx] && cmd[idx] <= '9') {
+ HIST_ENTRY *rl_he;
+
+ num = 0;
+ while (cmd[idx] && '0' <= cmd[idx] && cmd[idx] <= '9') {
+ num = num * 10 + cmd[idx] - '0';
+ idx++;
+ }
+ if (sign)
+ num = history_length - num + 1;
+
+ if (!(rl_he = history_get(num)))
+ return(NULL);
+
+ *cindex = idx;
+ return(rl_he->line);
+ }
+ sub = 0;
+ if (cmd[idx] == '?') {
+ sub = 1;
+ idx++;
+ }
+ begin = idx;
+ while (cmd[idx]) {
+ if (cmd[idx] == '\n')
+ break;
+ if (sub && cmd[idx] == '?')
+ break;
+ if (!sub && (cmd[idx] == ':' || cmd[idx] == ' '
+ || cmd[idx] == '\t' || cmd[idx] == qchar))
+ break;
+ idx++;
+ }
+ len = idx - begin;
+ if (sub && cmd[idx] == '?')
+ idx++;
+ if (sub && len == 0 && last_search_pat && *last_search_pat)
+ pat = last_search_pat;
+ else if (len == 0)
+ return(NULL);
+ else {
+ if ((pat = malloc(len + 1)) == NULL)
+ return NULL;
+ (void)strncpy(pat, cmd + begin, len);
+ pat[len] = '\0';
+ }
+
+ if (history(h, &ev, H_CURR) != 0) {
+ if (pat != last_search_pat)
+ free(pat);
+ return (NULL);
+ }
+ num = ev.num;
+
+ if (sub) {
+ if (pat != last_search_pat) {
+ if (last_search_pat)
+ free(last_search_pat);
+ last_search_pat = pat;
+ }
+ ret = history_search(pat, -1);
+ } else
+ ret = history_search_prefix(pat, -1);
+
+ if (ret == -1) {
+ /* restore to end of list on failed search */
+ history(h, &ev, H_FIRST);
+ (void)fprintf(rl_outstream, "%s: Event not found\n", pat);
+ if (pat != last_search_pat)
+ free(pat);
+ return(NULL);
+ }
+
+ if (sub && len) {
+ if (last_search_match && last_search_match != pat)
+ free(last_search_match);
+ last_search_match = pat;
+ }
+
+ if (pat != last_search_pat)
+ free(pat);
+
+ if (history(h, &ev, H_CURR) != 0)
+ return(NULL);
+ *cindex = idx;
+ rptr = ev.str;
+
+ /* roll back to original position */
+ (void)history(h, &ev, H_SET, num);
+
+ return rptr;
+}
+
+/*
+ * the real function doing history expansion - takes as argument command
+ * to do and data upon which the command should be executed
+ * does expansion the way I've understood readline documentation
+ *
+ * returns 0 if data was not modified, 1 if it was and 2 if the string
+ * should be only printed and not executed; in case of error,
+ * returns -1 and *result points to NULL
+ * it's callers responsibility to free() string returned in *result
+ */
+static int
+_history_expand_command(const char *command, size_t offs, size_t cmdlen,
+ char **result)
+{
+ char *tmp, *search = NULL, *aptr;
+ const char *ptr, *cmd;
+ static char *from = NULL, *to = NULL;
+ int start, end, idx, has_mods = 0;
+ int p_on = 0, g_on = 0;
+
+ *result = NULL;
+ aptr = NULL;
+ ptr = NULL;
+
+ /* First get event specifier */
+ idx = 0;
+
+ if (strchr(":^*$", command[offs + 1])) {
+ char str[4];
+ /*
+ * "!:" is shorthand for "!!:".
+ * "!^", "!*" and "!$" are shorthand for
+ * "!!:^", "!!:*" and "!!:$" respectively.
+ */
+ str[0] = str[1] = '!';
+ str[2] = '0';
+ ptr = get_history_event(str, &idx, 0);
+ idx = (command[offs + 1] == ':')? 1:0;
+ has_mods = 1;
+ } else {
+ if (command[offs + 1] == '#') {
+ /* use command so far */
+ if ((aptr = malloc(offs + 1)) == NULL)
+ return -1;
+ (void)strncpy(aptr, command, offs);
+ aptr[offs] = '\0';
+ idx = 1;
+ } else {
+ int qchar;
+
+ qchar = (offs > 0 && command[offs - 1] == '"')? '"':0;
+ ptr = get_history_event(command + offs, &idx, qchar);
+ }
+ has_mods = command[offs + idx] == ':';
+ }
+
+ if (ptr == NULL && aptr == NULL)
+ return(-1);
+
+ if (!has_mods) {
+ *result = strdup(aptr? aptr : ptr);
+ if (aptr)
+ free(aptr);
+ return(1);
+ }
+
+ cmd = command + offs + idx + 1;
+
+ /* Now parse any word designators */
+
+ if (*cmd == '%') /* last word matched by ?pat? */
+ tmp = strdup(last_search_match? last_search_match:"");
+ else if (strchr("^*$-0123456789", *cmd)) {
+ start = end = -1;
+ if (*cmd == '^')
+ start = end = 1, cmd++;
+ else if (*cmd == '$')
+ start = -1, cmd++;
+ else if (*cmd == '*')
+ start = 1, cmd++;
+ else if (*cmd == '-' || isdigit((unsigned char) *cmd)) {
+ start = 0;
+ while (*cmd && '0' <= *cmd && *cmd <= '9')
+ start = start * 10 + *cmd++ - '0';
+
+ if (*cmd == '-') {
+ if (isdigit((unsigned char) cmd[1])) {
+ cmd++;
+ end = 0;
+ while (*cmd && '0' <= *cmd && *cmd <= '9')
+ end = end * 10 + *cmd++ - '0';
+ } else if (cmd[1] == '$') {
+ cmd += 2;
+ end = -1;
+ } else {
+ cmd++;
+ end = -2;
+ }
+ } else if (*cmd == '*')
+ end = -1, cmd++;
+ else
+ end = start;
+ }
+ tmp = history_arg_extract(start, end, aptr? aptr:ptr);
+ if (tmp == NULL) {
+ (void)fprintf(rl_outstream, "%s: Bad word specifier",
+ command + offs + idx);
+ if (aptr)
+ free(aptr);
+ return(-1);
+ }
+ } else
+ tmp = strdup(aptr? aptr:ptr);
+
+ if (aptr)
+ free(aptr);
+
+ if (*cmd == 0 || (cmd - (command + offs) >= cmdlen)) {
+ *result = tmp;
+ return(1);
+ }
+
+ for (; *cmd; cmd++) {
+ if (*cmd == ':')
+ continue;
+ else if (*cmd == 'h') { /* remove trailing path */
+ if ((aptr = strrchr(tmp, '/')) != NULL)
+ *aptr = 0;
+ } else if (*cmd == 't') { /* remove leading path */
+ if ((aptr = strrchr(tmp, '/')) != NULL) {
+ aptr = strdup(aptr + 1);
+ free(tmp);
+ tmp = aptr;
+ }
+ } else if (*cmd == 'r') { /* remove trailing suffix */
+ if ((aptr = strrchr(tmp, '.')) != NULL)
+ *aptr = 0;
+ } else if (*cmd == 'e') { /* remove all but suffix */
+ if ((aptr = strrchr(tmp, '.')) != NULL) {
+ aptr = strdup(aptr);
+ free(tmp);
+ tmp = aptr;
+ }
+ } else if (*cmd == 'p') /* print only */
+ p_on = 1;
+ else if (*cmd == 'g')
+ g_on = 2;
+ else if (*cmd == 's' || *cmd == '&') {
+ char *what, *with, delim;
+ size_t len, from_len;
+ size_t size;
+
+ if (*cmd == '&' && (from == NULL || to == NULL))
+ continue;
+ else if (*cmd == 's') {
+ delim = *(++cmd), cmd++;
+ size = 16;
+ what = realloc(from, size);
+ if (what == NULL) {
+ free(from);
+ return 0;
+ }
+ len = 0;
+ for (; *cmd && *cmd != delim; cmd++) {
+ if (*cmd == '\\' && cmd[1] == delim)
+ cmd++;
+ if (len >= size) {
+ char *nwhat;
+ nwhat = realloc(what,
+ (size <<= 1));
+ if (nwhat == NULL) {
+ free(what);
+ return 0;
+ }
+ what = nwhat;
+ }
+ what[len++] = *cmd;
+ }
+ what[len] = '\0';
+ from = what;
+ if (*what == '\0') {
+ free(what);
+ if (search) {
+ from = strdup(search);
+ if (from == NULL)
+ return 0;
+ } else {
+ from = NULL;
+ return (-1);
+ }
+ }
+ cmd++; /* shift after delim */
+ if (!*cmd)
+ continue;
+
+ size = 16;
+ with = realloc(to, size);
+ if (with == NULL) {
+ free(to);
+ return -1;
+ }
+ len = 0;
+ from_len = strlen(from);
+ for (; *cmd && *cmd != delim; cmd++) {
+ if (len + from_len + 1 >= size) {
+ char *nwith;
+ size += from_len + 1;
+ nwith = realloc(with, size);
+ if (nwith == NULL) {
+ free(with);
+ return -1;
+ }
+ with = nwith;
+ }
+ if (*cmd == '&') {
+ /* safe */
+ (void)strcpy(&with[len], from);
+ len += from_len;
+ continue;
+ }
+ if (*cmd == '\\'
+ && (*(cmd + 1) == delim
+ || *(cmd + 1) == '&'))
+ cmd++;
+ with[len++] = *cmd;
+ }
+ with[len] = '\0';
+ to = with;
+ }
+
+ aptr = _rl_compat_sub(tmp, from, to, g_on);
+ if (aptr) {
+ free(tmp);
+ tmp = aptr;
+ }
+ g_on = 0;
+ }
+ }
+ *result = tmp;
+ return (p_on? 2:1);
+}
+
+
+/*
+ * csh-style history expansion
+ */
+int
+history_expand(char *str, char **output)
+{
+ int ret = 0;
+ size_t idx, i, size;
+ char *tmp, *result;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ if (history_expansion_char == 0) {
+ *output = strdup(str);
+ return(0);
+ }
+
+ *output = NULL;
+ if (str[0] == history_subst_char) {
+ /* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */
+ *output = malloc(strlen(str) + 4 + 1);
+ if (*output == NULL)
+ return 0;
+ (*output)[0] = (*output)[1] = history_expansion_char;
+ (*output)[2] = ':';
+ (*output)[3] = 's';
+ (void)strcpy((*output) + 4, str);
+ str = *output;
+ } else {
+ *output = strdup(str);
+ if (*output == NULL)
+ return 0;
+ }
+
+#define ADD_STRING(what, len) \
+ { \
+ if (idx + len + 1 > size) { \
+ char *nresult = realloc(result, (size += len + 1));\
+ if (nresult == NULL) { \
+ free(*output); \
+ return 0; \
+ } \
+ result = nresult; \
+ } \
+ (void)strncpy(&result[idx], what, len); \
+ idx += len; \
+ result[idx] = '\0'; \
+ }
+
+ result = NULL;
+ size = idx = 0;
+ for (i = 0; str[i];) {
+ int qchar, loop_again;
+ size_t len, start, j;
+
+ qchar = 0;
+ loop_again = 1;
+ start = j = i;
+loop:
+ for (; str[j]; j++) {
+ if (str[j] == '\\' &&
+ str[j + 1] == history_expansion_char) {
+ (void)strcpy(&str[j], &str[j + 1]);
+ continue;
+ }
+ if (!loop_again) {
+ if (isspace((unsigned char) str[j])
+ || str[j] == qchar)
+ break;
+ }
+ if (str[j] == history_expansion_char
+ && !strchr(history_no_expand_chars, str[j + 1])
+ && (!history_inhibit_expansion_function ||
+ (*history_inhibit_expansion_function)(str,
+ (int)j) == 0))
+ break;
+ }
+
+ if (str[j] && loop_again) {
+ i = j;
+ qchar = (j > 0 && str[j - 1] == '"' )? '"':0;
+ j++;
+ if (str[j] == history_expansion_char)
+ j++;
+ loop_again = 0;
+ goto loop;
+ }
+ len = i - start;
+ tmp = &str[start];
+ ADD_STRING(tmp, len);
+
+ if (str[i] == '\0' || str[i] != history_expansion_char) {
+ len = j - i;
+ tmp = &str[i];
+ ADD_STRING(tmp, len);
+ if (start == 0)
+ ret = 0;
+ else
+ ret = 1;
+ break;
+ }
+ ret = _history_expand_command (str, i, (j - i), &tmp);
+ if (ret > 0 && tmp) {
+ len = strlen(tmp);
+ ADD_STRING(tmp, len);
+ free(tmp);
+ }
+ i = j;
+ }
+
+ /* ret is 2 for "print only" option */
+ if (ret == 2) {
+ add_history(result);
+#ifdef GDB_411_HACK
+ /* gdb 4.11 has been shipped with readline, where */
+ /* history_expand() returned -1 when the line */
+ /* should not be executed; in readline 2.1+ */
+ /* it should return 2 in such a case */
+ ret = -1;
+#endif
+ }
+ free(*output);
+ *output = result;
+
+ return (ret);
+}
+
+/*
+* Return a string consisting of arguments of "str" from "start" to "end".
+*/
+char *
+history_arg_extract(int start, int end, const char *str)
+{
+ size_t i, len, max;
+ char **arr, *result;
+
+ arr = history_tokenize(str);
+ if (!arr)
+ return(NULL);
+ if (arr && *arr == NULL) {
+ free(arr);
+ return(NULL);
+ }
+
+ for (max = 0; arr[max]; max++)
+ continue;
+ max--;
+
+ if (start == '$')
+ start = max;
+ if (end == '$')
+ end = max;
+ if (end < 0)
+ end = max + end + 1;
+ if (start < 0)
+ start = end;
+
+ if (start < 0 || end < 0 || start > max || end > max || start > end)
+ return(NULL);
+
+ for (i = start, len = 0; i <= end; i++)
+ len += strlen(arr[i]) + 1;
+ len++;
+ result = malloc(len);
+ if (result == NULL)
+ return NULL;
+
+ for (i = start, len = 0; i <= end; i++) {
+ (void)strcpy(result + len, arr[i]);
+ len += strlen(arr[i]);
+ if (i < end)
+ result[len++] = ' ';
+ }
+ result[len] = 0;
+
+ for (i = 0; arr[i]; i++)
+ free(arr[i]);
+ free(arr);
+
+ return(result);
+}
+
+/*
+ * Parse the string into individual tokens,
+ * similar to how shell would do it.
+ */
+char **
+history_tokenize(const char *str)
+{
+ int size = 1, idx = 0, i, start;
+ size_t len;
+ char **result = NULL, *temp, delim = '\0';
+
+ for (i = 0; str[i];) {
+ while (isspace((unsigned char) str[i]))
+ i++;
+ start = i;
+ for (; str[i];) {
+ if (str[i] == '\\') {
+ if (str[i+1] != '\0')
+ i++;
+ } else if (str[i] == delim)
+ delim = '\0';
+ else if (!delim &&
+ (isspace((unsigned char) str[i]) ||
+ strchr("()<>;&|$", str[i])))
+ break;
+ else if (!delim && strchr("'`\"", str[i]))
+ delim = str[i];
+ if (str[i])
+ i++;
+ }
+
+ if (idx + 2 >= size) {
+ char **nresult;
+ size <<= 1;
+ nresult = realloc(result, size * sizeof(char *));
+ if (nresult == NULL) {
+ free(result);
+ return NULL;
+ }
+ result = nresult;
+ }
+ len = i - start;
+ temp = malloc(len + 1);
+ if (temp == NULL) {
+ for (i = 0; i < idx; i++)
+ free(result[i]);
+ free(result);
+ return NULL;
+ }
+ (void)strncpy(temp, &str[start], len);
+ temp[len] = '\0';
+ result[idx++] = temp;
+ result[idx] = NULL;
+ if (str[i])
+ i++;
+ }
+ return (result);
+}
+
+
+/*
+ * limit size of history record to ``max'' events
+ */
+void
+stifle_history(int max)
+{
+ HistEvent ev;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ if (history(h, &ev, H_SETSIZE, max) == 0)
+ max_input_history = max;
+}
+
+
+/*
+ * "unlimit" size of history - set the limit to maximum allowed int value
+ */
+int
+unstifle_history(void)
+{
+ HistEvent ev;
+ int omax;
+
+ history(h, &ev, H_SETSIZE, INT_MAX);
+ omax = max_input_history;
+ max_input_history = INT_MAX;
+ return (omax); /* some value _must_ be returned */
+}
+
+
+int
+history_is_stifled(void)
+{
+
+ /* cannot return true answer */
+ return (max_input_history != INT_MAX);
+}
+
+
+/*
+ * read history from a file given
+ */
+int
+read_history(const char *filename)
+{
+ HistEvent ev;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+ return (history(h, &ev, H_LOAD, filename));
+}
+
+
+/*
+ * write history to a file given
+ */
+int
+write_history(const char *filename)
+{
+ HistEvent ev;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+ return (history(h, &ev, H_SAVE, filename));
+}
+
+
+/*
+ * returns history ``num''th event
+ *
+ * returned pointer points to static variable
+ */
+HIST_ENTRY *
+history_get(int num)
+{
+ static HIST_ENTRY she;
+ HistEvent ev;
+ int curr_num;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ /* save current position */
+ if (history(h, &ev, H_CURR) != 0)
+ return (NULL);
+ curr_num = ev.num;
+
+ /* start from most recent */
+ if (history(h, &ev, H_FIRST) != 0)
+ return (NULL); /* error */
+
+ /* look backwards for event matching specified offset */
+ if (history(h, &ev, H_NEXT_EVENT, num))
+ return (NULL);
+
+ she.line = ev.str;
+ she.data = NULL;
+
+ /* restore pointer to where it was */
+ (void)history(h, &ev, H_SET, curr_num);
+
+ return (&she);
+}
+
+
+/*
+ * add the line to history table
+ */
+int
+add_history(const char *line)
+{
+ HistEvent ev;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ (void)history(h, &ev, H_ENTER, line);
+ if (history(h, &ev, H_GETSIZE) == 0)
+ history_length = ev.num;
+
+ return (!(history_length > 0)); /* return 0 if all is okay */
+}
+
+
+/*
+ * clear the history list - delete all entries
+ */
+void
+clear_history(void)
+{
+ HistEvent ev;
+
+ history(h, &ev, H_CLEAR);
+}
+
+
+/*
+ * returns offset of the current history event
+ */
+int
+where_history(void)
+{
+ HistEvent ev;
+ int curr_num, off;
+
+ if (history(h, &ev, H_CURR) != 0)
+ return (0);
+ curr_num = ev.num;
+
+ history(h, &ev, H_FIRST);
+ off = 1;
+ while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0)
+ off++;
+
+ return (off);
+}
+
+
+/*
+ * returns current history event or NULL if there is no such event
+ */
+HIST_ENTRY *
+current_history(void)
+{
+
+ return (_move_history(H_CURR));
+}
+
+
+/*
+ * returns total number of bytes history events' data are using
+ */
+int
+history_total_bytes(void)
+{
+ HistEvent ev;
+ int curr_num, size;
+
+ if (history(h, &ev, H_CURR) != 0)
+ return (-1);
+ curr_num = ev.num;
+
+ history(h, &ev, H_FIRST);
+ size = 0;
+ do
+ size += strlen(ev.str);
+ while (history(h, &ev, H_NEXT) == 0);
+
+ /* get to the same position as before */
+ history(h, &ev, H_PREV_EVENT, curr_num);
+
+ return (size);
+}
+
+
+/*
+ * sets the position in the history list to ``pos''
+ */
+int
+history_set_pos(int pos)
+{
+ HistEvent ev;
+ int curr_num;
+
+ if (pos > history_length || pos < 0)
+ return (-1);
+
+ history(h, &ev, H_CURR);
+ curr_num = ev.num;
+
+ if (history(h, &ev, H_SET, pos)) {
+ history(h, &ev, H_SET, curr_num);
+ return(-1);
+ }
+ return (0);
+}
+
+
+/*
+ * returns previous event in history and shifts pointer accordingly
+ */
+HIST_ENTRY *
+previous_history(void)
+{
+
+ return (_move_history(H_PREV));
+}
+
+
+/*
+ * returns next event in history and shifts pointer accordingly
+ */
+HIST_ENTRY *
+next_history(void)
+{
+
+ return (_move_history(H_NEXT));
+}
+
+
+/*
+ * searches for first history event containing the str
+ */
+int
+history_search(const char *str, int direction)
+{
+ HistEvent ev;
+ const char *strp;
+ int curr_num;
+
+ if (history(h, &ev, H_CURR) != 0)
+ return (-1);
+ curr_num = ev.num;
+
+ for (;;) {
+ if ((strp = strstr(ev.str, str)) != NULL)
+ return (int) (strp - ev.str);
+ if (history(h, &ev, direction < 0 ? H_NEXT:H_PREV) != 0)
+ break;
+ }
+ history(h, &ev, H_SET, curr_num);
+ return (-1);
+}
+
+
+/*
+ * searches for first history event beginning with str
+ */
+int
+history_search_prefix(const char *str, int direction)
+{
+ HistEvent ev;
+
+ return (history(h, &ev, direction < 0? H_PREV_STR:H_NEXT_STR, str));
+}
+
+
+/*
+ * search for event in history containing str, starting at offset
+ * abs(pos); continue backward, if pos<0, forward otherwise
+ */
+/* ARGSUSED */
+int
+history_search_pos(const char *str,
+ int direction __attribute__((__unused__)), int pos)
+{
+ HistEvent ev;
+ int curr_num, off;
+
+ off = (pos > 0) ? pos : -pos;
+ pos = (pos > 0) ? 1 : -1;
+
+ if (history(h, &ev, H_CURR) != 0)
+ return (-1);
+ curr_num = ev.num;
+
+ if (history_set_pos(off) != 0 || history(h, &ev, H_CURR) != 0)
+ return (-1);
+
+
+ for (;;) {
+ if (strstr(ev.str, str))
+ return (off);
+ if (history(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0)
+ break;
+ }
+
+ /* set "current" pointer back to previous state */
+ history(h, &ev, (pos < 0) ? H_NEXT_EVENT : H_PREV_EVENT, curr_num);
+
+ return (-1);
+}
+
+
+/********************************/
+/* completion functions */
+
+/*
+ * does tilde expansion of strings of type ``~user/foo''
+ * if ``user'' isn't valid user name or ``txt'' doesn't start
+ * w/ '~', returns pointer to strdup()ed copy of ``txt''
+ *
+ * it's callers's responsibility to free() returned string
+ */
+char *
+tilde_expand(char *txt)
+{
+ struct passwd *pass;
+ char *temp;
+ size_t len = 0;
+
+ if (txt[0] != '~')
+ return (strdup(txt));
+
+ temp = strchr(txt + 1, '/');
+ if (temp == NULL) {
+ temp = strdup(txt + 1);
+ if (temp == NULL)
+ return NULL;
+ } else {
+ len = temp - txt + 1; /* text until string after slash */
+ temp = malloc(len);
+ if (temp == NULL)
+ return NULL;
+ (void)strncpy(temp, txt + 1, len - 2);
+ temp[len - 2] = '\0';
+ }
+ pass = getpwnam(temp);
+ free(temp); /* value no more needed */
+ if (pass == NULL)
+ return (strdup(txt));
+
+ /* update pointer txt to point at string immedially following */
+ /* first slash */
+ txt += len;
+
+ temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
+ if (temp == NULL)
+ return NULL;
+ (void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
+
+ return (temp);
+}
+
+
+/*
+ * return first found file name starting by the ``text'' or NULL if no
+ * such file can be found
+ * value of ``state'' is ignored
+ *
+ * it's caller's responsibility to free returned string
+ */
+char *
+filename_completion_function(const char *text, int state)
+{
+ static DIR *dir = NULL;
+ static char *filename = NULL, *dirname = NULL;
+ static size_t filename_len = 0;
+ struct dirent *entry;
+ char *temp;
+ size_t len;
+
+ if (state == 0 || dir == NULL) {
+ temp = strrchr(text, '/');
+ if (temp) {
+ char *nptr;
+ temp++;
+ nptr = realloc(filename, strlen(temp) + 1);
+ if (nptr == NULL) {
+ free(filename);
+ return NULL;
+ }
+ filename = nptr;
+ (void)strcpy(filename, temp);
+ len = temp - text; /* including last slash */
+ nptr = realloc(dirname, len + 1);
+ if (nptr == NULL) {
+ free(filename);
+ return NULL;
+ }
+ dirname = nptr;
+ (void)strncpy(dirname, text, len);
+ dirname[len] = '\0';
+ } else {
+ if (*text == 0)
+ filename = NULL;
+ else {
+ filename = strdup(text);
+ if (filename == NULL)
+ return NULL;
+ }
+ dirname = NULL;
+ }
+
+ /* support for ``~user'' syntax */
+ if (dirname && *dirname == '~') {
+ char *nptr;
+ temp = tilde_expand(dirname);
+ if (temp == NULL)
+ return NULL;
+ nptr = realloc(dirname, strlen(temp) + 1);
+ if (nptr == NULL) {
+ free(dirname);
+ return NULL;
+ }
+ dirname = nptr;
+ (void)strcpy(dirname, temp); /* safe */
+ free(temp); /* no longer needed */
+ }
+ /* will be used in cycle */
+ filename_len = filename ? strlen(filename) : 0;
+
+ if (dir != NULL) {
+ (void)closedir(dir);
+ dir = NULL;
+ }
+ dir = opendir(dirname ? dirname : ".");
+ if (!dir)
+ return (NULL); /* cannot open the directory */
+ }
+ /* find the match */
+ while ((entry = readdir(dir)) != NULL) {
+ /* skip . and .. */
+ if (entry->d_name[0] == '.' && (!entry->d_name[1]
+ || (entry->d_name[1] == '.' && !entry->d_name[2])))
+ continue;
+ if (filename_len == 0)
+ break;
+ /* otherwise, get first entry where first */
+ /* filename_len characters are equal */
+ if (entry->d_name[0] == filename[0]
+#if defined(__SVR4) || defined(__linux__)
+ && strlen(entry->d_name) >= filename_len
+#else
+ && entry->d_namlen >= filename_len
+#endif
+ && strncmp(entry->d_name, filename,
+ filename_len) == 0)
+ break;
+ }
+
+ if (entry) { /* match found */
+
+ struct stat stbuf;
+#if defined(__SVR4) || defined(__linux__)
+ len = strlen(entry->d_name) +
+#else
+ len = entry->d_namlen +
+#endif
+ ((dirname) ? strlen(dirname) : 0) + 1 + 1;
+ temp = malloc(len);
+ if (temp == NULL)
+ return NULL;
+ (void)sprintf(temp, "%s%s",
+ dirname ? dirname : "", entry->d_name); /* safe */
+
+ /* test, if it's directory */
+ if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
+ strcat(temp, "/"); /* safe */
+ } else {
+ (void)closedir(dir);
+ dir = NULL;
+ temp = NULL;
+ }
+
+ return (temp);
+}
+
+
+/*
+ * a completion generator for usernames; returns _first_ username
+ * which starts with supplied text
+ * text contains a partial username preceded by random character
+ * (usually '~'); state is ignored
+ * it's callers responsibility to free returned value
+ */
+char *
+username_completion_function(const char *text, int state)
+{
+ struct passwd *pwd;
+
+ if (text[0] == '\0')
+ return (NULL);
+
+ if (*text == '~')
+ text++;
+
+ if (state == 0)
+ setpwent();
+
+ while ((pwd = getpwent()) && text[0] == pwd->pw_name[0]
+ && strcmp(text, pwd->pw_name) == 0);
+
+ if (pwd == NULL) {
+ endpwent();
+ return (NULL);
+ }
+ return (strdup(pwd->pw_name));
+}
+
+
+/*
+ * el-compatible wrapper around rl_complete; needed for key binding
+ */
+/* ARGSUSED */
+static unsigned char
+_el_rl_complete(EditLine *el __attribute__((__unused__)), int ch)
+{
+ return (unsigned char) rl_complete(0, ch);
+}
+
+/*
+ * el-compatible wrapper to send TSTP on ^Z
+ */
+/* ARGSUSED */
+static unsigned char
+_el_rl_tstp(EditLine *el __attribute__((__unused__)), int ch __attribute__((__unused__)))
+{
+ (void)kill(0, SIGTSTP);
+ return CC_NORM;
+}
+
+/*
+ * returns list of completions for text given
+ */
+char **
+completion_matches(const char *text, CPFunction *genfunc)
+{
+ char **match_list = NULL, *retstr, *prevstr;
+ size_t match_list_len, max_equal, which, i;
+ size_t matches;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ matches = 0;
+ match_list_len = 1;
+ while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
+ /* allow for list terminator here */
+ if (matches + 3 >= match_list_len) {
+ char **nmatch_list;
+ while (matches + 3 >= match_list_len)
+ match_list_len <<= 1;
+ nmatch_list = realloc(match_list,
+ match_list_len * sizeof(char *));
+ if (nmatch_list == NULL) {
+ free(match_list);
+ return NULL;
+ }
+ match_list = nmatch_list;
+
+ }
+ match_list[++matches] = retstr;
+ }
+
+ if (!match_list)
+ return NULL; /* nothing found */
+
+ /* find least denominator and insert it to match_list[0] */
+ which = 2;
+ prevstr = match_list[1];
+ max_equal = strlen(prevstr);
+ for (; which <= matches; which++) {
+ for (i = 0; i < max_equal &&
+ prevstr[i] == match_list[which][i]; i++)
+ continue;
+ max_equal = i;
+ }
+
+ retstr = malloc(max_equal + 1);
+ if (retstr == NULL) {
+ free(match_list);
+ return NULL;
+ }
+ (void)strncpy(retstr, match_list[1], max_equal);
+ retstr[max_equal] = '\0';
+ match_list[0] = retstr;
+
+ /* add NULL as last pointer to the array */
+ match_list[matches + 1] = (char *) NULL;
+
+ return (match_list);
+}
+
+/*
+ * Sort function for qsort(). Just wrapper around strcasecmp().
+ */
+static int
+_rl_qsort_string_compare(i1, i2)
+ const void *i1, *i2;
+{
+ const char *s1 = ((const char * const *)i1)[0];
+ const char *s2 = ((const char * const *)i2)[0];
+
+ return strcasecmp(s1, s2);
+}
+
+/*
+ * Display list of strings in columnar format on readline's output stream.
+ * 'matches' is list of strings, 'len' is number of strings in 'matches',
+ * 'max' is maximum length of string in 'matches'.
+ */
+void
+rl_display_match_list (matches, len, max)
+ char **matches;
+ int len, max;
+{
+ int i, idx, limit, count;
+ int screenwidth = e->el_term.t_size.h;
+
+ /*
+ * Find out how many entries can be put on one line, count
+ * with two spaces between strings.
+ */
+ limit = screenwidth / (max + 2);
+ if (limit == 0)
+ limit = 1;
+
+ /* how many lines of output */
+ count = len / limit;
+ if (count * limit < len)
+ count++;
+
+ /* Sort the items if they are not already sorted. */
+ qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
+ _rl_qsort_string_compare);
+
+ idx = 1;
+ for(; count > 0; count--) {
+ for(i = 0; i < limit && matches[idx]; i++, idx++)
+ (void)fprintf(e->el_outfile, "%-*s ", max,
+ matches[idx]);
+ (void)fprintf(e->el_outfile, "\n");
+ }
+}
+
+/*
+ * Complete the word at or before point, called by rl_complete()
+ * 'what_to_do' says what to do with the completion.
+ * `?' means list the possible completions.
+ * TAB means do standard completion.
+ * `*' means insert all of the possible completions.
+ * `!' means to do standard completion, and list all possible completions if
+ * there is more than one.
+ *
+ * Note: '*' support is not implemented
+ */
+static int
+rl_complete_internal(int what_to_do)
+{
+ Function *complet_func;
+ const LineInfo *li;
+ char *temp, **matches;
+ const char *ctemp;
+ size_t len;
+
+ rl_completion_type = what_to_do;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ complet_func = rl_completion_entry_function;
+ if (!complet_func)
+ complet_func = (Function *)(void *)filename_completion_function;
+
+ /* We now look backwards for the start of a filename/variable word */
+ li = el_line(e);
+ ctemp = (const char *) li->cursor;
+ while (ctemp > li->buffer
+ && !strchr(rl_basic_word_break_characters, ctemp[-1])
+ && (!rl_special_prefixes
+ || !strchr(rl_special_prefixes, ctemp[-1]) ) )
+ ctemp--;
+
+ len = li->cursor - ctemp;
+ temp = alloca(len + 1);
+ (void)strncpy(temp, ctemp, len);
+ temp[len] = '\0';
+
+ /* these can be used by function called in completion_matches() */
+ /* or (*rl_attempted_completion_function)() */
+ rl_point = li->cursor - li->buffer;
+ rl_end = li->lastchar - li->buffer;
+
+ if (rl_attempted_completion_function) {
+ int end = li->cursor - li->buffer;
+ matches = (*rl_attempted_completion_function) (temp, (int)
+ (end - len), end);
+ } else
+ matches = 0;
+ if (!rl_attempted_completion_function || !matches)
+ matches = completion_matches(temp, (CPFunction *)complet_func);
+
+ if (matches) {
+ int i, retval = CC_REFRESH;
+ int matches_num, maxlen, match_len, match_display=1;
+
+ /*
+ * Only replace the completed string with common part of
+ * possible matches if there is possible completion.
+ */
+ if (matches[0][0] != '\0') {
+ el_deletestr(e, (int) len);
+ el_insertstr(e, matches[0]);
+ }
+
+ if (what_to_do == '?')
+ goto display_matches;
+
+ if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
+ /*
+ * We found exact match. Add a space after
+ * it, unless we do filename completion and the
+ * object is a directory.
+ */
+ size_t alen = strlen(matches[0]);
+ if ((complet_func !=
+ (Function *)filename_completion_function
+ || (alen > 0 && (matches[0])[alen - 1] != '/'))
+ && rl_completion_append_character) {
+ char buf[2];
+ buf[0] = rl_completion_append_character;
+ buf[1] = '\0';
+ el_insertstr(e, buf);
+ }
+ } else if (what_to_do == '!') {
+ display_matches:
+ /*
+ * More than one match and requested to list possible
+ * matches.
+ */
+
+ for(i=1, maxlen=0; matches[i]; i++) {
+ match_len = strlen(matches[i]);
+ if (match_len > maxlen)
+ maxlen = match_len;
+ }
+ matches_num = i - 1;
+
+ /* newline to get on next line from command line */
+ (void)fprintf(e->el_outfile, "\n");
+
+ /*
+ * If there are too many items, ask user for display
+ * confirmation.
+ */
+ if (matches_num > rl_completion_query_items) {
+ (void)fprintf(e->el_outfile,
+ "Display all %d possibilities? (y or n) ",
+ matches_num);
+ (void)fflush(e->el_outfile);
+ if (getc(stdin) != 'y')
+ match_display = 0;
+ (void)fprintf(e->el_outfile, "\n");
+ }
+
+ if (match_display)
+ rl_display_match_list(matches, matches_num,
+ maxlen);
+ retval = CC_REDISPLAY;
+ } else if (matches[0][0]) {
+ /*
+ * There was some common match, but the name was
+ * not complete enough. Next tab will print possible
+ * completions.
+ */
+ el_beep(e);
+ } else {
+ /* lcd is not a valid object - further specification */
+ /* is needed */
+ el_beep(e);
+ retval = CC_NORM;
+ }
+
+ /* free elements of array and the array itself */
+ for (i = 0; matches[i]; i++)
+ free(matches[i]);
+ free(matches), matches = NULL;
+
+ return (retval);
+ }
+ return (CC_NORM);
+}
+
+
+/*
+ * complete word at current point
+ */
+int
+rl_complete(int ignore, int invoking_key)
+{
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ if (rl_inhibit_completion) {
+ char arr[2];
+ arr[0] = (char)invoking_key;
+ arr[1] = '\0';
+ el_insertstr(e, arr);
+ return (CC_REFRESH);
+ } else if (e->el_state.lastcmd == el_rl_complete_cmdnum)
+ return rl_complete_internal('?');
+ else if (_rl_complete_show_all)
+ return rl_complete_internal('!');
+ else
+ return (rl_complete_internal(TAB));
+}
+
+
+/*
+ * misc other functions
+ */
+
+/*
+ * bind key c to readline-type function func
+ */
+int
+rl_bind_key(int c, int func(int, int))
+{
+ int retval = -1;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ if (func == rl_insert) {
+ /* XXX notice there is no range checking of ``c'' */
+ e->el_map.key[c] = ED_INSERT;
+ retval = 0;
+ }
+ return (retval);
+}
+
+
+/*
+ * read one key from input - handles chars pushed back
+ * to input stream also
+ */
+int
+rl_read_key(void)
+{
+ char fooarr[2 * sizeof(int)];
+
+ if (e == NULL || h == NULL)
+ rl_initialize();
+
+ return (el_getc(e, fooarr));
+}
+
+
+/*
+ * reset the terminal
+ */
+/* ARGSUSED */
+void
+rl_reset_terminal(const char *p __attribute__((__unused__)))
+{
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+ el_reset(e);
+}
+
+
+/*
+ * insert character ``c'' back into input stream, ``count'' times
+ */
+int
+rl_insert(int count, int c)
+{
+ char arr[2];
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ /* XXX - int -> char conversion can lose on multichars */
+ arr[0] = c;
+ arr[1] = '\0';
+
+ for (; count > 0; count--)
+ el_push(e, arr);
+
+ return (0);
+}
+
+/*ARGSUSED*/
+int
+rl_newline(int count, int c)
+{
+ /*
+ * Readline-4.0 appears to ignore the args.
+ */
+ return rl_insert(1, '\n');
+}
+
+/*ARGSUSED*/
+static unsigned char
+rl_bind_wrapper(EditLine *el, unsigned char c)
+{
+ if (map[c] == NULL)
+ return CC_ERROR;
+ (*map[c])(NULL, c);
+
+ /* If rl_done was set by the above call, deal with it here */
+ if (rl_done)
+ return CC_EOF;
+
+ return CC_NORM;
+}
+
+int
+rl_add_defun(const char *name, Function *fun, int c)
+{
+ char dest[8];
+ if (c >= sizeof(map) / sizeof(map[0]) || c < 0)
+ return -1;
+ map[(unsigned char)c] = fun;
+ el_set(e, EL_ADDFN, name, name, rl_bind_wrapper);
+ vis(dest, c, VIS_WHITE|VIS_NOSLASH, 0);
+ el_set(e, EL_BIND, dest, name);
+ return 0;
+}
+
+void
+rl_callback_read_char()
+{
+ int count = 0, done = 0;
+ const char *buf = el_gets(e, &count);
+ char *wbuf;
+
+ if (buf == NULL || count-- <= 0)
+ return;
+ if (count == 0 && buf[0] == CTRL('d'))
+ done = 1;
+ if (buf[count] == '\n' || buf[count] == '\r')
+ done = 2;
+
+ if (done && rl_linefunc != NULL) {
+ el_set(e, EL_UNBUFFERED, 0);
+ if (done == 2) {
+ if ((wbuf = strdup(buf)) != NULL)
+ wbuf[count] = '\0';
+ } else
+ wbuf = NULL;
+ (*(void (*)(const char *))rl_linefunc)(wbuf);
+ }
+}
+
+void
+rl_callback_handler_install (const char *prompt, VFunction *linefunc)
+{
+ if (e == NULL) {
+ rl_initialize();
+ }
+ if (rl_prompt)
+ free(rl_prompt);
+ rl_prompt = prompt ? strdup(strchr(prompt, *prompt)) : NULL;
+ rl_linefunc = linefunc;
+ el_set(e, EL_UNBUFFERED, 1);
+}
+
+void
+rl_callback_handler_remove(void)
+{
+ el_set(e, EL_UNBUFFERED, 0);
+}
+
+void
+rl_redisplay(void)
+{
+ char a[2];
+ a[0] = CTRL('r');
+ a[1] = '\0';
+ el_push(e, a);
+}
+
+int
+rl_get_previous_history(int count, int key)
+{
+ char a[2];
+ a[0] = key;
+ a[1] = '\0';
+ while (count--)
+ el_push(e, a);
+ return 0;
+}
+
+void
+/*ARGSUSED*/
+rl_prep_terminal(int meta_flag)
+{
+ el_set(e, EL_PREP_TERM, 1);
+}
+
+void
+rl_deprep_terminal()
+{
+ el_set(e, EL_PREP_TERM, 0);
+}
+
+int
+rl_read_init_file(const char *s)
+{
+ return(el_source(e, s));
+}
+
+int
+rl_parse_and_bind(const char *line)
+{
+ const char **argv;
+ int argc;
+ Tokenizer *tok;
+
+ tok = tok_init(NULL);
+ tok_str(tok, line, &argc, &argv);
+ argc = el_parse(e, argc, argv);
+ tok_end(tok);
+ return (argc ? 1 : 0);
+}
+
+void
+rl_stuff_char(int c)
+{
+ char buf[2];
+
+ buf[0] = c;
+ buf[1] = '\0';
+ el_insertstr(e, buf);
+}
+
+static int
+_rl_event_read_char(EditLine *el, char *cp)
+{
+ int n, num_read = 0;
+
+ *cp = 0;
+ while (rl_event_hook) {
+
+ (*rl_event_hook)();
+
+#if defined(FIONREAD)
+ if (ioctl(el->el_infd, FIONREAD, &n) < 0)
+ return(-1);
+ if (n)
+ num_read = read(el->el_infd, cp, 1);
+ else
+ num_read = 0;
+#elif defined(F_SETFL) && defined(O_NDELAY)
+ if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0)
+ return(-1);
+ if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
+ return(-1);
+ num_read = read(el->el_infd, cp, 1);
+ if (fcntl(el->el_infd, F_SETFL, n))
+ return(-1);
+#else
+ /* not non-blocking, but what you gonna do? */
+ num_read = read(el->el_infd, cp, 1);
+ return(-1);
+#endif
+
+ if (num_read < 0 && errno == EAGAIN)
+ continue;
+ if (num_read == 0)
+ continue;
+ break;
+ }
+ if (!rl_event_hook)
+ el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
+ return(num_read);
+}
diff --git a/net/tnftp/files/libedit/readline/readline.h b/net/tnftp/files/libedit/readline/readline.h
index 64247b0f362..3790a4a9a92 100644
--- a/net/tnftp/files/libedit/readline/readline.h
+++ b/net/tnftp/files/libedit/readline/readline.h
@@ -1,4 +1,5 @@
-/* $NetBSD: readline.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: readline.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: readline.h,v 1.12 2004/09/08 18:15:37 christos Exp */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -36,7 +37,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _READLINE_H_
-#define _READLINE_H_
+#define _READLINE_H_
#include <sys/types.h>
@@ -53,6 +54,38 @@ typedef struct _hist_entry {
const char *data;
} HIST_ENTRY;
+typedef struct _keymap_entry {
+ char type;
+#define ISFUNC 0
+#define ISKMAP 1
+#define ISMACR 2
+ Function *function;
+} KEYMAP_ENTRY;
+
+#define KEYMAP_SIZE 256
+
+typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
+typedef KEYMAP_ENTRY *Keymap;
+
+#define control_character_threshold 0x20
+#define control_character_bit 0x40
+
+#ifndef CTRL
+#include <sys/ioctl.h>
+#if !defined(__sun__) && !defined(__hpux__)
+#include <sys/ttydefaults.h>
+#endif
+#ifndef CTRL
+#define CTRL(c) ((c) & 037)
+#endif
+#endif
+#ifndef UNCTRL
+#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
+#endif
+
+#define RUBOUT 0x7f
+#define ABORT_CHAR CTRL('G')
+
/* global variables used by readline enabled applications */
#ifdef __cplusplus
extern "C" {
@@ -68,12 +101,31 @@ extern int max_input_history;
extern char *rl_basic_word_break_characters;
extern char *rl_completer_word_break_characters;
extern char *rl_completer_quote_characters;
-extern CPFunction *rl_completion_entry_function;
+extern Function *rl_completion_entry_function;
extern CPPFunction *rl_attempted_completion_function;
extern int rl_completion_type;
extern int rl_completion_query_items;
extern char *rl_special_prefixes;
extern int rl_completion_append_character;
+extern int rl_inhibit_completion;
+extern Function *rl_pre_input_hook;
+extern Function *rl_startup_hook;
+extern char *rl_terminal_name;
+extern int rl_already_prompted;
+extern char *rl_prompt;
+/*
+ * The following is not implemented
+ */
+extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
+ emacs_meta_keymap,
+ emacs_ctlx_keymap;
+extern int rl_filename_completion_desired;
+extern int rl_ignore_completion_duplicates;
+extern Function *rl_getc_function;
+extern VFunction *rl_redisplay_function;
+extern VFunction *rl_completion_display_matches_hook;
+extern VFunction *rl_prep_term_function;
+extern VFunction *rl_deprep_term_function;
/* supported functions */
char *readline(const char *);
@@ -99,6 +151,8 @@ int read_history(const char *);
int write_history(const char *);
int history_expand(char *, char **);
char **history_tokenize(const char *);
+const char *get_history_event(const char *, int *, int);
+char *history_arg_extract(int, int, const char *);
char *tilde_expand(char *);
char *filename_completion_function(const char *, int);
@@ -111,6 +165,26 @@ void rl_display_match_list(char **, int, int);
int rl_insert(int, int);
void rl_reset_terminal(const char *);
int rl_bind_key(int, int (*)(int, int));
+int rl_newline(int, int);
+void rl_callback_read_char(void);
+void rl_callback_handler_install(const char *, VFunction *);
+void rl_callback_handler_remove(void);
+void rl_redisplay(void);
+int rl_get_previous_history(int, int);
+void rl_prep_terminal(int);
+void rl_deprep_terminal(void);
+int rl_read_init_file(const char *);
+int rl_parse_and_bind(const char *);
+void rl_stuff_char(int);
+int rl_add_defun(const char *, Function *, int);
+
+/*
+ * The following are not implemented
+ */
+Keymap rl_get_keymap(void);
+Keymap rl_make_bare_keymap(void);
+int rl_generic_bind(int, const char *, const char *, Keymap);
+int rl_bind_key_in_map(int, Function *, Keymap);
#ifdef __cplusplus
}
#endif
diff --git a/net/tnftp/files/libedit/refresh.c b/net/tnftp/files/libedit/refresh.c
index 719cfa0c827..c8f5799dc56 100644
--- a/net/tnftp/files/libedit/refresh.c
+++ b/net/tnftp/files/libedit/refresh.c
@@ -1,4 +1,5 @@
-/* $NetBSD: refresh.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: refresh.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: refresh.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* refresh.c: Lower level screen refreshing functions
*/
@@ -58,21 +66,21 @@ private void re__strncopy(char *, char *, size_t);
private void re__copy_and_pad(char *, const char *, size_t);
#ifdef DEBUG_REFRESH
-private void re_printstr(EditLine *, char *, char *, char *);
+private void re_printstr(EditLine *, const char *, char *, char *);
#define __F el->el_errfile
#define ELRE_ASSERT(a, b, c) do \
- if (a) { \
+ if (/*CONSTCOND*/ a) { \
(void) fprintf b; \
c; \
} \
- while (0)
+ while (/*CONSTCOND*/0)
#define ELRE_DEBUG(a, b) ELRE_ASSERT(a,b,;)
/* re_printstr():
* Print a string on the debugging pty
*/
private void
-re_printstr(EditLine *el, char *str, char *f, char *t)
+re_printstr(EditLine *el, const char *str, char *f, char *t)
{
ELRE_DEBUG(1, (__F, "%s:\"", str));
@@ -203,6 +211,14 @@ re_refresh(EditLine *el)
el->el_refresh.r_cursor.h = 0;
el->el_refresh.r_cursor.v = 0;
+ if (el->el_line.cursor >= el->el_line.lastchar) {
+ if (el->el_map.current == el->el_map.alt
+ && el->el_line.lastchar != el->el_line.buffer)
+ el->el_line.cursor = el->el_line.lastchar - 1;
+ else
+ el->el_line.cursor = el->el_line.lastchar;
+ }
+
cur.h = -1; /* set flag in case I'm not set */
cur.v = 0;
@@ -312,7 +328,6 @@ re_goto_bottom(EditLine *el)
{
term_move_to_line(el, el->el_refresh.r_oldcv);
- term__putc('\r');
term__putc('\n');
re_clear_display(el);
term__flush();
@@ -325,7 +340,8 @@ re_goto_bottom(EditLine *el)
*/
private void
/*ARGSUSED*/
-re_insert(EditLine *el, char *d, int dat, int dlen, char *s, int num)
+re_insert(EditLine *el __attribute__((__unused__)),
+ char *d, int dat, int dlen, char *s, int num)
{
char *a, *b;
@@ -368,7 +384,8 @@ re_insert(EditLine *el, char *d, int dat, int dlen, char *s, int num)
*/
private void
/*ARGSUSED*/
-re_delete(EditLine *el, char *d, int dat, int dlen, int num)
+re_delete(EditLine *el __attribute__((__unused__)),
+ char *d, int dat, int dlen, int num)
{
char *a, *b;
@@ -903,7 +920,7 @@ re_update_line(EditLine *el, char *old, char *new, int i)
private void
re__copy_and_pad(char *dst, const char *src, size_t width)
{
- int i;
+ size_t i;
for (i = 0; i < width; i++) {
if (*src == '\0')
@@ -927,6 +944,14 @@ re_refresh_cursor(EditLine *el)
char *cp, c;
int h, v, th;
+ if (el->el_line.cursor >= el->el_line.lastchar) {
+ if (el->el_map.current == el->el_map.alt
+ && el->el_line.lastchar != el->el_line.buffer)
+ el->el_line.cursor = el->el_line.lastchar - 1;
+ else
+ el->el_line.cursor = el->el_line.lastchar;
+ }
+
/* first we must find where the cursor is... */
h = el->el_prompt.p_pos.h;
v = el->el_prompt.p_pos.v;
@@ -1049,8 +1074,8 @@ re_fastaddc(EditLine *el)
re_fastputc(el, c);
} else {
re_fastputc(el, '\\');
- re_fastputc(el, (int) ((((unsigned int) c >> 6) & 7) + '0'));
- re_fastputc(el, (int) ((((unsigned int) c >> 3) & 7) + '0'));
+ re_fastputc(el, (int)(((((unsigned int)c) >> 6) & 3) + '0'));
+ re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0'));
re_fastputc(el, (c & 7) + '0');
}
term__flush();
diff --git a/net/tnftp/files/libedit/refresh.h b/net/tnftp/files/libedit/refresh.h
index 8481f171540..f8bfdbc9cd9 100644
--- a/net/tnftp/files/libedit/refresh.h
+++ b/net/tnftp/files/libedit/refresh.h
@@ -1,4 +1,5 @@
-/* $NetBSD: refresh.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: refresh.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: refresh.h,v 1.5 2003/08/07 16:44:33 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
diff --git a/net/tnftp/files/libedit/search.c b/net/tnftp/files/libedit/search.c
index 62d639a201b..cbe7b9cf2dd 100644
--- a/net/tnftp/files/libedit/search.c
+++ b/net/tnftp/files/libedit/search.c
@@ -1,4 +1,5 @@
-/* $NetBSD: search.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: search.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: search.c,v 1.20 2004/11/04 01:16:03 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: search.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* search.c: History and character search functions
*/
@@ -65,7 +73,8 @@ search_init(EditLine *el)
el->el_search.patlen = 0;
el->el_search.patdir = -1;
el->el_search.chacha = '\0';
- el->el_search.chadir = -1;
+ el->el_search.chadir = CHAR_FWD;
+ el->el_search.chatflg = 0;
return (0);
}
@@ -214,8 +223,11 @@ ce_inc_search(EditLine *el, int dir)
if (el->el_search.patlen == 0) { /* first round */
pchar = ':';
#ifdef ANCHOR
+#define LEN 2
el->el_search.patbuf[el->el_search.patlen++] = '.';
el->el_search.patbuf[el->el_search.patlen++] = '*';
+#else
+#define LEN 0
#endif
}
done = redo = 0;
@@ -224,7 +236,7 @@ ce_inc_search(EditLine *el, int dir)
*cp; *el->el_line.lastchar++ = *cp++)
continue;
*el->el_line.lastchar++ = pchar;
- for (cp = &el->el_search.patbuf[1];
+ for (cp = &el->el_search.patbuf[LEN];
cp < &el->el_search.patbuf[el->el_search.patlen];
*el->el_line.lastchar++ = *cp++)
continue;
@@ -237,7 +249,7 @@ ce_inc_search(EditLine *el, int dir)
switch (el->el_map.current[(unsigned char) ch]) {
case ED_INSERT:
case ED_DIGIT:
- if (el->el_search.patlen > EL_BUFSIZ - 3)
+ if (el->el_search.patlen >= EL_BUFSIZ - LEN)
term_beep(el);
else {
el->el_search.patbuf[el->el_search.patlen++] =
@@ -258,8 +270,9 @@ ce_inc_search(EditLine *el, int dir)
redo++;
break;
+ case EM_DELETE_PREV_CHAR:
case ED_DELETE_PREV_CHAR:
- if (el->el_search.patlen > 1)
+ if (el->el_search.patlen > LEN)
done++;
else
term_beep(el);
@@ -274,17 +287,18 @@ ce_inc_search(EditLine *el, int dir)
case 0027: /* ^W: Append word */
/* No can do if globbing characters in pattern */
- for (cp = &el->el_search.patbuf[1];; cp++)
- if (cp >= &el->el_search.patbuf[el->el_search.patlen]) {
+ for (cp = &el->el_search.patbuf[LEN];; cp++)
+ if (cp >= &el->el_search.patbuf[
+ el->el_search.patlen]) {
el->el_line.cursor +=
- el->el_search.patlen - 1;
+ el->el_search.patlen - LEN - 1;
cp = c__next_word(el->el_line.cursor,
el->el_line.lastchar, 1,
ce__isword);
while (el->el_line.cursor < cp &&
*el->el_line.cursor != '\n') {
- if (el->el_search.patlen >
- EL_BUFSIZ - 3) {
+ if (el->el_search.patlen >=
+ EL_BUFSIZ - LEN) {
term_beep(el);
break;
}
@@ -326,13 +340,13 @@ ce_inc_search(EditLine *el, int dir)
/* Can't search if unmatched '[' */
for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
ch = ']';
- cp > el->el_search.patbuf;
+ cp >= &el->el_search.patbuf[LEN];
cp--)
if (*cp == '[' || *cp == ']') {
ch = *cp;
break;
}
- if (el->el_search.patlen > 1 && ch != '[') {
+ if (el->el_search.patlen > LEN && ch != '[') {
if (redo && newdir == dir) {
if (pchar == '?') { /* wrap around */
el->el_history.eventno =
@@ -362,9 +376,8 @@ ce_inc_search(EditLine *el, int dir)
'\0';
if (el->el_line.cursor < el->el_line.buffer ||
el->el_line.cursor > el->el_line.lastchar ||
- (ret = ce_search_line(el,
- &el->el_search.patbuf[1],
- newdir)) == CC_ERROR) {
+ (ret = ce_search_line(el, newdir))
+ == CC_ERROR) {
/* avoid c_setpat */
el->el_state.lastcmd =
(el_action_t) newdir;
@@ -377,11 +390,11 @@ ce_inc_search(EditLine *el, int dir)
el->el_line.lastchar :
el->el_line.buffer;
(void) ce_search_line(el,
- &el->el_search.patbuf[1],
newdir);
}
}
- el->el_search.patbuf[--el->el_search.patlen] =
+ el->el_search.patlen -= LEN;
+ el->el_search.patbuf[el->el_search.patlen] =
'\0';
if (ret == CC_ERROR) {
term_beep(el);
@@ -437,29 +450,20 @@ cv_search(EditLine *el, int dir)
char tmpbuf[EL_BUFSIZ];
int tmplen;
- tmplen = 0;
#ifdef ANCHOR
- tmpbuf[tmplen++] = '.';
- tmpbuf[tmplen++] = '*';
+ tmpbuf[0] = '.';
+ tmpbuf[1] = '*';
#endif
+ tmplen = LEN;
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
el->el_search.patdir = dir;
- c_insert(el, 2); /* prompt + '\n' */
- *el->el_line.cursor++ = '\n';
- *el->el_line.cursor++ = dir == ED_SEARCH_PREV_HISTORY ? '/' : '?';
- re_refresh(el);
+ tmplen = c_gets(el, &tmpbuf[LEN],
+ dir == ED_SEARCH_PREV_HISTORY ? "\n/" : "\n?" );
+ if (tmplen == -1)
+ return CC_REFRESH;
-#ifdef ANCHOR
-#define LEN 2
-#else
-#define LEN 0
-#endif
-
- tmplen = c_gets(el, &tmpbuf[LEN]) + LEN;
+ tmplen += LEN;
ch = tmpbuf[tmplen];
tmpbuf[tmplen] = '\0';
@@ -468,9 +472,6 @@ cv_search(EditLine *el, int dir)
* Use the old pattern, but wild-card it.
*/
if (el->el_search.patlen == 0) {
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
re_refresh(el);
return (CC_ERROR);
}
@@ -501,19 +502,15 @@ cv_search(EditLine *el, int dir)
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
el->el_line.cursor = el->el_line.lastchar = el->el_line.buffer;
if ((dir == ED_SEARCH_PREV_HISTORY ? ed_search_prev_history(el, 0) :
- ed_search_next_history(el, 0)) == CC_ERROR) {
+ ed_search_next_history(el, 0)) == CC_ERROR) {
re_refresh(el);
return (CC_ERROR);
- } else {
- if (ch == 0033) {
- re_refresh(el);
- *el->el_line.lastchar++ = '\n';
- *el->el_line.lastchar = '\0';
- re_goto_bottom(el);
- return (CC_NEWLINE);
- } else
- return (CC_REFRESH);
}
+ if (ch == 0033) {
+ re_refresh(el);
+ return ed_newline(el, 0);
+ }
+ return (CC_REFRESH);
}
@@ -521,24 +518,39 @@ cv_search(EditLine *el, int dir)
* Look for a pattern inside a line
*/
protected el_action_t
-ce_search_line(EditLine *el, char *pattern, int dir)
+ce_search_line(EditLine *el, int dir)
{
- char *cp;
+ char *cp = el->el_line.cursor;
+ char *pattern = el->el_search.patbuf;
+ char oc, *ocp;
+#ifdef ANCHOR
+ ocp = &pattern[1];
+ oc = *ocp;
+ *ocp = '^';
+#else
+ ocp = pattern;
+ oc = *ocp;
+#endif
if (dir == ED_SEARCH_PREV_HISTORY) {
- for (cp = el->el_line.cursor; cp >= el->el_line.buffer; cp--)
- if (el_match(cp, pattern)) {
+ for (; cp >= el->el_line.buffer; cp--) {
+ if (el_match(cp, ocp)) {
+ *ocp = oc;
el->el_line.cursor = cp;
return (CC_NORM);
}
+ }
+ *ocp = oc;
return (CC_ERROR);
} else {
- for (cp = el->el_line.cursor; *cp != '\0' &&
- cp < el->el_line.limit; cp++)
- if (el_match(cp, pattern)) {
+ for (; *cp != '\0' && cp < el->el_line.limit; cp++) {
+ if (el_match(cp, ocp)) {
+ *ocp = oc;
el->el_line.cursor = cp;
return (CC_NORM);
}
+ }
+ *ocp = oc;
return (CC_ERROR);
}
}
@@ -570,69 +582,53 @@ cv_repeat_srch(EditLine *el, int c)
}
-/* cv_csearch_back():
- * Vi character search reverse
+/* cv_csearch():
+ * Vi character search
*/
protected el_action_t
-cv_csearch_back(EditLine *el, int ch, int count, int tflag)
+cv_csearch(EditLine *el, int direction, int ch, int count, int tflag)
{
char *cp;
- cp = el->el_line.cursor;
- while (count--) {
- if (*cp == ch)
- cp--;
- while (cp > el->el_line.buffer && *cp != ch)
- cp--;
- }
-
- if (cp < el->el_line.buffer || (cp == el->el_line.buffer && *cp != ch))
- return (CC_ERROR);
-
- if (*cp == ch && tflag)
- cp++;
-
- el->el_line.cursor = cp;
+ if (ch == 0)
+ return CC_ERROR;
- if (el->el_chared.c_vcmd.action & DELETE) {
- el->el_line.cursor++;
- cv_delfini(el);
- return (CC_REFRESH);
+ if (ch == -1) {
+ char c;
+ if (el_getc(el, &c) != 1)
+ return ed_end_of_file(el, 0);
+ ch = c;
}
- re_refresh_cursor(el);
- return (CC_NORM);
-}
-
-/* cv_csearch_fwd():
- * Vi character search forward
- */
-protected el_action_t
-cv_csearch_fwd(EditLine *el, int ch, int count, int tflag)
-{
- char *cp;
+ /* Save for ';' and ',' commands */
+ el->el_search.chacha = ch;
+ el->el_search.chadir = direction;
+ el->el_search.chatflg = tflag;
cp = el->el_line.cursor;
while (count--) {
if (*cp == ch)
- cp++;
- while (cp < el->el_line.lastchar && *cp != ch)
- cp++;
+ cp += direction;
+ for (;;cp += direction) {
+ if (cp >= el->el_line.lastchar)
+ return CC_ERROR;
+ if (cp < el->el_line.buffer)
+ return CC_ERROR;
+ if (*cp == ch)
+ break;
+ }
}
- if (cp >= el->el_line.lastchar)
- return (CC_ERROR);
-
- if (*cp == ch && tflag)
- cp--;
+ if (tflag)
+ cp -= direction;
el->el_line.cursor = cp;
- if (el->el_chared.c_vcmd.action & DELETE) {
- el->el_line.cursor++;
+ if (el->el_chared.c_vcmd.action != NOP) {
+ if (direction > 0)
+ el->el_line.cursor++;
cv_delfini(el);
- return (CC_REFRESH);
+ return CC_REFRESH;
}
- re_refresh_cursor(el);
- return (CC_NORM);
+ return CC_CURSOR;
}
diff --git a/net/tnftp/files/libedit/search.h b/net/tnftp/files/libedit/search.h
index e0ed88ae2c7..f8b90284281 100644
--- a/net/tnftp/files/libedit/search.h
+++ b/net/tnftp/files/libedit/search.h
@@ -1,4 +1,5 @@
-/* $NetBSD: search.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: search.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: search.h,v 1.8 2003/10/18 23:27:36 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -52,6 +49,7 @@ typedef struct el_search_t {
int patdir; /* Direction of the last search */
int chadir; /* Character search direction */
char chacha; /* Character we are looking for */
+ char chatflg; /* 0 if f, 1 if t */
} el_search_t;
@@ -62,9 +60,8 @@ protected int c_hmatch(EditLine *, const char *);
protected void c_setpat(EditLine *);
protected el_action_t ce_inc_search(EditLine *, int);
protected el_action_t cv_search(EditLine *, int);
-protected el_action_t ce_search_line(EditLine *, char *, int);
+protected el_action_t ce_search_line(EditLine *, int);
protected el_action_t cv_repeat_srch(EditLine *, int);
-protected el_action_t cv_csearch_back(EditLine *, int, int, int);
-protected el_action_t cv_csearch_fwd(EditLine *, int, int, int);
+protected el_action_t cv_csearch(EditLine *, int, int, int, int);
#endif /* _h_el_search */
diff --git a/net/tnftp/files/libedit/sig.c b/net/tnftp/files/libedit/sig.c
index 156cc492425..c9af37da1fb 100644
--- a/net/tnftp/files/libedit/sig.c
+++ b/net/tnftp/files/libedit/sig.c
@@ -1,4 +1,5 @@
-/* $NetBSD: sig.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: sig.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: sig.c,v 1.11 2003/08/07 16:44:33 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: sig.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* sig.c: Signal handling stuff.
* our policy is to trap all signals, set a good state
@@ -115,9 +123,9 @@ sig_init(EditLine *el)
#undef _DO
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
-#define SIGSIZE (sizeof(sighdl) / sizeof(sighdl[0]) * sizeof(sigfunc))
+#define SIGSIZE (sizeof(sighdl) / sizeof(sighdl[0]) * sizeof(el_signalhandler_t))
- el->el_signal = (sigfunc *) el_malloc(SIGSIZE);
+ el->el_signal = (el_signalhandler_t *) el_malloc(SIGSIZE);
if (el->el_signal == NULL)
return (-1);
for (i = 0; sighdl[i] != -1; i++)
@@ -157,7 +165,7 @@ sig_set(EditLine *el)
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
for (i = 0; sighdl[i] != -1; i++) {
- sigfunc s;
+ el_signalhandler_t s;
/* This could happen if we get interrupted */
if ((s = xsignal_restart(sighdl[i], sig_handler, 1)) != sig_handler)
el->el_signal[i] = s;
diff --git a/net/tnftp/files/libedit/sig.h b/net/tnftp/files/libedit/sig.h
index 52f421b4be6..e478d64cfbe 100644
--- a/net/tnftp/files/libedit/sig.h
+++ b/net/tnftp/files/libedit/sig.h
@@ -1,4 +1,5 @@
-/* $NetBSD: sig.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: sig.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -62,12 +59,8 @@
_DO(SIGCONT) \
_DO(SIGWINCH)
-typedef void (*sigfunc)(int);
-
- /* provided by ../src/util.c */
-sigfunc xsignal_restart(int, sigfunc, int);
-
-typedef sigfunc *el_signal_t;
+typedef void (*el_signalhandler_t)(int);
+typedef el_signalhandler_t *el_signal_t;
protected void sig_end(EditLine*);
protected int sig_init(EditLine*);
diff --git a/net/tnftp/files/libedit/sys.h b/net/tnftp/files/libedit/sys.h
index 598addbbd5b..6d33e798884 100644
--- a/net/tnftp/files/libedit/sys.h
+++ b/net/tnftp/files/libedit/sys.h
@@ -1,4 +1,5 @@
-/* $NetBSD: sys.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: sys.h,v 1.3 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: sys.h,v 1.9 2004/01/17 17:57:40 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -44,6 +41,26 @@
#ifndef _h_sys
#define _h_sys
+#if __not_for_tnftp
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
+# define __attribute__(A)
+#endif
+
+#ifndef __BEGIN_DECLS
+# ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+# else
+# define __BEGIN_DECLS
+# define __END_DECLS
+# endif
+#endif
+#endif /* __not_for_tnftp */
+
#ifndef public
# define public /* Externally visible functions/variables */
#endif
@@ -67,8 +84,63 @@ typedef void *ptr_t;
typedef void *ioctl_t;
#endif
-#undef REGEX /* Use POSIX.2 regular expression functions */
+#if __not_for_tnftp
+#include <stdio.h>
+
+#ifndef HAVE_STRLCAT
+#define strlcat libedit_strlcat
+size_t strlcat(char *dst, const char *src, size_t size);
+#endif
+
+#ifndef HAVE_STRLCPY
+#define strlcpy libedit_strlcpy
+size_t strlcpy(char *dst, const char *src, size_t size);
+#endif
+
+#ifndef HAVE_FGETLN
+#define fgetln libedit_fgetln
+char *fgetln(FILE *fp, size_t *len);
+#endif
+
+#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */
+#endif /* __not_for_tnftp */
+
+#ifdef notdef
+# undef REGEX
+# undef REGEXP
+# include <malloc.h>
+# ifdef __GNUC__
+/*
+ * Broken hdrs.
+ */
+extern int tgetent(const char *bp, char *name);
+extern int tgetflag(const char *id);
+extern int tgetnum(const char *id);
+extern char *tgetstr(const char *id, char **area);
+extern char *tgoto(const char *cap, int col, int row);
+extern int tputs(const char *str, int affcnt, int (*putc)(int));
+extern char *getenv(const char *);
+extern int fprintf(FILE *, const char *, ...);
+extern int sigsetmask(int);
+extern int sigblock(int);
+extern int fputc(int, FILE *);
+extern int fgetc(FILE *);
+extern int fflush(FILE *);
+extern int tolower(int);
+extern int toupper(int);
+extern int errno, sys_nerr;
+extern char *sys_errlist[];
+extern void perror(const char *);
+# include <string.h>
+# define strerror(e) sys_errlist[e]
+# endif
+# ifdef SABER
+extern ptr_t memcpy(ptr_t, const ptr_t, size_t);
+extern ptr_t memset(ptr_t, int, size_t);
+# endif
+extern char *fgetline(FILE *, int *);
+#endif
#if HAVE_REGEX_H
# include <regex.h>
diff --git a/net/tnftp/files/libedit/term.c b/net/tnftp/files/libedit/term.c
index 4705a538bfb..e722b8870c3 100644
--- a/net/tnftp/files/libedit/term.c
+++ b/net/tnftp/files/libedit/term.c
@@ -1,4 +1,5 @@
-/* $NetBSD: term.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: term.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,17 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
+#else
+__RCSID("NetBSD: term.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* term.c: Editor/termcap-curses interface
* We have to declare a static variable here, since the
@@ -337,6 +345,7 @@ term_init(EditLine *el)
term_init_arrow(el);
return (0);
}
+
/* term_end():
* Clean up the terminal stuff
*/
@@ -353,6 +362,8 @@ term_end(EditLine *el)
el->el_term.t_str = NULL;
el_free((ptr_t) el->el_term.t_val);
el->el_term.t_val = NULL;
+ el_free((ptr_t) el->el_term.t_fkey);
+ el->el_term.t_fkey = NULL;
term_free_display(el);
}
@@ -629,7 +640,8 @@ mc_again:
* from col 0
*/
if (EL_CAN_TAB ?
- (-del > (((unsigned int) where >> 3) +
+ ((unsigned int)-del >
+ (((unsigned int) where >> 3) +
(where & 07)))
: (-del > where)) {
term__putc('\r'); /* do a CR */
@@ -857,6 +869,12 @@ term_clear_to_bottom(EditLine *el)
}
#endif
+protected void
+term_get(EditLine *el, const char **term)
+{
+ *term = el->el_term.t_name;
+}
+
/* term_set():
* Read in the terminal capabilities from the requested terminal
@@ -918,8 +936,11 @@ term_set(EditLine *el, const char *term)
/* Get the size */
Val(T_co) = tgetnum("co");
Val(T_li) = tgetnum("li");
- for (t = tstr; t->name != NULL; t++)
- term_alloc(el, t, tgetstr(t->name, &area));
+ for (t = tstr; t->name != NULL; t++) {
+ /* XXX: some systems tgetstr needs non const */
+ term_alloc(el, t, tgetstr(strchr(t->name, *t->name),
+ &area));
+ }
}
if (Val(T_co) < 2)
@@ -938,6 +959,7 @@ term_set(EditLine *el, const char *term)
return (-1);
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
term_bind_arrow(el);
+ el->el_term.t_name = term;
return (i <= 0 ? -1 : 0);
}
@@ -1227,7 +1249,8 @@ term__flush(void)
*/
protected int
/*ARGSUSED*/
-term_telltc(EditLine *el, int argc, const char **argv)
+term_telltc(EditLine *el, int argc __attribute__((__unused__)),
+ const char **argv __attribute__((__unused__)))
{
const struct termcapstr *t;
char **ts;
@@ -1262,7 +1285,8 @@ term_telltc(EditLine *el, int argc, const char **argv)
*/
protected int
/*ARGSUSED*/
-term_settc(EditLine *el, int argc, const char **argv)
+term_settc(EditLine *el, int argc __attribute__((__unused__)),
+ const char **argv)
{
const struct termcapstr *ts;
const struct termcapval *tv;
@@ -1338,7 +1362,8 @@ term_settc(EditLine *el, int argc, const char **argv)
*/
protected int
/*ARGSUSED*/
-term_echotc(EditLine *el, int argc, const char **argv)
+term_echotc(EditLine *el, int argc __attribute__((__unused__)),
+ const char **argv)
{
char *cap, *scap, *ep;
int arg_need, arg_cols, arg_rows;
@@ -1397,7 +1422,7 @@ term_echotc(EditLine *el, int argc, const char **argv)
}
(void) fprintf(el->el_outfile, fmtd, 0);
#else
- (void) fprintf(el->el_outfile, fmtd, el->el_tty.t_speed);
+ (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed);
#endif
return (0);
} else if (strcmp(*argv, "rows") == 0 || strcmp(*argv, "lines") == 0) {
@@ -1416,8 +1441,10 @@ term_echotc(EditLine *el, int argc, const char **argv)
scap = el->el_term.t_str[t - tstr];
break;
}
- if (t->name == NULL)
- scap = tgetstr(*argv, &area);
+ if (t->name == NULL) {
+ /* XXX: some systems tgetstr needs non const */
+ scap = tgetstr(strchr(*argv, **argv), &area);
+ }
if (!scap || scap[0] == '\0') {
if (!silent)
(void) fprintf(el->el_errfile,
diff --git a/net/tnftp/files/libedit/term.h b/net/tnftp/files/libedit/term.h
index 54076974cb2..250a923b8fb 100644
--- a/net/tnftp/files/libedit/term.h
+++ b/net/tnftp/files/libedit/term.h
@@ -1,4 +1,5 @@
-/* $NetBSD: term.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: term.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: term.h,v 1.15 2003/09/14 21:48:55 christos Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -54,6 +51,7 @@ typedef struct { /* Symbolic function key bindings */
} fkey_t;
typedef struct {
+ const char *t_name; /* the terminal name */
coord_t t_size; /* # lines and cols */
int t_flags;
#define TERM_CAN_INSERT 0x001 /* Has insert cap */
@@ -100,6 +98,7 @@ protected void term_print_arrow(EditLine *, const char *);
protected int term_clear_arrow(EditLine *, const char *);
protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
protected void term_end(EditLine *);
+protected void term_get(EditLine *, const char **);
protected int term_set(EditLine *, const char *);
protected int term_settc(EditLine *, int, const char **);
protected int term_telltc(EditLine *, int, const char **);
diff --git a/net/tnftp/files/libedit/tokenizer.c b/net/tnftp/files/libedit/tokenizer.c
index 202d8904133..a773bc5c358 100644
--- a/net/tnftp/files/libedit/tokenizer.c
+++ b/net/tnftp/files/libedit/tokenizer.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tokenizer.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: tokenizer.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: tokenizer.c,v 1.14 2003/12/05 13:37:48 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,12 +36,23 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: tokenizer.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* tokenize.c: Bourne shell like tokenizer
*/
#include <string.h>
#include <stdlib.h>
-#include "tokenizer.h"
+#include "histedit.h"
typedef enum {
Q_none, Q_single, Q_double, Q_one, Q_doubleone
@@ -58,6 +66,7 @@ typedef enum {
#define WINCR 20
#define AINCR 10
+#define tok_strdup(a) strdup(a)
#define tok_malloc(a) malloc(a)
#define tok_free(a) free(a)
#define tok_realloc(a, b) realloc(a, b)
@@ -103,16 +112,29 @@ tok_init(const char *ifs)
{
Tokenizer *tok = (Tokenizer *) tok_malloc(sizeof(Tokenizer));
- tok->ifs = strdup(ifs ? ifs : IFS);
+ if (tok == NULL)
+ return NULL;
+ tok->ifs = tok_strdup(ifs ? ifs : IFS);
+ if (tok->ifs == NULL) {
+ tok_free((ptr_t)tok);
+ return NULL;
+ }
tok->argc = 0;
tok->amax = AINCR;
tok->argv = (char **) tok_malloc(sizeof(char *) * tok->amax);
- if (tok->argv == NULL)
- return (NULL);
+ if (tok->argv == NULL) {
+ tok_free((ptr_t)tok->ifs);
+ tok_free((ptr_t)tok);
+ return NULL;
+ }
tok->argv[0] = NULL;
tok->wspace = (char *) tok_malloc(WINCR);
- if (tok->wspace == NULL)
- return (NULL);
+ if (tok->wspace == NULL) {
+ tok_free((ptr_t)tok->argv);
+ tok_free((ptr_t)tok->ifs);
+ tok_free((ptr_t)tok);
+ return NULL;
+ }
tok->wmax = tok->wspace + WINCR;
tok->wstart = tok->wspace;
tok->wptr = tok->wspace;
@@ -154,21 +176,39 @@ tok_end(Tokenizer *tok)
/* tok_line():
- * Bourne shell like tokenizing
- * Return:
- * -1: Internal error
- * 3: Quoted return
- * 2: Unmatched double quote
- * 1: Unmatched single quote
- * 0: Ok
+ * Bourne shell (sh(1)) like tokenizing
+ * Arguments:
+ * tok current tokenizer state (setup with tok_init())
+ * line line to parse
+ * Returns:
+ * -1 Internal error
+ * 3 Quoted return
+ * 2 Unmatched double quote
+ * 1 Unmatched single quote
+ * 0 Ok
+ * Modifies (if return value is 0):
+ * argc number of arguments
+ * argv argument array
+ * cursorc if !NULL, argv element containing cursor
+ * cursorv if !NULL, offset in argv[cursorc] of cursor
*/
public int
-tok_line(Tokenizer *tok, const char *line, int *argc, const char ***argv)
+tok_line(Tokenizer *tok, const LineInfo *line,
+ int *argc, const char ***argv, int *cursorc, int *cursoro)
{
const char *ptr;
-
- for (;;) {
- switch (*(ptr = line++)) {
+ int cc, co;
+
+ cc = co = -1;
+ ptr = line->buffer;
+ for (ptr = line->buffer; ;ptr++) {
+ if (ptr >= line->lastchar)
+ ptr = "";
+ if (ptr == line->cursor) {
+ cc = tok->argc;
+ co = tok->wptr - tok->wstart;
+ }
+ switch (*ptr) {
case '\'':
tok->flags |= TOK_KEEP;
tok->flags &= ~TOK_EAT;
@@ -267,10 +307,7 @@ tok_line(Tokenizer *tok, const char *line, int *argc, const char ***argv)
tok->flags &= ~TOK_EAT;
switch (tok->quote) {
case Q_none:
- tok_finish(tok);
- *argv = (const char **)tok->argv;
- *argc = tok->argc;
- return (0);
+ goto tok_line_outok;
case Q_single:
case Q_double:
@@ -300,10 +337,7 @@ tok_line(Tokenizer *tok, const char *line, int *argc, const char ***argv)
tok->flags &= ~TOK_EAT;
return (3);
}
- tok_finish(tok);
- *argv = (const char **)tok->argv;
- *argc = tok->argc;
- return (0);
+ goto tok_line_outok;
case Q_single:
return (1);
@@ -388,4 +422,32 @@ tok_line(Tokenizer *tok, const char *line, int *argc, const char ***argv)
tok->argv = p;
}
}
+ tok_line_outok:
+ if (cc == -1 && co == -1) {
+ cc = tok->argc;
+ co = tok->wptr - tok->wstart;
+ }
+ if (cursorc != NULL)
+ *cursorc = cc;
+ if (cursoro != NULL)
+ *cursoro = co;
+ tok_finish(tok);
+ *argv = (const char **)tok->argv;
+ *argc = tok->argc;
+ return (0);
+}
+
+/* tok_str():
+ * Simpler version of tok_line, taking a NUL terminated line
+ * and splitting into words, ignoring cursor state.
+ */
+public int
+tok_str(Tokenizer *tok, const char *line, int *argc, const char ***argv)
+{
+ LineInfo li;
+
+ memset(&li, 0, sizeof(li));
+ li.buffer = line;
+ li.cursor = li.lastchar = strchr(line, '\0');
+ return (tok_line(tok, &li, argc, argv, NULL, NULL));
}
diff --git a/net/tnftp/files/libedit/tty.c b/net/tnftp/files/libedit/tty.c
index 719e129f6d3..a60929980a0 100644
--- a/net/tnftp/files/libedit/tty.c
+++ b/net/tnftp/files/libedit/tty.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tty.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,9 +36,21 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* tty.c: tty interface stuff
*/
+#include <assert.h>
#include "tty.h"
#include "el.h"
@@ -118,11 +127,11 @@ private const ttychar_t ttychar = {
private const ttymap_t tty_map[] = {
#ifdef VERASE
{C_ERASE, VERASE,
- {ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
+ {EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
#endif /* VERASE */
#ifdef VERASE2
{C_ERASE2, VERASE2,
- {ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
+ {EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
#endif /* VERASE2 */
#ifdef VKILL
{C_KILL, VKILL,
@@ -449,6 +458,7 @@ private const ttymodes_t ttymodes[] = {
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
+private int tty__getcharindex(int);
private void tty__getchar(struct termios *, unsigned char *);
private void tty__setchar(struct termios *, unsigned char *);
private speed_t tty__getspeed(struct termios *);
@@ -562,7 +572,7 @@ tty_init(EditLine *el)
*/
protected void
/*ARGSUSED*/
-tty_end(EditLine *el)
+tty_end(EditLine *el __attribute__((__unused__)))
{
/* XXX: Maybe reset to an initial state? */
@@ -582,6 +592,113 @@ tty__getspeed(struct termios *td)
return (spd);
}
+/* tty__getspeed():
+ * Return the index of the asked char in the c_cc array
+ */
+private int
+tty__getcharindex(int i)
+{
+ switch (i) {
+#ifdef VINTR
+ case C_INTR:
+ return VINTR;
+#endif /* VINTR */
+#ifdef VQUIT
+ case C_QUIT:
+ return VQUIT;
+#endif /* VQUIT */
+#ifdef VERASE
+ case C_ERASE:
+ return VERASE;
+#endif /* VERASE */
+#ifdef VKILL
+ case C_KILL:
+ return VKILL;
+#endif /* VKILL */
+#ifdef VEOF
+ case C_EOF:
+ return VEOF;
+#endif /* VEOF */
+#ifdef VEOL
+ case C_EOL:
+ return VEOL;
+#endif /* VEOL */
+#ifdef VEOL2
+ case C_EOL2:
+ return VEOL2;
+#endif /* VEOL2 */
+#ifdef VSWTCH
+ case C_SWTCH:
+ return VSWTCH;
+#endif /* VSWTCH */
+#ifdef VDSWTCH
+ case C_DSWTCH:
+ return VDSWTCH;
+#endif /* VDSWTCH */
+#ifdef VERASE2
+ case C_ERASE2:
+ return VERASE2;
+#endif /* VERASE2 */
+#ifdef VSTART
+ case C_START:
+ return VSTART;
+#endif /* VSTART */
+#ifdef VSTOP
+ case C_STOP:
+ return VSTOP;
+#endif /* VSTOP */
+#ifdef VWERASE
+ case C_WERASE:
+ return VWERASE;
+#endif /* VWERASE */
+#ifdef VSUSP
+ case C_SUSP:
+ return VSUSP;
+#endif /* VSUSP */
+#ifdef VDSUSP
+ case C_DSUSP:
+ return VDSUSP;
+#endif /* VDSUSP */
+#ifdef VREPRINT
+ case C_REPRINT:
+ return VREPRINT;
+#endif /* VREPRINT */
+#ifdef VDISCARD
+ case C_DISCARD:
+ return VDISCARD;
+#endif /* VDISCARD */
+#ifdef VLNEXT
+ case C_LNEXT:
+ return VLNEXT;
+#endif /* VLNEXT */
+#ifdef VSTATUS
+ case C_STATUS:
+ return VSTATUS;
+#endif /* VSTATUS */
+#ifdef VPAGE
+ case C_PAGE:
+ return VPAGE;
+#endif /* VPAGE */
+#ifdef VPGOFF
+ case C_PGOFF:
+ return VPGOFF;
+#endif /* VPGOFF */
+#ifdef VKILL2
+ case C_KILL2:
+ return VKILL2;
+#endif /* KILL2 */
+#ifdef VMIN
+ case C_MIN:
+ return VMIN;
+#endif /* VMIN */
+#ifdef VTIME
+ case C_TIME:
+ return VTIME;
+#endif /* VTIME */
+ default:
+ return -1;
+ }
+}
/* tty__getchar():
* Get the tty characters
@@ -1035,13 +1152,14 @@ tty_noquotemode(EditLine *el)
*/
protected int
/*ARGSUSED*/
-tty_stty(EditLine *el, int argc, const char **argv)
+tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
{
const ttymodes_t *m;
char x;
int aflag = 0;
const char *s, *d;
const char *name;
+ struct termios *tios = &el->el_tty.t_ex;
int z = EX_IO;
if (argv == NULL)
@@ -1056,14 +1174,17 @@ tty_stty(EditLine *el, int argc, const char **argv)
break;
case 'd':
argv++;
+ tios = &el->el_tty.t_ed;
z = ED_IO;
break;
case 'x':
argv++;
+ tios = &el->el_tty.t_ex;
z = EX_IO;
break;
case 'q':
argv++;
+ tios = &el->el_tty.t_ts;
z = QU_IO;
break;
default:
@@ -1113,6 +1234,7 @@ tty_stty(EditLine *el, int argc, const char **argv)
return (0);
}
while (argv && (s = *argv++)) {
+ char *p;
switch (*s) {
case '+':
case '-':
@@ -1123,8 +1245,11 @@ tty_stty(EditLine *el, int argc, const char **argv)
break;
}
d = s;
+ if ((p = strchr(s, '=')) != NULL)
+ *p++ = '\0';
for (m = ttymodes; m->m_name; m++)
- if (strcmp(m->m_name, d) == 0)
+ if (strcmp(m->m_name, d) == 0 &&
+ (p == NULL || m->m_type == MD_CHAR))
break;
if (!m->m_name) {
@@ -1132,6 +1257,16 @@ tty_stty(EditLine *el, int argc, const char **argv)
"%s: Invalid argument `%s'.\n", name, d);
return (-1);
}
+ if (p) {
+ int c = ffs((int)m->m_value);
+ int v = *p ? parse__escape((const char **const) &p) :
+ el->el_tty.t_vdisable;
+ assert(c-- != 0);
+ c = tty__getcharindex(c);
+ assert(c != -1);
+ tios->c_cc[c] = v;
+ continue;
+ }
switch (x) {
case '+':
el->el_tty.t_t[z][m->m_type].t_setmask |= m->m_value;
diff --git a/net/tnftp/files/libedit/tty.h b/net/tnftp/files/libedit/tty.h
index cc72c8eb7e3..8af3d1682b1 100644
--- a/net/tnftp/files/libedit/tty.h
+++ b/net/tnftp/files/libedit/tty.h
@@ -1,4 +1,5 @@
-/* $NetBSD: tty.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: tty.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: tty.h,v 1.10 2003/08/07 16:44:34 agc Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
diff --git a/net/tnftp/files/libedit/vi.c b/net/tnftp/files/libedit/vi.c
index 6ce4ac6ee14..23db282ea1a 100644
--- a/net/tnftp/files/libedit/vi.c
+++ b/net/tnftp/files/libedit/vi.c
@@ -1,4 +1,5 @@
-/* $NetBSD: vi.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: vi.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,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 University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -39,6 +36,21 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: vi.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* vi.c: Vi mode commands.
*/
@@ -53,22 +65,18 @@ private el_action_t cv_paste(EditLine *, int);
private el_action_t
cv_action(EditLine *el, int c)
{
- char *cp, *kp;
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
+ /* 'cc', 'dd' and (possibly) friends */
+ if (c != el->el_chared.c_vcmd.action)
+ return CC_ERROR;
+
+ if (!(c & YANK))
+ cv_undo(el);
+ cv_yank(el, el->el_line.buffer,
+ el->el_line.lastchar - el->el_line.buffer);
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_vcmd.pos = 0;
-
- el->el_chared.c_undo.isize = 0;
- el->el_chared.c_undo.dsize = 0;
- kp = el->el_chared.c_undo.buf;
- for (cp = el->el_line.buffer; cp < el->el_line.lastchar; cp++) {
- *kp++ = *cp;
- el->el_chared.c_undo.dsize++;
- }
-
- el->el_chared.c_undo.action = INSERT;
- el->el_chared.c_undo.ptr = el->el_line.buffer;
el->el_line.lastchar = el->el_line.buffer;
el->el_line.cursor = el->el_line.buffer;
if (c & INSERT)
@@ -79,25 +87,8 @@ cv_action(EditLine *el, int c)
el->el_chared.c_vcmd.pos = el->el_line.cursor;
el->el_chared.c_vcmd.action = c;
return (CC_ARGHACK);
-
-#ifdef notdef
- /*
- * I don't think that this is needed. But we keep it for now
- */
- else
- if (el_chared.c_vcmd.action == NOP) {
- el->el_chared.c_vcmd.pos = el->el_line.cursor;
- el->el_chared.c_vcmd.action = c;
- return (CC_ARGHACK);
- } else {
- el->el_chared.c_vcmd.action = 0;
- el->el_chared.c_vcmd.pos = 0;
- return (CC_ERROR);
- }
-#endif
}
-
/* cv_paste():
* Paste previous deletion before or after the cursor
*/
@@ -105,23 +96,25 @@ private el_action_t
cv_paste(EditLine *el, int c)
{
char *ptr;
- c_undo_t *un = &el->el_chared.c_undo;
+ c_kill_t *k = &el->el_chared.c_kill;
+ int len = k->last - k->buf;
+ if (k->buf == NULL || len == 0)
+ return (CC_ERROR);
#ifdef DEBUG_PASTE
- (void) fprintf(el->el_errfile, "Paste: %x \"%s\" +%d -%d\n",
- un->action, un->buf, un->isize, un->dsize);
+ (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", len, k->buf);
#endif
- if (un->isize == 0)
- return (CC_ERROR);
+
+ cv_undo(el);
if (!c && el->el_line.cursor < el->el_line.lastchar)
el->el_line.cursor++;
ptr = el->el_line.cursor;
- c_insert(el, (int) un->isize);
- if (el->el_line.cursor + un->isize > el->el_line.lastchar)
+ c_insert(el, len);
+ if (el->el_line.cursor + len > el->el_line.lastchar)
return (CC_ERROR);
- (void) memcpy(ptr, un->buf, un->isize);
+ (void) memcpy(ptr, k->buf, len +0u);
return (CC_REFRESH);
}
@@ -132,7 +125,7 @@ cv_paste(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_paste_next(EditLine *el, int c)
+vi_paste_next(EditLine *el, int c __attribute__((__unused__)))
{
return (cv_paste(el, 0));
@@ -145,31 +138,31 @@ vi_paste_next(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_paste_prev(EditLine *el, int c)
+vi_paste_prev(EditLine *el, int c __attribute__((__unused__)))
{
return (cv_paste(el, 1));
}
-/* vi_prev_space_word():
+/* vi_prev_big_word():
* Vi move to the previous space delimited word
* [B]
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_space_word(EditLine *el, int c)
+vi_prev_big_word(EditLine *el, int c)
{
if (el->el_line.cursor == el->el_line.buffer)
return (CC_ERROR);
- el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
+ el->el_line.cursor = cv_prev_word(el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
- cv__isword);
+ cv__isWord);
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -179,22 +172,22 @@ vi_prev_space_word(EditLine *el, int c)
/* vi_prev_word():
* Vi move to the previous word
- * [B]
+ * [b]
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_word(EditLine *el, int c)
+vi_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
return (CC_ERROR);
- el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
+ el->el_line.cursor = cv_prev_word(el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
- ce__isword);
+ cv__isword);
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -202,25 +195,23 @@ vi_prev_word(EditLine *el, int c)
}
-/* vi_next_space_word():
+/* vi_next_big_word():
* Vi move to the next space delimited word
* [W]
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_space_word(EditLine *el, int c)
+vi_next_big_word(EditLine *el, int c)
{
- if (el->el_line.cursor == el->el_line.lastchar)
+ if (el->el_line.cursor >= el->el_line.lastchar - 1)
return (CC_ERROR);
el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
- el->el_line.lastchar,
- el->el_state.argument,
- cv__isword);
+ el->el_line.lastchar, el->el_state.argument, cv__isWord);
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -234,19 +225,17 @@ vi_next_space_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_word(EditLine *el, int c)
+vi_next_word(EditLine *el, int c __attribute__((__unused__)))
{
- if (el->el_line.cursor == el->el_line.lastchar)
+ if (el->el_line.cursor >= el->el_line.lastchar - 1)
return (CC_ERROR);
el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
- el->el_line.lastchar,
- el->el_state.argument,
- ce__isword);
+ el->el_line.lastchar, el->el_state.argument, cv__isword);
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -261,19 +250,27 @@ vi_next_word(EditLine *el, int c)
protected el_action_t
vi_change_case(EditLine *el, int c)
{
+ int i;
- if (el->el_line.cursor < el->el_line.lastchar) {
- c = *el->el_line.cursor;
+ if (el->el_line.cursor >= el->el_line.lastchar)
+ return (CC_ERROR);
+ cv_undo(el);
+ for (i = 0; i < el->el_state.argument; i++) {
+
+ c = *(unsigned char *)el->el_line.cursor;
if (isupper(c))
- *el->el_line.cursor++ = tolower(c);
+ *el->el_line.cursor = tolower(c);
else if (islower(c))
- *el->el_line.cursor++ = toupper(c);
- else
- el->el_line.cursor++;
+ *el->el_line.cursor = toupper(c);
+
+ if (++el->el_line.cursor >= el->el_line.lastchar) {
+ el->el_line.cursor--;
+ re_fastaddc(el);
+ break;
+ }
re_fastaddc(el);
- return (CC_NORM);
}
- return (CC_ERROR);
+ return CC_NORM;
}
@@ -283,7 +280,7 @@ vi_change_case(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_change_meta(EditLine *el, int c)
+vi_change_meta(EditLine *el, int c __attribute__((__unused__)))
{
/*
@@ -300,15 +297,11 @@ vi_change_meta(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_insert_at_bol(EditLine *el, int c)
+vi_insert_at_bol(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
- el->el_chared.c_vcmd.ins = el->el_line.cursor;
-
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.action = DELETE;
-
+ cv_undo(el);
el->el_map.current = el->el_map.key;
return (CC_CURSOR);
}
@@ -320,16 +313,16 @@ vi_insert_at_bol(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_replace_char(EditLine *el, int c)
+vi_replace_char(EditLine *el, int c __attribute__((__unused__)))
{
+ if (el->el_line.cursor >= el->el_line.lastchar)
+ return CC_ERROR;
+
el->el_map.current = el->el_map.key;
el->el_state.inputmode = MODE_REPLACE_1;
- el->el_chared.c_undo.action = CHANGE;
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.isize = 0;
- el->el_chared.c_undo.dsize = 0;
- return (CC_NORM);
+ cv_undo(el);
+ return (CC_ARGHACK);
}
@@ -339,26 +332,23 @@ vi_replace_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_replace_mode(EditLine *el, int c)
+vi_replace_mode(EditLine *el, int c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
el->el_state.inputmode = MODE_REPLACE;
- el->el_chared.c_undo.action = CHANGE;
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.isize = 0;
- el->el_chared.c_undo.dsize = 0;
+ cv_undo(el);
return (CC_NORM);
}
/* vi_substitute_char():
* Vi replace character under the cursor and enter insert mode
- * [r]
+ * [s]
*/
protected el_action_t
/*ARGSUSED*/
-vi_substitute_char(EditLine *el, int c)
+vi_substitute_char(EditLine *el, int c __attribute__((__unused__)))
{
c_delafter(el, el->el_state.argument);
@@ -373,9 +363,12 @@ vi_substitute_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_substitute_line(EditLine *el, int c)
+vi_substitute_line(EditLine *el, int c __attribute__((__unused__)))
{
+ cv_undo(el);
+ cv_yank(el, el->el_line.buffer,
+ el->el_line.lastchar - el->el_line.buffer);
(void) em_kill_line(el, 0);
el->el_map.current = el->el_map.key;
return (CC_REFRESH);
@@ -388,9 +381,12 @@ vi_substitute_line(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_change_to_eol(EditLine *el, int c)
+vi_change_to_eol(EditLine *el, int c __attribute__((__unused__)))
{
+ cv_undo(el);
+ cv_yank(el, el->el_line.cursor,
+ el->el_line.lastchar - el->el_line.cursor);
(void) ed_kill_line(el, 0);
el->el_map.current = el->el_map.key;
return (CC_REFRESH);
@@ -403,15 +399,11 @@ vi_change_to_eol(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_insert(EditLine *el, int c)
+vi_insert(EditLine *el, int c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
-
- el->el_chared.c_vcmd.ins = el->el_line.cursor;
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.action = DELETE;
-
+ cv_undo(el);
return (CC_NORM);
}
@@ -422,7 +414,7 @@ vi_insert(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_add(EditLine *el, int c)
+vi_add(EditLine *el, int c __attribute__((__unused__)))
{
int ret;
@@ -435,9 +427,7 @@ vi_add(EditLine *el, int c)
} else
ret = CC_NORM;
- el->el_chared.c_vcmd.ins = el->el_line.cursor;
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.action = DELETE;
+ cv_undo(el);
return (ret);
}
@@ -449,16 +439,12 @@ vi_add(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_add_at_eol(EditLine *el, int c)
+vi_add_at_eol(EditLine *el, int c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
el->el_line.cursor = el->el_line.lastchar;
-
- /* Mark where insertion begins */
- el->el_chared.c_vcmd.ins = el->el_line.lastchar;
- el->el_chared.c_undo.ptr = el->el_line.lastchar;
- el->el_chared.c_undo.action = DELETE;
+ cv_undo(el);
return (CC_CURSOR);
}
@@ -469,29 +455,29 @@ vi_add_at_eol(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_delete_meta(EditLine *el, int c)
+vi_delete_meta(EditLine *el, int c __attribute__((__unused__)))
{
return (cv_action(el, DELETE));
}
-/* vi_end_word():
+/* vi_end_big_word():
* Vi move to the end of the current space delimited word
* [E]
*/
protected el_action_t
/*ARGSUSED*/
-vi_end_word(EditLine *el, int c)
+vi_end_big_word(EditLine *el, int c)
{
if (el->el_line.cursor == el->el_line.lastchar)
return (CC_ERROR);
el->el_line.cursor = cv__endword(el->el_line.cursor,
- el->el_line.lastchar, el->el_state.argument);
+ el->el_line.lastchar, el->el_state.argument, cv__isWord);
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
el->el_line.cursor++;
cv_delfini(el);
return (CC_REFRESH);
@@ -500,22 +486,22 @@ vi_end_word(EditLine *el, int c)
}
-/* vi_to_end_word():
+/* vi_end_word():
* Vi move to the end of the current word
* [e]
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_end_word(EditLine *el, int c)
+vi_end_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
return (CC_ERROR);
el->el_line.cursor = cv__endword(el->el_line.cursor,
- el->el_line.lastchar, el->el_state.argument);
+ el->el_line.lastchar, el->el_state.argument, cv__isword);
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
el->el_line.cursor++;
cv_delfini(el);
return (CC_REFRESH);
@@ -530,102 +516,21 @@ vi_to_end_word(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_undo(EditLine *el, int c)
+vi_undo(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *kp;
- char temp;
- int i, size;
- c_undo_t *un = &el->el_chared.c_undo;
-
-#ifdef DEBUG_UNDO
- (void) fprintf(el->el_errfile, "Undo: %x \"%s\" +%d -%d\n",
- un->action, un->buf, un->isize, un->dsize);
-#endif
- switch (un->action) {
- case DELETE:
- if (un->dsize == 0)
- return (CC_NORM);
-
- (void) memcpy(un->buf, un->ptr, un->dsize);
- for (cp = un->ptr; cp <= el->el_line.lastchar; cp++)
- *cp = cp[un->dsize];
+ c_undo_t un = el->el_chared.c_undo;
- el->el_line.lastchar -= un->dsize;
- el->el_line.cursor = un->ptr;
-
- un->action = INSERT;
- un->isize = un->dsize;
- un->dsize = 0;
- break;
-
- case DELETE | INSERT:
- size = un->isize - un->dsize;
- if (size > 0)
- i = un->dsize;
- else
- i = un->isize;
- cp = un->ptr;
- kp = un->buf;
- while (i-- > 0) {
- temp = *kp;
- *kp++ = *cp;
- *cp++ = temp;
- }
- if (size > 0) {
- el->el_line.cursor = cp;
- c_insert(el, size);
- while (size-- > 0 && cp < el->el_line.lastchar) {
- temp = *kp;
- *kp++ = *cp;
- *cp++ = temp;
- }
- } else if (size < 0) {
- size = -size;
- for (; cp <= el->el_line.lastchar; cp++) {
- *kp++ = *cp;
- *cp = cp[size];
- }
- el->el_line.lastchar -= size;
- }
- el->el_line.cursor = un->ptr;
- i = un->dsize;
- un->dsize = un->isize;
- un->isize = i;
- break;
+ if (un.len == -1)
+ return CC_ERROR;
- case INSERT:
- if (un->isize == 0)
- return (CC_NORM);
-
- el->el_line.cursor = un->ptr;
- c_insert(el, (int) un->isize);
- (void) memcpy(un->ptr, un->buf, un->isize);
- un->action = DELETE;
- un->dsize = un->isize;
- un->isize = 0;
- break;
-
- case CHANGE:
- if (un->isize == 0)
- return (CC_NORM);
-
- el->el_line.cursor = un->ptr;
- size = (int) (el->el_line.cursor - el->el_line.lastchar);
- if (size < un->isize)
- size = un->isize;
- cp = un->ptr;
- kp = un->buf;
- for (i = 0; i < size; i++) {
- temp = *kp;
- *kp++ = *cp;
- *cp++ = temp;
- }
- un->dsize = 0;
- break;
-
- default:
- return (CC_ERROR);
- }
+ /* switch line buffer and undo buffer */
+ el->el_chared.c_undo.buf = el->el_line.buffer;
+ el->el_chared.c_undo.len = el->el_line.lastchar - el->el_line.buffer;
+ el->el_chared.c_undo.cursor = el->el_line.cursor - el->el_line.buffer;
+ el->el_line.limit = un.buf + (el->el_line.limit - el->el_line.buffer);
+ el->el_line.buffer = un.buf;
+ el->el_line.cursor = un.buf + un.cursor;
+ el->el_line.lastchar = un.buf + un.len;
return (CC_REFRESH);
}
@@ -637,24 +542,14 @@ vi_undo(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_command_mode(EditLine *el, int c)
+vi_command_mode(EditLine *el, int c __attribute__((__unused__)))
{
- int size;
/* [Esc] cancels pending action */
- el->el_chared.c_vcmd.ins = 0;
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_vcmd.pos = 0;
el->el_state.doingarg = 0;
- size = el->el_chared.c_undo.ptr - el->el_line.cursor;
- if (size < 0)
- size = -size;
- if (el->el_chared.c_undo.action == (INSERT | DELETE) ||
- el->el_chared.c_undo.action == DELETE)
- el->el_chared.c_undo.dsize = size;
- else
- el->el_chared.c_undo.isize = size;
el->el_state.inputmode = MODE_INSERT;
el->el_map.current = el->el_map.alt;
@@ -674,42 +569,32 @@ protected el_action_t
vi_zero(EditLine *el, int c)
{
- if (el->el_state.doingarg) {
- if (el->el_state.argument > 1000000)
- return (CC_ERROR);
- el->el_state.argument =
- (el->el_state.argument * 10) + (c - '0');
- return (CC_ARGHACK);
- } else {
- el->el_line.cursor = el->el_line.buffer;
- if (el->el_chared.c_vcmd.action & DELETE) {
- cv_delfini(el);
- return (CC_REFRESH);
- }
- return (CC_CURSOR);
+ if (el->el_state.doingarg)
+ return ed_argument_digit(el, c);
+
+ el->el_line.cursor = el->el_line.buffer;
+ if (el->el_chared.c_vcmd.action != NOP) {
+ cv_delfini(el);
+ return (CC_REFRESH);
}
+ return (CC_CURSOR);
}
/* vi_delete_prev_char():
* Vi move to previous character (backspace)
- * [^H]
+ * [^H] in insert mode only
*/
protected el_action_t
/*ARGSUSED*/
-vi_delete_prev_char(EditLine *el, int c)
+vi_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
- if (el->el_chared.c_vcmd.ins == 0)
- return (CC_ERROR);
-
- if (el->el_chared.c_vcmd.ins >
- el->el_line.cursor - el->el_state.argument)
+ if (el->el_line.cursor <= el->el_line.buffer)
return (CC_ERROR);
- c_delbefore(el, el->el_state.argument);
- el->el_line.cursor -= el->el_state.argument;
-
+ c_delbefore1(el);
+ el->el_line.cursor--;
return (CC_REFRESH);
}
@@ -720,23 +605,35 @@ vi_delete_prev_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_list_or_eof(EditLine *el, int c)
+vi_list_or_eof(EditLine *el, int c __attribute__((__unused__)))
{
-#ifdef notyet
- if (el->el_line.cursor == el->el_line.lastchar &&
- el->el_line.cursor == el->el_line.buffer) {
-#endif
- term_overwrite(el, STReof, 4); /* then do a EOF */
- term__flush();
- return (CC_EOF);
-#ifdef notyet
+ if (el->el_line.cursor == el->el_line.lastchar) {
+ if (el->el_line.cursor == el->el_line.buffer) {
+ term_overwrite(el, STReof, 4); /* then do a EOF */
+ term__flush();
+ return (CC_EOF);
+ } else {
+ /*
+ * Here we could list completions, but it is an
+ * error right now
+ */
+ term_beep(el);
+ return (CC_ERROR);
+ }
} else {
+#ifdef notyet
re_goto_bottom(el);
*el->el_line.lastchar = '\0'; /* just in case */
return (CC_LIST_CHOICES);
- }
+#else
+ /*
+ * Just complain for now.
+ */
+ term_beep(el);
+ return (CC_ERROR);
#endif
+ }
}
@@ -746,7 +643,7 @@ vi_list_or_eof(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_kill_line_prev(EditLine *el, int c)
+vi_kill_line_prev(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -767,7 +664,7 @@ vi_kill_line_prev(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_search_prev(EditLine *el, int c)
+vi_search_prev(EditLine *el, int c __attribute__((__unused__)))
{
return (cv_search(el, ED_SEARCH_PREV_HISTORY));
@@ -780,7 +677,7 @@ vi_search_prev(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_search_next(EditLine *el, int c)
+vi_search_next(EditLine *el, int c __attribute__((__unused__)))
{
return (cv_search(el, ED_SEARCH_NEXT_HISTORY));
@@ -793,7 +690,7 @@ vi_search_next(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_search_next(EditLine *el, int c)
+vi_repeat_search_next(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_search.patlen == 0)
@@ -809,7 +706,7 @@ vi_repeat_search_next(EditLine *el, int c)
*/
/*ARGSUSED*/
protected el_action_t
-vi_repeat_search_prev(EditLine *el, int c)
+vi_repeat_search_prev(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_search.patlen == 0)
@@ -827,18 +724,9 @@ vi_repeat_search_prev(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_char(EditLine *el, int c)
+vi_next_char(EditLine *el, int c __attribute__((__unused__)))
{
- char ch;
-
- if (el_getc(el, &ch) != 1)
- return (ed_end_of_file(el, 0));
-
- el->el_search.chadir = CHAR_FWD;
- el->el_search.chacha = ch;
-
- return (cv_csearch_fwd(el, ch, el->el_state.argument, 0));
-
+ return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
}
@@ -848,17 +736,9 @@ vi_next_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_char(EditLine *el, int c)
+vi_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
- char ch;
-
- if (el_getc(el, &ch) != 1)
- return (ed_end_of_file(el, 0));
-
- el->el_search.chadir = CHAR_BACK;
- el->el_search.chacha = ch;
-
- return (cv_csearch_back(el, ch, el->el_state.argument, 0));
+ return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
}
@@ -868,15 +748,9 @@ vi_prev_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_next_char(EditLine *el, int c)
+vi_to_next_char(EditLine *el, int c __attribute__((__unused__)))
{
- char ch;
-
- if (el_getc(el, &ch) != 1)
- return (ed_end_of_file(el, 0));
-
- return (cv_csearch_fwd(el, ch, el->el_state.argument, 1));
-
+ return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
}
@@ -886,14 +760,9 @@ vi_to_next_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_prev_char(EditLine *el, int c)
+vi_to_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
- char ch;
-
- if (el_getc(el, &ch) != 1)
- return (ed_end_of_file(el, 0));
-
- return (cv_csearch_back(el, ch, el->el_state.argument, 1));
+ return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
}
@@ -903,17 +772,11 @@ vi_to_prev_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_next_char(EditLine *el, int c)
+vi_repeat_next_char(EditLine *el, int c __attribute__((__unused__)))
{
- if (el->el_search.chacha == 0)
- return (CC_ERROR);
-
- return (el->el_search.chadir == CHAR_FWD
- ? cv_csearch_fwd(el, el->el_search.chacha,
- el->el_state.argument, 0)
- : cv_csearch_back(el, el->el_search.chacha,
- el->el_state.argument, 0));
+ return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
+ el->el_state.argument, el->el_search.chatflg);
}
@@ -923,13 +786,345 @@ vi_repeat_next_char(EditLine *el, int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_prev_char(EditLine *el, int c)
+vi_repeat_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
+ el_action_t r;
+ int dir = el->el_search.chadir;
- if (el->el_search.chacha == 0)
- return (CC_ERROR);
+ r = cv_csearch(el, -dir, el->el_search.chacha,
+ el->el_state.argument, el->el_search.chatflg);
+ el->el_search.chadir = dir;
+ return r;
+}
+
+
+/* vi_match():
+ * Vi go to matching () {} or []
+ * [%]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_match(EditLine *el, int c)
+{
+ const char match_chars[] = "()[]{}";
+ char *cp;
+ int delta, i, count;
+ char o_ch, c_ch;
+
+ *el->el_line.lastchar = '\0'; /* just in case */
+
+ i = strcspn(el->el_line.cursor, match_chars);
+ o_ch = el->el_line.cursor[i];
+ if (o_ch == 0)
+ return CC_ERROR;
+ delta = strchr(match_chars, o_ch) - match_chars;
+ c_ch = match_chars[delta ^ 1];
+ count = 1;
+ delta = 1 - (delta & 1) * 2;
+
+ for (cp = &el->el_line.cursor[i]; count; ) {
+ cp += delta;
+ if (cp < el->el_line.buffer || cp >= el->el_line.lastchar)
+ return CC_ERROR;
+ if (*cp == o_ch)
+ count++;
+ else if (*cp == c_ch)
+ count--;
+ }
+
+ el->el_line.cursor = cp;
+
+ if (el->el_chared.c_vcmd.action != NOP) {
+ /* NB posix says char under cursor should NOT be deleted
+ for -ve delta - this is different to netbsd vi. */
+ if (delta > 0)
+ el->el_line.cursor++;
+ cv_delfini(el);
+ return (CC_REFRESH);
+ }
+ return (CC_CURSOR);
+}
+
+/* vi_undo_line():
+ * Vi undo all changes to line
+ * [U]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_undo_line(EditLine *el, int c)
+{
+
+ cv_undo(el);
+ return hist_get(el);
+}
+
+/* vi_to_column():
+ * Vi go to specified column
+ * [|]
+ * NB netbsd vi goes to screen column 'n', posix says nth character
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_to_column(EditLine *el, int c)
+{
+
+ el->el_line.cursor = el->el_line.buffer;
+ el->el_state.argument--;
+ return ed_next_char(el, 0);
+}
+
+/* vi_yank_end():
+ * Vi yank to end of line
+ * [Y]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_yank_end(EditLine *el, int c)
+{
+
+ cv_yank(el, el->el_line.cursor,
+ el->el_line.lastchar - el->el_line.cursor);
+ return CC_REFRESH;
+}
+
+/* vi_yank():
+ * Vi yank
+ * [y]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_yank(EditLine *el, int c)
+{
+
+ return cv_action(el, YANK);
+}
+
+/* vi_comment_out():
+ * Vi comment out current command
+ * [c]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_comment_out(EditLine *el, int c)
+{
+
+ el->el_line.cursor = el->el_line.buffer;
+ c_insert(el, 1);
+ *el->el_line.cursor = '#';
+ re_refresh(el);
+ return ed_newline(el, 0);
+}
+
+/* vi_alias():
+ * Vi include shell alias
+ * [@]
+ * NB: posix impiles that we should enter insert mode, however
+ * this is against historical precedent...
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_alias(EditLine *el, int c)
+{
+#ifdef __weak_extern
+ char alias_name[3];
+ char *alias_text;
+ extern char *get_alias_text(const char *);
+ __weak_extern(get_alias_text);
+
+ if (get_alias_text == 0) {
+ return CC_ERROR;
+ }
+
+ alias_name[0] = '_';
+ alias_name[2] = 0;
+ if (el_getc(el, &alias_name[1]) != 1)
+ return CC_ERROR;
+
+ alias_text = get_alias_text(alias_name);
+ if (alias_text != NULL)
+ el_push(el, alias_text);
+ return CC_NORM;
+#else
+ return CC_ERROR;
+#endif
+}
+
+/* vi_to_history_line():
+ * Vi go to specified history file line.
+ * [G]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_to_history_line(EditLine *el, int c)
+{
+ int sv_event_no = el->el_history.eventno;
+ el_action_t rval;
+
+
+ if (el->el_history.eventno == 0) {
+ (void) strncpy(el->el_history.buf, el->el_line.buffer,
+ EL_BUFSIZ);
+ el->el_history.last = el->el_history.buf +
+ (el->el_line.lastchar - el->el_line.buffer);
+ }
+
+ /* Lack of a 'count' means oldest, not 1 */
+ if (!el->el_state.doingarg) {
+ el->el_history.eventno = 0x7fffffff;
+ hist_get(el);
+ } else {
+ /* This is brain dead, all the rest of this code counts
+ * upwards going into the past. Here we need count in the
+ * other direction (to match the output of fc -l).
+ * I could change the world, but this seems to suffice.
+ */
+ el->el_history.eventno = 1;
+ if (hist_get(el) == CC_ERROR)
+ return CC_ERROR;
+ el->el_history.eventno = 1 + el->el_history.ev.num
+ - el->el_state.argument;
+ if (el->el_history.eventno < 0) {
+ el->el_history.eventno = sv_event_no;
+ return CC_ERROR;
+ }
+ }
+ rval = hist_get(el);
+ if (rval == CC_ERROR)
+ el->el_history.eventno = sv_event_no;
+ return rval;
+}
+
+/* vi_histedit():
+ * Vi edit history line with vi
+ * [v]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_histedit(EditLine *el, int c)
+{
+ int fd;
+ pid_t pid;
+ int st;
+ char tempfile[] = "/tmp/histedit.XXXXXXXXXX";
+ char *cp;
+
+ if (el->el_state.doingarg) {
+ if (vi_to_history_line(el, 0) == CC_ERROR)
+ return CC_ERROR;
+ }
+
+ fd = mkstemp(tempfile);
+ if (fd < 0)
+ return CC_ERROR;
+ cp = el->el_line.buffer;
+ write(fd, cp, el->el_line.lastchar - cp +0u);
+ write(fd, "\n", 1);
+ pid = fork();
+ switch (pid) {
+ case -1:
+ close(fd);
+ unlink(tempfile);
+ return CC_ERROR;
+ case 0:
+ close(fd);
+ execlp("vi", "vi", tempfile, 0);
+ exit(0);
+ /*NOTREACHED*/
+ default:
+ while (waitpid(pid, &st, 0) != pid)
+ continue;
+ lseek(fd, 0ll, SEEK_SET);
+ st = read(fd, cp, el->el_line.limit - cp +0u);
+ if (st > 0 && cp[st - 1] == '\n')
+ st--;
+ el->el_line.cursor = cp;
+ el->el_line.lastchar = cp + st;
+ break;
+ }
+
+ close(fd);
+ unlink(tempfile);
+ /* return CC_REFRESH; */
+ return ed_newline(el, 0);
+}
+
+/* vi_history_word():
+ * Vi append word from previous input line
+ * [_]
+ * Who knows where this one came from!
+ * '_' in vi means 'entire current line', so 'cc' is a synonym for 'c_'
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_history_word(EditLine *el, int c)
+{
+ const char *wp = HIST_FIRST(el);
+ const char *wep, *wsp;
+ int len;
+ char *cp;
+ const char *lim;
+
+ if (wp == NULL)
+ return CC_ERROR;
+
+ wep = wsp = 0;
+ do {
+ while (isspace((unsigned char)*wp))
+ wp++;
+ if (*wp == 0)
+ break;
+ wsp = wp;
+ while (*wp && !isspace((unsigned char)*wp))
+ wp++;
+ wep = wp;
+ } while ((!el->el_state.doingarg || --el->el_state.argument > 0) && *wp != 0);
+
+ if (wsp == 0 || (el->el_state.doingarg && el->el_state.argument != 0))
+ return CC_ERROR;
+
+ cv_undo(el);
+ len = wep - wsp;
+ if (el->el_line.cursor < el->el_line.lastchar)
+ el->el_line.cursor++;
+ c_insert(el, len + 1);
+ cp = el->el_line.cursor;
+ lim = el->el_line.limit;
+ if (cp < lim)
+ *cp++ = ' ';
+ while (wsp < wep && cp < lim)
+ *cp++ = *wsp++;
+ el->el_line.cursor = cp;
+
+ el->el_map.current = el->el_map.key;
+ return CC_REFRESH;
+}
+
+/* vi_redo():
+ * Vi redo last non-motion command
+ * [.]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_redo(EditLine *el, int c)
+{
+ c_redo_t *r = &el->el_chared.c_redo;
+
+ if (!el->el_state.doingarg && r->count) {
+ el->el_state.doingarg = 1;
+ el->el_state.argument = r->count;
+ }
+
+ el->el_chared.c_vcmd.pos = el->el_line.cursor;
+ el->el_chared.c_vcmd.action = r->action;
+ if (r->pos != r->buf) {
+ if (r->pos + 1 > r->lim)
+ /* sanity */
+ r->pos = r->lim - 1;
+ r->pos[0] = 0;
+ el_push(el, r->buf);
+ }
- return el->el_search.chadir == CHAR_BACK ?
- cv_csearch_fwd(el, el->el_search.chacha, el->el_state.argument, 0) :
- cv_csearch_back(el, el->el_search.chacha, el->el_state.argument, 0);
+ el->el_state.thiscmd = r->cmd;
+ el->el_state.thisch = r->ch;
+ return (*el->el_map.func[r->cmd])(el, r->ch);
}
diff --git a/net/tnftp/files/libnetbsd/Makefile.in b/net/tnftp/files/libnetbsd/Makefile.in
index 65ccea5e0e5..ee8661b3bf8 100644
--- a/net/tnftp/files/libnetbsd/Makefile.in
+++ b/net/tnftp/files/libnetbsd/Makefile.in
@@ -1,5 +1,4 @@
-#
-# $Id: Makefile.in,v 1.1 2004/03/11 13:01:01 grant Exp $
+# NetBSD: Makefile.in,v 1.3 2005/05/11 01:01:56 lukem Exp
#
srcdir = @srcdir@
diff --git a/net/tnftp/files/libnetbsd/err.c b/net/tnftp/files/libnetbsd/err.c
index 121fcb13467..64004688c56 100644
--- a/net/tnftp/files/libnetbsd/err.c
+++ b/net/tnftp/files/libnetbsd/err.c
@@ -1,4 +1,4 @@
-/* $Id: err.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: err.c,v 1.4 2005/05/11 01:01:56 lukem Exp */
/*
* Copyright 1997-2000 Luke Mewburn <lukem@NetBSD.org>.
diff --git a/net/tnftp/files/libnetbsd/fgetln.c b/net/tnftp/files/libnetbsd/fgetln.c
index 15c4032b036..25bfe98391c 100644
--- a/net/tnftp/files/libnetbsd/fgetln.c
+++ b/net/tnftp/files/libnetbsd/fgetln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetln.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: fgetln.c,v 1.2 2003/02/28 10:44:46 lukem Exp */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
diff --git a/net/tnftp/files/libnetbsd/fparseln.c b/net/tnftp/files/libnetbsd/fparseln.c
index a29ac8eef8a..207b35ee064 100644
--- a/net/tnftp/files/libnetbsd/fparseln.c
+++ b/net/tnftp/files/libnetbsd/fparseln.c
@@ -1,5 +1,5 @@
-/* $Id: fparseln.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: fparseln.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: fparseln.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: fparseln.c,v 1.5 1997/12/01 02:58:41 lukem Exp */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
diff --git a/net/tnftp/files/libnetbsd/fseeko.c b/net/tnftp/files/libnetbsd/fseeko.c
index 8a6ae2a6b82..e6752d7469f 100644
--- a/net/tnftp/files/libnetbsd/fseeko.c
+++ b/net/tnftp/files/libnetbsd/fseeko.c
@@ -1,4 +1,4 @@
-/* $Id: fseeko.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: fseeko.c,v 1.4 2005/05/11 01:01:56 lukem Exp */
/*
* Copyright 2002 Luke Mewburn <lukem@NetBSD.org>.
diff --git a/net/tnftp/files/libnetbsd/ftpglob.h b/net/tnftp/files/libnetbsd/ftpglob.h
index 308056e94be..5c59a6e5423 100644
--- a/net/tnftp/files/libnetbsd/ftpglob.h
+++ b/net/tnftp/files/libnetbsd/ftpglob.h
@@ -1,5 +1,5 @@
-/* $Id: ftpglob.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: ftpglob.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: ftpglob.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: glob.h,v 1.13 2001/03/16 21:02:42 christos Exp */
/*
* Copyright (c) 1989, 1993
diff --git a/net/tnftp/files/libnetbsd/ftpvis.h b/net/tnftp/files/libnetbsd/ftpvis.h
index fcf9e23417e..c13a27f9f53 100644
--- a/net/tnftp/files/libnetbsd/ftpvis.h
+++ b/net/tnftp/files/libnetbsd/ftpvis.h
@@ -1,4 +1,5 @@
-/* $NetBSD: ftpvis.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: ftpvis.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: vis.h,v 1.10 1998/11/13 12:20:18 christos Exp */
/*-
* Copyright (c) 1990, 1993
diff --git a/net/tnftp/files/libnetbsd/getaddrinfo.c b/net/tnftp/files/libnetbsd/getaddrinfo.c
index f24f9774a9f..82f8139ca90 100644
--- a/net/tnftp/files/libnetbsd/getaddrinfo.c
+++ b/net/tnftp/files/libnetbsd/getaddrinfo.c
@@ -1,5 +1,5 @@
-/* $Id: getaddrinfo.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $KAME: getaddrinfo.c,v 1.77 2000/07/09 04:35:14 itojun Exp $ */
+/* NetBSD: getaddrinfo.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from ? */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
diff --git a/net/tnftp/files/libnetbsd/getnameinfo.c b/net/tnftp/files/libnetbsd/getnameinfo.c
index 5bd5f96cb9f..c49f7fc143b 100644
--- a/net/tnftp/files/libnetbsd/getnameinfo.c
+++ b/net/tnftp/files/libnetbsd/getnameinfo.c
@@ -1,6 +1,5 @@
-/* $Id: getnameinfo.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: getnameinfo.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $KAME: getnameinfo.c,v 1.43 2000/06/12 04:27:03 itojun Exp $ */
+/* NetBSD: getnameinfo.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from ? */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
diff --git a/net/tnftp/files/libnetbsd/glob.c b/net/tnftp/files/libnetbsd/glob.c
index d43f2a58421..26ec800729f 100644
--- a/net/tnftp/files/libnetbsd/glob.c
+++ b/net/tnftp/files/libnetbsd/glob.c
@@ -1,5 +1,5 @@
-/* $Id: glob.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: glob.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: glob.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: __glob13.c,v 1.23 2001/09/18 16:37:26 christos Exp */
/*
* Copyright (c) 1989, 1993
diff --git a/net/tnftp/files/libnetbsd/inet_ntop.c b/net/tnftp/files/libnetbsd/inet_ntop.c
index ad13e54cb03..a7b27bd4ad7 100644
--- a/net/tnftp/files/libnetbsd/inet_ntop.c
+++ b/net/tnftp/files/libnetbsd/inet_ntop.c
@@ -1,5 +1,5 @@
-/* $Id: inet_ntop.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: inet_ntop.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: inet_ntop.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: inet_ntop.c,v 1.9 2000/01/22 22:19:16 mycroft Exp */
/* Copyright (c) 1996 by Internet Software Consortium.
*
diff --git a/net/tnftp/files/libnetbsd/inet_pton.c b/net/tnftp/files/libnetbsd/inet_pton.c
index cecafc485fb..ea846b48e23 100644
--- a/net/tnftp/files/libnetbsd/inet_pton.c
+++ b/net/tnftp/files/libnetbsd/inet_pton.c
@@ -1,5 +1,5 @@
-/* $Id: inet_pton.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: inet_pton.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: inet_pton.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp */
/* Copyright (c) 1996 by Internet Software Consortium.
*
diff --git a/net/tnftp/files/libnetbsd/mkstemp.c b/net/tnftp/files/libnetbsd/mkstemp.c
index f9adbe95593..2941a14f0f9 100644
--- a/net/tnftp/files/libnetbsd/mkstemp.c
+++ b/net/tnftp/files/libnetbsd/mkstemp.c
@@ -1,5 +1,5 @@
-/* $Id: mkstemp.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: mkstemp.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: mkstemp.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: gettemp.c,v 1.5 1999/09/20 04:39:30 lukem Exp */
/*
* Copyright (c) 1987, 1993
diff --git a/net/tnftp/files/libnetbsd/setprogname.c b/net/tnftp/files/libnetbsd/setprogname.c
index 856b8d0f129..6e60d5d22ae 100644
--- a/net/tnftp/files/libnetbsd/setprogname.c
+++ b/net/tnftp/files/libnetbsd/setprogname.c
@@ -1,5 +1,5 @@
-/* $Id: setprogname.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: setprogname.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: setprogname.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: setprogname.c,v 1.3 2002/01/31 19:21:58 tv Exp */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
diff --git a/net/tnftp/files/libnetbsd/sl_init.c b/net/tnftp/files/libnetbsd/sl_init.c
index 591d78ef00a..71e86c428d4 100644
--- a/net/tnftp/files/libnetbsd/sl_init.c
+++ b/net/tnftp/files/libnetbsd/sl_init.c
@@ -1,5 +1,5 @@
-/* $Id: sl_init.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: sl_init.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: sl_init.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: stringlist.c,v 1.8 1999/11/28 03:44:09 lukem Exp */
/*-
* Copyright (c) 1994, 1999 The NetBSD Foundation, Inc.
diff --git a/net/tnftp/files/libnetbsd/snprintf.c b/net/tnftp/files/libnetbsd/snprintf.c
index ad2cae886b5..4765ca8751d 100644
--- a/net/tnftp/files/libnetbsd/snprintf.c
+++ b/net/tnftp/files/libnetbsd/snprintf.c
@@ -1,4 +1,4 @@
-/* $Id: snprintf.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: snprintf.c,v 1.4 2005/05/11 01:01:56 lukem Exp */
/*
* Copyright Patrick Powell 1995
diff --git a/net/tnftp/files/libnetbsd/strdup.c b/net/tnftp/files/libnetbsd/strdup.c
index 9e4d145b195..e6c0c32a1a6 100644
--- a/net/tnftp/files/libnetbsd/strdup.c
+++ b/net/tnftp/files/libnetbsd/strdup.c
@@ -1,5 +1,5 @@
-/* $Id: strdup.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strdup.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strdup.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strdup.c,v 1.11 1999/09/20 04:3 9:46 lukem Exp */
/*
* Copyright (c) 1988, 1993
diff --git a/net/tnftp/files/libnetbsd/strerror.c b/net/tnftp/files/libnetbsd/strerror.c
index a835a3be37d..7d610c042fa 100644
--- a/net/tnftp/files/libnetbsd/strerror.c
+++ b/net/tnftp/files/libnetbsd/strerror.c
@@ -1,4 +1,4 @@
-/* $Id: strerror.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strerror.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
#include "tnftp.h"
diff --git a/net/tnftp/files/libnetbsd/strlcat.c b/net/tnftp/files/libnetbsd/strlcat.c
index b8ec6721321..e50fa35adec 100644
--- a/net/tnftp/files/libnetbsd/strlcat.c
+++ b/net/tnftp/files/libnetbsd/strlcat.c
@@ -1,5 +1,5 @@
-/* $Id: strlcat.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strlcat.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strlcat.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/*
diff --git a/net/tnftp/files/libnetbsd/strlcpy.c b/net/tnftp/files/libnetbsd/strlcpy.c
index b7eec08827b..9446235b5e7 100644
--- a/net/tnftp/files/libnetbsd/strlcpy.c
+++ b/net/tnftp/files/libnetbsd/strlcpy.c
@@ -1,5 +1,5 @@
-/* $Id: strlcpy.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strlcpy.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strlcpy.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/*
diff --git a/net/tnftp/files/libnetbsd/strptime.c b/net/tnftp/files/libnetbsd/strptime.c
index 053ddbd4100..87f5b251278 100644
--- a/net/tnftp/files/libnetbsd/strptime.c
+++ b/net/tnftp/files/libnetbsd/strptime.c
@@ -1,5 +1,5 @@
-/* $Id: strptime.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strptime.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strptime.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
diff --git a/net/tnftp/files/libnetbsd/strsep.c b/net/tnftp/files/libnetbsd/strsep.c
index 1074129173d..565728be0ef 100644
--- a/net/tnftp/files/libnetbsd/strsep.c
+++ b/net/tnftp/files/libnetbsd/strsep.c
@@ -1,5 +1,5 @@
-/* $Id: strsep.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strsep.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strsep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strsep.c,v 1.10 1999/09/20 04:39:48 lukem Exp */
/*-
* Copyright (c) 1990, 1993
diff --git a/net/tnftp/files/libnetbsd/strtoll.c b/net/tnftp/files/libnetbsd/strtoll.c
index 07066625da9..a67fddd51ef 100644
--- a/net/tnftp/files/libnetbsd/strtoll.c
+++ b/net/tnftp/files/libnetbsd/strtoll.c
@@ -1,5 +1,5 @@
-/* $Id: strtoll.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strtoll.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strtoll.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: strtoq.c,v 1.14 1999/09/20 04:39:42 lukem Exp */
/*-
* Copyright (c) 1992, 1993
diff --git a/net/tnftp/files/libnetbsd/strunvis.c b/net/tnftp/files/libnetbsd/strunvis.c
index 2a1a6eeb535..35d1c78f895 100644
--- a/net/tnftp/files/libnetbsd/strunvis.c
+++ b/net/tnftp/files/libnetbsd/strunvis.c
@@ -1,5 +1,5 @@
-/* $Id: strunvis.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strunvis.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strunvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: unvis.c,v 1.16 1999/09/20 04:39:06 lukem Exp */
/*-
* Copyright (c) 1989, 1993
diff --git a/net/tnftp/files/libnetbsd/strvis.c b/net/tnftp/files/libnetbsd/strvis.c
index 0475c563444..7f369f86334 100644
--- a/net/tnftp/files/libnetbsd/strvis.c
+++ b/net/tnftp/files/libnetbsd/strvis.c
@@ -1,5 +1,5 @@
-/* $Id: strvis.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
-/* $NetBSD: strvis.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: strvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from NetBSD: vis.c,v 1.13 1999/09/20 04:39:07 lukem Exp */
/*-
* Copyright (c) 1989, 1993
diff --git a/net/tnftp/files/libnetbsd/timegm.c b/net/tnftp/files/libnetbsd/timegm.c
index 126db278e00..094f8d1aaee 100644
--- a/net/tnftp/files/libnetbsd/timegm.c
+++ b/net/tnftp/files/libnetbsd/timegm.c
@@ -1,4 +1,5 @@
-/* $Id: timegm.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: timegm.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+/* from ? */
#include "tnftp.h"
diff --git a/net/tnftp/files/libnetbsd/usleep.c b/net/tnftp/files/libnetbsd/usleep.c
index 4f8d1986280..788d51694bb 100644
--- a/net/tnftp/files/libnetbsd/usleep.c
+++ b/net/tnftp/files/libnetbsd/usleep.c
@@ -1,4 +1,5 @@
-/* $Id: usleep.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: usleep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
+
/*-
* Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
* All rights reserved.
diff --git a/net/tnftp/files/src/Makefile.in b/net/tnftp/files/src/Makefile.in
index b9d6d7df583..6d6d75df0b5 100644
--- a/net/tnftp/files/src/Makefile.in
+++ b/net/tnftp/files/src/Makefile.in
@@ -1,5 +1,4 @@
-#
-# $Id: Makefile.in,v 1.1 2004/03/11 13:01:01 grant Exp $
+# NetBSD: Makefile.in,v 1.3 2005/05/11 03:01:40 lukem Exp
#
srcdir = @srcdir@
diff --git a/net/tnftp/files/src/complete.c b/net/tnftp/files/src/complete.c
index d911ab271fd..60578967665 100644
--- a/net/tnftp/files/src/complete.c
+++ b/net/tnftp/files/src/complete.c
@@ -1,4 +1,5 @@
-/* $NetBSD: complete.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: complete.c,v 1.3 2005/05/11 02:41:28 lukem Exp */
+/* from NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp */
/*-
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
@@ -36,6 +37,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#if 0
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("NetBSD: complete.c,v 1.3 2005/05/11 02:41:28 lukem Exp");
+#endif /* not lint */
+#endif
+
/*
* FTP user program - command and file completion routines
*/