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

Obtained from:	NetBSD
This commit is contained in:
David E. O'Brien 2011-03-31 18:31:27 +00:00
parent 307eee7ed0
commit 8dfe73baa3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/libedit/dist/; revision=220218
svn path=/vendor/NetBSD/libedit/2007-01-12/; revision=220219; tag=vendor/NetBSD/libedit/2007-01-12
19 changed files with 422 additions and 198 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.34 2005/05/28 12:02:53 lukem Exp $
# $NetBSD: Makefile,v 1.35 2006/08/31 20:20:38 rpaulo Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@ -37,7 +37,7 @@ INCSDIR=/usr/include
CLEANFILES+=editline.c
CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp
CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp
CLEANFILES+=test.o test
CLEANFILES+=tc1.o tc1
CPPFLAGS+=-I. -I${LIBEDITDIR}
CPPFLAGS+=-I. -I${.CURDIR}
CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
@ -94,9 +94,9 @@ editline.c: ${OSRCS} makelist Makefile
${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \
mv ${.TARGET}.tmp ${.TARGET}
test.o: ${LIBEDITDIR}/TEST/test.c
tc1.o: ${LIBEDITDIR}/TEST/tc1.c
test: libedit.a test.o
tc1: libedit.a tc1.o
${_MKTARGET_LINK}
${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermcap

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.2 2003/12/05 13:37:48 lukem Exp $
# $NetBSD: Makefile,v 1.3 2006/08/31 20:20:38 rpaulo Exp $
NOMAN=1
PROG=test
PROG=tc1
CPPFLAGS=-I${.CURDIR}/..
LDADD+=-ledit -ltermcap
DPADD+=${LIBEDIT} ${LIBTERMCAP}

View File

@ -1,4 +1,4 @@
/* $NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $ */
/* $NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: test.c,v 1.18 2005/06/01 11:37:52 lukem Exp $");
__RCSID("$NetBSD: tc1.c,v 1.1 2006/08/31 20:20:38 rpaulo Exp $");
#endif
#endif /* not lint && not SCCSID */

View File

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

View File

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

176
el.c
View File

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

3
el.h
View File

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

View File

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

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecomplete.h,v 1.4 2005/06/11 18:18:59 christos Exp $ */
/* $NetBSD: filecomplete.h,v 1.5 2006/08/21 12:45:30 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: histedit.h,v 1.28 2005/07/14 15:00:58 christos Exp $ */
/* $NetBSD: histedit.h,v 1.31 2006/12/15 22:13:33 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
#define _HISTEDIT_H_
#define LIBEDIT_MAJOR 2
#define LIBEDIT_MINOR 9
#define LIBEDIT_MINOR 10
#include <sys/types.h>
#include <stdio.h>
@ -109,7 +109,7 @@ int el_parse(EditLine *, int, const char **);
* Low level editline access functions
*/
int el_set(EditLine *, int, ...);
int el_get(EditLine *, int, void *);
int el_get(EditLine *, int, ...);
unsigned char _el_fn_complete(EditLine *, int);
/*
@ -133,6 +133,9 @@ unsigned char _el_fn_complete(EditLine *, int);
#define EL_CLIENTDATA 14 /* , void *); */
#define EL_UNBUFFERED 15 /* , int); */
#define EL_PREP_TERM 16 /* , int); */
#define EL_GETTC 17 /* , const char *, ..., NULL); */
#define EL_GETFP 18 /* , int, FILE **) */
#define EL_SETFP 19 /* , int, FILE *) */
#define EL_BUILTIN_GETCFN (NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: history.c,v 1.31 2005/08/01 14:34:06 christos Exp $ */
/* $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: history.c,v 1.31 2005/08/01 14:34:06 christos Exp $");
__RCSID("$NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -548,6 +548,7 @@ history_end(History *h)
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
h_free(h->h_ref);
h_free(h);
}

6
map.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $ */
/* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: map.c,v 1.23 2006/03/06 21:11:56 christos Exp $");
__RCSID("$NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -1383,7 +1383,7 @@ map_bind(EditLine *el, int argc, const char **argv)
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type\n", ntype));
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
break;
}
return (0);

8
read.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp $ */
/* $NetBSD: read.h,v 1.5 2006/08/21 12:45:30 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $ */
/* $NetBSD: readline.c,v 1.70 2006/11/24 00:01:17 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -38,7 +34,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $");
__RCSID("$NetBSD: readline.c,v 1.70 2006/11/24 00:01:17 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@ -53,6 +49,7 @@ __RCSID("$NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $");
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#ifdef HAVE_VIS_H
#include <vis.h>
#else
@ -67,6 +64,9 @@ __RCSID("$NetBSD: readline.c,v 1.66 2006/03/21 17:52:50 christos Exp $");
#include "readline/readline.h"
#include "filecomplete.h"
void rl_prep_terminal(int);
void rl_deprep_terminal(void);
/* for rl_complete() */
#define TAB '\r'
@ -89,6 +89,9 @@ char *rl_line_buffer = NULL;
VCPFunction *rl_linefunc = NULL;
int rl_done = 0;
VFunction *rl_event_hook = NULL;
KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
emacs_meta_keymap,
emacs_ctlx_keymap;
int history_base = 1; /* probably never subject to change */
int history_length = 0;
@ -114,11 +117,13 @@ int rl_already_prompted = 0;
int rl_filename_completion_desired = 0;
int rl_ignore_completion_duplicates = 0;
int rl_catch_signals = 1;
int readline_echoing_p = 1;
int _rl_print_completions_horizontally = 0;
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;
VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
/*
* The current prompt string.
@ -155,6 +160,7 @@ int rl_completion_append_character = ' ';
static History *h = NULL;
static EditLine *e = NULL;
static Function *map[256];
static jmp_buf topbuf;
/* internal functions */
static unsigned char _el_rl_complete(EditLine *, int);
@ -323,9 +329,10 @@ rl_initialize(void)
* trailing newline (if there is any)
*/
char *
readline(const char *prompt)
readline(const char *p)
{
HistEvent ev;
const char * volatile prompt = p;
int count;
const char *ret;
char *buf;
@ -336,6 +343,8 @@ readline(const char *prompt)
rl_done = 0;
(void)setjmp(topbuf);
/* update prompt accordingly to what has been passed */
if (!prompt)
prompt = "";
@ -921,10 +930,6 @@ loop:
ret = 1;
break;
}
if (tmp) {
free(tmp);
tmp = NULL;
}
ret = _history_expand_command (str, i, (j - i), &tmp);
if (ret > 0 && tmp) {
len = strlen(tmp);
@ -1715,7 +1720,7 @@ rl_prep_terminal(int meta_flag)
}
void
rl_deprep_terminal()
rl_deprep_terminal(void)
{
el_set(e, EL_PREP_TERM, 0);
}
@ -1810,3 +1815,82 @@ _rl_update_pos(void)
rl_point = li->cursor - li->buffer;
rl_end = li->lastchar - li->buffer;
}
void
rl_get_screen_size(int *rows, int *cols)
{
if (rows)
el_get(e, EL_GETTC, "li", rows);
if (cols)
el_get(e, EL_GETTC, "co", cols);
}
void
rl_set_screen_size(int rows, int cols)
{
char buf[64];
(void)snprintf(buf, sizeof(buf), "%d", rows);
el_set(e, EL_SETTC, "li", buf);
(void)snprintf(buf, sizeof(buf), "%d", cols);
el_set(e, EL_SETTC, "co", buf);
}
char *
rl_filename_completion_function (const char *text, int state)
{
return fn_filename_completion_function(text, state);
}
int
_rl_abort_internal(void)
{
el_beep(e);
longjmp(topbuf, 1);
/*NOTREACHED*/
}
int
_rl_qsort_string_compare(char **s1, char **s2)
{
return strcoll(*s1, *s2);
}
int
/*ARGSUSED*/
rl_kill_text(int from, int to)
{
return 0;
}
Keymap
rl_make_bare_keymap(void)
{
return NULL;
}
Keymap
rl_get_keymap(void)
{
return NULL;
}
void
/*ARGSUSED*/
rl_set_keymap(Keymap k)
{
}
int
/*ARGSUSED*/
rl_generic_bind(int type, const char * keyseq, const char * data, Keymap k)
{
return 0;
}
int
/*ARGSUSED*/
rl_bind_key_in_map(int key, Function *fun, Keymap k)
{
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: readline.h,v 1.17 2005/07/14 15:00:58 christos Exp $ */
/* $NetBSD: readline.h,v 1.19 2006/11/24 00:01:17 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -127,6 +123,8 @@ extern VFunction *rl_redisplay_function;
extern VFunction *rl_completion_display_matches_hook;
extern VFunction *rl_prep_term_function;
extern VFunction *rl_deprep_term_function;
extern int readline_echoing_p;
extern int _rl_print_completions_horizontally;
/* supported functions */
char *readline(const char *);
@ -180,11 +178,18 @@ int rl_parse_and_bind(const char *);
int rl_variable_bind(const char *, const char *);
void rl_stuff_char(int);
int rl_add_defun(const char *, Function *, int);
void rl_get_screen_size(int *, int *);
void rl_set_screen_size(int, int);
char *rl_filename_completion_function (const char *, int);
int _rl_abort_internal(void);
int _rl_qsort_string_compare(char **, char **);
/*
* The following are not implemented
*/
int rl_kill_text(int, int);
Keymap rl_get_keymap(void);
void rl_set_keymap(Keymap);
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);

View File

@ -1,5 +1,5 @@
# $NetBSD: shlib_version,v 1.15 2003/12/05 13:37:48 lukem Exp $
# $NetBSD: shlib_version,v 1.16 2006/11/24 00:01:17 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=2
minor=9
minor=10

130
term.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: term.c,v 1.45 2006/03/18 19:23:14 christos Exp $ */
/* $NetBSD: term.c,v 1.46 2006/11/24 00:01:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
__RCSID("$NetBSD: term.c,v 1.45 2006/03/18 19:23:14 christos Exp $");
__RCSID("$NetBSD: term.c,v 1.46 2006/11/24 00:01:17 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -1328,7 +1328,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
const char *what, *how;
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
return (-1);
return -1;
what = argv[1];
how = argv[2];
@ -1343,7 +1343,7 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
if (ts->name != NULL) {
term_alloc(el, ts, how);
term_setflags(el);
return (0);
return 0;
}
/*
* Do the numeric ones second
@ -1352,46 +1352,100 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)),
if (strcmp(tv->name, what) == 0)
break;
if (tv->name != NULL) {
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
tv == &tval[T_am] || tv == &tval[T_xn]) {
if (strcmp(how, "yes") == 0)
el->el_term.t_val[tv - tval] = 1;
else if (strcmp(how, "no") == 0)
el->el_term.t_val[tv - tval] = 0;
else {
(void) fprintf(el->el_errfile,
"settc: Bad value `%s'.\n", how);
return (-1);
}
term_setflags(el);
if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
return (-1);
return (0);
} else {
long i;
char *ep;
if (tv->name != NULL)
return -1;
i = strtol(how, &ep, 10);
if (*ep != '\0') {
(void) fprintf(el->el_errfile,
"settc: Bad value `%s'.\n", how);
return (-1);
}
el->el_term.t_val[tv - tval] = (int) i;
el->el_term.t_size.v = Val(T_co);
el->el_term.t_size.h = Val(T_li);
if (tv == &tval[T_co] || tv == &tval[T_li])
if (term_change_size(el, Val(T_li), Val(T_co))
== -1)
return (-1);
return (0);
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
tv == &tval[T_am] || tv == &tval[T_xn]) {
if (strcmp(how, "yes") == 0)
el->el_term.t_val[tv - tval] = 1;
else if (strcmp(how, "no") == 0)
el->el_term.t_val[tv - tval] = 0;
else {
(void) fprintf(el->el_errfile,
"%s: Bad value `%s'.\n", argv[0], how);
return -1;
}
term_setflags(el);
if (term_change_size(el, Val(T_li), Val(T_co)) == -1)
return -1;
return 0;
} else {
long i;
char *ep;
i = strtol(how, &ep, 10);
if (*ep != '\0') {
(void) fprintf(el->el_errfile,
"%s: Bad value `%s'.\n", argv[0], how);
return -1;
}
el->el_term.t_val[tv - tval] = (int) i;
el->el_term.t_size.v = Val(T_co);
el->el_term.t_size.h = Val(T_li);
if (tv == &tval[T_co] || tv == &tval[T_li])
if (term_change_size(el, Val(T_li), Val(T_co))
== -1)
return -1;
return 0;
}
return (-1);
}
/* term_gettc():
* Get the current terminal characteristics
*/
protected int
/*ARGSUSED*/
term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
{
const struct termcapstr *ts;
const struct termcapval *tv;
char *what;
void *how;
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
return (-1);
what = argv[1];
how = argv[2];
/*
* Do the strings first
*/
for (ts = tstr; ts->name != NULL; ts++)
if (strcmp(ts->name, what) == 0)
break;
if (ts->name != NULL) {
*(char **)how = el->el_term.t_str[ts - tstr];
return 0;
}
/*
* Do the numeric ones second
*/
for (tv = tval; tv->name != NULL; tv++)
if (strcmp(tv->name, what) == 0)
break;
if (tv->name == NULL)
return -1;
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
tv == &tval[T_am] || tv == &tval[T_xn]) {
static char yes[] = "yes";
static char no[] = "no";
if (el->el_term.t_val[tv - tval])
*(char **)how = yes;
else
*(char **)how = no;
return 0;
} else {
*(int *)how = el->el_term.t_val[tv - tval];
return 0;
}
}
/* term_echotc():
* Print the termcap string out with variable substitution
*/

3
term.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: term.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */
/* $NetBSD: term.h,v 1.18 2006/11/24 00:01:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -100,6 +100,7 @@ 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_gettc(EditLine *, int, char **);
protected int term_telltc(EditLine *, int, const char **);
protected int term_echotc(EditLine *, int, const char **);
protected void term_writec(EditLine *, int);

11
vi.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: vi.c,v 1.25 2006/03/06 21:11:56 christos Exp $ */
/* $NetBSD: vi.c,v 1.27 2006/10/22 07:48:13 mrg Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: vi.c,v 1.25 2006/03/06 21:11:56 christos Exp $");
__RCSID("$NetBSD: vi.c,v 1.27 2006/10/22 07:48:13 mrg Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -915,15 +915,16 @@ vi_comment_out(EditLine *el, int c)
* NB: posix implies that we should enter insert mode, however
* this is against historical precedent...
*/
#ifdef __weak_reference
extern char *get_alias_text(const char *) __weak_reference(get_alias_text);
#endif
protected el_action_t
/*ARGSUSED*/
vi_alias(EditLine *el, int c)
{
#ifdef __weak_extern
#ifdef __weak_reference
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;