Project

General

Profile

Bug #619 ยป libedit.patch

pavalos, 04/28/2007 11:23 PM

View differences:

include/histedit.h 28 Apr 2007 17:52:08 -0000
/* $DragonFly: src/include/histedit.h,v 1.4 2005/11/13 11:58:30 corecode Exp $ */
/* $NetBSD: histedit.h,v 1.27 2005/06/12 06:58:21 christos Exp $ */
/* $NetBSD: histedit.h,v 1.31 2006/12/15 22:13:33 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
......
* 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);
/*
......
#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)
......
#define H_CLEAR 19 /* , void); */
#define H_SETUNIQUE 20 /* , int); */
#define H_GETUNIQUE 21 /* , void); */
#define H_DEL 22 /* , int); */
/*
lib/libedit/Makefile 28 Apr 2007 19:46:00 -0000
fcns.h: ${AHDR} makelist
sh ${.CURDIR}/makelist -fh ${AHDR} > ${.TARGET}
fcns.c: ${AHDR} fcns.h makelist
fcns.c: ${AHDR} fcns.h help.h makelist
sh ${.CURDIR}/makelist -fc ${AHDR} > ${.TARGET}
help.c: ${ASRC} makelist
......
help.h: ${ASRC} makelist
sh ${.CURDIR}/makelist -bh ${ASRC} > ${.TARGET}
editline.c:
editline.c: ${OSRCS} makelist
sh ${.CURDIR}/makelist -e ${OSRCS} > ${.TARGET}
beforedepend editline.o editline.po editline.So: \
lib/libedit/chared.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)chared.c 8.1 (Berkeley) 6/4/93
* $NetBSD: chared.c,v 1.23 2005/06/01 11:37:52 lukem Exp $
* $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $
* $DragonFly: src/lib/libedit/chared.c,v 1.7 2005/11/13 11:58:30 corecode Exp $
*/
......
#include <stdlib.h>
#include "el.h"
private void ch__clearmacro(EditLine *);
/* value to leave unused in line buffer */
#define EL_LEAVE 2
......
protected int
ch_init(EditLine *el)
{
c_macro_t *ma = &el->el_chared.c_macro;
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
if (el->el_line.buffer == NULL)
return (-1);
......
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
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)
ma->level = -1;
ma->offset = 0;
ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
if (ma->macro == NULL)
return (-1);
return (0);
}
......
* Reset the character editor
*/
protected void
ch_reset(EditLine *el)
ch_reset(EditLine *el, int mclear)
{
el->el_line.cursor = el->el_line.buffer;
el->el_line.lastchar = el->el_line.buffer;
......
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
el->el_chared.c_macro.level = -1;
el->el_history.eventno = 0;
if (mclear)
ch__clearmacro(el);
}
private void
ch__clearmacro(el)
EditLine *el;
{
c_macro_t *ma = &el->el_chared.c_macro;
while (ma->level >= 0)
el_free((ptr_t)ma->macro[ma->level--]);
}
/* ch_enlargebufs():
......
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;
ch_reset(el, 1);
el_free((ptr_t) el->el_chared.c_macro.macro);
el->el_chared.c_macro.macro = NULL;
ch_reset(el);
}
lib/libedit/chared.h 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)chared.h 8.1 (Berkeley) 6/4/93
* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $
* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $
* $DragonFly: src/lib/libedit/chared.h,v 1.4 2005/11/13 11:58:30 corecode Exp $
*/
......
#define EL_MAXMACRO 10
/*
* This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
* This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
* like real vi: i.e. the transition from command<->insert modes moves
* the cursor.
*
......
} el_chared_t;
#define STReof "^D\b\b"
#define STRQQ "\"\""
#define isglob(a) (strchr("*[]?", (a)) != NULL)
......
protected int c_hpos(EditLine *);
protected int ch_init(EditLine *);
protected void ch_reset(EditLine *);
protected void ch_reset(EditLine *, int);
protected int ch_enlargebufs(EditLine *, size_t);
protected void ch_end(EditLine *);
lib/libedit/common.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)common.c 8.1 (Berkeley) 6/4/93
* $NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $
* $NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $
* $DragonFly: src/lib/libedit/common.c,v 1.5 2005/11/13 11:58:30 corecode Exp $
*/
......
*/
protected el_action_t
/*ARGSUSED*/
ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
ed_delete_next_char(EditLine *el, int c)
{
#ifdef notdef /* XXX */
#define EL el->el_line
......
#ifdef KSHVI
return (CC_ERROR);
#else
term_overwrite(el, STReof, 4);
/* then do a EOF */
term__flush();
/* then do an EOF */
term_writechar(el, c);
return (CC_EOF);
#endif
} else {
......
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
{
ch_reset(el);
ch_reset(el, 0);
return (CC_REFRESH);
}
lib/libedit/editline.3 28 Apr 2007 17:52:08 -0000
.\" 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.
.\"
......
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $NetBSD: editline.3,v 1.46 2005/03/19 17:36:02 christos Exp $
.\" $NetBSD: editline.3,v 1.55 2007/01/12 16:31:13 christos Exp $
.\" $DragonFly: src/lib/libedit/editline.3,v 1.3 2005/11/13 11:58:30 corecode Exp $
.\"
.Dd March 19, 2005
.Dd January 12, 2007
.Os
.Dt EDITLINE 3
.Sh NAME
......
.Nm el_push ,
.Nm el_parse ,
.Nm el_set ,
.Nm el_get ,
.Nm el_source ,
.Nm el_resize ,
.Nm el_line ,
......
.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
......
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
......
.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"
......
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
......
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
......
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.
Set flag that 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.
Retrieve the current setting if adjacent identical elements should
be entered into the history.
.It Dv H_DEL , Fa "int e"
Delete the event numbered
.Fa e .
This function is only provided for
.Xr readline 3
compatibility.
The caller is responsible for free'ing the string in the returned
.Fa HistEvent .
.El
.Pp
.Fn history
......
.Xr sh 1 ,
.Xr signal 3 ,
.Xr termcap 3 ,
.Xr editrc 5
.Xr editrc 5 ,
.Xr termcap 5
.Sh HISTORY
The
.Nm
lib/libedit/editrc.5 28 Apr 2007 17:52:08 -0000
.\" 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.
.\"
......
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $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 $
.\" $DragonFly: src/lib/libedit/editrc.5,v 1.4 2006/03/27 16:45:43 swildner Exp $
.\"
.Dd October 18, 2003
lib/libedit/el.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)el.c 8.2 (Berkeley) 1/3/94
* $NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp $
* $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $
* $DragonFly: src/lib/libedit/el.c,v 1.5 2005/11/13 11:58:30 corecode Exp $
*/
......
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;
......
{
tty_cookedmode(el);
ch_reset(el); /* XXX: Do we want that? */
ch_reset(el, 0); /* XXX: Do we want that? */
}
......
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;
......
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
case EL_GETTC:
case EL_ECHOTC:
case EL_SETTY:
{
......
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) {
......
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;
......
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;
......
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);
......
break;
case EL_PREP_TERM:
rv = va_arg(va, int);
rv = va_arg(ap, int);
if (rv)
(void) tty_rawmode(el);
else
......
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);
}
......
* 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, (void *) &ret, op);
rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op);
break;
case EL_EDITOR:
rv = map_get_editor(el, (void *) &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;
......
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);
}
lib/libedit/el.h 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)el.h 8.1 (Berkeley) 6/4/93
* $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 $
* $DragonFly: src/lib/libedit/el.h,v 1.2 2005/11/13 11:58:30 corecode Exp $
*/
......
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 */
lib/libedit/emacs.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)emacs.c 8.1 (Berkeley) 6/4/93
* $NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $
* $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $
* $DragonFly: src/lib/libedit/emacs.c,v 1.5 2005/11/13 11:58:30 corecode Exp $
*/
......
*/
protected el_action_t
/*ARGSUSED*/
em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
em_delete_or_list(EditLine *el, int c)
{
if (el->el_line.cursor == el->el_line.lastchar) {
/* if I'm at the end */
if (el->el_line.cursor == el->el_line.buffer) {
/* and the beginning */
term_overwrite(el, STReof, 4); /* then do a EOF */
term__flush();
term_writec(el, c); /* then do an EOF */
return (CC_EOF);
} else {
/*
lib/libedit/filecomplete.c 28 Apr 2007 17:52:08 -0000
* 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.
*
......
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: filecomplete.c,v 1.7 2005/06/11 18:18:59 christos Exp $
* $NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $
* $DragonFly: src/lib/libedit/filecomplete.c,v 1.1 2005/11/13 11:58:30 corecode Exp $
*/
......
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 = '?';
......
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';
......
} else
matches = 0;
if (!attempted_completion_function ||
(over != NULL && *over && !matches))
(over != NULL && !*over && !matches))
matches = completion_matches(temp, complet_func);
if (over != NULL)
*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.
......
/* 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;
}
/*
lib/libedit/filecomplete.h 28 Apr 2007 17:52:08 -0000
* 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.
*
......
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $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 $
* $DragonFly: src/lib/libedit/filecomplete.h,v 1.1 2005/11/13 11:58:30 corecode Exp $
*/
#ifndef _FILECOMPLETE_H_
lib/libedit/history.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)history.c 8.1 (Berkeley) 6/4/93
* $NetBSD: history.c,v 1.29 2005/07/06 21:13:02 christos Exp $
* $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $
* $DragonFly: src/lib/libedit/history.c,v 1.6 2005/11/13 11:58:30 corecode Exp $
*/
......
history_gfun_t h_prev; /* Get the previous element */
history_gfun_t h_curr; /* Get the current element */
history_sfun_t h_set; /* Set the current element */
history_sfun_t h_del; /* Set the given element */
history_vfun_t h_clear; /* Clear the history list */
history_efun_t h_enter; /* Add an element */
history_efun_t h_add; /* Append to an element */
......
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
#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 HDEL(h, ev, n) (*(h)->h_del)((h)->h_ref, ev, n)
#define h_strdup(a) strdup(a)
#define h_malloc(a) malloc(a)
......
#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 *);
private int history_def_next(ptr_t, HistEvent *);
private int history_def_first(ptr_t, HistEvent *);
private int history_def_prev(ptr_t, HistEvent *);
private int history_def_last(ptr_t, HistEvent *);
private int history_def_curr(ptr_t, HistEvent *);
private int history_def_set(ptr_t, HistEvent *, const int n);
private int history_def_set(ptr_t, HistEvent *, const int);
private void history_def_clear(ptr_t, HistEvent *);
private int history_def_enter(ptr_t, HistEvent *, const char *);
private int history_def_add(ptr_t, HistEvent *, const char *);
private int history_def_del(ptr_t, HistEvent *, const 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 *);
......
}
/* history_def_del():
* Delete element hp of the h list
*/
/* ARGSUSED */
private int
history_def_del(ptr_t p, HistEvent *ev __attribute__((__unused__)),
const int num)
{
history_t *h = (history_t *) p;
if (history_def_set(h, ev, num) != 0)
return (-1);
ev->str = strdup(h->cursor->ev.str);
ev->num = h->cursor->ev.num;
history_def_delete(h, ev, h->cursor);
return (0);
}
/* history_def_delete():
* Delete element hp of the h list
*/
......
HistEventPrivate *evp = (void *)&hp->ev;
if (hp == &h->list)
abort();
if (h->cursor == hp)
h->cursor = hp->prev;
hp->prev->next = hp->next;
hp->next->prev = hp->prev;
h_free((ptr_t) evp->str);
......
h->h_clear = history_def_clear;
h->h_enter = history_def_enter;
h->h_add = history_def_add;
h->h_del = history_def_del;
return (h);
}
......
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
h_free(h->h_ref);
h_free(h);
}
......
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
nh->h_ref == NULL) {
nh->h_del == NULL || nh->h_ref == NULL) {
if (h->h_next != history_def_next) {
history_def_init(&h->h_ref, &ev, 0);
h->h_first = history_def_first;
......
h->h_clear = history_def_clear;
h->h_enter = history_def_enter;
h->h_add = history_def_add;
h->h_del = history_def_del;
}
return (-1);
}
......
h->h_clear = nh->h_clear;
h->h_enter = nh->h_enter;
h->h_add = nh->h_add;
h->h_del = nh->h_del;
return (0);
}
......
retval = HADD(h, ev, str);
break;
case H_DEL:
retval = HDEL(h, ev, va_arg(va, const int));
break;
case H_ENTER:
str = va_arg(va, const char *);
if ((retval = HENTER(h, ev, str)) != -1)
......
hf.h_clear = va_arg(va, history_vfun_t);
hf.h_enter = va_arg(va, history_efun_t);
hf.h_add = va_arg(va, history_efun_t);
hf.h_del = va_arg(va, history_sfun_t);
if ((retval = history_set_fun(h, &hf)) == -1)
he_seterrev(ev, _HE_PARAM_MISSING);
lib/libedit/key.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)key.c 8.1 (Berkeley) 6/4/93
* $NetBSD: key.c,v 1.16 2005/07/06 21:13:02 christos Exp $
* $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $
* $DragonFly: src/lib/libedit/key.c,v 1.5 2005/11/13 11:58:30 corecode Exp $
*/
......
* the extended-key map.
*
* An extended-key (key) is a sequence of keystrokes introduced
* with an sequence introducer and consisting of an arbitrary
* with a sequence introducer and consisting of an arbitrary
* number of characters. This module maintains a map (the el->el_key.map)
* to convert these extended-key sequences into input strs
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
......
private int node_lookup(EditLine *, const char *, key_node_t *,
int);
private int node_enum(EditLine *, key_node_t *, int);
private int key__decode_char(char *, int, int);
#define KEY_BUFSIZ EL_BUFSIZ
......
/* node__get():
* Returns pointer to an key_node_t for ch.
* Returns pointer to a key_node_t for ch.
*/
private key_node_t *
node__get(int ch)
......
/* If match put this char into el->el_key.buf. Recurse */
if (ptr->ch == *str) {
/* match found */
ncnt = key__decode_char(el->el_key.buf, cnt,
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
(unsigned char) ptr->ch);
if (ptr->next != NULL)
/* not yet at leaf */
......
return (-1);
}
/* put this char at end of str */
ncnt = key__decode_char(el->el_key.buf, cnt, (unsigned char) ptr->ch);
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
(unsigned char)ptr->ch);
if (ptr->next == NULL) {
/* print this key and function */
el->el_key.buf[ncnt + 1] = '"';
......
switch (ntype) {
case XK_STR:
case XK_EXE:
(void) fprintf(el->el_outfile, fmt, key,
key__decode_str(val->str, unparsbuf,
ntype == XK_STR ? "\"\"" : "[]"));
(void) key__decode_str(val->str, unparsbuf,
sizeof(unparsbuf),
ntype == XK_STR ? "\"\"" : "[]");
(void) fprintf(el->el_outfile, fmt, key, unparsbuf);
break;
case XK_CMD:
for (fp = el->el_map.help; fp->name; fp++)
......
}
#define ADDC(c) \
if (b < eb) \
*b++ = c; \
else \
b++
/* key__decode_char():
* Put a printable form of char in buf.
*/
private int
key__decode_char(char *buf, int cnt, int ch)
protected int
key__decode_char(char *buf, int cnt, int off, int ch)
{
char *sb = buf + off;
char *eb = buf + cnt;
char *b = sb;
if (ch == 0) {
buf[cnt++] = '^';
buf[cnt] = '@';
return (cnt);
ADDC('^');
ADDC('@');
return b - sb;
}
if (iscntrl(ch)) {
buf[cnt++] = '^';
ADDC('^');
if (ch == '\177')
buf[cnt] = '?';
ADDC('?');
else
buf[cnt] = ch | 0100;
ADDC(ch | 0100);
} else if (ch == '^') {
buf[cnt++] = '\\';
buf[cnt] = '^';
ADDC('\\');
ADDC('^');
} else if (ch == '\\') {
buf[cnt++] = '\\';
buf[cnt] = '\\';
ADDC('\\');
ADDC('\\');
} else if (ch == ' ' || (isprint(ch) && !isspace(ch))) {
buf[cnt] = ch;
ADDC(ch);
} else {
buf[cnt++] = '\\';
buf[cnt++] = (((unsigned int) ch >> 6) & 7) + '0';
buf[cnt++] = (((unsigned int) ch >> 3) & 7) + '0';
buf[cnt] = (ch & 7) + '0';
ADDC('\\');
ADDC((((unsigned int) ch >> 6) & 7) + '0');
ADDC((((unsigned int) ch >> 3) & 7) + '0');
ADDC((ch & 7) + '0');
}
return (cnt);
return b - sb;
}
/* key__decode_str():
* Make a printable version of the ey
*/
protected char *
key__decode_str(const char *str, char *buf, const char *sep)
protected int
key__decode_str(const char *str, char *buf, int len, const char *sep)
{
char *b;
char *b = buf, *eb = b + len;
const char *p;
b = buf;
if (sep[0] != '\0')
*b++ = sep[0];
if (*str == 0) {
*b++ = '^';
*b++ = '@';
if (sep[0] != '\0' && sep[1] != '\0')
*b++ = sep[1];
*b++ = 0;
return (buf);
if (sep[0] != '\0') {
ADDC(sep[0]);
}
if (*str == '\0') {
ADDC('^');
ADDC('@');
if (sep[0] != '\0' && sep[1] != '\0') {
ADDC(sep[1]);
}
goto done;
}
for (p = str; *p != 0; p++) {
if (iscntrl((unsigned char) *p)) {
*b++ = '^';
if (*p == '\177')
*b++ = '?';
else
*b++ = *p | 0100;
ADDC('^');
if (*p == '\177') {
ADDC('?');
} else {
ADDC(*p | 0100);
}
} else if (*p == '^' || *p == '\\') {
*b++ = '\\';
*b++ = *p;
ADDC('\\');
ADDC(*p);
} else if (*p == ' ' || (isprint((unsigned char) *p) &&
!isspace((unsigned char) *p))) {
*b++ = *p;
ADDC(*p);
} else {
*b++ = '\\';
*b++ = (((unsigned int) *p >> 6) & 7) + '0';
*b++ = (((unsigned int) *p >> 3) & 7) + '0';
*b++ = (*p & 7) + '0';
ADDC('\\');
ADDC((((unsigned int) *p >> 6) & 7) + '0');
ADDC((((unsigned int) *p >> 3) & 7) + '0');
ADDC((*p & 7) + '0');
}
}
if (sep[0] != '\0' && sep[1] != '\0')
*b++ = sep[1];
*b++ = 0;
return (buf); /* should check for overflow */
if (sep[0] != '\0' && sep[1] != '\0') {
ADDC(sep[1]);
}
done:
ADDC('\0');
if (b - buf >= len)
buf[len - 1] = '\0';
return b - buf;
}
lib/libedit/key.h 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)key.h 8.1 (Berkeley) 6/4/93
* $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $
* $NetBSD: key.h,v 1.10 2006/03/23 20:22:51 christos Exp $
* $DragonFly: src/lib/libedit/key.h,v 1.4 2005/11/13 11:58:30 corecode Exp $
*/
......
protected void key_print(EditLine *, const char *);
protected void key_kprint(EditLine *, const char *, key_value_t *,
int);
protected char *key__decode_str(const char *, char *, const char *);
protected int key__decode_str(const char *, char *, int,
const char *);
protected int key__decode_char(char *, int, int, int);
#endif /* _h_el_key */
lib/libedit/makelist 28 Apr 2007 17:52:08 -0000
# SUCH DAMAGE.
#
# @(#)makelist 5.3 (Berkeley) 6/4/93
# $NetBSD: makelist,v 1.9 2005/05/16 13:14:43 lukem Exp $
# $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $
# $DragonFly: src/lib/libedit/makelist,v 1.4 2005/11/13 11:58:30 corecode Exp $
# makelist.sh: Automatically generate header files...
......
}
}
END {
printf(" { NULL, 0, NULL }\n");
printf("};\n");
printf("\nprotected const el_bindings_t* help__get()");
printf("{ return el_func_help; }\n");
......
#
-fh)
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
sort | tr '[a-z]' '[A-Z]' | $AWK '
sort | tr '[:lower:]' '[:upper:]' | $AWK '
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n");
lib/libedit/map.c 28 Apr 2007 17:52:08 -0000
* SUCH DAMAGE.
*
* @(#)map.c 8.1 (Berkeley) 6/4/93
* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $
* $NetBSD: map.c,v 1.24 2006/04/09 01:36:51 christos Exp $
* $DragonFly: src/lib/libedit/map.c,v 1.6 2005/11/13 11:58:30 corecode Exp $
*/
......
map_print_key(EditLine *el, el_action_t *map, const char *in)
{
char outbuf[EL_BUFSIZ];
el_bindings_t *bp;
el_bindings_t *bp, *ep;
if (in[0] == '\0' || in[1] == '\0') {
(void) key__decode_str(in, outbuf, "");
for (bp = el->el_map.help; bp->name != NULL; bp++)
(void) key__decode_str(in, outbuf, sizeof(outbuf), "");
ep = &el->el_map.help[el->el_map.nfunc];
for (bp = el->el_map.help; bp < ep; bp++)
if (bp->func == map[(unsigned char) *in]) {
(void) fprintf(el->el_outfile,
"%s\t->\t%s\n", outbuf, bp->name);
......
private void
map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
{
el_bindings_t *bp;
el_bindings_t *bp, *ep;
char firstbuf[2], lastbuf[2];
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
......
lastbuf[0] = last;
lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) {
if (first == last)
if (first == last) {
(void) key__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-15s-> is undefined\n",
key__decode_str(firstbuf, unparsbuf, STRQQ));
"%-15s-> is undefined\n", unparsbuf);
}
return;
}
for (bp = el->el_map.help; bp->name != NULL; bp++) {
ep = &el->el_map.help[el->el_map.nfunc];
for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) {
if (first == last) {
(void) key__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, "%-15s-> %s\n",
key__decode_str(firstbuf, unparsbuf, STRQQ),
bp->name);
unparsbuf, bp->name);
} else {
(void) key__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) key__decode_str(lastbuf, extrabuf,
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)