MFV r296159
Sync our libedit with NetBSD's libedit 2016-02-27. Obtained from: NetBSD
This commit is contained in:
commit
e81f248547
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296175
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.37 2009/01/18 12:17:49 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/4/93
|
||||
# $FreeBSD$
|
||||
|
||||
@ -6,7 +6,7 @@ LIB= edit
|
||||
SHLIB_MAJOR= 7
|
||||
SHLIBDIR?= /lib
|
||||
|
||||
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
|
||||
|
||||
@ -34,7 +34,6 @@ CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
|
||||
|
||||
INCS= histedit.h
|
||||
|
||||
OSRCS+= eln.c
|
||||
SRCS+= tokenizern.c historyn.c
|
||||
CLEANFILES+= tokenizern.c historyn.c
|
||||
CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR
|
||||
|
@ -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,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: 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 */
|
||||
__FBSDID("$FreeBSD$");
|
||||
@ -50,15 +50,15 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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"
|
||||
|
||||
@ -158,7 +158,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);
|
||||
|
||||
/*
|
||||
|
@ -5,13 +5,16 @@ __FBSDID("$FreeBSD$");
|
||||
#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"
|
||||
|
||||
|
@ -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,7 +37,7 @@
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -46,8 +46,12 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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 *);
|
||||
|
||||
@ -201,7 +205,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;
|
||||
}
|
||||
@ -211,7 +215,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;
|
||||
@ -225,7 +229,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);
|
||||
}
|
||||
@ -235,7 +239,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--;
|
||||
|
||||
@ -259,7 +263,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))
|
||||
@ -277,7 +281,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;
|
||||
|
||||
@ -306,7 +310,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;
|
||||
|
||||
@ -370,7 +374,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;
|
||||
|
||||
@ -673,9 +677,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);
|
||||
@ -690,26 +694,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;
|
||||
|
||||
|
@ -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
|
||||
@ -41,11 +41,6 @@
|
||||
#ifndef _h_el_chared
|
||||
#define _h_el_chared
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
#define EL_MAXMACRO 10
|
||||
|
||||
/*
|
||||
@ -140,24 +135,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 *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $ */
|
||||
/* $NetBSD: chartype.c,v 1.23 2016/02/28 23:02:24 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -31,13 +31,16 @@
|
||||
*/
|
||||
#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.23 2016/02/28 23:02:24 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "el.h"
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
#define CT_BUFSIZ ((size_t)1024)
|
||||
|
||||
@ -206,6 +209,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 *
|
||||
@ -329,7 +354,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);
|
||||
|
@ -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.
|
||||
@ -32,7 +32,6 @@
|
||||
#define _h_chartype_f
|
||||
|
||||
|
||||
|
||||
#ifdef WIDECHAR
|
||||
|
||||
/* Ideally we should also test the value of the define to see if it
|
||||
@ -55,21 +54,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)
|
||||
@ -110,21 +106,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_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)
|
||||
@ -245,5 +238,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 */
|
||||
|
@ -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,7 +37,7 @@
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -46,7 +46,13 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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
|
||||
@ -54,7 +60,7 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
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);
|
||||
@ -68,7 +74,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;
|
||||
|
||||
@ -87,14 +93,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);
|
||||
}
|
||||
|
||||
@ -111,7 +117,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;
|
||||
|
||||
@ -139,7 +145,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
|
||||
@ -186,7 +192,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;
|
||||
|
||||
@ -207,7 +213,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;
|
||||
@ -230,7 +236,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;
|
||||
@ -253,7 +259,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) {
|
||||
@ -266,7 +272,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;
|
||||
@ -279,7 +285,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;
|
||||
|
||||
@ -308,7 +314,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)
|
||||
@ -334,7 +340,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) {
|
||||
@ -358,14 +364,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);
|
||||
@ -378,7 +382,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))
|
||||
@ -406,7 +410,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))
|
||||
@ -432,7 +436,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;
|
||||
@ -450,7 +454,7 @@ ed_unassigned(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -464,7 +468,7 @@ ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -478,7 +482,7 @@ ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -492,7 +496,7 @@ ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -506,7 +510,7 @@ ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -520,7 +524,7 @@ ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -534,7 +538,7 @@ 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__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -547,7 +551,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);
|
||||
@ -563,7 +567,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)
|
||||
@ -583,7 +587,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 */
|
||||
@ -599,7 +603,7 @@ ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_REDISPLAY;
|
||||
@ -612,7 +616,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);
|
||||
@ -627,7 +631,7 @@ 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__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return CC_NORM;
|
||||
@ -640,7 +644,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;
|
||||
@ -660,7 +664,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 */
|
||||
@ -678,7 +681,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;
|
||||
|
||||
@ -705,11 +708,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;
|
||||
@ -748,7 +751,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++;
|
||||
@ -773,11 +776,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;
|
||||
@ -827,7 +830,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);
|
||||
@ -870,7 +873,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);
|
||||
@ -904,7 +907,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;
|
||||
|
@ -21,8 +21,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
|
||||
@ -188,9 +188,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
|
||||
|
||||
@ -257,6 +254,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 */
|
||||
|
||||
|
@ -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.
|
||||
@ -55,7 +55,7 @@ typedef void *histdata_t;
|
||||
|
||||
typedef struct _hist_entry {
|
||||
const char *line;
|
||||
histdata_t data;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
typedef struct _keymap_entry {
|
||||
@ -89,7 +89,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'
|
||||
|
||||
@ -98,7 +98,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;
|
||||
@ -199,10 +199,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);
|
||||
@ -218,6 +218,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
|
||||
|
@ -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.
|
||||
@ -28,7 +28,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 3, 2015
|
||||
.Dd February 24, 2016
|
||||
.Dt EDITLINE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -72,7 +72,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
|
||||
@ -130,9 +130,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
|
||||
@ -175,6 +175,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 ,
|
||||
@ -240,14 +250,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
|
||||
@ -746,7 +784,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
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -48,13 +48,17 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
#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.
|
||||
@ -95,12 +99,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);
|
||||
@ -209,7 +211,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;
|
||||
}
|
||||
|
||||
@ -308,7 +310,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;
|
||||
}
|
||||
|
||||
@ -437,7 +438,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;
|
||||
|
||||
@ -514,6 +515,7 @@ el_source(EditLine *el, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
ssize_t slen;
|
||||
char *ptr;
|
||||
char *path = NULL;
|
||||
const Char *dptr;
|
||||
@ -550,15 +552,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++;
|
||||
@ -567,6 +571,7 @@ el_source(EditLine *el, const char *fname)
|
||||
if ((error = parse_line(el, dptr)) == -1)
|
||||
break;
|
||||
}
|
||||
free(ptr);
|
||||
|
||||
el_free(path);
|
||||
(void) fclose(fp);
|
||||
|
@ -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
|
||||
@ -49,8 +49,6 @@
|
||||
|
||||
#include "histedit.h"
|
||||
#include "chartype.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */
|
||||
|
||||
@ -59,11 +57,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 */
|
||||
|
||||
@ -73,7 +67,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 */
|
||||
@ -88,7 +82,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;
|
||||
|
||||
@ -105,13 +99,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 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $ */
|
||||
/* $NetBSD: eln.c,v 1.28 2016/02/28 23:02:24 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -12,13 +12,6 @@
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@ -34,36 +27,40 @@
|
||||
*/
|
||||
#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.28 2016/02/28 23:02:24 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -78,17 +75,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);
|
||||
}
|
||||
|
||||
@ -233,7 +228,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);
|
||||
@ -247,10 +242,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 * */
|
||||
@ -344,7 +337,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;
|
||||
@ -399,3 +391,4 @@ el_insertstr(EditLine *el, const char *str)
|
||||
{
|
||||
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
|
||||
}
|
||||
#endif /* WIDECHAR */
|
||||
|
@ -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,7 +37,7 @@
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -46,7 +46,10 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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
|
||||
@ -54,7 +57,7 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
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) {
|
||||
@ -90,7 +93,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;
|
||||
|
||||
@ -119,7 +122,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;
|
||||
|
||||
@ -155,7 +158,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;
|
||||
|
||||
@ -177,7 +180,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;
|
||||
|
||||
@ -210,7 +213,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;
|
||||
|
||||
@ -239,14 +242,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;
|
||||
@ -259,7 +262,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;
|
||||
@ -284,7 +287,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;
|
||||
|
||||
@ -308,7 +311,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;
|
||||
|
||||
@ -340,7 +343,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;
|
||||
|
||||
@ -364,7 +367,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;
|
||||
@ -378,7 +381,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;
|
||||
|
||||
@ -395,7 +398,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)
|
||||
@ -412,7 +415,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;
|
||||
@ -425,7 +428,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) ?
|
||||
@ -439,7 +442,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;
|
||||
|
||||
@ -466,7 +469,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;
|
||||
@ -479,7 +482,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;
|
||||
@ -493,7 +496,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,27 +31,24 @@
|
||||
|
||||
#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/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#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', '"', '\\', '\'', '`', '@',
|
||||
@ -100,9 +97,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
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$");
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
/* hist_init():
|
||||
|
@ -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
|
||||
@ -41,8 +41,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 {
|
||||
@ -83,7 +81,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 */
|
||||
|
@ -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
|
||||
@ -143,7 +143,7 @@ unsigned char _el_fn_sh_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 */
|
||||
@ -251,20 +251,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 ====
|
||||
*/
|
||||
|
@ -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,7 +37,7 @@
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -46,11 +46,11 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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";
|
||||
|
||||
@ -734,7 +734,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;
|
||||
@ -745,26 +747,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;
|
||||
@ -773,7 +772,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;
|
||||
@ -782,6 +780,7 @@ history_load(TYPE(History) *h, const char *fname)
|
||||
oomem:
|
||||
h_free(ptr);
|
||||
done:
|
||||
free(line);
|
||||
(void) fclose(fp);
|
||||
return i;
|
||||
}
|
||||
@ -813,8 +812,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));
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -65,8 +65,8 @@ __FBSDID("$FreeBSD$");
|
||||
* 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"
|
||||
|
||||
@ -75,10 +75,10 @@ __FBSDID("$FreeBSD$");
|
||||
* 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*/
|
||||
};
|
||||
@ -87,7 +87,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 **,
|
||||
@ -277,21 +277,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;
|
||||
@ -314,7 +316,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,
|
||||
@ -460,14 +462,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;
|
||||
|
@ -79,7 +79,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 {
|
||||
@ -94,7 +95,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_";
|
||||
@ -163,7 +164,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");
|
||||
}'
|
||||
@ -176,6 +177,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;
|
||||
|
@ -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,7 +37,7 @@
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -46,11 +46,16 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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 *);
|
||||
@ -1144,15 +1149,15 @@ 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) {
|
||||
@ -1302,8 +1307,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;
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -56,16 +56,19 @@ __FBSDID("$FreeBSD$");
|
||||
* 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 },
|
||||
@ -141,7 +144,7 @@ protected int
|
||||
parse__escape(const Char **ptr)
|
||||
{
|
||||
const Char *p;
|
||||
Int c;
|
||||
wint_t c;
|
||||
|
||||
p = *ptr;
|
||||
|
||||
@ -253,7 +256,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':
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.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
|
||||
@ -41,8 +41,6 @@
|
||||
#ifndef _h_el_prompt
|
||||
#define _h_el_prompt
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef Char *(*el_pfunc_t)(EditLine *);
|
||||
|
||||
typedef struct el_prompt_t {
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -47,18 +47,21 @@ __FBSDID("$FreeBSD$");
|
||||
* 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 *);
|
||||
|
||||
@ -241,18 +244,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;
|
||||
@ -261,7 +267,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)
|
||||
@ -296,29 +302,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;
|
||||
@ -334,50 +328,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():
|
||||
@ -395,11 +398,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;
|
||||
@ -441,12 +444,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;
|
||||
}
|
||||
@ -487,6 +486,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;
|
||||
@ -502,7 +502,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);
|
||||
@ -554,7 +555,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);
|
||||
|
@ -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.
|
||||
@ -37,7 +37,7 @@
|
||||
#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 */
|
||||
|
@ -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,30 +31,29 @@
|
||||
|
||||
#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/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#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);
|
||||
@ -169,13 +168,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);
|
||||
|
||||
|
||||
@ -212,14 +211,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;
|
||||
}
|
||||
|
||||
@ -2102,12 +2101,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)();
|
||||
@ -2116,7 +2117,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)
|
||||
@ -2124,12 +2125,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
|
||||
|
||||
@ -2141,6 +2142,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;
|
||||
}
|
||||
|
||||
@ -2203,7 +2205,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++)
|
||||
@ -2325,3 +2327,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: 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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -47,18 +47,17 @@ __FBSDID("$FreeBSD$");
|
||||
* 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);
|
||||
@ -66,7 +65,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; \
|
||||
@ -127,7 +126,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 */
|
||||
@ -163,16 +162,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)
|
||||
@ -194,7 +193,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.
|
||||
*/
|
||||
@ -453,7 +452,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)
|
||||
@ -1054,14 +1053,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;
|
||||
|
@ -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
|
||||
@ -41,15 +41,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 *);
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -47,12 +47,15 @@ __FBSDID("$FreeBSD$");
|
||||
* 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
|
||||
@ -211,8 +214,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;
|
||||
|
||||
@ -251,9 +255,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:
|
||||
@ -347,14 +353,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 =
|
||||
@ -569,7 +575,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
|
||||
@ -595,35 +601,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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -41,8 +41,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 */
|
||||
@ -61,7 +59,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 */
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -48,9 +48,12 @@ __FBSDID("$FreeBSD$");
|
||||
* 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[] = {
|
||||
@ -70,9 +73,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);
|
||||
@ -106,6 +110,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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
@ -43,8 +43,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
|
||||
|
@ -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
|
||||
@ -88,14 +88,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
|
||||
@ -110,13 +105,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 *);
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -48,12 +48,14 @@ __FBSDID("$FreeBSD$");
|
||||
* 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
|
||||
@ -68,9 +70,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <term.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef _REENTRANT
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
@ -274,31 +273,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():
|
||||
@ -420,14 +433,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;
|
||||
@ -435,19 +448,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;
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +495,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)
|
||||
@ -492,8 +508,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;
|
||||
}
|
||||
@ -559,8 +574,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;
|
||||
}
|
||||
@ -654,7 +668,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;
|
||||
}
|
||||
@ -710,7 +724,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;
|
||||
}
|
||||
@ -751,7 +765,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;
|
||||
}
|
||||
@ -1241,13 +1255,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';
|
||||
@ -1268,10 +1282,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';
|
||||
|
@ -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
|
||||
@ -41,8 +41,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 */
|
||||
@ -105,8 +103,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 *);
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -47,8 +47,9 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* tokenize.c: Bourne shell like tokenizer
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
#include "chartype.h"
|
||||
|
||||
@ -415,8 +416,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;
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -48,11 +48,13 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
#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;
|
||||
@ -61,7 +63,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;
|
||||
|
||||
@ -157,7 +159,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}}
|
||||
};
|
||||
|
||||
@ -498,6 +500,7 @@ tty_setup(EditLine *el)
|
||||
{
|
||||
int rst = 1;
|
||||
|
||||
el->el_tty.t_initialized = 0;
|
||||
if (el->el_flags & EDIT_DISABLED)
|
||||
return 0;
|
||||
|
||||
@ -560,6 +563,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;
|
||||
}
|
||||
|
||||
@ -585,6 +589,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,
|
||||
@ -904,9 +911,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 */
|
||||
@ -978,7 +985,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)
|
||||
@ -1176,8 +1183,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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -41,8 +41,6 @@
|
||||
#ifndef _h_el_tty
|
||||
#define _h_el_tty
|
||||
|
||||
#include "sys.h"
|
||||
#include "histedit.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -475,8 +473,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;
|
||||
|
||||
|
||||
|
127
lib/libedit/vi.c
127
lib/libedit/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,16 +33,11 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
#include <sys/cdefs.h>
|
||||
@ -51,21 +46,31 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* 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))
|
||||
@ -92,7 +97,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);
|
||||
@ -124,7 +129,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);
|
||||
@ -137,7 +142,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);
|
||||
@ -150,7 +155,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)
|
||||
@ -175,7 +180,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)
|
||||
@ -200,7 +205,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)
|
||||
@ -224,7 +229,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)
|
||||
@ -247,7 +252,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;
|
||||
|
||||
@ -279,7 +284,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__)))
|
||||
{
|
||||
|
||||
/*
|
||||
@ -296,7 +301,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;
|
||||
@ -312,7 +317,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)
|
||||
@ -331,7 +336,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;
|
||||
@ -347,7 +352,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);
|
||||
@ -362,7 +367,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);
|
||||
@ -380,7 +385,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);
|
||||
@ -398,7 +403,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;
|
||||
@ -413,7 +418,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;
|
||||
|
||||
@ -438,7 +443,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;
|
||||
@ -454,7 +459,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);
|
||||
@ -467,7 +472,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)
|
||||
@ -491,7 +496,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)
|
||||
@ -515,7 +520,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;
|
||||
|
||||
@ -542,7 +547,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 */
|
||||
@ -566,7 +571,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)
|
||||
@ -582,12 +587,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)
|
||||
@ -605,7 +610,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) {
|
||||
@ -642,7 +647,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;
|
||||
|
||||
@ -663,7 +668,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);
|
||||
@ -676,7 +681,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);
|
||||
@ -689,7 +694,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)
|
||||
@ -705,7 +710,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)
|
||||
@ -723,7 +728,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);
|
||||
}
|
||||
@ -735,7 +740,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);
|
||||
}
|
||||
@ -747,7 +752,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);
|
||||
}
|
||||
@ -759,7 +764,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);
|
||||
}
|
||||
@ -771,7 +776,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,
|
||||
@ -785,7 +790,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;
|
||||
@ -803,7 +808,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;
|
||||
@ -850,7 +855,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);
|
||||
@ -864,7 +869,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;
|
||||
@ -878,7 +883,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,
|
||||
@ -892,7 +897,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);
|
||||
@ -904,7 +909,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;
|
||||
@ -922,7 +927,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;
|
||||
@ -948,7 +953,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;
|
||||
@ -993,7 +998,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;
|
||||
@ -1077,7 +1082,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;
|
||||
@ -1127,7 +1132,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