Import libedit 2016-02-27
Obtained from: NetBSD
This commit is contained in:
parent
c729c39672
commit
4593a7cde5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/libedit/dist/; revision=296159 svn path=/vendor/NetBSD/libedit/2016-02-27/; revision=296160; tag=vendor/NetBSD/libedit/2016-02-27
11
Makefile
11
Makefile
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.53 2015/01/29 20:30:02 joerg Exp $
|
||||
# $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/4/93
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
@ -15,7 +15,7 @@ COPTS+= -Wunused-parameter
|
||||
CWARNFLAGS.gcc+= -Wconversion
|
||||
CWARNFLAGS.clang+= -Wno-cast-qual
|
||||
|
||||
OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
|
||||
OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \
|
||||
hist.c keymacro.c map.c chartype.c \
|
||||
parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
|
||||
|
||||
@ -37,7 +37,6 @@ MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \
|
||||
SRCS= editline.c readline.c tokenizer.c history.c
|
||||
|
||||
.if ${WIDECHAR} == "yes"
|
||||
OSRCS += eln.c
|
||||
SRCS += tokenizern.c historyn.c
|
||||
CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
|
||||
CPPFLAGS+=-DWIDECHAR
|
||||
@ -52,12 +51,12 @@ 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 tc1.o tc1
|
||||
CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
|
||||
CPPFLAGS+=-I. -I${LIBEDITDIR}
|
||||
CPPFLAGS+=-I. -I${LIBEDITDIR}
|
||||
CPPFLAGS+=-I. -I${.CURDIR}
|
||||
CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
|
||||
CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT
|
||||
|
||||
AHDR=vi.h emacs.h common.h
|
||||
AHDR=vi.h emacs.h common.h
|
||||
ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
|
||||
|
||||
DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c
|
||||
@ -120,7 +119,7 @@ historyn.c: makelist Makefile
|
||||
|
||||
tc1.o: ${LIBEDITDIR}/TEST/tc1.c
|
||||
|
||||
tc1: libedit.a tc1.o
|
||||
tc1: libedit.a tc1.o
|
||||
${_MKTARGET_LINK}
|
||||
${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.5 2010/02/03 15:34:43 roy Exp $
|
||||
# $NetBSD: Makefile,v 1.6 2016/02/15 21:38:07 christos Exp $
|
||||
|
||||
WIDECHAR ?= yes
|
||||
|
||||
NOMAN=1
|
||||
PROG=wtc1
|
||||
@ -6,6 +8,10 @@ CPPFLAGS=-I${.CURDIR}/..
|
||||
LDADD+=-ledit -ltermlib
|
||||
DPADD+=${LIBEDIT} ${LIBTERMLIB}
|
||||
|
||||
.if "${WIDECHAR}" == "yes"
|
||||
CPPFLAGS+=-DWIDECHAR
|
||||
.endif
|
||||
|
||||
.ifdef DEBUG
|
||||
CPPFLAGS+=-DDEBUG
|
||||
.endif
|
||||
|
16
TEST/tc1.c
16
TEST/tc1.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $ */
|
||||
/* $NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -42,22 +42,22 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $");
|
||||
__RCSID("$NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* test.c: A little test program
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
@ -157,7 +157,7 @@ main(int argc, char *argv[])
|
||||
/* Add a user-defined function */
|
||||
el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
|
||||
|
||||
/* Bind tab to it */
|
||||
/* Bind tab to it */
|
||||
el_set(el, EL_BIND, "^I", "ed-complete", NULL);
|
||||
|
||||
/*
|
||||
|
12
TEST/wtc1.c
12
TEST/wtc1.c
@ -1,14 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <err.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../histedit.h"
|
||||
|
||||
|
42
chared.c
42
chared.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $ */
|
||||
/* $NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,15 +37,19 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $");
|
||||
__RCSID("$NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* chared.c: Character editor utilities
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
|
||||
private void ch__clearmacro (EditLine *);
|
||||
|
||||
@ -199,7 +203,7 @@ c_delbefore1(EditLine *el)
|
||||
* Return if p is part of a word according to emacs
|
||||
*/
|
||||
protected int
|
||||
ce__isword(Int p)
|
||||
ce__isword(wint_t p)
|
||||
{
|
||||
return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
|
||||
}
|
||||
@ -209,7 +213,7 @@ ce__isword(Int p)
|
||||
* Return if p is part of a word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isword(Int p)
|
||||
cv__isword(wint_t p)
|
||||
{
|
||||
if (Isalnum(p) || p == '_')
|
||||
return 1;
|
||||
@ -223,7 +227,7 @@ cv__isword(Int p)
|
||||
* Return if p is part of a big word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isWord(Int p)
|
||||
cv__isWord(wint_t p)
|
||||
{
|
||||
return !Isspace(p);
|
||||
}
|
||||
@ -233,7 +237,7 @@ cv__isWord(Int p)
|
||||
* Find the previous word
|
||||
*/
|
||||
protected Char *
|
||||
c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
|
||||
c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t))
|
||||
{
|
||||
p--;
|
||||
|
||||
@ -257,7 +261,7 @@ c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
|
||||
* Find the next word
|
||||
*/
|
||||
protected Char *
|
||||
c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
|
||||
c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t))
|
||||
{
|
||||
while (n--) {
|
||||
while ((p < high) && !(*wtest)(*p))
|
||||
@ -275,7 +279,7 @@ c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
|
||||
* Find the next word vi style
|
||||
*/
|
||||
protected Char *
|
||||
cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
|
||||
cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t))
|
||||
{
|
||||
int test;
|
||||
|
||||
@ -304,7 +308,7 @@ 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(Char *p, Char *low, int n, int (*wtest)(Int))
|
||||
cv_prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t))
|
||||
{
|
||||
int test;
|
||||
|
||||
@ -368,7 +372,7 @@ cv_delfini(EditLine *el)
|
||||
* Go to the end of this word according to vi
|
||||
*/
|
||||
protected Char *
|
||||
cv__endword(Char *p, Char *high, int n, int (*wtest)(Int))
|
||||
cv__endword(Char *p, Char *high, int n, int (*wtest)(wint_t))
|
||||
{
|
||||
int test;
|
||||
|
||||
@ -522,7 +526,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
|
||||
|
||||
|
||||
oldbuf = el->el_line.buffer;
|
||||
|
||||
el->el_line.buffer = newbuffer;
|
||||
@ -571,7 +575,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
|
||||
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;
|
||||
|
||||
@ -671,9 +675,9 @@ el_cursor(EditLine *el, int n)
|
||||
protected int
|
||||
c_gets(EditLine *el, Char *buf, const Char *prompt)
|
||||
{
|
||||
Char ch;
|
||||
wchar_t wch;
|
||||
ssize_t len;
|
||||
Char *cp = el->el_line.buffer;
|
||||
Char *cp = el->el_line.buffer, ch;
|
||||
|
||||
if (prompt) {
|
||||
len = (ssize_t)Strlen(prompt);
|
||||
@ -688,26 +692,28 @@ c_gets(EditLine *el, Char *buf, const Char *prompt)
|
||||
el->el_line.lastchar = cp + 1;
|
||||
re_refresh(el);
|
||||
|
||||
if (FUN(el,getc)(el, &ch) != 1) {
|
||||
if (el_wgetc(el, &wch) != 1) {
|
||||
ed_end_of_file(el, 0);
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
ch = (Char)wch;
|
||||
|
||||
switch (ch) {
|
||||
|
||||
case 0010: /* Delete and backspace */
|
||||
case L'\b': /* Delete and backspace */
|
||||
case 0177:
|
||||
if (len == 0) {
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
len--;
|
||||
cp--;
|
||||
continue;
|
||||
|
||||
case 0033: /* ESC */
|
||||
case '\r': /* Newline */
|
||||
case '\n':
|
||||
case L'\r': /* Newline */
|
||||
case L'\n':
|
||||
buf[len] = ch;
|
||||
break;
|
||||
|
||||
|
29
chared.h
29
chared.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chared.h,v 1.22 2014/06/18 18:12:28 christos Exp $ */
|
||||
/* $NetBSD: chared.h,v 1.27 2016/02/16 22:53:14 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,11 +40,6 @@
|
||||
#ifndef _h_el_chared
|
||||
#define _h_el_chared
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
#define EL_MAXMACRO 10
|
||||
|
||||
/*
|
||||
@ -139,24 +134,18 @@ typedef struct el_chared_t {
|
||||
#define MODE_REPLACE 1
|
||||
#define MODE_REPLACE_1 2
|
||||
|
||||
#include "common.h"
|
||||
#include "vi.h"
|
||||
#include "emacs.h"
|
||||
#include "search.h"
|
||||
#include "fcns.h"
|
||||
|
||||
|
||||
protected int cv__isword(Int);
|
||||
protected int cv__isWord(Int);
|
||||
protected int cv__isword(wint_t);
|
||||
protected int cv__isWord(wint_t);
|
||||
protected void cv_delfini(EditLine *);
|
||||
protected Char *cv__endword(Char *, Char *, int, int (*)(Int));
|
||||
protected int ce__isword(Int);
|
||||
protected Char *cv__endword(Char *, Char *, int, int (*)(wint_t));
|
||||
protected int ce__isword(wint_t);
|
||||
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(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 Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(wint_t));
|
||||
protected Char *cv_prev_word(Char *, Char *, int, int (*)(wint_t));
|
||||
protected Char *c__next_word(Char *, Char *, int, int (*)(wint_t));
|
||||
protected Char *c__prev_word(Char *, Char *, int, int (*)(wint_t));
|
||||
protected void c_insert(EditLine *, int);
|
||||
protected void c_delbefore(EditLine *, int);
|
||||
protected void c_delbefore1(EditLine *);
|
||||
|
36
chartype.c
36
chartype.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $ */
|
||||
/* $NetBSD: chartype.c,v 1.22 2016/02/24 17:20:01 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -38,10 +38,14 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
|
||||
__RCSID("$NetBSD: chartype.c,v 1.22 2016/02/24 17:20:01 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
#include "el.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
#define CT_BUFSIZ ((size_t)1024)
|
||||
|
||||
@ -72,7 +76,7 @@ ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (wsize <= conv->wsize)
|
||||
if (wsize <= conv->wsize)
|
||||
return 0;
|
||||
|
||||
conv->wsize = wsize;
|
||||
@ -210,6 +214,28 @@ ct_encode_char(char *dst, size_t len, Char c)
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
size_t
|
||||
ct_mbrtowc(wchar_t *wc, const char *s, size_t n)
|
||||
{
|
||||
mbstate_t mbs;
|
||||
/* This only works because UTF-8 is stateless */
|
||||
memset(&mbs, 0, sizeof(mbs));
|
||||
return mbrtowc(wc, s, n, &mbs);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
size_t
|
||||
ct_mbrtowc(wchar_t *wc, const char *s, size_t n)
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
if (n == 0)
|
||||
return (size_t)-2;
|
||||
if (wc != NULL)
|
||||
*wc = *s;
|
||||
return *s != '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
protected const Char *
|
||||
@ -333,7 +359,7 @@ ct_visual_char(Char *dst, size_t len, Char c)
|
||||
return c > 0xffff ? 8 : 7;
|
||||
#else
|
||||
*dst++ = '\\';
|
||||
#define tooctaldigit(v) ((v) + '0')
|
||||
#define tooctaldigit(v) (Char)((v) + '0')
|
||||
*dst++ = tooctaldigit(((unsigned int) c >> 6) & 0x7);
|
||||
*dst++ = tooctaldigit(((unsigned int) c >> 3) & 0x7);
|
||||
*dst++ = tooctaldigit(((unsigned int) c ) & 0x7);
|
||||
|
23
chartype.h
23
chartype.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $ */
|
||||
/* $NetBSD: chartype.h,v 1.23 2016/02/24 17:20:01 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,6 @@
|
||||
#define _h_chartype_f
|
||||
|
||||
|
||||
|
||||
#ifdef WIDECHAR
|
||||
|
||||
/* Ideally we should also test the value of the define to see if it
|
||||
@ -60,21 +59,18 @@
|
||||
#warning Build environment does not support non-BMP characters
|
||||
#endif
|
||||
|
||||
#define ct_mbtowc mbtowc
|
||||
#define ct_mbtowc_reset mbtowc(0,0,(size_t)0)
|
||||
#define ct_wctob wctob
|
||||
#define ct_wctomb wctomb
|
||||
#define ct_wctomb_reset wctomb(0,0)
|
||||
#define ct_wcstombs wcstombs
|
||||
#define ct_mbstowcs mbstowcs
|
||||
|
||||
#define Char wchar_t
|
||||
#define Int wint_t
|
||||
#define FUN(prefix,rest) prefix ## _w ## rest
|
||||
#define FUNW(type) type ## _w
|
||||
#define TYPE(type) type ## W
|
||||
#define FCHAR "%lc"
|
||||
#define FSTR "%ls"
|
||||
#define STR(x) L ## x
|
||||
#define STR(x) L ## x
|
||||
#define UC(c) c
|
||||
#define Isalpha(x) iswalpha(x)
|
||||
#define Isalnum(x) iswalnum(x)
|
||||
@ -115,21 +111,18 @@ Width(wchar_t c)
|
||||
|
||||
#else /* NARROW */
|
||||
|
||||
#define ct_mbtowc error
|
||||
#define ct_mbtowc_reset
|
||||
#define ct_wctob(w) ((int)(w))
|
||||
#define ct_wctomb error
|
||||
#define ct_wctomb_reset
|
||||
#define ct_wctomb_reset
|
||||
#define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a))
|
||||
#define ct_mbstowcs(a, b, c) (strncpy(a, b, c), strlen(a))
|
||||
|
||||
#define Char char
|
||||
#define Int int
|
||||
#define FUN(prefix,rest) prefix ## _ ## rest
|
||||
#define FUNW(type) type
|
||||
#define TYPE(type) type
|
||||
#define FCHAR "%c"
|
||||
#define FSTR "%s"
|
||||
#define STR(x) x
|
||||
#define STR(x) x
|
||||
#define UC(c) (unsigned char)(c)
|
||||
|
||||
#define Isalpha(x) isalpha((unsigned char)x)
|
||||
@ -218,7 +211,7 @@ protected size_t ct_enc_width(Char);
|
||||
#define VISUAL_WIDTH_MAX ((size_t)8)
|
||||
|
||||
/* The terminal is thought of in terms of X columns by Y lines. In the cases
|
||||
* where a wide character takes up more than one column, the adjacent
|
||||
* where a wide character takes up more than one column, the adjacent
|
||||
* occupied column entries will contain this faux character. */
|
||||
#define MB_FILL_CHAR ((Char)-1)
|
||||
|
||||
@ -250,5 +243,7 @@ protected const Char *ct_visual_string(const Char *);
|
||||
protected int ct_chr_class(Char c);
|
||||
#endif
|
||||
|
||||
size_t ct_mbrtowc(wchar_t *, const char *, size_t);
|
||||
|
||||
|
||||
#endif /* _chartype_f */
|
||||
|
115
common.c
115
common.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $ */
|
||||
/* $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,14 +37,20 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $");
|
||||
__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* common.c: Common Editor functions
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
#include "parse.h"
|
||||
#include "vi.h"
|
||||
|
||||
/* ed_end_of_file():
|
||||
* Indicate end of file
|
||||
@ -52,7 +58,7 @@ __RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $");
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
@ -66,7 +72,7 @@ ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Insert a character [bound to all insert keys]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_insert(EditLine *el, Int c)
|
||||
ed_insert(EditLine *el, wint_t c)
|
||||
{
|
||||
int count = el->el_state.argument;
|
||||
|
||||
@ -85,14 +91,14 @@ ed_insert(EditLine *el, Int c)
|
||||
|| el->el_line.cursor >= el->el_line.lastchar)
|
||||
c_insert(el, 1);
|
||||
|
||||
*el->el_line.cursor++ = c;
|
||||
*el->el_line.cursor++ = (Char)c;
|
||||
re_fastaddc(el); /* fast refresh for one char. */
|
||||
} else {
|
||||
if (el->el_state.inputmode != MODE_REPLACE_1)
|
||||
c_insert(el, el->el_state.argument);
|
||||
|
||||
while (count-- && el->el_line.cursor < el->el_line.lastchar)
|
||||
*el->el_line.cursor++ = c;
|
||||
*el->el_line.cursor++ = (Char)c;
|
||||
re_refresh(el);
|
||||
}
|
||||
|
||||
@ -109,7 +115,7 @@ ed_insert(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *p, *kp;
|
||||
|
||||
@ -137,7 +143,7 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
#ifdef DEBUG_EDIT
|
||||
#define EL el->el_line
|
||||
@ -184,7 +190,7 @@ ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -205,7 +211,7 @@ ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
@ -228,7 +234,7 @@ ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
@ -251,7 +257,7 @@ ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* [^T] [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_transpose_chars(EditLine *el, Int c)
|
||||
ed_transpose_chars(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
@ -264,7 +270,7 @@ ed_transpose_chars(EditLine *el, Int c)
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
el->el_line.cursor[-1] = (Char)c;
|
||||
return CC_REFRESH;
|
||||
} else
|
||||
return CC_ERROR;
|
||||
@ -277,7 +283,7 @@ ed_transpose_chars(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *lim = el->el_line.lastchar;
|
||||
|
||||
@ -306,7 +312,7 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
@ -332,7 +338,7 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.buffer) {
|
||||
@ -356,14 +362,12 @@ ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* [^V] [^V]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_quoted_insert(EditLine *el, Int c)
|
||||
ed_quoted_insert(EditLine *el, wint_t c)
|
||||
{
|
||||
int num;
|
||||
Char tc;
|
||||
|
||||
tty_quotemode(el);
|
||||
num = FUN(el,getc)(el, &tc);
|
||||
c = tc;
|
||||
num = el_wgetc(el, &c);
|
||||
tty_noquotemode(el);
|
||||
if (num == 1)
|
||||
return ed_insert(el, c);
|
||||
@ -376,7 +380,7 @@ ed_quoted_insert(EditLine *el, Int c)
|
||||
* Adds to argument or enters a digit
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_digit(EditLine *el, Int c)
|
||||
ed_digit(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (!Isdigit(c))
|
||||
@ -404,7 +408,7 @@ ed_digit(EditLine *el, Int c)
|
||||
* For ESC-n
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_argument_digit(EditLine *el, Int c)
|
||||
ed_argument_digit(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (!Isdigit(c))
|
||||
@ -430,7 +434,7 @@ ed_argument_digit(EditLine *el, Int c)
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_unassigned(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_ERROR;
|
||||
@ -447,8 +451,8 @@ ed_unassigned(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -461,8 +465,8 @@ ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -475,8 +479,8 @@ ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -489,8 +493,8 @@ ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -503,8 +507,8 @@ ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -517,8 +521,8 @@ ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -531,8 +535,8 @@ ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -545,7 +549,7 @@ ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_newline(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
@ -561,7 +565,7 @@ ed_newline(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
@ -581,7 +585,7 @@ ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
terminal_clear_screen(el); /* clear the whole real screen */
|
||||
@ -596,8 +600,8 @@ ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_REDISPLAY;
|
||||
@ -610,7 +614,7 @@ ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
ch_reset(el, 0);
|
||||
@ -624,8 +628,8 @@ ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -638,7 +642,7 @@ ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
char beep = 0;
|
||||
int sv_event = el->el_history.eventno;
|
||||
@ -658,7 +662,6 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
if (hist_get(el) == CC_ERROR) {
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
el->el_history.eventno = sv_event;
|
||||
|
||||
}
|
||||
beep = 1;
|
||||
/* el->el_history.eventno was fixed by first call */
|
||||
@ -676,7 +679,7 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
el_action_t beep = CC_REFRESH, rval;
|
||||
|
||||
@ -703,11 +706,11 @@ ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
int found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
@ -746,7 +749,7 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp)) {
|
||||
found++;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
h++;
|
||||
@ -771,11 +774,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
int found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
@ -825,7 +828,7 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
@ -868,7 +871,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
@ -902,7 +905,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_command(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_command(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
10
config.h
10
config.h
@ -20,8 +20,8 @@
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `fgetln' function. */
|
||||
#define HAVE_FGETLN 1
|
||||
/* Define to 1 if you have the `getline' function. */
|
||||
#define HAVE_GETLINE 1
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#define HAVE_FORK 1
|
||||
@ -187,9 +187,6 @@
|
||||
/* Define to 1 if you have the `vis' function. */
|
||||
#define HAVE_VIS 1
|
||||
|
||||
/* Define to 1 if you have the `wcsdup' function. */
|
||||
#define HAVE_WCSDUP 1
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#define HAVE_WORKING_FORK 1
|
||||
|
||||
@ -256,6 +253,9 @@
|
||||
/* Version number of package */
|
||||
#define VERSION "3.0"
|
||||
|
||||
/* Define to 1 if the system provides the SIZE_MAX constant */
|
||||
#define HAVE_SIZE_MAX 1
|
||||
|
||||
/* Define to 1 if you want wide-character code */
|
||||
/* #undef WIDECHAR */
|
||||
|
||||
|
64
editline.3
64
editline.3
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: editline.3,v 1.85 2015/11/03 21:36:59 christos Exp $
|
||||
.\" $NetBSD: editline.3,v 1.88 2016/02/25 14:59:22 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@ -26,7 +26,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd November 3, 2015
|
||||
.Dd February 24, 2016
|
||||
.Dt EDITLINE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -70,7 +70,7 @@
|
||||
.Nm tok_wreset ,
|
||||
.Nm tok_line ,
|
||||
.Nm tok_wline ,
|
||||
.Nm tok_str
|
||||
.Nm tok_str ,
|
||||
.Nm tok_wstr
|
||||
.Nd line editor, history and tokenization functions
|
||||
.Sh LIBRARY
|
||||
@ -128,9 +128,9 @@
|
||||
.Ft void
|
||||
.Fn el_wdeletestr "EditLine *e" "int count"
|
||||
.Ft History *
|
||||
.Fn history_init
|
||||
.Fn history_init void
|
||||
.Ft HistoryW *
|
||||
.Fn history_winit
|
||||
.Fn history_winit void
|
||||
.Ft void
|
||||
.Fn history_end "History *h"
|
||||
.Ft void
|
||||
@ -173,6 +173,16 @@ library (which needs the
|
||||
library).
|
||||
Programs should be linked with
|
||||
.Fl ledit ltermcap .
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
library respects the
|
||||
.Ev LC_CTYPE
|
||||
locale set by the application program and never uses
|
||||
.Xr setlocale 3
|
||||
to change the locale.
|
||||
The only locales supported are UTF-8 and the default C or POSIX locale.
|
||||
If any other locale is set, behaviour is undefined.
|
||||
.Sh LINE EDITING FUNCTIONS
|
||||
The line editing functions use a common data structure,
|
||||
.Fa EditLine ,
|
||||
@ -238,14 +248,42 @@ contains the error code that caused it.
|
||||
The return value may not remain valid across calls to
|
||||
.Fn el_gets
|
||||
and must be copied if the data is to be retained.
|
||||
.It Fn el_wgetc
|
||||
Read a wide character from the tty, respecting the current locale,
|
||||
or from the input stream written by
|
||||
.Fn el_wpush
|
||||
and
|
||||
.Fn el_push
|
||||
if that is not empty, and store it in
|
||||
.Fa ch .
|
||||
If an invalid or incomplete character is found, it is discarded,
|
||||
.Va errno
|
||||
is set to
|
||||
.Er EILSEQ ,
|
||||
and the next character is read and stored in
|
||||
.Fa ch .
|
||||
Returns 1 if a valid character was read, 0 on end of file, or \-1 on
|
||||
.Xr read 2
|
||||
failure.
|
||||
In the latter case,
|
||||
.Va errno
|
||||
is set to indicate the error.
|
||||
.It Fn el_getc
|
||||
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,
|
||||
in which case
|
||||
.Dv errno
|
||||
can be inspected for the cause.
|
||||
Read a wide character as described for
|
||||
.Fn el_wgetc
|
||||
and return 0 on end of file or \-1 on failure.
|
||||
If the wide character can be represented as a single-byte character,
|
||||
convert it with
|
||||
.Xr wctob 3 ,
|
||||
store the result in
|
||||
.Fa ch ,
|
||||
and return 1; otherwise, set
|
||||
.Va errno
|
||||
to
|
||||
.Er ERANGE
|
||||
and return \-1.
|
||||
In the C or POSIX locale, this simply reads a byte, but for any other
|
||||
locale, including UTF-8, this is rarely useful.
|
||||
.It Fn el_push
|
||||
Pushes
|
||||
.Fa str
|
||||
@ -744,7 +782,7 @@ to the last new element of the history.
|
||||
.It Dv H_ENTER , Fa "const char *str"
|
||||
Add
|
||||
.Fa str
|
||||
as a new element to the history, and, if necessary,
|
||||
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
|
||||
|
33
el.c
33
el.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $ */
|
||||
/* $NetBSD: el.c,v 1.83 2016/02/24 17:13:22 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.74 2015/12/08 12:56:55 christos Exp $");
|
||||
__RCSID("$NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -46,13 +46,17 @@ __RCSID("$NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $");
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIDECHAR
|
||||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#include "el.h"
|
||||
#include "parse.h"
|
||||
|
||||
/* el_init():
|
||||
* Initialize editline and set default parameters.
|
||||
@ -93,12 +97,10 @@ el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
|
||||
* Initialize all the modules. Order is important!!!
|
||||
*/
|
||||
el->el_flags = 0;
|
||||
#ifdef WIDECHAR
|
||||
if (setlocale(LC_CTYPE, NULL) != NULL){
|
||||
if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
|
||||
el->el_flags |= CHARSET_IS_UTF8;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (terminal_init(el) == -1) {
|
||||
el_free(el->el_prog);
|
||||
@ -207,7 +209,7 @@ FUN(el,set)(EditLine *el, int op, ...)
|
||||
el_pfunc_t p = va_arg(ap, el_pfunc_t);
|
||||
int c = va_arg(ap, int);
|
||||
|
||||
rv = prompt_set(el, p, c, op, 1);
|
||||
rv = prompt_set(el, p, (Char)c, op, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -306,7 +308,6 @@ FUN(el,set)(EditLine *el, int op, ...)
|
||||
{
|
||||
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
|
||||
rv = el_read_setfn(el, rc);
|
||||
el->el_flags &= ~NARROW_READ;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -435,7 +436,7 @@ FUN(el,get)(EditLine *el, int op, ...)
|
||||
char *argv[20];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < (int)__arraycount(argv); i++)
|
||||
for (i = 1; i < (int)__arraycount(argv); i++)
|
||||
if ((argv[i] = va_arg(ap, char *)) == NULL)
|
||||
break;
|
||||
|
||||
@ -512,6 +513,7 @@ el_source(EditLine *el, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
ssize_t slen;
|
||||
char *ptr;
|
||||
char *path = NULL;
|
||||
const Char *dptr;
|
||||
@ -548,15 +550,17 @@ el_source(EditLine *el, const char *fname)
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((ptr = fgetln(fp, &len)) != NULL) {
|
||||
ptr = NULL;
|
||||
len = 0;
|
||||
while ((slen = getline(&ptr, &len, fp)) != -1) {
|
||||
if (*ptr == '\n')
|
||||
continue; /* Empty line. */
|
||||
if (slen > 0 && ptr[--slen] == '\n')
|
||||
ptr[slen] = '\0';
|
||||
|
||||
dptr = ct_decode_string(ptr, &el->el_scratch);
|
||||
if (!dptr)
|
||||
continue;
|
||||
if (len > 0 && dptr[len - 1] == '\n')
|
||||
--len;
|
||||
|
||||
/* loop until first non-space char or EOL */
|
||||
while (*dptr != '\0' && Isspace(*dptr))
|
||||
dptr++;
|
||||
@ -565,6 +569,7 @@ el_source(EditLine *el, const char *fname)
|
||||
if ((error = parse_line(el, dptr)) == -1)
|
||||
break;
|
||||
}
|
||||
free(ptr);
|
||||
|
||||
el_free(path);
|
||||
(void) fclose(fp);
|
||||
|
16
el.h
16
el.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $ */
|
||||
/* $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -48,8 +48,6 @@
|
||||
|
||||
#include "histedit.h"
|
||||
#include "chartype.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */
|
||||
|
||||
@ -58,11 +56,7 @@
|
||||
#define EDIT_DISABLED 0x04
|
||||
#define UNBUFFERED 0x08
|
||||
#define CHARSET_IS_UTF8 0x10
|
||||
#define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */
|
||||
#define NARROW_HISTORY 0x40
|
||||
#define NARROW_READ 0x80
|
||||
|
||||
typedef int bool_t; /* True or not */
|
||||
|
||||
typedef unsigned char el_action_t; /* Index to command array */
|
||||
|
||||
@ -72,7 +66,7 @@ typedef struct coord_t { /* Position on the screen */
|
||||
} coord_t;
|
||||
|
||||
typedef struct el_line_t {
|
||||
Char *buffer; /* Input line */
|
||||
Char *buffer; /* Input line */
|
||||
Char *cursor; /* Cursor position */
|
||||
Char *lastchar; /* Last character */
|
||||
const Char *limit; /* Max position */
|
||||
@ -87,7 +81,7 @@ 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 */
|
||||
el_action_t thiscmd; /* this command */
|
||||
Char thisch; /* char that generated it */
|
||||
} el_state_t;
|
||||
|
||||
@ -104,13 +98,11 @@ typedef struct el_state_t {
|
||||
#include "terminal.h"
|
||||
#include "refresh.h"
|
||||
#include "chared.h"
|
||||
#include "common.h"
|
||||
#include "search.h"
|
||||
#include "hist.h"
|
||||
#include "fcns.h" /* el_func_t is needed for map.h */
|
||||
#include "map.h"
|
||||
#include "parse.h"
|
||||
#include "sig.h"
|
||||
#include "help.h"
|
||||
#include "read.h"
|
||||
|
||||
struct editline {
|
||||
|
46
eln.c
46
eln.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $ */
|
||||
/* $NetBSD: eln.c,v 1.27 2016/02/24 17:13:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -34,34 +34,38 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
|
||||
__RCSID("$NetBSD: eln.c,v 1.27 2016/02/24 17:13:22 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
#include "histedit.h"
|
||||
#include "el.h"
|
||||
#include "read.h"
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
public int
|
||||
el_getc(EditLine *el, char *cp)
|
||||
{
|
||||
int num_read;
|
||||
wchar_t wc = 0;
|
||||
|
||||
if (!(el->el_flags & CHARSET_IS_UTF8))
|
||||
el->el_flags |= IGNORE_EXTCHARS;
|
||||
num_read = el_wgetc (el, &wc);
|
||||
if (!(el->el_flags & CHARSET_IS_UTF8))
|
||||
el->el_flags &= ~IGNORE_EXTCHARS;
|
||||
|
||||
if (num_read > 0)
|
||||
*cp = (char)wc;
|
||||
return num_read;
|
||||
num_read = el_wgetc(el, &wc);
|
||||
*cp = '\0';
|
||||
if (num_read <= 0)
|
||||
return num_read;
|
||||
num_read = ct_wctob(wc);
|
||||
if (num_read == EOF) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
} else {
|
||||
*cp = (char)num_read;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIDECHAR
|
||||
public void
|
||||
el_push(EditLine *el, const char *str)
|
||||
{
|
||||
@ -76,17 +80,15 @@ el_gets(EditLine *el, int *nread)
|
||||
{
|
||||
const wchar_t *tmp;
|
||||
|
||||
if (!(el->el_flags & CHARSET_IS_UTF8))
|
||||
el->el_flags |= IGNORE_EXTCHARS;
|
||||
tmp = el_wgets(el, nread);
|
||||
if (tmp != NULL) {
|
||||
int i;
|
||||
size_t nwread = 0;
|
||||
for (int i = 0; i < *nread; i++)
|
||||
|
||||
for (i = 0; i < *nread; i++)
|
||||
nwread += ct_enc_width(tmp[i]);
|
||||
*nread = (int)nwread;
|
||||
}
|
||||
if (!(el->el_flags & CHARSET_IS_UTF8))
|
||||
el->el_flags &= ~IGNORE_EXTCHARS;
|
||||
return ct_encode_string(tmp, &el->el_lgcyconv);
|
||||
}
|
||||
|
||||
@ -231,7 +233,7 @@ el_set(EditLine *el, int op, ...)
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
// XXX: The two strdup's leak
|
||||
/* XXX: The two strdup's leak */
|
||||
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
|
||||
func);
|
||||
ct_free_argv(wargv);
|
||||
@ -245,10 +247,8 @@ el_set(EditLine *el, int op, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX: do we need to change el_rfunc_t? */
|
||||
case EL_GETCFN: /* el_rfunc_t */
|
||||
ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
|
||||
el->el_flags |= NARROW_READ;
|
||||
break;
|
||||
|
||||
case EL_CLIENTDATA: /* void * */
|
||||
@ -342,7 +342,6 @@ el_get(EditLine *el, int op, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX: do we need to change el_rfunc_t? */
|
||||
case EL_GETCFN: /* el_rfunc_t */
|
||||
ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
|
||||
break;
|
||||
@ -397,3 +396,4 @@ el_insertstr(EditLine *el, const char *str)
|
||||
{
|
||||
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
|
||||
}
|
||||
#endif /* WIDECHAR */
|
||||
|
49
emacs.c
49
emacs.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $ */
|
||||
/* $NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,14 +37,17 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $");
|
||||
__RCSID("$NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* emacs.c: Emacs functions
|
||||
*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "emacs.h"
|
||||
|
||||
/* em_delete_or_list():
|
||||
* Delete character under cursor or list completions if at end of line
|
||||
@ -52,7 +55,7 @@ __RCSID("$NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $");
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_or_list(EditLine *el, Int c)
|
||||
em_delete_or_list(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
@ -88,7 +91,7 @@ em_delete_or_list(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *p, *kp;
|
||||
|
||||
@ -117,7 +120,7 @@ em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_yank(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -153,7 +156,7 @@ em_yank(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -175,7 +178,7 @@ em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_kill_region(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -208,7 +211,7 @@ em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_copy_region(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -237,14 +240,14 @@ em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Gosling emacs transpose chars [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
em_gosmacs_transpose(EditLine *el, Int c)
|
||||
em_gosmacs_transpose(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
el->el_line.cursor[-1] = (Char)c;
|
||||
return CC_REFRESH;
|
||||
} else
|
||||
return CC_ERROR;
|
||||
@ -257,7 +260,7 @@ em_gosmacs_transpose(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
return CC_ERROR;
|
||||
@ -282,7 +285,7 @@ em_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *ep;
|
||||
|
||||
@ -306,7 +309,7 @@ em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *ep;
|
||||
|
||||
@ -338,7 +341,7 @@ em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *ep;
|
||||
|
||||
@ -362,7 +365,7 @@ em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_set_mark(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.cursor;
|
||||
@ -376,7 +379,7 @@ em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp;
|
||||
|
||||
@ -393,7 +396,7 @@ em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{ /* multiply current argument by 4 */
|
||||
|
||||
if (el->el_state.argument > 1000000)
|
||||
@ -410,7 +413,7 @@ em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_meta_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.metanext = 1;
|
||||
@ -423,7 +426,7 @@ em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
|
||||
@ -437,7 +440,7 @@ em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *oldc, *dp;
|
||||
|
||||
@ -464,7 +467,7 @@ em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
@ -477,7 +480,7 @@ em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
@ -491,7 +494,7 @@ em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
em_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $ */
|
||||
/* $NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -31,25 +31,22 @@
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $");
|
||||
__RCSID("$NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos 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>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "fcns.h" /* for EL_NUM_FCNS */
|
||||
#include "histedit.h"
|
||||
#include "filecomplete.h"
|
||||
|
||||
static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@',
|
||||
@ -96,9 +93,9 @@ fn_tilde_expand(const char *txt)
|
||||
}
|
||||
if (temp[0] == 0) {
|
||||
#ifdef HAVE_GETPW_R_POSIX
|
||||
if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
|
||||
if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
|
||||
&pass) != 0)
|
||||
pass = NULL;
|
||||
pass = NULL;
|
||||
#elif HAVE_GETPW_R_DRAFT
|
||||
pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf));
|
||||
#else
|
||||
@ -464,7 +461,7 @@ fn_complete(EditLine *el,
|
||||
cur_off - (int)len, cur_off);
|
||||
} else
|
||||
matches = 0;
|
||||
if (!attempted_completion_function ||
|
||||
if (!attempted_completion_function ||
|
||||
(over != NULL && !*over && !matches))
|
||||
matches = completion_matches(
|
||||
ct_encode_string(temp, &el->el_scratch), complet_func);
|
||||
@ -514,7 +511,7 @@ fn_complete(EditLine *el,
|
||||
}
|
||||
/* matches[1] through matches[i-1] are available */
|
||||
matches_num = (size_t)(i - 1);
|
||||
|
||||
|
||||
/* newline to get on next line from command line */
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
|
||||
|
6
hist.c
6
hist.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
|
||||
/* $NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
|
||||
__RCSID("$NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -45,6 +45,8 @@ __RCSID("$NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
/* hist_init():
|
||||
|
6
hist.h
6
hist.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hist.h,v 1.15 2016/01/30 15:05:27 christos Exp $ */
|
||||
/* $NetBSD: hist.h,v 1.18 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,8 +40,6 @@
|
||||
#ifndef _h_el_hist
|
||||
#define _h_el_hist
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...);
|
||||
|
||||
typedef struct el_history_t {
|
||||
@ -82,7 +80,7 @@ protected int hist_set(EditLine *, hist_fun_t, void *);
|
||||
protected int hist_command(EditLine *, int, const Char **);
|
||||
protected int hist_enlargebuf(EditLine *, size_t, size_t);
|
||||
#ifdef WIDECHAR
|
||||
protected wchar_t *hist_convert(EditLine *, int, void *);
|
||||
protected wchar_t *hist_convert(EditLine *, int, void *);
|
||||
#endif
|
||||
|
||||
#endif /* _h_el_hist */
|
||||
|
17
histedit.h
17
histedit.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: histedit.h,v 1.53 2014/06/18 18:12:28 christos Exp $ */
|
||||
/* $NetBSD: histedit.h,v 1.55 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -128,7 +128,7 @@ unsigned char _el_fn_complete(EditLine *, int);
|
||||
* For operations that support set or set/get, the argument types listed are for
|
||||
* the "set" operation. For "get", each listed type must be a pointer.
|
||||
* E.g. EL_EDITMODE takes an int when set, but an int* when get.
|
||||
*
|
||||
*
|
||||
* Operations that only support "get" have the correct argument types listed.
|
||||
*/
|
||||
#define EL_PROMPT 0 /* , prompt_func); set/get */
|
||||
@ -141,7 +141,7 @@ unsigned char _el_fn_complete(EditLine *, int);
|
||||
#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */
|
||||
#define EL_SETTY 8 /* , const Char *, ..., NULL); set */
|
||||
#define EL_ADDFN 9 /* , const Char *, const Char, set */
|
||||
/* el_func_t); */
|
||||
/* el_func_t); */
|
||||
#define EL_HIST 10 /* , hist_fun_t, const void *); set */
|
||||
#define EL_EDITMODE 11 /* , int); set/get */
|
||||
#define EL_RPROMPT 12 /* , prompt_func); set/get */
|
||||
@ -249,20 +249,9 @@ int tok_str(Tokenizer *, const char *,
|
||||
/*
|
||||
* Begin Wide Character Support
|
||||
*/
|
||||
#ifdef __linux__
|
||||
/* Apparently we need _GNU_SOURCE defined to get access to wcsdup on Linux */
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
/*
|
||||
* Wide character versions
|
||||
*/
|
||||
|
||||
/*
|
||||
* ==== Editing ====
|
||||
*/
|
||||
|
43
history.c
43
history.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $ */
|
||||
/* $NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,18 +37,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $");
|
||||
__RCSID("$NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* hist.c: TYPE(History) access functions
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <vis.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vis.h>
|
||||
|
||||
static const char hist_cookie[] = "_HiStOrY_V2_\n";
|
||||
|
||||
@ -437,7 +437,7 @@ history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private void
|
||||
history_def_delete(history_t *h,
|
||||
history_def_delete(history_t *h,
|
||||
TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp)
|
||||
{
|
||||
HistEventPrivate *evp = (void *)&hp->ev;
|
||||
@ -732,7 +732,9 @@ history_load(TYPE(History) *h, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
size_t sz, max_size;
|
||||
size_t llen;
|
||||
ssize_t sz;
|
||||
size_t max_size;
|
||||
char *ptr;
|
||||
int i = -1;
|
||||
TYPE(HistEvent) ev;
|
||||
@ -743,26 +745,23 @@ history_load(TYPE(History) *h, const char *fname)
|
||||
if ((fp = fopen(fname, "r")) == NULL)
|
||||
return i;
|
||||
|
||||
if ((line = fgetln(fp, &sz)) == NULL)
|
||||
line = NULL;
|
||||
llen = 0;
|
||||
if ((sz = getline(&line, &llen, fp)) == -1)
|
||||
goto done;
|
||||
|
||||
if (strncmp(line, hist_cookie, sz) != 0)
|
||||
if (strncmp(line, hist_cookie, (size_t)sz) != 0)
|
||||
goto done;
|
||||
|
||||
ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
|
||||
if (ptr == NULL)
|
||||
goto done;
|
||||
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
|
||||
char c = line[sz];
|
||||
|
||||
if (sz != 0 && line[sz - 1] == '\n')
|
||||
for (i = 0; (sz = getline(&line, &llen, fp)) != -1; i++) {
|
||||
if (sz > 0 && line[sz - 1] == '\n')
|
||||
line[--sz] = '\0';
|
||||
else
|
||||
line[sz] = '\0';
|
||||
|
||||
if (max_size < sz) {
|
||||
if (max_size < (size_t)sz) {
|
||||
char *nptr;
|
||||
max_size = (sz + 1024) & (size_t)~1023;
|
||||
max_size = ((size_t)sz + 1024) & (size_t)~1023;
|
||||
nptr = h_realloc(ptr, max_size * sizeof(*ptr));
|
||||
if (nptr == NULL) {
|
||||
i = -1;
|
||||
@ -771,7 +770,6 @@ history_load(TYPE(History) *h, const char *fname)
|
||||
ptr = nptr;
|
||||
}
|
||||
(void) strunvis(ptr, line);
|
||||
line[sz] = c;
|
||||
if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) {
|
||||
i = -1;
|
||||
goto oomem;
|
||||
@ -780,6 +778,7 @@ history_load(TYPE(History) *h, const char *fname)
|
||||
oomem:
|
||||
h_free(ptr);
|
||||
done:
|
||||
free(line);
|
||||
(void) fclose(fp);
|
||||
return i;
|
||||
}
|
||||
@ -811,8 +810,8 @@ history_save_fp(TYPE(History) *h, FILE *fp)
|
||||
retval != -1;
|
||||
retval = HPREV(h, &ev), i++) {
|
||||
str = ct_encode_string(ev.str, &conv);
|
||||
len = strlen(str) * 4;
|
||||
if (len >= max_size) {
|
||||
len = strlen(str) * 4 + 1;
|
||||
if (len > max_size) {
|
||||
char *nptr;
|
||||
max_size = (len + 1024) & (size_t)~1023;
|
||||
nptr = h_realloc(ptr, max_size * sizeof(*ptr));
|
||||
|
26
keymacro.c
26
keymacro.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $ */
|
||||
/* $NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
|
||||
__RCSID("$NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -63,8 +63,8 @@ __RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
|
||||
* 1) It is not possible to have one key that is a
|
||||
* substr of another.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
@ -73,10 +73,10 @@ __RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
|
||||
* linked list of these node elements
|
||||
*/
|
||||
struct keymacro_node_t {
|
||||
Char ch; /* single character of key */
|
||||
Char ch; /* single character of key */
|
||||
int type; /* node type */
|
||||
keymacro_value_t val; /* command code or pointer to str, */
|
||||
/* if this is a leaf */
|
||||
/* if this is a leaf */
|
||||
struct keymacro_node_t *next; /* ptr to next char of this key */
|
||||
struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/
|
||||
};
|
||||
@ -85,7 +85,7 @@ private int node_trav(EditLine *, keymacro_node_t *, Char *,
|
||||
keymacro_value_t *);
|
||||
private int node__try(EditLine *, keymacro_node_t *, const Char *,
|
||||
keymacro_value_t *, int);
|
||||
private keymacro_node_t *node__get(Int);
|
||||
private keymacro_node_t *node__get(wint_t);
|
||||
private void node__free(keymacro_node_t *);
|
||||
private void node__put(EditLine *, keymacro_node_t *);
|
||||
private int node__delete(EditLine *, keymacro_node_t **,
|
||||
@ -275,21 +275,23 @@ keymacro_print(EditLine *el, const Char *key)
|
||||
|
||||
/* node_trav():
|
||||
* recursively traverses node in tree until match or mismatch is
|
||||
* found. May read in more characters.
|
||||
* found. May read in more characters.
|
||||
*/
|
||||
private int
|
||||
node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
|
||||
{
|
||||
wchar_t wc;
|
||||
|
||||
if (ptr->ch == *ch) {
|
||||
/* match found */
|
||||
if (ptr->next) {
|
||||
/* key not complete so get next char */
|
||||
if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */
|
||||
if (el_wgetc(el, &wc) != 1) {/* if EOF or error */
|
||||
val->cmd = ED_END_OF_FILE;
|
||||
return XK_CMD;
|
||||
/* PWP: Pretend we just read an end-of-file */
|
||||
}
|
||||
*ch = (Char)wc;
|
||||
return node_trav(el, ptr->next, ch, val);
|
||||
} else {
|
||||
*val = ptr->val;
|
||||
@ -312,7 +314,7 @@ node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
|
||||
|
||||
|
||||
/* node__try():
|
||||
* Find a node that matches *str or allocate a new one
|
||||
* Find a node that matches *str or allocate a new one
|
||||
*/
|
||||
private int
|
||||
node__try(EditLine *el, keymacro_node_t *ptr, const Char *str,
|
||||
@ -458,14 +460,14 @@ node__put(EditLine *el, keymacro_node_t *ptr)
|
||||
* Returns pointer to a keymacro_node_t for ch.
|
||||
*/
|
||||
private keymacro_node_t *
|
||||
node__get(Int ch)
|
||||
node__get(wint_t ch)
|
||||
{
|
||||
keymacro_node_t *ptr;
|
||||
|
||||
ptr = el_malloc(sizeof(*ptr));
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
ptr->ch = ch;
|
||||
ptr->ch = (Char)ch;
|
||||
ptr->type = XK_NOD;
|
||||
ptr->val.str = NULL;
|
||||
ptr->next = NULL;
|
||||
@ -594,7 +596,7 @@ keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
(void) keymacro__decode_str(val->str, unparsbuf,
|
||||
sizeof(unparsbuf),
|
||||
sizeof(unparsbuf),
|
||||
ntype == XK_STR ? "\"\"" : "[]");
|
||||
(void) fprintf(el->el_outfile, fmt,
|
||||
ct_encode_string(key, &el->el_scratch), unparsbuf);
|
||||
|
14
makelist
14
makelist
@ -1,5 +1,5 @@
|
||||
#!/bin/sh -
|
||||
# $NetBSD: makelist,v 1.18 2012/03/21 05:34:54 matt Exp $
|
||||
# $NetBSD: makelist,v 1.24 2016/02/17 19:47:49 christos Exp $
|
||||
#
|
||||
# Copyright (c) 1992, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
@ -61,7 +61,7 @@ case $FLAG in
|
||||
#include "${FILES}"
|
||||
_EOF
|
||||
;;
|
||||
|
||||
|
||||
-h)
|
||||
set - `echo $FILES | sed -e 's/\\./_/g'`
|
||||
hdr="_h_`basename $1`"
|
||||
@ -78,7 +78,8 @@ _EOF
|
||||
# XXX: need a space between name and prototype so that -fc and -fh
|
||||
# parsing is much easier
|
||||
#
|
||||
printf("protected el_action_t\t%s (EditLine *, Int);\n", name);
|
||||
printf("protected el_action_t\t%s (EditLine *, wint_t);\n",
|
||||
name);
|
||||
}
|
||||
}
|
||||
END {
|
||||
@ -93,7 +94,7 @@ _EOF
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"config.h\"\n#include \"el.h\"\n");
|
||||
printf("#include \"chartype.h\"\n");
|
||||
printf("#include \"help.h\"\n");
|
||||
printf("private const struct el_bindings_t el_func_help[] = {\n");
|
||||
low = "abcdefghijklmnopqrstuvwxyz_";
|
||||
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
@ -162,7 +163,7 @@ _EOF
|
||||
END {
|
||||
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
|
||||
|
||||
printf("typedef el_action_t (*el_func_t)(EditLine *, Int);");
|
||||
printf("typedef el_action_t (*el_func_t)(EditLine *, wint_t);");
|
||||
printf("\nprotected const el_func_t* func__get(void);\n");
|
||||
printf("#endif /* _h_fcns_c */\n");
|
||||
}'
|
||||
@ -175,6 +176,9 @@ _EOF
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"config.h\"\n#include \"el.h\"\n");
|
||||
printf("#include \"common.h\"\n");
|
||||
printf("#include \"emacs.h\"\n");
|
||||
printf("#include \"vi.h\"\n");
|
||||
printf("private const el_func_t el_func[] = {");
|
||||
maxlen = 80;
|
||||
needn = 1;
|
||||
|
33
map.c
33
map.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $ */
|
||||
/* $NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,18 +37,23 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
|
||||
__RCSID("$NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* map.c: Editor function definitions
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "help.h"
|
||||
#include "parse.h"
|
||||
|
||||
private void map_print_key(EditLine *, el_action_t *, const Char *);
|
||||
private void map_print_some_keys(EditLine *, el_action_t *, Int, Int);
|
||||
private void map_print_some_keys(EditLine *, el_action_t *, wint_t, wint_t);
|
||||
private void map_print_all_keys(EditLine *);
|
||||
private void map_init_nls(EditLine *);
|
||||
private void map_init_meta(EditLine *);
|
||||
@ -1142,19 +1147,19 @@ map_print_key(EditLine *el, el_action_t *map, const Char *in)
|
||||
* Print keys from first to last
|
||||
*/
|
||||
private void
|
||||
map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
|
||||
map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
|
||||
{
|
||||
el_bindings_t *bp, *ep;
|
||||
Char firstbuf[2], lastbuf[2];
|
||||
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
|
||||
|
||||
firstbuf[0] = first;
|
||||
firstbuf[0] = (Char)first;
|
||||
firstbuf[1] = 0;
|
||||
lastbuf[0] = last;
|
||||
lastbuf[0] = (Char)last;
|
||||
lastbuf[1] = 0;
|
||||
if (map[first] == ED_UNASSIGNED) {
|
||||
if (first == last) {
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
sizeof(unparsbuf), STRQQ);
|
||||
(void) fprintf(el->el_outfile,
|
||||
"%-15s-> is undefined\n", unparsbuf);
|
||||
@ -1165,14 +1170,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
|
||||
for (bp = el->el_map.help; bp < ep; bp++) {
|
||||
if (bp->func == map[first]) {
|
||||
if (first == last) {
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
sizeof(unparsbuf), STRQQ);
|
||||
(void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
|
||||
unparsbuf, bp->name);
|
||||
} else {
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
sizeof(unparsbuf), STRQQ);
|
||||
(void) keymacro__decode_str(lastbuf, extrabuf,
|
||||
(void) keymacro__decode_str(lastbuf, extrabuf,
|
||||
sizeof(extrabuf), STRQQ);
|
||||
(void) fprintf(el->el_outfile,
|
||||
"%-4s to %-7s-> " FSTR "\n",
|
||||
@ -1183,14 +1188,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
|
||||
}
|
||||
#ifdef MAP_DEBUG
|
||||
if (map == el->el_map.key) {
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
sizeof(unparsbuf), STRQQ);
|
||||
(void) fprintf(el->el_outfile,
|
||||
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
|
||||
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
|
||||
first, el->el_map.key[first]);
|
||||
} else {
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
(void) keymacro__decode_str(firstbuf, unparsbuf,
|
||||
sizeof(unparsbuf), STRQQ);
|
||||
(void) fprintf(el->el_outfile,
|
||||
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
|
||||
@ -1300,8 +1305,8 @@ map_bind(EditLine *el, int argc, const Char **argv)
|
||||
return 0;
|
||||
default:
|
||||
(void) fprintf(el->el_errfile,
|
||||
"" FSTR ": Invalid switch `" FCHAR "'.\n",
|
||||
argv[0], (Int)p[1]);
|
||||
"" FSTR ": Invalid switch `%lc'.\n",
|
||||
argv[0], (wint_t)p[1]);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
17
parse.c
17
parse.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -54,16 +54,19 @@ __RCSID("$NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $");
|
||||
* settc
|
||||
* setty
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "parse.h"
|
||||
|
||||
private const struct {
|
||||
const Char *name;
|
||||
int (*func)(EditLine *, int, const Char **);
|
||||
} cmds[] = {
|
||||
{ STR("bind"), map_bind },
|
||||
{ STR("bind"), map_bind },
|
||||
{ STR("echotc"), terminal_echotc },
|
||||
{ STR("edit"), el_editmode },
|
||||
{ STR("edit"), el_editmode },
|
||||
{ STR("history"), hist_command },
|
||||
{ STR("telltc"), terminal_telltc },
|
||||
{ STR("settc"), terminal_settc },
|
||||
@ -139,7 +142,7 @@ protected int
|
||||
parse__escape(const Char **ptr)
|
||||
{
|
||||
const Char *p;
|
||||
Int c;
|
||||
wint_t c;
|
||||
|
||||
p = *ptr;
|
||||
|
||||
@ -251,7 +254,7 @@ parse__string(Char *out, const Char *in)
|
||||
case '^':
|
||||
if ((n = parse__escape(&in)) == -1)
|
||||
return NULL;
|
||||
*out++ = n;
|
||||
*out++ = (Char)n;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
|
4
prompt.c
4
prompt.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
|
||||
/* $NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
|
||||
__RCSID("$NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
|
6
prompt.h
6
prompt.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prompt.h,v 1.10 2009/12/30 22:37:40 christos Exp $ */
|
||||
/* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,15 +40,13 @@
|
||||
#ifndef _h_el_prompt
|
||||
#define _h_el_prompt
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef Char *(*el_pfunc_t)(EditLine *);
|
||||
|
||||
typedef struct el_prompt_t {
|
||||
el_pfunc_t p_func; /* Function to return the prompt */
|
||||
coord_t p_pos; /* position in the line after prompt */
|
||||
Char p_ignore; /* character to start/end literal */
|
||||
int p_wide;
|
||||
int p_wide;
|
||||
} el_prompt_t;
|
||||
|
||||
protected void prompt_print(EditLine *, int);
|
||||
|
118
read.c
118
read.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $ */
|
||||
/* $NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $");
|
||||
__RCSID("$NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -45,18 +45,21 @@ __RCSID("$NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $");
|
||||
* read.c: Clean this junk up! This is horrible code.
|
||||
* Terminal read functions
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
#define OKCMD -1 /* must be -1! */
|
||||
|
||||
private int read__fixio(int, int);
|
||||
private int read_preread(EditLine *);
|
||||
private int read_char(EditLine *, Char *);
|
||||
private int read_char(EditLine *, wchar_t *);
|
||||
private int read_getcmd(EditLine *, el_action_t *, Char *);
|
||||
private void read_pop(c_macro_t *);
|
||||
|
||||
@ -239,18 +242,21 @@ FUN(el,push)(EditLine *el, const Char *str)
|
||||
private int
|
||||
read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
|
||||
{
|
||||
static const Char meta = (Char)0x80;
|
||||
el_action_t cmd;
|
||||
wchar_t wc;
|
||||
int num;
|
||||
|
||||
el->el_errno = 0;
|
||||
do {
|
||||
if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
|
||||
if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */
|
||||
el->el_errno = num == 0 ? 0 : errno;
|
||||
return 0; /* not OKCMD */
|
||||
}
|
||||
*ch = (Char)wc;
|
||||
|
||||
#ifdef KANJI
|
||||
if ((*ch & 0200)) {
|
||||
if ((*ch & meta)) {
|
||||
el->el_state.metanext = 0;
|
||||
cmd = CcViMap[' '];
|
||||
break;
|
||||
@ -259,7 +265,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
|
||||
|
||||
if (el->el_state.metanext) {
|
||||
el->el_state.metanext = 0;
|
||||
*ch |= 0200;
|
||||
*ch |= meta;
|
||||
}
|
||||
#ifdef WIDECHAR
|
||||
if (*ch >= N_KEYS)
|
||||
@ -294,29 +300,17 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
|
||||
return OKCMD;
|
||||
}
|
||||
|
||||
#ifdef WIDECHAR
|
||||
/* utf8_islead():
|
||||
* Test whether a byte is a leading byte of a UTF-8 sequence.
|
||||
*/
|
||||
private int
|
||||
utf8_islead(int c)
|
||||
{
|
||||
return c < 0x80 || /* single byte char */
|
||||
(c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* read_char():
|
||||
* Read a character from the tty.
|
||||
*/
|
||||
private int
|
||||
read_char(EditLine *el, Char *cp)
|
||||
read_char(EditLine *el, wchar_t *cp)
|
||||
{
|
||||
ssize_t num_read;
|
||||
int tried = 0;
|
||||
char cbuf[MB_LEN_MAX];
|
||||
size_t cbp = 0;
|
||||
int bytes = 0;
|
||||
int save_errno = errno;
|
||||
|
||||
again:
|
||||
el->el_signal->sig_no = 0;
|
||||
@ -332,50 +326,59 @@ read_char(EditLine *el, Char *cp)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!tried && read__fixio(el->el_infd, e) == 0)
|
||||
if (!tried && read__fixio(el->el_infd, e) == 0) {
|
||||
errno = save_errno;
|
||||
tried = 1;
|
||||
else {
|
||||
} else {
|
||||
errno = e;
|
||||
*cp = '\0';
|
||||
*cp = L'\0';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for EOF */
|
||||
if (num_read == 0) {
|
||||
errno = 0;
|
||||
*cp = '\0';
|
||||
*cp = L'\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WIDECHAR
|
||||
if (el->el_flags & CHARSET_IS_UTF8) {
|
||||
if (!utf8_islead((unsigned char)cbuf[0]))
|
||||
goto again; /* discard the byte we read and try again */
|
||||
for (;;) {
|
||||
|
||||
++cbp;
|
||||
if ((bytes = ct_mbtowc(cp, cbuf, cbp)) == -1) {
|
||||
ct_mbtowc_reset;
|
||||
if (cbp >= MB_LEN_MAX) { /* "shouldn't happen" */
|
||||
switch (ct_mbrtowc(cp, cbuf, cbp)) {
|
||||
case (size_t)-1:
|
||||
if (cbp > 1) {
|
||||
/*
|
||||
* Invalid sequence, discard all bytes
|
||||
* except the last one.
|
||||
*/
|
||||
cbuf[0] = cbuf[cbp - 1];
|
||||
cbp = 0;
|
||||
break;
|
||||
} else {
|
||||
/* Invalid byte, discard it. */
|
||||
cbp = 0;
|
||||
goto again;
|
||||
}
|
||||
case (size_t)-2:
|
||||
/*
|
||||
* We don't support other multibyte charsets.
|
||||
* The second condition shouldn't happen
|
||||
* and is here merely for additional safety.
|
||||
*/
|
||||
if ((el->el_flags & CHARSET_IS_UTF8) == 0 ||
|
||||
cbp >= MB_LEN_MAX) {
|
||||
errno = EILSEQ;
|
||||
*cp = '\0';
|
||||
*cp = L'\0';
|
||||
return -1;
|
||||
}
|
||||
/* Incomplete sequence, read another byte. */
|
||||
goto again;
|
||||
default:
|
||||
/* Valid character, process it. */
|
||||
return 1;
|
||||
}
|
||||
} else if (isascii((unsigned char)cbuf[0]) ||
|
||||
/* we don't support other multibyte charsets */
|
||||
++cbp != 1 ||
|
||||
/* Try non-ASCII characters in a 8-bit character set */
|
||||
(bytes = ct_mbtowc(cp, cbuf, cbp)) != 1)
|
||||
#endif
|
||||
*cp = (unsigned char)cbuf[0];
|
||||
|
||||
if ((el->el_flags & IGNORE_EXTCHARS) && bytes > 1) {
|
||||
cbp = 0; /* skip this character */
|
||||
goto again;
|
||||
}
|
||||
|
||||
return (int)num_read;
|
||||
}
|
||||
|
||||
/* read_pop():
|
||||
@ -393,11 +396,11 @@ read_pop(c_macro_t *ma)
|
||||
ma->offset = 0;
|
||||
}
|
||||
|
||||
/* el_getc():
|
||||
* Read a character
|
||||
/* el_wgetc():
|
||||
* Read a wide character
|
||||
*/
|
||||
public int
|
||||
FUN(el,getc)(EditLine *el, Char *cp)
|
||||
el_wgetc(EditLine *el, wchar_t *cp)
|
||||
{
|
||||
int num_read;
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
@ -439,12 +442,8 @@ FUN(el,getc)(EditLine *el, Char *cp)
|
||||
num_read = (*el->el_read.read_char)(el, cp);
|
||||
if (num_read < 0)
|
||||
el->el_errno = errno;
|
||||
#ifdef WIDECHAR
|
||||
if (el->el_flags & NARROW_READ)
|
||||
*cp = *(char *)(void *)cp;
|
||||
#endif
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Got it %c\n", *cp);
|
||||
(void) fprintf(el->el_errfile, "Got it %lc\n", *cp);
|
||||
#endif /* DEBUG_READ */
|
||||
return num_read;
|
||||
}
|
||||
@ -485,6 +484,7 @@ FUN(el,gets)(EditLine *el, int *nread)
|
||||
int retval;
|
||||
el_action_t cmdnum = 0;
|
||||
int num; /* how many chars we have read at NL */
|
||||
wchar_t wc;
|
||||
Char ch, *cp;
|
||||
int crlf = 0;
|
||||
int nrb;
|
||||
@ -500,7 +500,8 @@ FUN(el,gets)(EditLine *el, int *nread)
|
||||
size_t idx;
|
||||
|
||||
cp = el->el_line.buffer;
|
||||
while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
|
||||
while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
|
||||
*cp = (Char)wc;
|
||||
/* make sure there is space for next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (size_t)(cp - el->el_line.buffer);
|
||||
@ -552,7 +553,8 @@ FUN(el,gets)(EditLine *el, int *nread)
|
||||
|
||||
terminal__flush(el);
|
||||
|
||||
while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
|
||||
while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
|
||||
*cp = (Char)wc;
|
||||
/* make sure there is space next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (size_t)(cp - el->el_line.buffer);
|
||||
|
6
read.h
6
read.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: read.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */
|
||||
/* $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -35,12 +35,12 @@
|
||||
#ifndef _h_el_read
|
||||
#define _h_el_read
|
||||
|
||||
typedef int (*el_rfunc_t)(EditLine *, Char *);
|
||||
typedef int (*el_rfunc_t)(EditLine *, wchar_t *);
|
||||
|
||||
typedef struct el_read_t {
|
||||
el_rfunc_t read_char; /* Function to read a character */
|
||||
} el_read_t;
|
||||
|
||||
|
||||
protected int read_init(EditLine *);
|
||||
protected void read_prepare(EditLine *);
|
||||
protected void read_finish(EditLine *);
|
||||
|
63
readline.c
63
readline.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $ */
|
||||
/* $NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -31,28 +31,27 @@
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $");
|
||||
__RCSID("$NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos 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 <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vis.h>
|
||||
|
||||
#include "readline/readline.h"
|
||||
#include "el.h"
|
||||
#include "fcns.h" /* for EL_NUM_FCNS */
|
||||
#include "histedit.h"
|
||||
#include "filecomplete.h"
|
||||
|
||||
void rl_prep_terminal(int);
|
||||
@ -167,13 +166,13 @@ static jmp_buf topbuf;
|
||||
static unsigned char _el_rl_complete(EditLine *, int);
|
||||
static unsigned char _el_rl_tstp(EditLine *, int);
|
||||
static char *_get_prompt(EditLine *);
|
||||
static int _getc_function(EditLine *, char *);
|
||||
static int _getc_function(EditLine *, wchar_t *);
|
||||
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_event_read_char(EditLine *, char *);
|
||||
static int _rl_event_read_char(EditLine *, wchar_t *);
|
||||
static void _rl_update_pos(void);
|
||||
|
||||
|
||||
@ -210,14 +209,14 @@ _move_history(int op)
|
||||
*/
|
||||
static int
|
||||
/*ARGSUSED*/
|
||||
_getc_function(EditLine *el __attribute__((__unused__)), char *c)
|
||||
_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = (*rl_getc_function)(NULL);
|
||||
if (i == -1)
|
||||
return 0;
|
||||
*c = (char)i;
|
||||
*c = (wchar_t)i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -267,7 +266,7 @@ rl_set_prompt(const char *prompt)
|
||||
|
||||
if (!prompt)
|
||||
prompt = "";
|
||||
if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
|
||||
if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
|
||||
return 0;
|
||||
if (rl_prompt)
|
||||
el_free(rl_prompt);
|
||||
@ -361,7 +360,7 @@ rl_initialize(void)
|
||||
"ReadLine compatible suspend function",
|
||||
_el_rl_tstp);
|
||||
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
|
||||
|
||||
|
||||
/*
|
||||
* Set some readline compatible key-bindings.
|
||||
*/
|
||||
@ -2008,7 +2007,7 @@ rl_callback_read_char(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
|
||||
{
|
||||
if (e == NULL) {
|
||||
@ -2017,9 +2016,9 @@ rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
|
||||
(void)rl_set_prompt(prompt);
|
||||
rl_linefunc = linefunc;
|
||||
el_set(e, EL_UNBUFFERED, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
rl_callback_handler_remove(void)
|
||||
{
|
||||
el_set(e, EL_UNBUFFERED, 0);
|
||||
@ -2100,12 +2099,14 @@ rl_stuff_char(int c)
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_event_read_char(EditLine *el, char *cp)
|
||||
_rl_event_read_char(EditLine *el, wchar_t *wc)
|
||||
{
|
||||
char ch;
|
||||
int n;
|
||||
ssize_t num_read = 0;
|
||||
|
||||
*cp = '\0';
|
||||
ch = '\0';
|
||||
*wc = L'\0';
|
||||
while (rl_event_hook) {
|
||||
|
||||
(*rl_event_hook)();
|
||||
@ -2114,7 +2115,7 @@ _rl_event_read_char(EditLine *el, char *cp)
|
||||
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
|
||||
return -1;
|
||||
if (n)
|
||||
num_read = read(el->el_infd, cp, (size_t)1);
|
||||
num_read = read(el->el_infd, &ch, (size_t)1);
|
||||
else
|
||||
num_read = 0;
|
||||
#elif defined(F_SETFL) && defined(O_NDELAY)
|
||||
@ -2122,12 +2123,12 @@ _rl_event_read_char(EditLine *el, char *cp)
|
||||
return -1;
|
||||
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
|
||||
return -1;
|
||||
num_read = read(el->el_infd, cp, 1);
|
||||
num_read = read(el->el_infd, &ch, 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);
|
||||
num_read = read(el->el_infd, &ch, 1);
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
@ -2139,6 +2140,7 @@ _rl_event_read_char(EditLine *el, char *cp)
|
||||
}
|
||||
if (!rl_event_hook)
|
||||
el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
|
||||
*wc = (wchar_t)ch;
|
||||
return (int)num_read;
|
||||
}
|
||||
|
||||
@ -2201,7 +2203,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
|
||||
}
|
||||
qsort(&list[1], len - 1, sizeof(*list),
|
||||
(int (*)(const void *, const void *)) strcmp);
|
||||
min = SIZE_T_MAX;
|
||||
min = SIZE_MAX;
|
||||
for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
|
||||
b = list[i + 1];
|
||||
for (j = 0; a[j] && a[j] == b[j]; j++)
|
||||
@ -2219,7 +2221,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
|
||||
list[0][min] = '\0';
|
||||
}
|
||||
return list;
|
||||
|
||||
|
||||
out:
|
||||
el_free(list);
|
||||
return NULL;
|
||||
@ -2323,3 +2325,10 @@ void
|
||||
rl_free_line_state(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
/*ARGSUSED*/
|
||||
rl_set_keyboard_input_timeout(int u __attribute__((__unused__)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.7 2003/08/03 09:23:15 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.8 2016/02/17 19:47:49 christos Exp $
|
||||
|
||||
NOOBJ= # defined
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readline.h,v 1.37 2015/06/02 15:36:45 christos Exp $ */
|
||||
/* $NetBSD: readline.h,v 1.39 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -53,7 +53,7 @@ typedef void *histdata_t;
|
||||
|
||||
typedef struct _hist_entry {
|
||||
const char *line;
|
||||
histdata_t data;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
typedef struct _keymap_entry {
|
||||
@ -87,7 +87,7 @@ typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
#define RUBOUT 0x7f
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
#define RL_READLINE_VERSION 0x0402
|
||||
#define RL_READLINE_VERSION 0x0402
|
||||
#define RL_PROMPT_START_IGNORE '\1'
|
||||
#define RL_PROMPT_END_IGNORE '\2'
|
||||
|
||||
@ -96,7 +96,7 @@ typedef KEYMAP_ENTRY *Keymap;
|
||||
extern "C" {
|
||||
#endif
|
||||
extern const char *rl_library_version;
|
||||
extern int rl_readline_version;
|
||||
extern int rl_readline_version;
|
||||
extern char *rl_readline_name;
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
@ -197,10 +197,10 @@ int rl_add_defun(const char *, rl_command_func_t *, int);
|
||||
HISTORY_STATE *history_get_history_state(void);
|
||||
void rl_get_screen_size(int *, int *);
|
||||
void rl_set_screen_size(int, int);
|
||||
char *rl_filename_completion_function (const char *, int);
|
||||
char *rl_filename_completion_function (const char *, int);
|
||||
int _rl_abort_internal(void);
|
||||
int _rl_qsort_string_compare(char **, char **);
|
||||
char **rl_completion_matches(const char *, rl_compentry_func_t *);
|
||||
char **rl_completion_matches(const char *, rl_compentry_func_t *);
|
||||
void rl_forced_update_display(void);
|
||||
int rl_set_prompt(const char *);
|
||||
int rl_on_new_line(void);
|
||||
@ -216,6 +216,8 @@ int rl_generic_bind(int, const char *, const char *, Keymap);
|
||||
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
|
||||
void rl_cleanup_after_signal(void);
|
||||
void rl_free_line_state(void);
|
||||
int rl_set_keyboard_input_timeout(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
33
refresh.c
33
refresh.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $ */
|
||||
/* $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $");
|
||||
__RCSID("$NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -45,18 +45,17 @@ __RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $");
|
||||
* refresh.c: Lower level screen refreshing functions
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
private void re_nextline(EditLine *);
|
||||
private void re_addc(EditLine *, Int);
|
||||
private void re_addc(EditLine *, wint_t);
|
||||
private void re_update_line(EditLine *, Char *, Char *, int);
|
||||
private void re_insert (EditLine *, Char *, int, int, Char *, int);
|
||||
private void re_delete(EditLine *, Char *, int, int, int);
|
||||
private void re_fastputc(EditLine *, Int);
|
||||
private void re_fastputc(EditLine *, wint_t);
|
||||
private void re_clear_eol(EditLine *, int, int, int);
|
||||
private void re__strncopy(Char *, Char *, size_t);
|
||||
private void re__copy_and_pad(Char *, const Char *, size_t);
|
||||
@ -64,7 +63,7 @@ private void re__copy_and_pad(Char *, const Char *, size_t);
|
||||
#ifdef DEBUG_REFRESH
|
||||
private void re_printstr(EditLine *, const char *, char *, char *);
|
||||
#define __F el->el_errfile
|
||||
#define ELRE_ASSERT(a, b, c) do \
|
||||
#define ELRE_ASSERT(a, b, c) do \
|
||||
if (/*CONSTCOND*/ a) { \
|
||||
(void) fprintf b; \
|
||||
c; \
|
||||
@ -110,7 +109,7 @@ re_nextline(EditLine *el)
|
||||
for(i = 1; i < lins; i++)
|
||||
el->el_vdisplay[i - 1] = el->el_vdisplay[i];
|
||||
|
||||
firstline[0] = '\0'; /* empty the string */
|
||||
firstline[0] = '\0'; /* empty the string */
|
||||
el->el_vdisplay[i - 1] = firstline;
|
||||
} else
|
||||
el->el_refresh.r_cursor.v++;
|
||||
@ -125,7 +124,7 @@ re_nextline(EditLine *el)
|
||||
* Draw c, expanding tabs, control chars etc.
|
||||
*/
|
||||
private void
|
||||
re_addc(EditLine *el, Int c)
|
||||
re_addc(EditLine *el, wint_t c)
|
||||
{
|
||||
switch (ct_chr_class((Char)c)) {
|
||||
case CHTYPE_TAB: /* expand the tab */
|
||||
@ -161,16 +160,16 @@ re_addc(EditLine *el, Int c)
|
||||
* Draw the character given
|
||||
*/
|
||||
protected void
|
||||
re_putc(EditLine *el, Int c, int shift)
|
||||
re_putc(EditLine *el, wint_t c, int shift)
|
||||
{
|
||||
int i, w = Width(c);
|
||||
ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c));
|
||||
ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c));
|
||||
|
||||
while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h))
|
||||
re_putc(el, ' ', 1);
|
||||
|
||||
el->el_vdisplay[el->el_refresh.r_cursor.v]
|
||||
[el->el_refresh.r_cursor.h] = c;
|
||||
[el->el_refresh.r_cursor.h] = (Char)c;
|
||||
/* assumes !shift is only used for single-column chars */
|
||||
i = w;
|
||||
while (--i > 0)
|
||||
@ -192,7 +191,7 @@ re_putc(EditLine *el, Int c, int shift)
|
||||
|
||||
/* re_refresh():
|
||||
* draws the new virtual screen image from the current input
|
||||
* line, then goes line-by-line changing the real image to the new
|
||||
* line, then goes line-by-line changing the real image to the new
|
||||
* virtual image. The routine to re-draw a line can be replaced
|
||||
* easily in hopes of a smarter one being placed there.
|
||||
*/
|
||||
@ -451,7 +450,7 @@ re__strncopy(Char *a, Char *b, size_t n)
|
||||
* in order to make sure that we have cleared the previous contents of
|
||||
* the line. fx and sx is the number of characters inserted or deleted
|
||||
* in the first or second diff, diff is the difference between the
|
||||
* number of characters between the new and old line.
|
||||
* number of characters between the new and old line.
|
||||
*/
|
||||
private void
|
||||
re_clear_eol(EditLine *el, int fx, int sx, int diff)
|
||||
@ -1052,14 +1051,14 @@ re_refresh_cursor(EditLine *el)
|
||||
* Add a character fast.
|
||||
*/
|
||||
private void
|
||||
re_fastputc(EditLine *el, Int c)
|
||||
re_fastputc(EditLine *el, wint_t c)
|
||||
{
|
||||
int w = Width((Char)c);
|
||||
while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h)
|
||||
re_fastputc(el, ' ');
|
||||
|
||||
terminal__putc(el, c);
|
||||
el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
|
||||
el->el_display[el->el_cursor.v][el->el_cursor.h++] = (Char)c;
|
||||
while (--w > 0)
|
||||
el->el_display[el->el_cursor.v][el->el_cursor.h++]
|
||||
= MB_FILL_CHAR;
|
||||
@ -1077,7 +1076,7 @@ re_fastputc(EditLine *el, Int c)
|
||||
if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) {
|
||||
int i, lins = el->el_terminal.t_size.v;
|
||||
Char *firstline = el->el_display[0];
|
||||
|
||||
|
||||
for(i = 1; i < lins; i++)
|
||||
el->el_display[i - 1] = el->el_display[i];
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: refresh.h,v 1.6 2009/12/30 22:37:40 christos Exp $ */
|
||||
/* $NetBSD: refresh.h,v 1.9 2016/02/16 15:53:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,15 +40,13 @@
|
||||
#ifndef _h_el_refresh
|
||||
#define _h_el_refresh
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct {
|
||||
coord_t r_cursor; /* Refresh cursor position */
|
||||
int r_oldcv; /* Vertical locations */
|
||||
int r_newcv;
|
||||
} el_refresh_t;
|
||||
|
||||
protected void re_putc(EditLine *, Int, int);
|
||||
protected void re_putc(EditLine *, wint_t, int);
|
||||
protected void re_clear_lines(EditLine *);
|
||||
protected void re_clear_display(EditLine *);
|
||||
protected void re_refresh(EditLine *);
|
||||
|
34
search.c
34
search.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $ */
|
||||
/* $NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $");
|
||||
__RCSID("$NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -45,12 +45,15 @@ __RCSID("$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $");
|
||||
* search.c: History and character search functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(REGEX)
|
||||
#include <regex.h>
|
||||
#elif defined(REGEXP)
|
||||
#include <regexp.h>
|
||||
#endif
|
||||
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* Adjust cursor in vi mode to include the character under it
|
||||
@ -209,8 +212,9 @@ ce_inc_search(EditLine *el, int dir)
|
||||
STRbck[] = {'b', 'c', 'k', '\0'};
|
||||
static Char pchar = ':';/* ':' = normal, '?' = failed */
|
||||
static Char endcmd[2] = {'\0', '\0'};
|
||||
Char ch, *ocursor = el->el_line.cursor, oldpchar = pchar;
|
||||
Char *ocursor = el->el_line.cursor, oldpchar = pchar, ch;
|
||||
const Char *cp;
|
||||
wchar_t wch;
|
||||
|
||||
el_action_t ret = CC_NORM;
|
||||
|
||||
@ -249,9 +253,11 @@ ce_inc_search(EditLine *el, int dir)
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
|
||||
if (FUN(el,getc)(el, &ch) != 1)
|
||||
if (el_wgetc(el, &wch) != 1)
|
||||
return ed_end_of_file(el, 0);
|
||||
|
||||
ch = (Char)wch;
|
||||
|
||||
switch (el->el_map.current[(unsigned char) ch]) {
|
||||
case ED_INSERT:
|
||||
case ED_DIGIT:
|
||||
@ -345,14 +351,14 @@ ce_inc_search(EditLine *el, int dir)
|
||||
|
||||
/* Can't search if unmatched '[' */
|
||||
for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
|
||||
ch = ']';
|
||||
ch = L']';
|
||||
cp >= &el->el_search.patbuf[LEN];
|
||||
cp--)
|
||||
if (*cp == '[' || *cp == ']') {
|
||||
ch = *cp;
|
||||
break;
|
||||
}
|
||||
if (el->el_search.patlen > LEN && ch != '[') {
|
||||
if (el->el_search.patlen > LEN && ch != L'[') {
|
||||
if (redo && newdir == dir) {
|
||||
if (pchar == '?') { /* wrap around */
|
||||
el->el_history.eventno =
|
||||
@ -567,7 +573,7 @@ ce_search_line(EditLine *el, int dir)
|
||||
* Vi repeat search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_repeat_srch(EditLine *el, Int c)
|
||||
cv_repeat_srch(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
#ifdef SDEBUG
|
||||
@ -593,35 +599,33 @@ cv_repeat_srch(EditLine *el, Int c)
|
||||
* Vi character search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_csearch(EditLine *el, int direction, Int ch, int count, int tflag)
|
||||
cv_csearch(EditLine *el, int direction, wint_t ch, int count, int tflag)
|
||||
{
|
||||
Char *cp;
|
||||
|
||||
if (ch == 0)
|
||||
return CC_ERROR;
|
||||
|
||||
if (ch == (Int)-1) {
|
||||
Char c;
|
||||
if (FUN(el,getc)(el, &c) != 1)
|
||||
if (ch == (wint_t)-1) {
|
||||
if (el_wgetc(el, &ch) != 1)
|
||||
return ed_end_of_file(el, 0);
|
||||
ch = c;
|
||||
}
|
||||
|
||||
/* Save for ';' and ',' commands */
|
||||
el->el_search.chacha = ch;
|
||||
el->el_search.chacha = (Char)ch;
|
||||
el->el_search.chadir = direction;
|
||||
el->el_search.chatflg = (char)tflag;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
while (count--) {
|
||||
if ((Int)*cp == ch)
|
||||
if ((wint_t)*cp == ch)
|
||||
cp += direction;
|
||||
for (;;cp += direction) {
|
||||
if (cp >= el->el_line.lastchar)
|
||||
return CC_ERROR;
|
||||
if (cp < el->el_line.buffer)
|
||||
return CC_ERROR;
|
||||
if ((Int)*cp == ch)
|
||||
if ((wint_t)*cp == ch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
8
search.h
8
search.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: search.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */
|
||||
/* $NetBSD: search.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,8 +40,6 @@
|
||||
#ifndef _h_el_search
|
||||
#define _h_el_search
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct el_search_t {
|
||||
Char *patbuf; /* The pattern buffer */
|
||||
size_t patlen; /* Length of the pattern buffer */
|
||||
@ -60,7 +58,7 @@ 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 *, int);
|
||||
protected el_action_t cv_repeat_srch(EditLine *, Int);
|
||||
protected el_action_t cv_csearch(EditLine *, int, Int, int, int);
|
||||
protected el_action_t cv_repeat_srch(EditLine *, wint_t);
|
||||
protected el_action_t cv_csearch(EditLine *, int, wint_t, int, int);
|
||||
|
||||
#endif /* _h_el_search */
|
||||
|
13
sig.c
13
sig.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $ */
|
||||
/* $NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $");
|
||||
__RCSID("$NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -46,9 +46,12 @@ __RCSID("$NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $");
|
||||
* our policy is to trap all signals, set a good state
|
||||
* and pass the ball to our caller.
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
|
||||
private EditLine *sel = NULL;
|
||||
|
||||
private const int sighdl[] = {
|
||||
@ -68,9 +71,10 @@ private void sig_handler(int);
|
||||
private void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
int i;
|
||||
int i, save_errno;
|
||||
sigset_t nset, oset;
|
||||
|
||||
save_errno = errno;
|
||||
(void) sigemptyset(&nset);
|
||||
(void) sigaddset(&nset, signo);
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
@ -104,6 +108,7 @@ sig_handler(int signo)
|
||||
sigemptyset(&sel->el_signal->sig_action[i].sa_mask);
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
(void) kill(0, signo);
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
|
||||
|
4
sig.h
4
sig.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sig.h,v 1.8 2009/02/19 15:20:22 christos Exp $ */
|
||||
/* $NetBSD: sig.h,v 1.10 2016/02/16 15:53:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -42,8 +42,6 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
/*
|
||||
* Define here all the signals we are going to handle
|
||||
* The _DO macro is used to iterate in the source code
|
||||
|
24
sys.h
24
sys.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys.h,v 1.17 2011/09/28 14:08:04 christos Exp $ */
|
||||
/* $NetBSD: sys.h,v 1.23 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -57,7 +57,7 @@
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef public
|
||||
# define public /* Externally visible functions/variables */
|
||||
#endif
|
||||
@ -87,14 +87,9 @@ size_t strlcat(char *dst, const char *src, size_t size);
|
||||
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
|
||||
|
||||
#ifndef HAVE_WCSDUP
|
||||
#include <wchar.h>
|
||||
wchar_t *wcsdup(const wchar_t *);
|
||||
#ifndef HAVE_GETLINE
|
||||
#define getline libedit_getline
|
||||
ssize_t getline(char **line, size_t *len, FILE *fp);
|
||||
#endif
|
||||
|
||||
#ifndef _DIAGASSERT
|
||||
@ -109,13 +104,18 @@ wchar_t *wcsdup(const wchar_t *);
|
||||
typedef unsigned int u_int32_t;
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_T_MAX
|
||||
#define SIZE_T_MAX ((size_t)-1)
|
||||
#ifndef HAVE_SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)-1)
|
||||
#endif
|
||||
|
||||
#define REGEX /* Use POSIX.2 regular expression functions */
|
||||
#undef REGEXP /* Use UNIX V8 regular expression functions */
|
||||
|
||||
#ifndef WIDECHAR
|
||||
#define setlocale(c, l) /*LINTED*/NULL
|
||||
#define nl_langinfo(i) ""
|
||||
#endif
|
||||
|
||||
#if defined(__sun)
|
||||
extern int tgetent(char *, const char *);
|
||||
extern int tgetflag(char *);
|
||||
|
82
terminal.c
82
terminal.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $ */
|
||||
/* $NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 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: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $");
|
||||
__RCSID("$NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -46,12 +46,14 @@ __RCSID("$NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $");
|
||||
* We have to declare a static variable here, since the
|
||||
* termcap putchar routine does not take an argument!
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_TERMCAP_H
|
||||
#include <termcap.h>
|
||||
#endif
|
||||
@ -65,9 +67,6 @@ __RCSID("$NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $");
|
||||
#if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H)
|
||||
#include <term.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef _REENTRANT
|
||||
#include <pthread.h>
|
||||
@ -272,31 +271,45 @@ terminal_init(EditLine *el)
|
||||
el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
|
||||
sizeof(*el->el_terminal.t_buf));
|
||||
if (el->el_terminal.t_buf == NULL)
|
||||
return -1;
|
||||
goto fail1;
|
||||
el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
|
||||
sizeof(*el->el_terminal.t_cap));
|
||||
if (el->el_terminal.t_cap == NULL)
|
||||
return -1;
|
||||
goto fail2;
|
||||
el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
|
||||
sizeof(*el->el_terminal.t_fkey));
|
||||
if (el->el_terminal.t_fkey == NULL)
|
||||
return -1;
|
||||
goto fail3;
|
||||
el->el_terminal.t_loc = 0;
|
||||
el->el_terminal.t_str = el_malloc(T_str *
|
||||
sizeof(*el->el_terminal.t_str));
|
||||
if (el->el_terminal.t_str == NULL)
|
||||
return -1;
|
||||
goto fail4;
|
||||
(void) memset(el->el_terminal.t_str, 0, T_str *
|
||||
sizeof(*el->el_terminal.t_str));
|
||||
el->el_terminal.t_val = el_malloc(T_val *
|
||||
sizeof(*el->el_terminal.t_val));
|
||||
if (el->el_terminal.t_val == NULL)
|
||||
return -1;
|
||||
goto fail5;
|
||||
(void) memset(el->el_terminal.t_val, 0, T_val *
|
||||
sizeof(*el->el_terminal.t_val));
|
||||
(void) terminal_set(el, NULL);
|
||||
terminal_init_arrow(el);
|
||||
return 0;
|
||||
fail5:
|
||||
free(el->el_terminal.t_str);
|
||||
el->el_terminal.t_str = NULL;
|
||||
fail4:
|
||||
free(el->el_terminal.t_fkey);
|
||||
el->el_terminal.t_fkey = NULL;
|
||||
fail3:
|
||||
free(el->el_terminal.t_cap);
|
||||
el->el_terminal.t_cap = NULL;
|
||||
fail2:
|
||||
free(el->el_terminal.t_buf);
|
||||
el->el_terminal.t_buf = NULL;
|
||||
fail1:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* terminal_end():
|
||||
@ -418,14 +431,14 @@ terminal_alloc_display(EditLine *el)
|
||||
|
||||
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
|
||||
if (b == NULL)
|
||||
return -1;
|
||||
goto done;
|
||||
for (i = 0; i < c->v; i++) {
|
||||
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
|
||||
if (b[i] == NULL) {
|
||||
while (--i >= 0)
|
||||
el_free(b[i]);
|
||||
el_free(b);
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
b[c->v] = NULL;
|
||||
@ -433,19 +446,22 @@ terminal_alloc_display(EditLine *el)
|
||||
|
||||
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
|
||||
if (b == NULL)
|
||||
return -1;
|
||||
goto done;
|
||||
for (i = 0; i < c->v; i++) {
|
||||
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
|
||||
if (b[i] == NULL) {
|
||||
while (--i >= 0)
|
||||
el_free(b[i]);
|
||||
el_free(b);
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
b[c->v] = NULL;
|
||||
el->el_vdisplay = b;
|
||||
return 0;
|
||||
done:
|
||||
terminal_free_display(el);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -477,7 +493,7 @@ terminal_free_display(EditLine *el)
|
||||
|
||||
/* terminal_move_to_line():
|
||||
* move to line <where> (first line == 0)
|
||||
* as efficiently as possible
|
||||
* as efficiently as possible
|
||||
*/
|
||||
protected void
|
||||
terminal_move_to_line(EditLine *el, int where)
|
||||
@ -490,8 +506,7 @@ terminal_move_to_line(EditLine *el, int where)
|
||||
if (where > el->el_terminal.t_size.v) {
|
||||
#ifdef DEBUG_SCREEN
|
||||
(void) fprintf(el->el_errfile,
|
||||
"terminal_move_to_line: where is ridiculous: %d\r\n",
|
||||
where);
|
||||
"%s: where is ridiculous: %d\r\n", __func__, where);
|
||||
#endif /* DEBUG_SCREEN */
|
||||
return;
|
||||
}
|
||||
@ -557,8 +572,7 @@ terminal_move_to_char(EditLine *el, int where)
|
||||
if (where > el->el_terminal.t_size.h) {
|
||||
#ifdef DEBUG_SCREEN
|
||||
(void) fprintf(el->el_errfile,
|
||||
"terminal_move_to_char: where is riduculous: %d\r\n",
|
||||
where);
|
||||
"%s: where is ridiculous: %d\r\n", __func__, where);
|
||||
#endif /* DEBUG_SCREEN */
|
||||
return;
|
||||
}
|
||||
@ -594,7 +608,7 @@ terminal_move_to_char(EditLine *el, int where)
|
||||
i < (where & ~0x7);
|
||||
i += 8)
|
||||
terminal__putc(el,
|
||||
'\t');
|
||||
'\t');
|
||||
/* then tab over */
|
||||
el->el_cursor.h = where & ~0x7;
|
||||
}
|
||||
@ -652,7 +666,7 @@ terminal_overwrite(EditLine *el, const Char *cp, size_t n)
|
||||
if (n > (size_t)el->el_terminal.t_size.h) {
|
||||
#ifdef DEBUG_SCREEN
|
||||
(void) fprintf(el->el_errfile,
|
||||
"terminal_overwrite: n is riduculous: %d\r\n", n);
|
||||
"%s: n is ridiculous: %d\r\n", __func__, n);
|
||||
#endif /* DEBUG_SCREEN */
|
||||
return;
|
||||
}
|
||||
@ -708,7 +722,7 @@ terminal_deletechars(EditLine *el, int num)
|
||||
if (num > el->el_terminal.t_size.h) {
|
||||
#ifdef DEBUG_SCREEN
|
||||
(void) fprintf(el->el_errfile,
|
||||
"terminal_deletechars: num is riduculous: %d\r\n", num);
|
||||
"%s: num is ridiculous: %d\r\n", __func__, num);
|
||||
#endif /* DEBUG_SCREEN */
|
||||
return;
|
||||
}
|
||||
@ -749,7 +763,7 @@ terminal_insertwrite(EditLine *el, Char *cp, int num)
|
||||
if (num > el->el_terminal.t_size.h) {
|
||||
#ifdef DEBUG_SCREEN
|
||||
(void) fprintf(el->el_errfile,
|
||||
"StartInsert: num is riduculous: %d\r\n", num);
|
||||
"%s: num is ridiculous: %d\r\n", __func__, num);
|
||||
#endif /* DEBUG_SCREEN */
|
||||
return;
|
||||
}
|
||||
@ -1239,13 +1253,13 @@ terminal_tputs(EditLine *el, const char *cap, int affcnt)
|
||||
* Add a character
|
||||
*/
|
||||
protected int
|
||||
terminal__putc(EditLine *el, Int c)
|
||||
terminal__putc(EditLine *el, wint_t c)
|
||||
{
|
||||
char buf[MB_LEN_MAX +1];
|
||||
ssize_t i;
|
||||
if (c == (Int)MB_FILL_CHAR)
|
||||
if (c == (wint_t)MB_FILL_CHAR)
|
||||
return 0;
|
||||
i = ct_encode_char(buf, (size_t)MB_LEN_MAX, c);
|
||||
i = ct_encode_char(buf, (size_t)MB_LEN_MAX, (Char)c);
|
||||
if (i <= 0)
|
||||
return (int)i;
|
||||
buf[i] = '\0';
|
||||
@ -1266,10 +1280,10 @@ terminal__flush(EditLine *el)
|
||||
* Write the given character out, in a human readable form
|
||||
*/
|
||||
protected void
|
||||
terminal_writec(EditLine *el, Int c)
|
||||
terminal_writec(EditLine *el, wint_t c)
|
||||
{
|
||||
Char visbuf[VISUAL_WIDTH_MAX +1];
|
||||
ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c);
|
||||
ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, (Char)c);
|
||||
if (vcnt < 0)
|
||||
vcnt = 0;
|
||||
visbuf[vcnt] = '\0';
|
||||
@ -1283,7 +1297,7 @@ terminal_writec(EditLine *el, Int c)
|
||||
*/
|
||||
protected int
|
||||
/*ARGSUSED*/
|
||||
terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
|
||||
terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
|
||||
const Char **argv __attribute__((__unused__)))
|
||||
{
|
||||
const struct termcapstr *t;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: terminal.h,v 1.4 2012/03/24 20:09:30 christos Exp $ */
|
||||
/* $NetBSD: terminal.h,v 1.7 2016/02/16 15:53:48 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,8 +40,6 @@
|
||||
#ifndef _h_el_terminal
|
||||
#define _h_el_terminal
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct { /* Symbolic function key bindings */
|
||||
const Char *name; /* name of the key */
|
||||
int key; /* Index in termcap table */
|
||||
@ -104,8 +102,8 @@ protected int terminal_settc(EditLine *, int, const Char **);
|
||||
protected int terminal_gettc(EditLine *, int, char **);
|
||||
protected int terminal_telltc(EditLine *, int, const Char **);
|
||||
protected int terminal_echotc(EditLine *, int, const Char **);
|
||||
protected void terminal_writec(EditLine *, Int);
|
||||
protected int terminal__putc(EditLine *, Int);
|
||||
protected void terminal_writec(EditLine *, wint_t);
|
||||
protected int terminal__putc(EditLine *, wint_t);
|
||||
protected void terminal__flush(EditLine *);
|
||||
|
||||
/*
|
||||
|
11
tokenizer.c
11
tokenizer.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $ */
|
||||
/* $NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $");
|
||||
__RCSID("$NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -45,8 +45,9 @@ __RCSID("$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $");
|
||||
/*
|
||||
* tokenize.c: Bourne shell like tokenizer
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
#include "chartype.h"
|
||||
|
||||
@ -413,8 +414,10 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line,
|
||||
Char **p;
|
||||
tok->amax += AINCR;
|
||||
p = tok_realloc(tok->argv, tok->amax * sizeof(*p));
|
||||
if (p == NULL)
|
||||
if (p == NULL) {
|
||||
tok->amax -= AINCR;
|
||||
return -1;
|
||||
}
|
||||
tok->argv = p;
|
||||
}
|
||||
}
|
||||
|
33
tty.c
33
tty.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $");
|
||||
__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -46,11 +46,13 @@ __RCSID("$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $");
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h> /* for isatty */
|
||||
#include <strings.h> /* for ffs */
|
||||
#include <stdlib.h> /* for abort */
|
||||
#include <string.h>
|
||||
#include <strings.h> /* for ffs */
|
||||
#include <unistd.h> /* for isatty */
|
||||
|
||||
#include "el.h"
|
||||
#include "tty.h"
|
||||
#include "parse.h"
|
||||
|
||||
typedef struct ttymodes_t {
|
||||
const char *m_name;
|
||||
@ -59,7 +61,7 @@ typedef struct ttymodes_t {
|
||||
} ttymodes_t;
|
||||
|
||||
typedef struct ttymap_t {
|
||||
Int nch, och; /* Internal and termio rep of chars */
|
||||
wint_t nch, och; /* Internal and termio rep of chars */
|
||||
el_action_t bind[3]; /* emacs, vi, and vi-cmd */
|
||||
} ttymap_t;
|
||||
|
||||
@ -155,7 +157,7 @@ private const ttymap_t tty_map[] = {
|
||||
{C_LNEXT, VLNEXT,
|
||||
{ED_QUOTED_INSERT, ED_QUOTED_INSERT, ED_UNASSIGNED}},
|
||||
#endif /* VLNEXT */
|
||||
{(Int)-1, (Int)-1,
|
||||
{(wint_t)-1, (wint_t)-1,
|
||||
{ED_UNASSIGNED, ED_UNASSIGNED, ED_UNASSIGNED}}
|
||||
};
|
||||
|
||||
@ -496,6 +498,7 @@ tty_setup(EditLine *el)
|
||||
{
|
||||
int rst = 1;
|
||||
|
||||
el->el_tty.t_initialized = 0;
|
||||
if (el->el_flags & EDIT_DISABLED)
|
||||
return 0;
|
||||
|
||||
@ -558,6 +561,7 @@ tty_setup(EditLine *el)
|
||||
|
||||
tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]);
|
||||
tty_bind_char(el, 1);
|
||||
el->el_tty.t_initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -583,6 +587,9 @@ tty_end(EditLine *el)
|
||||
if (el->el_flags & EDIT_DISABLED)
|
||||
return;
|
||||
|
||||
if (el->el_tty.t_initialized)
|
||||
return;
|
||||
|
||||
if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
|
||||
#ifdef DEBUG_TTY
|
||||
(void) fprintf(el->el_errfile,
|
||||
@ -902,9 +909,9 @@ tty_bind_char(EditLine *el, int force)
|
||||
dalt = NULL;
|
||||
}
|
||||
|
||||
for (tp = tty_map; tp->nch != (Int)-1; tp++) {
|
||||
new[0] = t_n[tp->nch];
|
||||
old[0] = t_o[tp->och];
|
||||
for (tp = tty_map; tp->nch != (wint_t)-1; tp++) {
|
||||
new[0] = (Char)t_n[tp->nch];
|
||||
old[0] = (Char)t_o[tp->och];
|
||||
if (new[0] == old[0] && !force)
|
||||
continue;
|
||||
/* Put the old default binding back, and set the new binding */
|
||||
@ -976,7 +983,7 @@ tty_update_char(EditLine *el, int mode, int c) {
|
||||
|
||||
|
||||
/* tty_rawmode():
|
||||
* Set terminal into 1 character at a time mode.
|
||||
* Set terminal into 1 character at a time mode.
|
||||
*/
|
||||
protected int
|
||||
tty_rawmode(EditLine *el)
|
||||
@ -1174,8 +1181,8 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv)
|
||||
break;
|
||||
default:
|
||||
(void) fprintf(el->el_errfile,
|
||||
"%s: Unknown switch `" FCHAR "'.\n",
|
||||
name, (Int)argv[0][1]);
|
||||
"%s: Unknown switch `%lc'.\n",
|
||||
name, (wint_t)argv[0][1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
7
tty.h
7
tty.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tty.h,v 1.15 2014/05/19 19:54:12 christos Exp $ */
|
||||
/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -40,8 +40,6 @@
|
||||
#ifndef _h_el_tty
|
||||
#define _h_el_tty
|
||||
|
||||
#include "sys.h"
|
||||
#include "histedit.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -474,8 +472,9 @@ typedef struct {
|
||||
int t_tabs;
|
||||
int t_eight;
|
||||
speed_t t_speed;
|
||||
int t_mode;
|
||||
unsigned char t_mode;
|
||||
unsigned char t_vdisable;
|
||||
unsigned char t_initialized;
|
||||
} el_tty_t;
|
||||
|
||||
|
||||
|
129
vi.c
129
vi.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $ */
|
||||
/* $NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -33,37 +33,42 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.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.47 2015/10/21 21:45:30 christos Exp $");
|
||||
__RCSID("$NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* vi.c: Vi mode commands.
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <sys/wait.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
private el_action_t cv_action(EditLine *, Int);
|
||||
private el_action_t cv_paste(EditLine *, Int);
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
#include "emacs.h"
|
||||
#include "vi.h"
|
||||
|
||||
private el_action_t cv_action(EditLine *, wint_t);
|
||||
private el_action_t cv_paste(EditLine *, wint_t);
|
||||
|
||||
/* cv_action():
|
||||
* Handle vi actions.
|
||||
*/
|
||||
private el_action_t
|
||||
cv_action(EditLine *el, Int c)
|
||||
cv_action(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
/* 'cc', 'dd' and (possibly) friends */
|
||||
if (c != (Int)el->el_chared.c_vcmd.action)
|
||||
if (c != (wint_t)el->el_chared.c_vcmd.action)
|
||||
return CC_ERROR;
|
||||
|
||||
if (!(c & YANK))
|
||||
@ -90,7 +95,7 @@ cv_action(EditLine *el, Int c)
|
||||
* Paste previous deletion before or after the cursor
|
||||
*/
|
||||
private el_action_t
|
||||
cv_paste(EditLine *el, Int c)
|
||||
cv_paste(EditLine *el, wint_t c)
|
||||
{
|
||||
c_kill_t *k = &el->el_chared.c_kill;
|
||||
size_t len = (size_t)(k->last - k->buf);
|
||||
@ -122,7 +127,7 @@ cv_paste(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_paste(el, 0);
|
||||
@ -135,7 +140,7 @@ vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_paste(el, 1);
|
||||
@ -148,7 +153,7 @@ vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
@ -173,7 +178,7 @@ vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
@ -198,7 +203,7 @@ vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor >= el->el_line.lastchar - 1)
|
||||
@ -222,7 +227,7 @@ vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor >= el->el_line.lastchar - 1)
|
||||
@ -245,7 +250,7 @@ vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* [~]
|
||||
*/
|
||||
protected el_action_t
|
||||
vi_change_case(EditLine *el, Int c)
|
||||
vi_change_case(EditLine *el, wint_t c)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -277,7 +282,7 @@ vi_change_case(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
/*
|
||||
@ -294,7 +299,7 @@ vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
@ -310,7 +315,7 @@ vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor >= el->el_line.lastchar)
|
||||
@ -329,7 +334,7 @@ vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
@ -345,7 +350,7 @@ vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
c_delafter(el, el->el_state.argument);
|
||||
@ -360,7 +365,7 @@ vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
cv_undo(el);
|
||||
@ -378,7 +383,7 @@ vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
cv_undo(el);
|
||||
@ -396,7 +401,7 @@ vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_insert(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_insert(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
@ -411,7 +416,7 @@ vi_insert(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_add(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_add(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -436,7 +441,7 @@ vi_add(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
@ -452,7 +457,7 @@ vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_action(el, DELETE);
|
||||
@ -465,7 +470,7 @@ vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
@ -489,7 +494,7 @@ vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
@ -513,7 +518,7 @@ vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_undo(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_undo(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
c_undo_t un = el->el_chared.c_undo;
|
||||
|
||||
@ -540,7 +545,7 @@ vi_undo(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
/* [Esc] cancels pending action */
|
||||
@ -564,7 +569,7 @@ vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* [0]
|
||||
*/
|
||||
protected el_action_t
|
||||
vi_zero(EditLine *el, Int c)
|
||||
vi_zero(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_state.doingarg)
|
||||
@ -580,12 +585,12 @@ vi_zero(EditLine *el, Int c)
|
||||
|
||||
|
||||
/* vi_delete_prev_char():
|
||||
* Vi move to previous character (backspace)
|
||||
* Vi move to previous character (backspace)
|
||||
* [^H] in insert mode only
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
@ -603,7 +608,7 @@ vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_list_or_eof(EditLine *el, Int c)
|
||||
vi_list_or_eof(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
@ -640,7 +645,7 @@ vi_list_or_eof(EditLine *el, Int c)
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
|
||||
@ -661,7 +666,7 @@ vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_search(el, ED_SEARCH_PREV_HISTORY);
|
||||
@ -674,7 +679,7 @@ vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_search(el, ED_SEARCH_NEXT_HISTORY);
|
||||
@ -687,7 +692,7 @@ vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_search.patlen == 0)
|
||||
@ -703,7 +708,7 @@ vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
protected el_action_t
|
||||
vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_search.patlen == 0)
|
||||
@ -721,7 +726,7 @@ vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
|
||||
}
|
||||
@ -733,7 +738,7 @@ vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
|
||||
}
|
||||
@ -745,7 +750,7 @@ vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
|
||||
}
|
||||
@ -757,7 +762,7 @@ vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
|
||||
}
|
||||
@ -769,7 +774,7 @@ vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
|
||||
@ -783,7 +788,7 @@ vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
el_action_t r;
|
||||
int dir = el->el_search.chadir;
|
||||
@ -801,7 +806,7 @@ vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_match(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char match_chars[] = STR("()[]{}");
|
||||
Char *cp;
|
||||
@ -848,7 +853,7 @@ vi_match(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
cv_undo(el);
|
||||
@ -862,7 +867,7 @@ vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_to_column(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
@ -876,7 +881,7 @@ vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
cv_yank(el, el->el_line.cursor,
|
||||
@ -890,7 +895,7 @@ vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_yank(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_yank(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return cv_action(el, YANK);
|
||||
@ -902,7 +907,7 @@ vi_yank(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
@ -920,7 +925,7 @@ vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_alias(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_alias(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
char alias_name[3];
|
||||
const char *alias_text;
|
||||
@ -946,7 +951,7 @@ vi_alias(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
int sv_event_no = el->el_history.eventno;
|
||||
el_action_t rval;
|
||||
@ -972,7 +977,7 @@ vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
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_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;
|
||||
@ -991,7 +996,7 @@ vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_histedit(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_histedit(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
int fd;
|
||||
pid_t pid;
|
||||
@ -1075,7 +1080,7 @@ vi_histedit(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_history_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char *wp = HIST_FIRST(el);
|
||||
const Char *wep, *wsp;
|
||||
@ -1125,7 +1130,7 @@ vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_redo(EditLine *el, Int c __attribute__((__unused__)))
|
||||
vi_redo(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
c_redo_t *r = &el->el_chared.c_redo;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user