1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-20 15:43:16 +00:00

Revert r296175

Undo update of libedit 2016-02-27

Something in libedit appears to be causing breakage in lldb38.
The changes are not generally huge but they are suficient to
to justify reverting for now.

Reported by:	novel, bapt
This commit is contained in:
Pedro F. Giffuni 2016-03-06 21:32:54 +00:00
parent ee3147b53a
commit 1f37f0f18f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296435
42 changed files with 597 additions and 686 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $ # $NetBSD: Makefile,v 1.37 2009/01/18 12:17:49 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93 # @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$ # $FreeBSD$
@ -6,7 +6,7 @@ LIB= edit
SHLIB_MAJOR= 7 SHLIB_MAJOR= 7
SHLIBDIR?= /lib SHLIBDIR?= /lib
OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \ OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
hist.c keymacro.c map.c chartype.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 parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
@ -34,6 +34,7 @@ CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
INCS= histedit.h INCS= histedit.h
OSRCS+= eln.c
SRCS+= tokenizern.c historyn.c SRCS+= tokenizern.c historyn.c
CLEANFILES+= tokenizern.c historyn.c CLEANFILES+= tokenizern.c historyn.c
CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR

View File

@ -1,4 +1,4 @@
/* $NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
@ -50,15 +50,15 @@ __FBSDID("$FreeBSD$");
/* /*
* test.c: A little test program * test.c: A little test program
*/ */
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h> #include <dirent.h>
#include <locale.h> #include <locale.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "histedit.h" #include "histedit.h"
@ -158,7 +158,7 @@ main(int argc, char *argv[])
/* Add a user-defined function */ /* Add a user-defined function */
el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); 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); el_set(el, EL_BIND, "^I", "ed-complete", NULL);
/* /*

View File

@ -5,16 +5,13 @@ __FBSDID("$FreeBSD$");
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <ctype.h>
#include <dirent.h>
#include <err.h> #include <err.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <limits.h> #include <limits.h>
#include <locale.h> #include <locale.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../histedit.h" #include "../histedit.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $ */ /* $NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $"); __RCSID("$NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,12 +46,8 @@ __FBSDID("$FreeBSD$");
/* /*
* chared.c: Character editor utilities * chared.c: Character editor utilities
*/ */
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "el.h" #include "el.h"
#include "common.h"
private void ch__clearmacro (EditLine *); private void ch__clearmacro (EditLine *);
@ -205,7 +201,7 @@ c_delbefore1(EditLine *el)
* Return if p is part of a word according to emacs * Return if p is part of a word according to emacs
*/ */
protected int protected int
ce__isword(wint_t p) ce__isword(Int p)
{ {
return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL; return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
} }
@ -215,7 +211,7 @@ ce__isword(wint_t p)
* Return if p is part of a word according to vi * Return if p is part of a word according to vi
*/ */
protected int protected int
cv__isword(wint_t p) cv__isword(Int p)
{ {
if (Isalnum(p) || p == '_') if (Isalnum(p) || p == '_')
return 1; return 1;
@ -229,7 +225,7 @@ cv__isword(wint_t p)
* Return if p is part of a big word according to vi * Return if p is part of a big word according to vi
*/ */
protected int protected int
cv__isWord(wint_t p) cv__isWord(Int p)
{ {
return !Isspace(p); return !Isspace(p);
} }
@ -239,7 +235,7 @@ cv__isWord(wint_t p)
* Find the previous word * Find the previous word
*/ */
protected Char * protected Char *
c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t)) c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
{ {
p--; p--;
@ -263,7 +259,7 @@ c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t))
* Find the next word * Find the next word
*/ */
protected Char * protected Char *
c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t)) c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
{ {
while (n--) { while (n--) {
while ((p < high) && !(*wtest)(*p)) while ((p < high) && !(*wtest)(*p))
@ -281,7 +277,7 @@ c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t))
* Find the next word vi style * Find the next word vi style
*/ */
protected Char * protected Char *
cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t)) cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
{ {
int test; int test;
@ -310,7 +306,7 @@ cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t))
* Find the previous word vi style * Find the previous word vi style
*/ */
protected Char * protected Char *
cv_prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t)) cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
{ {
int test; int test;
@ -374,7 +370,7 @@ cv_delfini(EditLine *el)
* Go to the end of this word according to vi * Go to the end of this word according to vi
*/ */
protected Char * protected Char *
cv__endword(Char *p, Char *high, int n, int (*wtest)(wint_t)) cv__endword(Char *p, Char *high, int n, int (*wtest)(Int))
{ {
int test; int test;
@ -528,7 +524,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
/* zero the newly added memory, leave old data in */ /* zero the newly added memory, leave old data in */
(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
oldbuf = el->el_line.buffer; oldbuf = el->el_line.buffer;
el->el_line.buffer = newbuffer; el->el_line.buffer = newbuffer;
@ -577,7 +573,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
el->el_chared.c_redo.lim = newbuffer + el->el_chared.c_redo.lim = newbuffer +
(el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
el->el_chared.c_redo.buf = newbuffer; el->el_chared.c_redo.buf = newbuffer;
if (!hist_enlargebuf(el, sz, newsz)) if (!hist_enlargebuf(el, sz, newsz))
return 0; return 0;
@ -677,9 +673,9 @@ el_cursor(EditLine *el, int n)
protected int protected int
c_gets(EditLine *el, Char *buf, const Char *prompt) c_gets(EditLine *el, Char *buf, const Char *prompt)
{ {
wchar_t wch; Char ch;
ssize_t len; ssize_t len;
Char *cp = el->el_line.buffer, ch; Char *cp = el->el_line.buffer;
if (prompt) { if (prompt) {
len = (ssize_t)Strlen(prompt); len = (ssize_t)Strlen(prompt);
@ -694,28 +690,26 @@ c_gets(EditLine *el, Char *buf, const Char *prompt)
el->el_line.lastchar = cp + 1; el->el_line.lastchar = cp + 1;
re_refresh(el); re_refresh(el);
if (el_wgetc(el, &wch) != 1) { if (FUN(el,getc)(el, &ch) != 1) {
ed_end_of_file(el, 0); ed_end_of_file(el, 0);
len = -1; len = -1;
break; break;
} }
ch = (Char)wch;
switch (ch) { switch (ch) {
case L'\b': /* Delete and backspace */ case 0010: /* Delete and backspace */
case 0177: case 0177:
if (len == 0) { if (len == 0) {
len = -1; len = -1;
break; break;
} }
len--;
cp--; cp--;
continue; continue;
case 0033: /* ESC */ case 0033: /* ESC */
case L'\r': /* Newline */ case '\r': /* Newline */
case L'\n': case '\n':
buf[len] = ch; buf[len] = ch;
break; break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: chared.h,v 1.27 2016/02/16 22:53:14 christos Exp $ */ /* $NetBSD: chared.h,v 1.22 2014/06/18 18:12:28 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,6 +41,11 @@
#ifndef _h_el_chared #ifndef _h_el_chared
#define _h_el_chared #define _h_el_chared
#include <ctype.h>
#include <string.h>
#include "histedit.h"
#define EL_MAXMACRO 10 #define EL_MAXMACRO 10
/* /*
@ -135,18 +140,24 @@ typedef struct el_chared_t {
#define MODE_REPLACE 1 #define MODE_REPLACE 1
#define MODE_REPLACE_1 2 #define MODE_REPLACE_1 2
#include "common.h"
#include "vi.h"
#include "emacs.h"
#include "search.h"
#include "fcns.h"
protected int cv__isword(wint_t);
protected int cv__isWord(wint_t); protected int cv__isword(Int);
protected int cv__isWord(Int);
protected void cv_delfini(EditLine *); protected void cv_delfini(EditLine *);
protected Char *cv__endword(Char *, Char *, int, int (*)(wint_t)); protected Char *cv__endword(Char *, Char *, int, int (*)(Int));
protected int ce__isword(wint_t); protected int ce__isword(Int);
protected void cv_undo(EditLine *); protected void cv_undo(EditLine *);
protected void cv_yank(EditLine *, const Char *, int); protected void cv_yank(EditLine *, const Char *, int);
protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(wint_t)); protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(Int));
protected Char *cv_prev_word(Char *, Char *, int, int (*)(wint_t)); protected Char *cv_prev_word(Char *, Char *, int, int (*)(Int));
protected Char *c__next_word(Char *, Char *, int, int (*)(wint_t)); protected Char *c__next_word(Char *, Char *, int, int (*)(Int));
protected Char *c__prev_word(Char *, Char *, int, int (*)(wint_t)); protected Char *c__prev_word(Char *, Char *, int, int (*)(Int));
protected void c_insert(EditLine *, int); protected void c_insert(EditLine *, int);
protected void c_delbefore(EditLine *, int); protected void c_delbefore(EditLine *, int);
protected void c_delbefore1(EditLine *); protected void c_delbefore1(EditLine *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: chartype.c,v 1.23 2016/02/28 23:02:24 christos Exp $ */ /* $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $ */
/*- /*-
* Copyright (c) 2009 The NetBSD Foundation, Inc. * Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -31,16 +31,13 @@
*/ */
#include "config.h" #include "config.h"
#if !defined(lint) && !defined(SCCSID) #if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: chartype.c,v 1.23 2016/02/28 23:02:24 christos Exp $"); __RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "el.h" #include "el.h"
#include <stdlib.h>
#define CT_BUFSIZ ((size_t)1024) #define CT_BUFSIZ ((size_t)1024)
@ -71,7 +68,7 @@ ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
{ {
void *p; void *p;
if (wsize <= conv->wsize) if (wsize <= conv->wsize)
return 0; return 0;
conv->wsize = wsize; conv->wsize = wsize;
@ -209,28 +206,6 @@ ct_encode_char(char *dst, size_t len, Char c)
} }
return l; 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 #endif
protected const Char * protected const Char *
@ -354,7 +329,7 @@ ct_visual_char(Char *dst, size_t len, Char c)
return c > 0xffff ? 8 : 7; return c > 0xffff ? 8 : 7;
#else #else
*dst++ = '\\'; *dst++ = '\\';
#define tooctaldigit(v) (Char)((v) + '0') #define tooctaldigit(v) ((v) + '0')
*dst++ = tooctaldigit(((unsigned int) c >> 6) & 0x7); *dst++ = tooctaldigit(((unsigned int) c >> 6) & 0x7);
*dst++ = tooctaldigit(((unsigned int) c >> 3) & 0x7); *dst++ = tooctaldigit(((unsigned int) c >> 3) & 0x7);
*dst++ = tooctaldigit(((unsigned int) c ) & 0x7); *dst++ = tooctaldigit(((unsigned int) c ) & 0x7);

View File

@ -1,4 +1,4 @@
/* $NetBSD: chartype.h,v 1.23 2016/02/24 17:20:01 christos Exp $ */ /* $NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $ */
/*- /*-
* Copyright (c) 2009 The NetBSD Foundation, Inc. * Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -32,6 +32,7 @@
#define _h_chartype_f #define _h_chartype_f
#ifdef WIDECHAR #ifdef WIDECHAR
/* Ideally we should also test the value of the define to see if it /* Ideally we should also test the value of the define to see if it
@ -54,18 +55,21 @@
#warning Build environment does not support non-BMP characters #warning Build environment does not support non-BMP characters
#endif #endif
#define ct_wctob wctob #define ct_mbtowc mbtowc
#define ct_mbtowc_reset mbtowc(0,0,(size_t)0)
#define ct_wctomb wctomb #define ct_wctomb wctomb
#define ct_wctomb_reset wctomb(0,0) #define ct_wctomb_reset wctomb(0,0)
#define ct_wcstombs wcstombs #define ct_wcstombs wcstombs
#define ct_mbstowcs mbstowcs #define ct_mbstowcs mbstowcs
#define Char wchar_t #define Char wchar_t
#define Int wint_t
#define FUN(prefix,rest) prefix ## _w ## rest #define FUN(prefix,rest) prefix ## _w ## rest
#define FUNW(type) type ## _w #define FUNW(type) type ## _w
#define TYPE(type) type ## W #define TYPE(type) type ## W
#define FCHAR "%lc"
#define FSTR "%ls" #define FSTR "%ls"
#define STR(x) L ## x #define STR(x) L ## x
#define UC(c) c #define UC(c) c
#define Isalpha(x) iswalpha(x) #define Isalpha(x) iswalpha(x)
#define Isalnum(x) iswalnum(x) #define Isalnum(x) iswalnum(x)
@ -106,18 +110,21 @@ Width(wchar_t c)
#else /* NARROW */ #else /* NARROW */
#define ct_wctob(w) ((int)(w)) #define ct_mbtowc error
#define ct_mbtowc_reset
#define ct_wctomb error #define ct_wctomb error
#define ct_wctomb_reset #define ct_wctomb_reset
#define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a)) #define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a))
#define ct_mbstowcs(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 Char char
#define Int int
#define FUN(prefix,rest) prefix ## _ ## rest #define FUN(prefix,rest) prefix ## _ ## rest
#define FUNW(type) type #define FUNW(type) type
#define TYPE(type) type #define TYPE(type) type
#define FCHAR "%c"
#define FSTR "%s" #define FSTR "%s"
#define STR(x) x #define STR(x) x
#define UC(c) (unsigned char)(c) #define UC(c) (unsigned char)(c)
#define Isalpha(x) isalpha((unsigned char)x) #define Isalpha(x) isalpha((unsigned char)x)
@ -206,7 +213,7 @@ protected size_t ct_enc_width(Char);
#define VISUAL_WIDTH_MAX ((size_t)8) #define VISUAL_WIDTH_MAX ((size_t)8)
/* The terminal is thought of in terms of X columns by Y lines. In the cases /* The terminal is thought of in terms of X columns by Y lines. In the cases
* where a wide character takes up more than one column, the adjacent * where a wide character takes up more than one column, the adjacent
* occupied column entries will contain this faux character. */ * occupied column entries will contain this faux character. */
#define MB_FILL_CHAR ((Char)-1) #define MB_FILL_CHAR ((Char)-1)
@ -238,7 +245,5 @@ protected const Char *ct_visual_string(const Char *);
protected int ct_chr_class(Char c); protected int ct_chr_class(Char c);
#endif #endif
size_t ct_mbrtowc(wchar_t *, const char *, size_t);
#endif /* _chartype_f */ #endif /* _chartype_f */

View File

@ -1,4 +1,4 @@
/* $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */ /* $NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $"); __RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,13 +46,7 @@ __FBSDID("$FreeBSD$");
/* /*
* common.c: Common Editor functions * common.c: Common Editor functions
*/ */
#include <ctype.h>
#include <string.h>
#include "el.h" #include "el.h"
#include "common.h"
#include "parse.h"
#include "vi.h"
/* ed_end_of_file(): /* ed_end_of_file():
* Indicate end of file * Indicate end of file
@ -60,7 +54,7 @@ __FBSDID("$FreeBSD$");
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__))) ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
{ {
re_goto_bottom(el); re_goto_bottom(el);
@ -74,7 +68,7 @@ ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
* Insert a character [bound to all insert keys] * Insert a character [bound to all insert keys]
*/ */
protected el_action_t protected el_action_t
ed_insert(EditLine *el, wint_t c) ed_insert(EditLine *el, Int c)
{ {
int count = el->el_state.argument; int count = el->el_state.argument;
@ -93,14 +87,14 @@ ed_insert(EditLine *el, wint_t c)
|| el->el_line.cursor >= el->el_line.lastchar) || el->el_line.cursor >= el->el_line.lastchar)
c_insert(el, 1); c_insert(el, 1);
*el->el_line.cursor++ = (Char)c; *el->el_line.cursor++ = c;
re_fastaddc(el); /* fast refresh for one char. */ re_fastaddc(el); /* fast refresh for one char. */
} else { } else {
if (el->el_state.inputmode != MODE_REPLACE_1) if (el->el_state.inputmode != MODE_REPLACE_1)
c_insert(el, el->el_state.argument); c_insert(el, el->el_state.argument);
while (count-- && el->el_line.cursor < el->el_line.lastchar) while (count-- && el->el_line.cursor < el->el_line.lastchar)
*el->el_line.cursor++ = (Char)c; *el->el_line.cursor++ = c;
re_refresh(el); re_refresh(el);
} }
@ -117,7 +111,7 @@ ed_insert(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *p, *kp; Char *cp, *p, *kp;
@ -145,7 +139,7 @@ ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__))) ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
#ifdef DEBUG_EDIT #ifdef DEBUG_EDIT
#define EL el->el_line #define EL el->el_line
@ -192,7 +186,7 @@ ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__))) ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -213,7 +207,7 @@ ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__))) ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_line.cursor = el->el_line.lastchar; el->el_line.cursor = el->el_line.lastchar;
@ -236,7 +230,7 @@ ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__))) ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_line.cursor = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer;
@ -259,7 +253,7 @@ ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
* [^T] [^T] * [^T] [^T]
*/ */
protected el_action_t protected el_action_t
ed_transpose_chars(EditLine *el, wint_t c) ed_transpose_chars(EditLine *el, Int c)
{ {
if (el->el_line.cursor < el->el_line.lastchar) { if (el->el_line.cursor < el->el_line.lastchar) {
@ -272,7 +266,7 @@ ed_transpose_chars(EditLine *el, wint_t c)
/* must have at least two chars entered */ /* must have at least two chars entered */
c = el->el_line.cursor[-2]; c = el->el_line.cursor[-2];
el->el_line.cursor[-2] = el->el_line.cursor[-1]; el->el_line.cursor[-2] = el->el_line.cursor[-1];
el->el_line.cursor[-1] = (Char)c; el->el_line.cursor[-1] = c;
return CC_REFRESH; return CC_REFRESH;
} else } else
return CC_ERROR; return CC_ERROR;
@ -285,7 +279,7 @@ ed_transpose_chars(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_next_char(EditLine *el, wint_t c __attribute__((__unused__))) ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *lim = el->el_line.lastchar; Char *lim = el->el_line.lastchar;
@ -314,7 +308,7 @@ ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.buffer) if (el->el_line.cursor == el->el_line.buffer)
@ -340,7 +334,7 @@ ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor > el->el_line.buffer) { if (el->el_line.cursor > el->el_line.buffer) {
@ -364,12 +358,14 @@ ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
* [^V] [^V] * [^V] [^V]
*/ */
protected el_action_t protected el_action_t
ed_quoted_insert(EditLine *el, wint_t c) ed_quoted_insert(EditLine *el, Int c)
{ {
int num; int num;
Char tc;
tty_quotemode(el); tty_quotemode(el);
num = el_wgetc(el, &c); num = FUN(el,getc)(el, &tc);
c = tc;
tty_noquotemode(el); tty_noquotemode(el);
if (num == 1) if (num == 1)
return ed_insert(el, c); return ed_insert(el, c);
@ -382,7 +378,7 @@ ed_quoted_insert(EditLine *el, wint_t c)
* Adds to argument or enters a digit * Adds to argument or enters a digit
*/ */
protected el_action_t protected el_action_t
ed_digit(EditLine *el, wint_t c) ed_digit(EditLine *el, Int c)
{ {
if (!Isdigit(c)) if (!Isdigit(c))
@ -410,7 +406,7 @@ ed_digit(EditLine *el, wint_t c)
* For ESC-n * For ESC-n
*/ */
protected el_action_t protected el_action_t
ed_argument_digit(EditLine *el, wint_t c) ed_argument_digit(EditLine *el, Int c)
{ {
if (!Isdigit(c)) if (!Isdigit(c))
@ -436,7 +432,7 @@ ed_argument_digit(EditLine *el, wint_t c)
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_unassigned(EditLine *el __attribute__((__unused__)), ed_unassigned(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_ERROR; return CC_ERROR;
@ -453,8 +449,8 @@ ed_unassigned(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_sigint(EditLine *el __attribute__((__unused__)), ed_tty_sigint(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -467,8 +463,8 @@ ed_tty_sigint(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_dsusp(EditLine *el __attribute__((__unused__)), ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -481,8 +477,8 @@ ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_flush_output(EditLine *el __attribute__((__unused__)), ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -495,8 +491,8 @@ ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_sigquit(EditLine *el __attribute__((__unused__)), ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -509,8 +505,8 @@ ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)), ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -523,8 +519,8 @@ ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_stop_output(EditLine *el __attribute__((__unused__)), ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -537,8 +533,8 @@ ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_tty_start_output(EditLine *el __attribute__((__unused__)), ed_tty_start_output(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -551,7 +547,7 @@ ed_tty_start_output(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_newline(EditLine *el, wint_t c __attribute__((__unused__))) ed_newline(EditLine *el, Int c __attribute__((__unused__)))
{ {
re_goto_bottom(el); re_goto_bottom(el);
@ -567,7 +563,7 @@ ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor <= el->el_line.buffer) if (el->el_line.cursor <= el->el_line.buffer)
@ -587,7 +583,7 @@ ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__))) ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
{ {
terminal_clear_screen(el); /* clear the whole real screen */ terminal_clear_screen(el); /* clear the whole real screen */
@ -602,8 +598,8 @@ ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_redisplay(EditLine *el __attribute__((__unused__)), ed_redisplay(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_REDISPLAY; return CC_REDISPLAY;
@ -616,7 +612,7 @@ ed_redisplay(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_start_over(EditLine *el, wint_t c __attribute__((__unused__))) ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
{ {
ch_reset(el, 0); ch_reset(el, 0);
@ -630,8 +626,8 @@ ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)), ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
wint_t c __attribute__((__unused__))) Int c __attribute__((__unused__)))
{ {
return CC_NORM; return CC_NORM;
@ -644,7 +640,7 @@ ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__))) ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
{ {
char beep = 0; char beep = 0;
int sv_event = el->el_history.eventno; int sv_event = el->el_history.eventno;
@ -664,6 +660,7 @@ ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
if (hist_get(el) == CC_ERROR) { if (hist_get(el) == CC_ERROR) {
if (el->el_map.type == MAP_VI) { if (el->el_map.type == MAP_VI) {
el->el_history.eventno = sv_event; el->el_history.eventno = sv_event;
} }
beep = 1; beep = 1;
/* el->el_history.eventno was fixed by first call */ /* el->el_history.eventno was fixed by first call */
@ -681,7 +678,7 @@ ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_next_history(EditLine *el, wint_t c __attribute__((__unused__))) ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
{ {
el_action_t beep = CC_REFRESH, rval; el_action_t beep = CC_REFRESH, rval;
@ -708,11 +705,11 @@ ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__))) ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
{ {
const Char *hp; const Char *hp;
int h; int h;
int found = 0; bool_t found = 0;
el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_undo.len = -1; el->el_chared.c_undo.len = -1;
@ -751,7 +748,7 @@ ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
(el->el_line.lastchar - el->el_line.buffer)) || (el->el_line.lastchar - el->el_line.buffer)) ||
hp[el->el_line.lastchar - el->el_line.buffer]) && hp[el->el_line.lastchar - el->el_line.buffer]) &&
c_hmatch(el, hp)) { c_hmatch(el, hp)) {
found = 1; found++;
break; break;
} }
h++; h++;
@ -776,11 +773,11 @@ ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__))) ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
{ {
const Char *hp; const Char *hp;
int h; int h;
int found = 0; bool_t found = 0;
el->el_chared.c_vcmd.action = NOP; el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_undo.len = -1; el->el_chared.c_undo.len = -1;
@ -830,7 +827,7 @@ ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__))) ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *ptr; Char *ptr;
int nchars = c_hpos(el); int nchars = c_hpos(el);
@ -873,7 +870,7 @@ ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_next_line(EditLine *el, wint_t c __attribute__((__unused__))) ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *ptr; Char *ptr;
int nchars = c_hpos(el); int nchars = c_hpos(el);
@ -907,7 +904,7 @@ ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
ed_command(EditLine *el, wint_t c __attribute__((__unused__))) ed_command(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char tmpbuf[EL_BUFSIZ]; Char tmpbuf[EL_BUFSIZ];
int tmplen; int tmplen;

View File

@ -21,8 +21,8 @@
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1 #define HAVE_FCNTL_H 1
/* Define to 1 if you have the `getline' function. */ /* Define to 1 if you have the `fgetln' function. */
#define HAVE_GETLINE 1 #define HAVE_FGETLN 1
/* Define to 1 if you have the `fork' function. */ /* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1 #define HAVE_FORK 1
@ -188,6 +188,9 @@
/* Define to 1 if you have the `vis' function. */ /* Define to 1 if you have the `vis' function. */
#define HAVE_VIS 1 #define HAVE_VIS 1
/* Define to 1 if you have the `wcsdup' function. */
#define HAVE_WCSDUP 1
/* Define to 1 if `fork' works. */ /* Define to 1 if `fork' works. */
#define HAVE_WORKING_FORK 1 #define HAVE_WORKING_FORK 1
@ -254,9 +257,6 @@
/* Version number of package */ /* Version number of package */
#define VERSION "3.0" #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 */ /* Define to 1 if you want wide-character code */
/* #undef WIDECHAR */ /* #undef WIDECHAR */

View File

@ -1,4 +1,4 @@
/* $NetBSD: readline.h,v 1.39 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: readline.h,v 1.37 2015/06/02 15:36:45 christos Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -55,7 +55,7 @@ typedef void *histdata_t;
typedef struct _hist_entry { typedef struct _hist_entry {
const char *line; const char *line;
histdata_t data; histdata_t data;
} HIST_ENTRY; } HIST_ENTRY;
typedef struct _keymap_entry { typedef struct _keymap_entry {
@ -89,7 +89,7 @@ typedef KEYMAP_ENTRY *Keymap;
#define RUBOUT 0x7f #define RUBOUT 0x7f
#define ABORT_CHAR CTRL('G') #define ABORT_CHAR CTRL('G')
#define RL_READLINE_VERSION 0x0402 #define RL_READLINE_VERSION 0x0402
#define RL_PROMPT_START_IGNORE '\1' #define RL_PROMPT_START_IGNORE '\1'
#define RL_PROMPT_END_IGNORE '\2' #define RL_PROMPT_END_IGNORE '\2'
@ -98,7 +98,7 @@ typedef KEYMAP_ENTRY *Keymap;
extern "C" { extern "C" {
#endif #endif
extern const char *rl_library_version; extern const char *rl_library_version;
extern int rl_readline_version; extern int rl_readline_version;
extern char *rl_readline_name; extern char *rl_readline_name;
extern FILE *rl_instream; extern FILE *rl_instream;
extern FILE *rl_outstream; 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); HISTORY_STATE *history_get_history_state(void);
void rl_get_screen_size(int *, int *); void rl_get_screen_size(int *, int *);
void rl_set_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_abort_internal(void);
int _rl_qsort_string_compare(char **, char **); 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); void rl_forced_update_display(void);
int rl_set_prompt(const char *); int rl_set_prompt(const char *);
int rl_on_new_line(void); int rl_on_new_line(void);
@ -218,8 +218,6 @@ int rl_generic_bind(int, const char *, const char *, Keymap);
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap); int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
void rl_cleanup_after_signal(void); void rl_cleanup_after_signal(void);
void rl_free_line_state(void); void rl_free_line_state(void);
int rl_set_keyboard_input_timeout(int);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,4 +1,4 @@
.\" $NetBSD: editline.3,v 1.88 2016/02/25 14:59:22 wiz Exp $ .\" $NetBSD: editline.3,v 1.85 2015/11/03 21:36:59 christos Exp $
.\" .\"
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc. .\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -28,7 +28,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd February 24, 2016 .Dd November 3, 2015
.Dt EDITLINE 3 .Dt EDITLINE 3
.Os .Os
.Sh NAME .Sh NAME
@ -72,7 +72,7 @@
.Nm tok_wreset , .Nm tok_wreset ,
.Nm tok_line , .Nm tok_line ,
.Nm tok_wline , .Nm tok_wline ,
.Nm tok_str , .Nm tok_str
.Nm tok_wstr .Nm tok_wstr
.Nd line editor, history and tokenization functions .Nd line editor, history and tokenization functions
.Sh LIBRARY .Sh LIBRARY
@ -130,9 +130,9 @@
.Ft void .Ft void
.Fn el_wdeletestr "EditLine *e" "int count" .Fn el_wdeletestr "EditLine *e" "int count"
.Ft History * .Ft History *
.Fn history_init void .Fn history_init
.Ft HistoryW * .Ft HistoryW *
.Fn history_winit void .Fn history_winit
.Ft void .Ft void
.Fn history_end "History *h" .Fn history_end "History *h"
.Ft void .Ft void
@ -175,16 +175,6 @@ library (which needs the
library). library).
Programs should be linked with Programs should be linked with
.Fl ledit ltermcap . .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 .Sh LINE EDITING FUNCTIONS
The line editing functions use a common data structure, The line editing functions use a common data structure,
.Fa EditLine , .Fa EditLine ,
@ -250,42 +240,14 @@ contains the error code that caused it.
The return value may not remain valid across calls to The return value may not remain valid across calls to
.Fn el_gets .Fn el_gets
and must be copied if the data is to be retained. 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 .It Fn el_getc
Read a wide character as described for Read a character from the tty.
.Fn el_wgetc .Fa ch
and return 0 on end of file or \-1 on failure. is modified to contain the character read.
If the wide character can be represented as a single-byte character, Returns the number of characters read if successful, \-1 otherwise,
convert it with in which case
.Xr wctob 3 , .Dv errno
store the result in can be inspected for the cause.
.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 .It Fn el_push
Pushes Pushes
.Fa str .Fa str
@ -784,7 +746,7 @@ to the last new element of the history.
.It Dv H_ENTER , Fa "const char *str" .It Dv H_ENTER , Fa "const char *str"
Add Add
.Fa str .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. removing the oldest entry to keep the list to the created size.
If If
.Dv H_SETUNIQUE .Dv H_SETUNIQUE

View File

@ -1,4 +1,4 @@
/* $NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $ */ /* $NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else #else
__RCSID("$NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $"); __RCSID("$NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -48,17 +48,13 @@ __FBSDID("$FreeBSD$");
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WIDECHAR #include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <locale.h> #include <locale.h>
#include <langinfo.h> #include <langinfo.h>
#endif
#include "el.h" #include "el.h"
#include "parse.h"
/* el_init(): /* el_init():
* Initialize editline and set default parameters. * Initialize editline and set default parameters.
@ -99,10 +95,12 @@ el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
* Initialize all the modules. Order is important!!! * Initialize all the modules. Order is important!!!
*/ */
el->el_flags = 0; el->el_flags = 0;
#ifdef WIDECHAR
if (setlocale(LC_CTYPE, NULL) != NULL){ if (setlocale(LC_CTYPE, NULL) != NULL){
if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
el->el_flags |= CHARSET_IS_UTF8; el->el_flags |= CHARSET_IS_UTF8;
} }
#endif
if (terminal_init(el) == -1) { if (terminal_init(el) == -1) {
el_free(el->el_prog); el_free(el->el_prog);
@ -211,7 +209,7 @@ FUN(el,set)(EditLine *el, int op, ...)
el_pfunc_t p = va_arg(ap, el_pfunc_t); el_pfunc_t p = va_arg(ap, el_pfunc_t);
int c = va_arg(ap, int); int c = va_arg(ap, int);
rv = prompt_set(el, p, (Char)c, op, 1); rv = prompt_set(el, p, c, op, 1);
break; break;
} }
@ -310,6 +308,7 @@ FUN(el,set)(EditLine *el, int op, ...)
{ {
el_rfunc_t rc = va_arg(ap, el_rfunc_t); el_rfunc_t rc = va_arg(ap, el_rfunc_t);
rv = el_read_setfn(el, rc); rv = el_read_setfn(el, rc);
el->el_flags &= ~NARROW_READ;
break; break;
} }
@ -438,7 +437,7 @@ FUN(el,get)(EditLine *el, int op, ...)
char *argv[20]; char *argv[20];
int i; 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) if ((argv[i] = va_arg(ap, char *)) == NULL)
break; break;
@ -515,7 +514,6 @@ el_source(EditLine *el, const char *fname)
{ {
FILE *fp; FILE *fp;
size_t len; size_t len;
ssize_t slen;
char *ptr; char *ptr;
char *path = NULL; char *path = NULL;
const Char *dptr; const Char *dptr;
@ -552,17 +550,15 @@ el_source(EditLine *el, const char *fname)
return -1; return -1;
} }
ptr = NULL; while ((ptr = fgetln(fp, &len)) != NULL) {
len = 0;
while ((slen = getline(&ptr, &len, fp)) != -1) {
if (*ptr == '\n') if (*ptr == '\n')
continue; /* Empty line. */ continue; /* Empty line. */
if (slen > 0 && ptr[--slen] == '\n')
ptr[slen] = '\0';
dptr = ct_decode_string(ptr, &el->el_scratch); dptr = ct_decode_string(ptr, &el->el_scratch);
if (!dptr) if (!dptr)
continue; continue;
if (len > 0 && dptr[len - 1] == '\n')
--len;
/* loop until first non-space char or EOL */ /* loop until first non-space char or EOL */
while (*dptr != '\0' && Isspace(*dptr)) while (*dptr != '\0' && Isspace(*dptr))
dptr++; dptr++;
@ -571,7 +567,6 @@ el_source(EditLine *el, const char *fname)
if ((error = parse_line(el, dptr)) == -1) if ((error = parse_line(el, dptr)) == -1)
break; break;
} }
free(ptr);
el_free(path); el_free(path);
(void) fclose(fp); (void) fclose(fp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */ /* $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -49,6 +49,8 @@
#include "histedit.h" #include "histedit.h"
#include "chartype.h" #include "chartype.h"
#include <stdio.h>
#include <sys/types.h>
#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */ #define EL_BUFSIZ ((size_t)1024) /* Maximum line size */
@ -57,7 +59,11 @@
#define EDIT_DISABLED 0x04 #define EDIT_DISABLED 0x04
#define UNBUFFERED 0x08 #define UNBUFFERED 0x08
#define CHARSET_IS_UTF8 0x10 #define CHARSET_IS_UTF8 0x10
#define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */
#define NARROW_HISTORY 0x40 #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 */ typedef unsigned char el_action_t; /* Index to command array */
@ -67,7 +73,7 @@ typedef struct coord_t { /* Position on the screen */
} coord_t; } coord_t;
typedef struct el_line_t { typedef struct el_line_t {
Char *buffer; /* Input line */ Char *buffer; /* Input line */
Char *cursor; /* Cursor position */ Char *cursor; /* Cursor position */
Char *lastchar; /* Last character */ Char *lastchar; /* Last character */
const Char *limit; /* Max position */ const Char *limit; /* Max position */
@ -82,7 +88,7 @@ typedef struct el_state_t {
int argument; /* Numeric argument */ int argument; /* Numeric argument */
int metanext; /* Is the next char a meta char */ int metanext; /* Is the next char a meta char */
el_action_t lastcmd; /* Previous command */ el_action_t lastcmd; /* Previous command */
el_action_t thiscmd; /* this command */ el_action_t thiscmd; /* this command */
Char thisch; /* char that generated it */ Char thisch; /* char that generated it */
} el_state_t; } el_state_t;
@ -99,11 +105,13 @@ typedef struct el_state_t {
#include "terminal.h" #include "terminal.h"
#include "refresh.h" #include "refresh.h"
#include "chared.h" #include "chared.h"
#include "common.h"
#include "search.h" #include "search.h"
#include "hist.h" #include "hist.h"
#include "fcns.h" /* el_func_t is needed for map.h */
#include "map.h" #include "map.h"
#include "parse.h"
#include "sig.h" #include "sig.h"
#include "help.h"
#include "read.h" #include "read.h"
struct editline { struct editline {

View File

@ -1,4 +1,4 @@
/* $NetBSD: eln.c,v 1.28 2016/02/28 23:02:24 christos Exp $ */ /* $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $ */
/*- /*-
* Copyright (c) 2009 The NetBSD Foundation, Inc. * Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -12,6 +12,13 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * 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 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@ -27,40 +34,36 @@
*/ */
#include "config.h" #include "config.h"
#if !defined(lint) && !defined(SCCSID) #if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: eln.c,v 1.28 2016/02/28 23:02:24 christos Exp $"); __RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <errno.h> #include "histedit.h"
#include "el.h"
#include "read.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "el.h"
public int public int
el_getc(EditLine *el, char *cp) el_getc(EditLine *el, char *cp)
{ {
int num_read; int num_read;
wchar_t wc = 0; wchar_t wc = 0;
num_read = el_wgetc(el, &wc); if (!(el->el_flags & CHARSET_IS_UTF8))
*cp = '\0'; el->el_flags |= IGNORE_EXTCHARS;
if (num_read <= 0) num_read = el_wgetc (el, &wc);
return num_read; if (!(el->el_flags & CHARSET_IS_UTF8))
num_read = ct_wctob(wc); el->el_flags &= ~IGNORE_EXTCHARS;
if (num_read == EOF) {
errno = ERANGE; if (num_read > 0)
return -1; *cp = (char)wc;
} else { return num_read;
*cp = (char)num_read;
return 1;
}
} }
#ifdef WIDECHAR
public void public void
el_push(EditLine *el, const char *str) el_push(EditLine *el, const char *str)
{ {
@ -75,15 +78,17 @@ el_gets(EditLine *el, int *nread)
{ {
const wchar_t *tmp; const wchar_t *tmp;
if (!(el->el_flags & CHARSET_IS_UTF8))
el->el_flags |= IGNORE_EXTCHARS;
tmp = el_wgets(el, nread); tmp = el_wgets(el, nread);
if (tmp != NULL) { if (tmp != NULL) {
int i;
size_t nwread = 0; size_t nwread = 0;
for (int i = 0; i < *nread; i++)
for (i = 0; i < *nread; i++)
nwread += ct_enc_width(tmp[i]); nwread += ct_enc_width(tmp[i]);
*nread = (int)nwread; *nread = (int)nwread;
} }
if (!(el->el_flags & CHARSET_IS_UTF8))
el->el_flags &= ~IGNORE_EXTCHARS;
return ct_encode_string(tmp, &el->el_lgcyconv); return ct_encode_string(tmp, &el->el_lgcyconv);
} }
@ -228,7 +233,7 @@ el_set(EditLine *el, int op, ...)
ret = -1; ret = -1;
goto out; goto out;
} }
/* XXX: The two strdup's leak */ // XXX: The two strdup's leak
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]), ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
func); func);
ct_free_argv(wargv); ct_free_argv(wargv);
@ -242,8 +247,10 @@ el_set(EditLine *el, int op, ...)
break; break;
} }
/* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */ case EL_GETCFN: /* el_rfunc_t */
ret = el_wset(el, op, va_arg(ap, el_rfunc_t)); ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
el->el_flags |= NARROW_READ;
break; break;
case EL_CLIENTDATA: /* void * */ case EL_CLIENTDATA: /* void * */
@ -337,6 +344,7 @@ el_get(EditLine *el, int op, ...)
break; break;
} }
/* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */ case EL_GETCFN: /* el_rfunc_t */
ret = el_wget(el, op, va_arg(ap, el_rfunc_t *)); ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
break; break;
@ -391,4 +399,3 @@ el_insertstr(EditLine *el, const char *str)
{ {
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv)); return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
} }
#endif /* WIDECHAR */

View File

@ -1,4 +1,4 @@
/* $NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $ */ /* $NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $"); __RCSID("$NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,10 +46,7 @@ __FBSDID("$FreeBSD$");
/* /*
* emacs.c: Emacs functions * emacs.c: Emacs functions
*/ */
#include <ctype.h>
#include "el.h" #include "el.h"
#include "emacs.h"
/* em_delete_or_list(): /* em_delete_or_list():
* Delete character under cursor or list completions if at end of line * Delete character under cursor or list completions if at end of line
@ -57,7 +54,7 @@ __FBSDID("$FreeBSD$");
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_delete_or_list(EditLine *el, wint_t c) em_delete_or_list(EditLine *el, Int c)
{ {
if (el->el_line.cursor == el->el_line.lastchar) { if (el->el_line.cursor == el->el_line.lastchar) {
@ -93,7 +90,7 @@ em_delete_or_list(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__))) em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *p, *kp; Char *cp, *p, *kp;
@ -122,7 +119,7 @@ em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_yank(EditLine *el, wint_t c __attribute__((__unused__))) em_yank(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -158,7 +155,7 @@ em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_kill_line(EditLine *el, wint_t c __attribute__((__unused__))) em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -180,7 +177,7 @@ em_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_kill_region(EditLine *el, wint_t c __attribute__((__unused__))) em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -213,7 +210,7 @@ em_kill_region(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_copy_region(EditLine *el, wint_t c __attribute__((__unused__))) em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -242,14 +239,14 @@ em_copy_region(EditLine *el, wint_t c __attribute__((__unused__)))
* Gosling emacs transpose chars [^T] * Gosling emacs transpose chars [^T]
*/ */
protected el_action_t protected el_action_t
em_gosmacs_transpose(EditLine *el, wint_t c) em_gosmacs_transpose(EditLine *el, Int c)
{ {
if (el->el_line.cursor > &el->el_line.buffer[1]) { if (el->el_line.cursor > &el->el_line.buffer[1]) {
/* must have at least two chars entered */ /* must have at least two chars entered */
c = el->el_line.cursor[-2]; c = el->el_line.cursor[-2];
el->el_line.cursor[-2] = el->el_line.cursor[-1]; el->el_line.cursor[-2] = el->el_line.cursor[-1];
el->el_line.cursor[-1] = (Char)c; el->el_line.cursor[-1] = c;
return CC_REFRESH; return CC_REFRESH;
} else } else
return CC_ERROR; return CC_ERROR;
@ -262,7 +259,7 @@ em_gosmacs_transpose(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_next_word(EditLine *el, wint_t c __attribute__((__unused__))) em_next_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.lastchar) if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR; return CC_ERROR;
@ -287,7 +284,7 @@ em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_upper_case(EditLine *el, wint_t c __attribute__((__unused__))) em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *ep; Char *cp, *ep;
@ -311,7 +308,7 @@ em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__))) em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *ep; Char *cp, *ep;
@ -343,7 +340,7 @@ em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_lower_case(EditLine *el, wint_t c __attribute__((__unused__))) em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *ep; Char *cp, *ep;
@ -367,7 +364,7 @@ em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_set_mark(EditLine *el, wint_t c __attribute__((__unused__))) em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_chared.c_kill.mark = el->el_line.cursor; el->el_chared.c_kill.mark = el->el_line.cursor;
@ -381,7 +378,7 @@ em_set_mark(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__))) em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp; Char *cp;
@ -398,7 +395,7 @@ em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__))) em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
{ /* multiply current argument by 4 */ { /* multiply current argument by 4 */
if (el->el_state.argument > 1000000) if (el->el_state.argument > 1000000)
@ -415,7 +412,7 @@ em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_meta_next(EditLine *el, wint_t c __attribute__((__unused__))) em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_state.metanext = 1; el->el_state.metanext = 1;
@ -428,7 +425,7 @@ em_meta_next(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__))) em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ? el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
@ -442,7 +439,7 @@ em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *cp, *oldc, *dp; Char *cp, *oldc, *dp;
@ -469,7 +466,7 @@ em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__))) em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_search.patlen = 0; el->el_search.patlen = 0;
@ -482,7 +479,7 @@ em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__))) em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_search.patlen = 0; el->el_search.patlen = 0;
@ -496,7 +493,7 @@ em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
em_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor <= el->el_line.buffer) if (el->el_line.cursor <= el->el_line.buffer)

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -31,24 +31,27 @@
#include "config.h" #include "config.h"
#if !defined(lint) && !defined(SCCSID) #if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $");
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdio.h>
#include <dirent.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 <errno.h>
#include <fcntl.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 "el.h"
#include "fcns.h" /* for EL_NUM_FCNS */
#include "histedit.h"
#include "filecomplete.h" #include "filecomplete.h"
static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@',
@ -97,9 +100,9 @@ fn_tilde_expand(const char *txt)
} }
if (temp[0] == 0) { if (temp[0] == 0) {
#ifdef HAVE_GETPW_R_POSIX #ifdef HAVE_GETPW_R_POSIX
if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
&pass) != 0) &pass) != 0)
pass = NULL; pass = NULL;
#elif HAVE_GETPW_R_DRAFT #elif HAVE_GETPW_R_DRAFT
pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf)); pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf));
#else #else
@ -481,7 +484,7 @@ fn_complete(EditLine *el,
cur_off - (int)len, cur_off); cur_off - (int)len, cur_off);
} else } else
matches = 0; matches = 0;
if (!attempted_completion_function || if (!attempted_completion_function ||
(over != NULL && !*over && !matches)) (over != NULL && !*over && !matches))
matches = completion_matches( matches = completion_matches(
ct_encode_string(dequoted_temp ? dequoted_temp : temp, ct_encode_string(dequoted_temp ? dequoted_temp : temp,
@ -540,7 +543,7 @@ fn_complete(EditLine *el,
} }
/* matches[1] through matches[i-1] are available */ /* matches[1] through matches[i-1] are available */
matches_num = (size_t)(i - 1); matches_num = (size_t)(i - 1);
/* newline to get on next line from command line */ /* newline to get on next line from command line */
(void)fprintf(el->el_outfile, "\n"); (void)fprintf(el->el_outfile, "\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $ */ /* $NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $"); __RCSID("$NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$");
* hist.c: History access functions * hist.c: History access functions
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "el.h" #include "el.h"
/* hist_init(): /* hist_init():

View File

@ -1,4 +1,4 @@
/* $NetBSD: hist.h,v 1.18 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: hist.h,v 1.15 2016/01/30 15:05:27 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,6 +41,8 @@
#ifndef _h_el_hist #ifndef _h_el_hist
#define _h_el_hist #define _h_el_hist
#include "histedit.h"
typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...); typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...);
typedef struct el_history_t { typedef struct el_history_t {
@ -81,7 +83,7 @@ protected int hist_set(EditLine *, hist_fun_t, void *);
protected int hist_command(EditLine *, int, const Char **); protected int hist_command(EditLine *, int, const Char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t); protected int hist_enlargebuf(EditLine *, size_t, size_t);
#ifdef WIDECHAR #ifdef WIDECHAR
protected wchar_t *hist_convert(EditLine *, int, void *); protected wchar_t *hist_convert(EditLine *, int, void *);
#endif #endif
#endif /* _h_el_hist */ #endif /* _h_el_hist */

View File

@ -1,4 +1,4 @@
/* $NetBSD: histedit.h,v 1.55 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: histedit.h,v 1.53 2014/06/18 18:12:28 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -130,7 +130,7 @@ unsigned char _el_fn_sh_complete(EditLine *, int);
* For operations that support set or set/get, the argument types listed are for * For operations that support set or set/get, the argument types listed are for
* the "set" operation. For "get", each listed type must be a pointer. * the "set" operation. For "get", each listed type must be a pointer.
* E.g. EL_EDITMODE takes an int when set, but an int* when get. * E.g. EL_EDITMODE takes an int when set, but an int* when get.
* *
* Operations that only support "get" have the correct argument types listed. * Operations that only support "get" have the correct argument types listed.
*/ */
#define EL_PROMPT 0 /* , prompt_func); set/get */ #define EL_PROMPT 0 /* , prompt_func); set/get */
@ -143,7 +143,7 @@ unsigned char _el_fn_sh_complete(EditLine *, int);
#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */ #define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */
#define EL_SETTY 8 /* , const Char *, ..., NULL); set */ #define EL_SETTY 8 /* , const Char *, ..., NULL); set */
#define EL_ADDFN 9 /* , const Char *, const Char, 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_HIST 10 /* , hist_fun_t, const void *); set */
#define EL_EDITMODE 11 /* , int); set/get */ #define EL_EDITMODE 11 /* , int); set/get */
#define EL_RPROMPT 12 /* , prompt_func); set/get */ #define EL_RPROMPT 12 /* , prompt_func); set/get */
@ -251,9 +251,20 @@ int tok_str(Tokenizer *, const char *,
/* /*
* Begin Wide Character Support * 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 <wchar.h>
#include <wctype.h> #include <wctype.h>
/*
* Wide character versions
*/
/* /*
* ==== Editing ==== * ==== Editing ====
*/ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,11 +46,11 @@ __FBSDID("$FreeBSD$");
/* /*
* hist.c: TYPE(History) access functions * hist.c: TYPE(History) access functions
*/ */
#include <sys/stat.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <vis.h> #include <vis.h>
#include <sys/stat.h>
static const char hist_cookie[] = "_HiStOrY_V2_\n"; static const char hist_cookie[] = "_HiStOrY_V2_\n";
@ -439,7 +439,7 @@ history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
*/ */
/* ARGSUSED */ /* ARGSUSED */
private void private void
history_def_delete(history_t *h, history_def_delete(history_t *h,
TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp) TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp)
{ {
HistEventPrivate *evp = (void *)&hp->ev; HistEventPrivate *evp = (void *)&hp->ev;
@ -734,9 +734,7 @@ history_load(TYPE(History) *h, const char *fname)
{ {
FILE *fp; FILE *fp;
char *line; char *line;
size_t llen; size_t sz, max_size;
ssize_t sz;
size_t max_size;
char *ptr; char *ptr;
int i = -1; int i = -1;
TYPE(HistEvent) ev; TYPE(HistEvent) ev;
@ -747,23 +745,26 @@ history_load(TYPE(History) *h, const char *fname)
if ((fp = fopen(fname, "r")) == NULL) if ((fp = fopen(fname, "r")) == NULL)
return i; return i;
line = NULL; if ((line = fgetln(fp, &sz)) == NULL)
llen = 0;
if ((sz = getline(&line, &llen, fp)) == -1)
goto done; goto done;
if (strncmp(line, hist_cookie, (size_t)sz) != 0) if (strncmp(line, hist_cookie, sz) != 0)
goto done; goto done;
ptr = h_malloc((max_size = 1024) * sizeof(*ptr)); ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
if (ptr == NULL) if (ptr == NULL)
goto done; goto done;
for (i = 0; (sz = getline(&line, &llen, fp)) != -1; i++) { for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
if (sz > 0 && line[sz - 1] == '\n') char c = line[sz];
if (sz != 0 && line[sz - 1] == '\n')
line[--sz] = '\0'; line[--sz] = '\0';
if (max_size < (size_t)sz) { else
line[sz] = '\0';
if (max_size < sz) {
char *nptr; char *nptr;
max_size = ((size_t)sz + 1024) & (size_t)~1023; max_size = (sz + 1024) & (size_t)~1023;
nptr = h_realloc(ptr, max_size * sizeof(*ptr)); nptr = h_realloc(ptr, max_size * sizeof(*ptr));
if (nptr == NULL) { if (nptr == NULL) {
i = -1; i = -1;
@ -772,6 +773,7 @@ history_load(TYPE(History) *h, const char *fname)
ptr = nptr; ptr = nptr;
} }
(void) strunvis(ptr, line); (void) strunvis(ptr, line);
line[sz] = c;
if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) { if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) {
i = -1; i = -1;
goto oomem; goto oomem;
@ -780,7 +782,6 @@ history_load(TYPE(History) *h, const char *fname)
oomem: oomem:
h_free(ptr); h_free(ptr);
done: done:
free(line);
(void) fclose(fp); (void) fclose(fp);
return i; return i;
} }
@ -812,8 +813,8 @@ history_save_fp(TYPE(History) *h, FILE *fp)
retval != -1; retval != -1;
retval = HPREV(h, &ev), i++) { retval = HPREV(h, &ev), i++) {
str = ct_encode_string(ev.str, &conv); str = ct_encode_string(ev.str, &conv);
len = strlen(str) * 4 + 1; len = strlen(str) * 4;
if (len > max_size) { if (len >= max_size) {
char *nptr; char *nptr;
max_size = (len + 1024) & (size_t)~1023; max_size = (len + 1024) & (size_t)~1023;
nptr = h_realloc(ptr, max_size * sizeof(*ptr)); nptr = h_realloc(ptr, max_size * sizeof(*ptr));

View File

@ -1,4 +1,4 @@
/* $NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $ */ /* $NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $"); __RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -65,8 +65,8 @@ __FBSDID("$FreeBSD$");
* 1) It is not possible to have one key that is a * 1) It is not possible to have one key that is a
* substr of another. * substr of another.
*/ */
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "el.h" #include "el.h"
@ -75,10 +75,10 @@ __FBSDID("$FreeBSD$");
* linked list of these node elements * linked list of these node elements
*/ */
struct keymacro_node_t { struct keymacro_node_t {
Char ch; /* single character of key */ Char ch; /* single character of key */
int type; /* node type */ int type; /* node type */
keymacro_value_t val; /* command code or pointer to str, */ 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 *next; /* ptr to next char of this key */
struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/ 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 *); keymacro_value_t *);
private int node__try(EditLine *, keymacro_node_t *, const Char *, private int node__try(EditLine *, keymacro_node_t *, const Char *,
keymacro_value_t *, int); keymacro_value_t *, int);
private keymacro_node_t *node__get(wint_t); private keymacro_node_t *node__get(Int);
private void node__free(keymacro_node_t *); private void node__free(keymacro_node_t *);
private void node__put(EditLine *, keymacro_node_t *); private void node__put(EditLine *, keymacro_node_t *);
private int node__delete(EditLine *, keymacro_node_t **, private int node__delete(EditLine *, keymacro_node_t **,
@ -277,23 +277,21 @@ keymacro_print(EditLine *el, const Char *key)
/* node_trav(): /* node_trav():
* recursively traverses node in tree until match or mismatch is * recursively traverses node in tree until match or mismatch is
* found. May read in more characters. * found. May read in more characters.
*/ */
private int private int
node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
{ {
wchar_t wc;
if (ptr->ch == *ch) { if (ptr->ch == *ch) {
/* match found */ /* match found */
if (ptr->next) { if (ptr->next) {
/* key not complete so get next char */ /* key not complete so get next char */
if (el_wgetc(el, &wc) != 1) {/* if EOF or error */ if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */
val->cmd = ED_END_OF_FILE; val->cmd = ED_END_OF_FILE;
return XK_CMD; return XK_CMD;
/* PWP: Pretend we just read an end-of-file */ /* PWP: Pretend we just read an end-of-file */
} }
*ch = (Char)wc;
return node_trav(el, ptr->next, ch, val); return node_trav(el, ptr->next, ch, val);
} else { } else {
*val = ptr->val; *val = ptr->val;
@ -316,7 +314,7 @@ node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
/* node__try(): /* 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 private int
node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, node__try(EditLine *el, keymacro_node_t *ptr, const Char *str,
@ -462,14 +460,14 @@ node__put(EditLine *el, keymacro_node_t *ptr)
* Returns pointer to a keymacro_node_t for ch. * Returns pointer to a keymacro_node_t for ch.
*/ */
private keymacro_node_t * private keymacro_node_t *
node__get(wint_t ch) node__get(Int ch)
{ {
keymacro_node_t *ptr; keymacro_node_t *ptr;
ptr = el_malloc(sizeof(*ptr)); ptr = el_malloc(sizeof(*ptr));
if (ptr == NULL) if (ptr == NULL)
return NULL; return NULL;
ptr->ch = (Char)ch; ptr->ch = ch;
ptr->type = XK_NOD; ptr->type = XK_NOD;
ptr->val.str = NULL; ptr->val.str = NULL;
ptr->next = NULL; ptr->next = NULL;
@ -598,7 +596,7 @@ keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
case XK_STR: case XK_STR:
case XK_EXE: case XK_EXE:
(void) keymacro__decode_str(val->str, unparsbuf, (void) keymacro__decode_str(val->str, unparsbuf,
sizeof(unparsbuf), sizeof(unparsbuf),
ntype == XK_STR ? "\"\"" : "[]"); ntype == XK_STR ? "\"\"" : "[]");
(void) fprintf(el->el_outfile, fmt, (void) fprintf(el->el_outfile, fmt,
ct_encode_string(key, &el->el_scratch), unparsbuf); ct_encode_string(key, &el->el_scratch), unparsbuf);

View File

@ -62,7 +62,7 @@ case $FLAG in
#include "${FILES}" #include "${FILES}"
_EOF _EOF
;; ;;
-h) -h)
set - `echo $FILES | sed -e 's/\\./_/g'` set - `echo $FILES | sed -e 's/\\./_/g'`
hdr="_h_`basename $1`" hdr="_h_`basename $1`"
@ -79,8 +79,7 @@ _EOF
# XXX: need a space between name and prototype so that -fc and -fh # XXX: need a space between name and prototype so that -fc and -fh
# parsing is much easier # parsing is much easier
# #
printf("protected el_action_t\t%s (EditLine *, wint_t);\n", printf("protected el_action_t\t%s (EditLine *, Int);\n", name);
name);
} }
} }
END { END {
@ -95,7 +94,7 @@ _EOF
BEGIN { BEGIN {
printf("/* Automatically generated file, do not edit */\n"); printf("/* Automatically generated file, do not edit */\n");
printf("#include \"config.h\"\n#include \"el.h\"\n"); printf("#include \"config.h\"\n#include \"el.h\"\n");
printf("#include \"help.h\"\n"); printf("#include \"chartype.h\"\n");
printf("private const struct el_bindings_t el_func_help[] = {\n"); printf("private const struct el_bindings_t el_func_help[] = {\n");
low = "abcdefghijklmnopqrstuvwxyz_"; low = "abcdefghijklmnopqrstuvwxyz_";
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
@ -164,7 +163,7 @@ _EOF
END { END {
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count); printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
printf("typedef el_action_t (*el_func_t)(EditLine *, wint_t);"); printf("typedef el_action_t (*el_func_t)(EditLine *, Int);");
printf("\nprotected const el_func_t* func__get(void);\n"); printf("\nprotected const el_func_t* func__get(void);\n");
printf("#endif /* _h_fcns_c */\n"); printf("#endif /* _h_fcns_c */\n");
}' }'
@ -177,9 +176,6 @@ _EOF
BEGIN { BEGIN {
printf("/* Automatically generated file, do not edit */\n"); printf("/* Automatically generated file, do not edit */\n");
printf("#include \"config.h\"\n#include \"el.h\"\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[] = {"); printf("private const el_func_t el_func[] = {");
maxlen = 80; maxlen = 80;
needn = 1; needn = 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,16 +46,11 @@ __FBSDID("$FreeBSD$");
/* /*
* map.c: Editor function definitions * map.c: Editor function definitions
*/ */
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "el.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_key(EditLine *, el_action_t *, const Char *);
private void map_print_some_keys(EditLine *, el_action_t *, wint_t, wint_t); private void map_print_some_keys(EditLine *, el_action_t *, Int, Int);
private void map_print_all_keys(EditLine *); private void map_print_all_keys(EditLine *);
private void map_init_nls(EditLine *); private void map_init_nls(EditLine *);
private void map_init_meta(EditLine *); private void map_init_meta(EditLine *);
@ -1149,19 +1144,19 @@ map_print_key(EditLine *el, el_action_t *map, const Char *in)
* Print keys from first to last * Print keys from first to last
*/ */
private void private void
map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last) map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
{ {
el_bindings_t *bp, *ep; el_bindings_t *bp, *ep;
Char firstbuf[2], lastbuf[2]; Char firstbuf[2], lastbuf[2];
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
firstbuf[0] = (Char)first; firstbuf[0] = first;
firstbuf[1] = 0; firstbuf[1] = 0;
lastbuf[0] = (Char)last; lastbuf[0] = last;
lastbuf[1] = 0; lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) { if (map[first] == ED_UNASSIGNED) {
if (first == last) { if (first == last) {
(void) keymacro__decode_str(firstbuf, unparsbuf, (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ); sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%-15s-> is undefined\n", unparsbuf); "%-15s-> is undefined\n", unparsbuf);
@ -1172,14 +1167,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
for (bp = el->el_map.help; bp < ep; bp++) { for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) { if (bp->func == map[first]) {
if (first == last) { if (first == last) {
(void) keymacro__decode_str(firstbuf, unparsbuf, (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ); sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n", (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
unparsbuf, bp->name); unparsbuf, bp->name);
} else { } else {
(void) keymacro__decode_str(firstbuf, unparsbuf, (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ); sizeof(unparsbuf), STRQQ);
(void) keymacro__decode_str(lastbuf, extrabuf, (void) keymacro__decode_str(lastbuf, extrabuf,
sizeof(extrabuf), STRQQ); sizeof(extrabuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"%-4s to %-7s-> " FSTR "\n", "%-4s to %-7s-> " FSTR "\n",
@ -1190,14 +1185,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
} }
#ifdef MAP_DEBUG #ifdef MAP_DEBUG
if (map == el->el_map.key) { if (map == el->el_map.key) {
(void) keymacro__decode_str(firstbuf, unparsbuf, (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ); sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf); "BUG!!! %s isn't bound to anything.\n", unparsbuf);
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n", (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
first, el->el_map.key[first]); first, el->el_map.key[first]);
} else { } else {
(void) keymacro__decode_str(firstbuf, unparsbuf, (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ); sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, (void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf); "BUG!!! %s isn't bound to anything.\n", unparsbuf);
@ -1307,8 +1302,8 @@ map_bind(EditLine *el, int argc, const Char **argv)
return 0; return 0;
default: default:
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"" FSTR ": Invalid switch `%lc'.\n", "" FSTR ": Invalid switch `" FCHAR "'.\n",
argv[0], (wint_t)p[1]); argv[0], (Int)p[1]);
} }
else else
break; break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -56,19 +56,16 @@ __FBSDID("$FreeBSD$");
* settc * settc
* setty * setty
*/ */
#include <stdlib.h>
#include <string.h>
#include "el.h" #include "el.h"
#include "parse.h" #include <stdlib.h>
private const struct { private const struct {
const Char *name; const Char *name;
int (*func)(EditLine *, int, const Char **); int (*func)(EditLine *, int, const Char **);
} cmds[] = { } cmds[] = {
{ STR("bind"), map_bind }, { STR("bind"), map_bind },
{ STR("echotc"), terminal_echotc }, { STR("echotc"), terminal_echotc },
{ STR("edit"), el_editmode }, { STR("edit"), el_editmode },
{ STR("history"), hist_command }, { STR("history"), hist_command },
{ STR("telltc"), terminal_telltc }, { STR("telltc"), terminal_telltc },
{ STR("settc"), terminal_settc }, { STR("settc"), terminal_settc },
@ -144,7 +141,7 @@ protected int
parse__escape(const Char **ptr) parse__escape(const Char **ptr)
{ {
const Char *p; const Char *p;
wint_t c; Int c;
p = *ptr; p = *ptr;
@ -256,7 +253,7 @@ parse__string(Char *out, const Char *in)
case '^': case '^':
if ((n = parse__escape(&in)) == -1) if ((n = parse__escape(&in)) == -1)
return NULL; return NULL;
*out++ = (Char)n; *out++ = n;
break; break;
case 'M': case 'M':

View File

@ -1,4 +1,4 @@
/* $NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $ */ /* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $"); __RCSID("$NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: prompt.h,v 1.10 2009/12/30 22:37:40 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,13 +41,15 @@
#ifndef _h_el_prompt #ifndef _h_el_prompt
#define _h_el_prompt #define _h_el_prompt
#include "histedit.h"
typedef Char *(*el_pfunc_t)(EditLine *); typedef Char *(*el_pfunc_t)(EditLine *);
typedef struct el_prompt_t { typedef struct el_prompt_t {
el_pfunc_t p_func; /* Function to return the prompt */ el_pfunc_t p_func; /* Function to return the prompt */
coord_t p_pos; /* position in the line after prompt */ coord_t p_pos; /* position in the line after prompt */
Char p_ignore; /* character to start/end literal */ Char p_ignore; /* character to start/end literal */
int p_wide; int p_wide;
} el_prompt_t; } el_prompt_t;
protected void prompt_print(EditLine *, int); protected void prompt_print(EditLine *, int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $ */ /* $NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $"); __RCSID("$NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -47,21 +47,18 @@ __FBSDID("$FreeBSD$");
* read.c: Clean this junk up! This is horrible code. * read.c: Clean this junk up! This is horrible code.
* Terminal read functions * Terminal read functions
*/ */
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include "el.h" #include "el.h"
#define OKCMD -1 /* must be -1! */ #define OKCMD -1 /* must be -1! */
private int read__fixio(int, int); private int read__fixio(int, int);
private int read_preread(EditLine *); private int read_preread(EditLine *);
private int read_char(EditLine *, wchar_t *); private int read_char(EditLine *, Char *);
private int read_getcmd(EditLine *, el_action_t *, Char *); private int read_getcmd(EditLine *, el_action_t *, Char *);
private void read_pop(c_macro_t *); private void read_pop(c_macro_t *);
@ -244,21 +241,18 @@ FUN(el,push)(EditLine *el, const Char *str)
private int private int
read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
{ {
static const Char meta = (Char)0x80;
el_action_t cmd; el_action_t cmd;
wchar_t wc;
int num; int num;
el->el_errno = 0; el->el_errno = 0;
do { do {
if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */ if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
el->el_errno = num == 0 ? 0 : errno; el->el_errno = num == 0 ? 0 : errno;
return 0; /* not OKCMD */ return 0; /* not OKCMD */
} }
*ch = (Char)wc;
#ifdef KANJI #ifdef KANJI
if ((*ch & meta)) { if ((*ch & 0200)) {
el->el_state.metanext = 0; el->el_state.metanext = 0;
cmd = CcViMap[' ']; cmd = CcViMap[' '];
break; break;
@ -267,7 +261,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
if (el->el_state.metanext) { if (el->el_state.metanext) {
el->el_state.metanext = 0; el->el_state.metanext = 0;
*ch |= meta; *ch |= 0200;
} }
#ifdef WIDECHAR #ifdef WIDECHAR
if (*ch >= N_KEYS) if (*ch >= N_KEYS)
@ -302,17 +296,29 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
return OKCMD; 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_char():
* Read a character from the tty. * Read a character from the tty.
*/ */
private int private int
read_char(EditLine *el, wchar_t *cp) read_char(EditLine *el, Char *cp)
{ {
ssize_t num_read; ssize_t num_read;
int tried = 0; int tried = 0;
char cbuf[MB_LEN_MAX]; char cbuf[MB_LEN_MAX];
size_t cbp = 0; size_t cbp = 0;
int save_errno = errno; int bytes = 0;
again: again:
el->el_signal->sig_no = 0; el->el_signal->sig_no = 0;
@ -328,59 +334,50 @@ read_char(EditLine *el, wchar_t *cp)
default: default:
break; break;
} }
if (!tried && read__fixio(el->el_infd, e) == 0) { if (!tried && read__fixio(el->el_infd, e) == 0)
errno = save_errno;
tried = 1; tried = 1;
} else { else {
errno = e; errno = e;
*cp = L'\0'; *cp = '\0';
return -1; return -1;
} }
} }
/* Test for EOF */ /* Test for EOF */
if (num_read == 0) { if (num_read == 0) {
*cp = L'\0'; errno = 0;
*cp = '\0';
return 0; return 0;
} }
for (;;) { #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 */
++cbp; ++cbp;
switch (ct_mbrtowc(cp, cbuf, cbp)) { if ((bytes = ct_mbtowc(cp, cbuf, cbp)) == -1) {
case (size_t)-1: ct_mbtowc_reset;
if (cbp > 1) { if (cbp >= MB_LEN_MAX) { /* "shouldn't happen" */
/*
* 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; errno = EILSEQ;
*cp = L'\0'; *cp = '\0';
return -1; return -1;
} }
/* Incomplete sequence, read another byte. */
goto again; 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(): /* read_pop():
@ -398,11 +395,11 @@ read_pop(c_macro_t *ma)
ma->offset = 0; ma->offset = 0;
} }
/* el_wgetc(): /* el_getc():
* Read a wide character * Read a character
*/ */
public int public int
el_wgetc(EditLine *el, wchar_t *cp) FUN(el,getc)(EditLine *el, Char *cp)
{ {
int num_read; int num_read;
c_macro_t *ma = &el->el_chared.c_macro; c_macro_t *ma = &el->el_chared.c_macro;
@ -444,8 +441,12 @@ el_wgetc(EditLine *el, wchar_t *cp)
num_read = (*el->el_read.read_char)(el, cp); num_read = (*el->el_read.read_char)(el, cp);
if (num_read < 0) if (num_read < 0)
el->el_errno = errno; el->el_errno = errno;
#ifdef WIDECHAR
if (el->el_flags & NARROW_READ)
*cp = *(char *)(void *)cp;
#endif
#ifdef DEBUG_READ #ifdef DEBUG_READ
(void) fprintf(el->el_errfile, "Got it %lc\n", *cp); (void) fprintf(el->el_errfile, "Got it %c\n", *cp);
#endif /* DEBUG_READ */ #endif /* DEBUG_READ */
return num_read; return num_read;
} }
@ -486,7 +487,6 @@ FUN(el,gets)(EditLine *el, int *nread)
int retval; int retval;
el_action_t cmdnum = 0; el_action_t cmdnum = 0;
int num; /* how many chars we have read at NL */ int num; /* how many chars we have read at NL */
wchar_t wc;
Char ch, *cp; Char ch, *cp;
int crlf = 0; int crlf = 0;
int nrb; int nrb;
@ -502,8 +502,7 @@ FUN(el,gets)(EditLine *el, int *nread)
size_t idx; size_t idx;
cp = el->el_line.buffer; cp = el->el_line.buffer;
while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
*cp = (Char)wc;
/* make sure there is space for next character */ /* make sure there is space for next character */
if (cp + 1 >= el->el_line.limit) { if (cp + 1 >= el->el_line.limit) {
idx = (size_t)(cp - el->el_line.buffer); idx = (size_t)(cp - el->el_line.buffer);
@ -555,8 +554,7 @@ FUN(el,gets)(EditLine *el, int *nread)
terminal__flush(el); terminal__flush(el);
while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
*cp = (Char)wc;
/* make sure there is space next character */ /* make sure there is space next character */
if (cp + 1 >= el->el_line.limit) { if (cp + 1 >= el->el_line.limit) {
idx = (size_t)(cp - el->el_line.buffer); idx = (size_t)(cp - el->el_line.buffer);

View File

@ -1,4 +1,4 @@
/* $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $ */ /* $NetBSD: read.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,12 +37,12 @@
#ifndef _h_el_read #ifndef _h_el_read
#define _h_el_read #define _h_el_read
typedef int (*el_rfunc_t)(EditLine *, wchar_t *); typedef int (*el_rfunc_t)(EditLine *, Char *);
typedef struct el_read_t { typedef struct el_read_t {
el_rfunc_t read_char; /* Function to read a character */ el_rfunc_t read_char; /* Function to read a character */
} el_read_t; } el_read_t;
protected int read_init(EditLine *); protected int read_init(EditLine *);
protected void read_prepare(EditLine *); protected void read_prepare(EditLine *);
protected void read_finish(EditLine *); protected void read_finish(EditLine *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $ */ /* $NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -31,29 +31,30 @@
#include "config.h" #include "config.h"
#if !defined(lint) && !defined(SCCSID) #if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $"); __RCSID("$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $");
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <stdio.h>
#include <dirent.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 <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <pwd.h>
#include <setjmp.h> #include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <vis.h> #include <vis.h>
#include "readline/readline.h" #include "readline/readline.h"
#include "el.h" #include "el.h"
#include "fcns.h" /* for EL_NUM_FCNS */
#include "histedit.h"
#include "filecomplete.h" #include "filecomplete.h"
void rl_prep_terminal(int); void rl_prep_terminal(int);
@ -168,13 +169,13 @@ static jmp_buf topbuf;
static unsigned char _el_rl_complete(EditLine *, int); static unsigned char _el_rl_complete(EditLine *, int);
static unsigned char _el_rl_tstp(EditLine *, int); static unsigned char _el_rl_tstp(EditLine *, int);
static char *_get_prompt(EditLine *); static char *_get_prompt(EditLine *);
static int _getc_function(EditLine *, wchar_t *); static int _getc_function(EditLine *, char *);
static HIST_ENTRY *_move_history(int); static HIST_ENTRY *_move_history(int);
static int _history_expand_command(const char *, size_t, size_t, static int _history_expand_command(const char *, size_t, size_t,
char **); char **);
static char *_rl_compat_sub(const char *, const char *, static char *_rl_compat_sub(const char *, const char *,
const char *, int); const char *, int);
static int _rl_event_read_char(EditLine *, wchar_t *); static int _rl_event_read_char(EditLine *, char *);
static void _rl_update_pos(void); static void _rl_update_pos(void);
@ -211,14 +212,14 @@ _move_history(int op)
*/ */
static int static int
/*ARGSUSED*/ /*ARGSUSED*/
_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c) _getc_function(EditLine *el __attribute__((__unused__)), char *c)
{ {
int i; int i;
i = (*rl_getc_function)(NULL); i = (*rl_getc_function)(NULL);
if (i == -1) if (i == -1)
return 0; return 0;
*c = (wchar_t)i; *c = (char)i;
return 1; return 1;
} }
@ -268,7 +269,7 @@ rl_set_prompt(const char *prompt)
if (!prompt) if (!prompt)
prompt = ""; prompt = "";
if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0) if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
return 0; return 0;
if (rl_prompt) if (rl_prompt)
el_free(rl_prompt); el_free(rl_prompt);
@ -362,7 +363,7 @@ rl_initialize(void)
"ReadLine compatible suspend function", "ReadLine compatible suspend function",
_el_rl_tstp); _el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL); el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
/* /*
* Set some readline compatible key-bindings. * Set some readline compatible key-bindings.
*/ */
@ -2009,7 +2010,7 @@ rl_callback_read_char(void)
} }
} }
void void
rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc) rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
{ {
if (e == NULL) { if (e == NULL) {
@ -2018,9 +2019,9 @@ rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
(void)rl_set_prompt(prompt); (void)rl_set_prompt(prompt);
rl_linefunc = linefunc; rl_linefunc = linefunc;
el_set(e, EL_UNBUFFERED, 1); el_set(e, EL_UNBUFFERED, 1);
} }
void void
rl_callback_handler_remove(void) rl_callback_handler_remove(void)
{ {
el_set(e, EL_UNBUFFERED, 0); el_set(e, EL_UNBUFFERED, 0);
@ -2101,14 +2102,12 @@ rl_stuff_char(int c)
} }
static int static int
_rl_event_read_char(EditLine *el, wchar_t *wc) _rl_event_read_char(EditLine *el, char *cp)
{ {
char ch;
int n; int n;
ssize_t num_read = 0; ssize_t num_read = 0;
ch = '\0'; *cp = '\0';
*wc = L'\0';
while (rl_event_hook) { while (rl_event_hook) {
(*rl_event_hook)(); (*rl_event_hook)();
@ -2117,7 +2116,7 @@ _rl_event_read_char(EditLine *el, wchar_t *wc)
if (ioctl(el->el_infd, FIONREAD, &n) < 0) if (ioctl(el->el_infd, FIONREAD, &n) < 0)
return -1; return -1;
if (n) if (n)
num_read = read(el->el_infd, &ch, (size_t)1); num_read = read(el->el_infd, cp, (size_t)1);
else else
num_read = 0; num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY) #elif defined(F_SETFL) && defined(O_NDELAY)
@ -2125,12 +2124,12 @@ _rl_event_read_char(EditLine *el, wchar_t *wc)
return -1; return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
return -1; return -1;
num_read = read(el->el_infd, &ch, 1); num_read = read(el->el_infd, cp, 1);
if (fcntl(el->el_infd, F_SETFL, n)) if (fcntl(el->el_infd, F_SETFL, n))
return -1; return -1;
#else #else
/* not non-blocking, but what you gonna do? */ /* not non-blocking, but what you gonna do? */
num_read = read(el->el_infd, &ch, 1); num_read = read(el->el_infd, cp, 1);
return -1; return -1;
#endif #endif
@ -2142,7 +2141,6 @@ _rl_event_read_char(EditLine *el, wchar_t *wc)
} }
if (!rl_event_hook) if (!rl_event_hook)
el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN); el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
*wc = (wchar_t)ch;
return (int)num_read; return (int)num_read;
} }
@ -2205,7 +2203,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
} }
qsort(&list[1], len - 1, sizeof(*list), qsort(&list[1], len - 1, sizeof(*list),
(int (*)(const void *, const void *)) strcmp); (int (*)(const void *, const void *)) strcmp);
min = SIZE_MAX; min = SIZE_T_MAX;
for (i = 1, a = list[i]; i < len - 1; i++, a = b) { for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
b = list[i + 1]; b = list[i + 1];
for (j = 0; a[j] && a[j] == b[j]; j++) for (j = 0; a[j] && a[j] == b[j]; j++)
@ -2223,7 +2221,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
list[0][min] = '\0'; list[0][min] = '\0';
} }
return list; return list;
out: out:
el_free(list); el_free(list);
return NULL; return NULL;
@ -2327,10 +2325,3 @@ void
rl_free_line_state(void) rl_free_line_state(void)
{ {
} }
int
/*ARGSUSED*/
rl_set_keyboard_input_timeout(int u __attribute__((__unused__)))
{
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -47,17 +47,18 @@ __FBSDID("$FreeBSD$");
* refresh.c: Lower level screen refreshing functions * refresh.c: Lower level screen refreshing functions
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include "el.h" #include "el.h"
private void re_nextline(EditLine *); private void re_nextline(EditLine *);
private void re_addc(EditLine *, wint_t); private void re_addc(EditLine *, Int);
private void re_update_line(EditLine *, Char *, Char *, int); private void re_update_line(EditLine *, Char *, Char *, int);
private void re_insert (EditLine *, Char *, int, int, Char *, int); private void re_insert (EditLine *, Char *, int, int, Char *, int);
private void re_delete(EditLine *, Char *, int, int, int); private void re_delete(EditLine *, Char *, int, int, int);
private void re_fastputc(EditLine *, wint_t); private void re_fastputc(EditLine *, Int);
private void re_clear_eol(EditLine *, int, int, int); private void re_clear_eol(EditLine *, int, int, int);
private void re__strncopy(Char *, Char *, size_t); private void re__strncopy(Char *, Char *, size_t);
private void re__copy_and_pad(Char *, const Char *, size_t); private void re__copy_and_pad(Char *, const Char *, size_t);
@ -65,7 +66,7 @@ private void re__copy_and_pad(Char *, const Char *, size_t);
#ifdef DEBUG_REFRESH #ifdef DEBUG_REFRESH
private void re_printstr(EditLine *, const char *, char *, char *); private void re_printstr(EditLine *, const char *, char *, char *);
#define __F el->el_errfile #define __F el->el_errfile
#define ELRE_ASSERT(a, b, c) do \ #define ELRE_ASSERT(a, b, c) do \
if (/*CONSTCOND*/ a) { \ if (/*CONSTCOND*/ a) { \
(void) fprintf b; \ (void) fprintf b; \
c; \ c; \
@ -111,7 +112,7 @@ re_nextline(EditLine *el)
for(i = 1; i < lins; i++) for(i = 1; i < lins; i++)
el->el_vdisplay[i - 1] = el->el_vdisplay[i]; el->el_vdisplay[i - 1] = el->el_vdisplay[i];
firstline[0] = '\0'; /* empty the string */ firstline[0] = '\0'; /* empty the string */
el->el_vdisplay[i - 1] = firstline; el->el_vdisplay[i - 1] = firstline;
} else } else
el->el_refresh.r_cursor.v++; el->el_refresh.r_cursor.v++;
@ -126,7 +127,7 @@ re_nextline(EditLine *el)
* Draw c, expanding tabs, control chars etc. * Draw c, expanding tabs, control chars etc.
*/ */
private void private void
re_addc(EditLine *el, wint_t c) re_addc(EditLine *el, Int c)
{ {
switch (ct_chr_class((Char)c)) { switch (ct_chr_class((Char)c)) {
case CHTYPE_TAB: /* expand the tab */ case CHTYPE_TAB: /* expand the tab */
@ -162,16 +163,16 @@ re_addc(EditLine *el, wint_t c)
* Draw the character given * Draw the character given
*/ */
protected void protected void
re_putc(EditLine *el, wint_t c, int shift) re_putc(EditLine *el, Int c, int shift)
{ {
int i, w = Width(c); int i, w = Width(c);
ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c)); ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c));
while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h)) while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h))
re_putc(el, ' ', 1); re_putc(el, ' ', 1);
el->el_vdisplay[el->el_refresh.r_cursor.v] el->el_vdisplay[el->el_refresh.r_cursor.v]
[el->el_refresh.r_cursor.h] = (Char)c; [el->el_refresh.r_cursor.h] = c;
/* assumes !shift is only used for single-column chars */ /* assumes !shift is only used for single-column chars */
i = w; i = w;
while (--i > 0) while (--i > 0)
@ -193,7 +194,7 @@ re_putc(EditLine *el, wint_t c, int shift)
/* re_refresh(): /* re_refresh():
* draws the new virtual screen image from the current input * 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 * virtual image. The routine to re-draw a line can be replaced
* easily in hopes of a smarter one being placed there. * easily in hopes of a smarter one being placed there.
*/ */
@ -452,7 +453,7 @@ re__strncopy(Char *a, Char *b, size_t n)
* in order to make sure that we have cleared the previous contents of * 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 * 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 * 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 private void
re_clear_eol(EditLine *el, int fx, int sx, int diff) re_clear_eol(EditLine *el, int fx, int sx, int diff)
@ -1053,14 +1054,14 @@ re_refresh_cursor(EditLine *el)
* Add a character fast. * Add a character fast.
*/ */
private void private void
re_fastputc(EditLine *el, wint_t c) re_fastputc(EditLine *el, Int c)
{ {
int w = Width((Char)c); int w = Width((Char)c);
while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h) while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h)
re_fastputc(el, ' '); re_fastputc(el, ' ');
terminal__putc(el, c); terminal__putc(el, c);
el->el_display[el->el_cursor.v][el->el_cursor.h++] = (Char)c; el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
while (--w > 0) while (--w > 0)
el->el_display[el->el_cursor.v][el->el_cursor.h++] el->el_display[el->el_cursor.v][el->el_cursor.h++]
= MB_FILL_CHAR; = MB_FILL_CHAR;
@ -1078,7 +1079,7 @@ re_fastputc(EditLine *el, wint_t c)
if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) {
int i, lins = el->el_terminal.t_size.v; int i, lins = el->el_terminal.t_size.v;
Char *firstline = el->el_display[0]; Char *firstline = el->el_display[0];
for(i = 1; i < lins; i++) for(i = 1; i < lins; i++)
el->el_display[i - 1] = el->el_display[i]; el->el_display[i - 1] = el->el_display[i];

View File

@ -1,4 +1,4 @@
/* $NetBSD: refresh.h,v 1.9 2016/02/16 15:53:48 christos Exp $ */ /* $NetBSD: refresh.h,v 1.6 2009/12/30 22:37:40 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,13 +41,15 @@
#ifndef _h_el_refresh #ifndef _h_el_refresh
#define _h_el_refresh #define _h_el_refresh
#include "histedit.h"
typedef struct { typedef struct {
coord_t r_cursor; /* Refresh cursor position */ coord_t r_cursor; /* Refresh cursor position */
int r_oldcv; /* Vertical locations */ int r_oldcv; /* Vertical locations */
int r_newcv; int r_newcv;
} el_refresh_t; } el_refresh_t;
protected void re_putc(EditLine *, wint_t, int); protected void re_putc(EditLine *, Int, int);
protected void re_clear_lines(EditLine *); protected void re_clear_lines(EditLine *);
protected void re_clear_display(EditLine *); protected void re_clear_display(EditLine *);
protected void re_refresh(EditLine *); protected void re_refresh(EditLine *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */ /* $NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $"); __RCSID("$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -47,15 +47,12 @@ __FBSDID("$FreeBSD$");
* search.c: History and character search functions * search.c: History and character search functions
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#if defined(REGEX) #if defined(REGEX)
#include <regex.h> #include <regex.h>
#elif defined(REGEXP) #elif defined(REGEXP)
#include <regexp.h> #include <regexp.h>
#endif #endif
#include "el.h" #include "el.h"
#include "common.h"
/* /*
* Adjust cursor in vi mode to include the character under it * Adjust cursor in vi mode to include the character under it
@ -214,9 +211,8 @@ ce_inc_search(EditLine *el, int dir)
STRbck[] = {'b', 'c', 'k', '\0'}; STRbck[] = {'b', 'c', 'k', '\0'};
static Char pchar = ':';/* ':' = normal, '?' = failed */ static Char pchar = ':';/* ':' = normal, '?' = failed */
static Char endcmd[2] = {'\0', '\0'}; static Char endcmd[2] = {'\0', '\0'};
Char *ocursor = el->el_line.cursor, oldpchar = pchar, ch; Char ch, *ocursor = el->el_line.cursor, oldpchar = pchar;
const Char *cp; const Char *cp;
wchar_t wch;
el_action_t ret = CC_NORM; el_action_t ret = CC_NORM;
@ -255,11 +251,9 @@ ce_inc_search(EditLine *el, int dir)
*el->el_line.lastchar = '\0'; *el->el_line.lastchar = '\0';
re_refresh(el); re_refresh(el);
if (el_wgetc(el, &wch) != 1) if (FUN(el,getc)(el, &ch) != 1)
return ed_end_of_file(el, 0); return ed_end_of_file(el, 0);
ch = (Char)wch;
switch (el->el_map.current[(unsigned char) ch]) { switch (el->el_map.current[(unsigned char) ch]) {
case ED_INSERT: case ED_INSERT:
case ED_DIGIT: case ED_DIGIT:
@ -353,14 +347,14 @@ ce_inc_search(EditLine *el, int dir)
/* Can't search if unmatched '[' */ /* Can't search if unmatched '[' */
for (cp = &el->el_search.patbuf[el->el_search.patlen-1], for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
ch = L']'; ch = ']';
cp >= &el->el_search.patbuf[LEN]; cp >= &el->el_search.patbuf[LEN];
cp--) cp--)
if (*cp == '[' || *cp == ']') { if (*cp == '[' || *cp == ']') {
ch = *cp; ch = *cp;
break; break;
} }
if (el->el_search.patlen > LEN && ch != L'[') { if (el->el_search.patlen > LEN && ch != '[') {
if (redo && newdir == dir) { if (redo && newdir == dir) {
if (pchar == '?') { /* wrap around */ if (pchar == '?') { /* wrap around */
el->el_history.eventno = el->el_history.eventno =
@ -575,7 +569,7 @@ ce_search_line(EditLine *el, int dir)
* Vi repeat search * Vi repeat search
*/ */
protected el_action_t protected el_action_t
cv_repeat_srch(EditLine *el, wint_t c) cv_repeat_srch(EditLine *el, Int c)
{ {
#ifdef SDEBUG #ifdef SDEBUG
@ -601,33 +595,35 @@ cv_repeat_srch(EditLine *el, wint_t c)
* Vi character search * Vi character search
*/ */
protected el_action_t protected el_action_t
cv_csearch(EditLine *el, int direction, wint_t ch, int count, int tflag) cv_csearch(EditLine *el, int direction, Int ch, int count, int tflag)
{ {
Char *cp; Char *cp;
if (ch == 0) if (ch == 0)
return CC_ERROR; return CC_ERROR;
if (ch == (wint_t)-1) { if (ch == (Int)-1) {
if (el_wgetc(el, &ch) != 1) Char c;
if (FUN(el,getc)(el, &c) != 1)
return ed_end_of_file(el, 0); return ed_end_of_file(el, 0);
ch = c;
} }
/* Save for ';' and ',' commands */ /* Save for ';' and ',' commands */
el->el_search.chacha = (Char)ch; el->el_search.chacha = ch;
el->el_search.chadir = direction; el->el_search.chadir = direction;
el->el_search.chatflg = (char)tflag; el->el_search.chatflg = (char)tflag;
cp = el->el_line.cursor; cp = el->el_line.cursor;
while (count--) { while (count--) {
if ((wint_t)*cp == ch) if ((Int)*cp == ch)
cp += direction; cp += direction;
for (;;cp += direction) { for (;;cp += direction) {
if (cp >= el->el_line.lastchar) if (cp >= el->el_line.lastchar)
return CC_ERROR; return CC_ERROR;
if (cp < el->el_line.buffer) if (cp < el->el_line.buffer)
return CC_ERROR; return CC_ERROR;
if ((wint_t)*cp == ch) if ((Int)*cp == ch)
break; break;
} }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: search.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */ /* $NetBSD: search.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,6 +41,8 @@
#ifndef _h_el_search #ifndef _h_el_search
#define _h_el_search #define _h_el_search
#include "histedit.h"
typedef struct el_search_t { typedef struct el_search_t {
Char *patbuf; /* The pattern buffer */ Char *patbuf; /* The pattern buffer */
size_t patlen; /* Length of the pattern buffer */ size_t patlen; /* Length of the pattern buffer */
@ -59,7 +61,7 @@ protected void c_setpat(EditLine *);
protected el_action_t ce_inc_search(EditLine *, int); protected el_action_t ce_inc_search(EditLine *, int);
protected el_action_t cv_search(EditLine *, int); protected el_action_t cv_search(EditLine *, int);
protected el_action_t ce_search_line(EditLine *, int); protected el_action_t ce_search_line(EditLine *, int);
protected el_action_t cv_repeat_srch(EditLine *, wint_t); protected el_action_t cv_repeat_srch(EditLine *, Int);
protected el_action_t cv_csearch(EditLine *, int, wint_t, int, int); protected el_action_t cv_csearch(EditLine *, int, Int, int, int);
#endif /* _h_el_search */ #endif /* _h_el_search */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $ */ /* $NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $"); __RCSID("$NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -48,11 +48,8 @@ __FBSDID("$FreeBSD$");
* our policy is to trap all signals, set a good state * our policy is to trap all signals, set a good state
* and pass the ball to our caller. * and pass the ball to our caller.
*/ */
#include <errno.h>
#include <stdlib.h>
#include "el.h" #include "el.h"
#include "common.h" #include <stdlib.h>
private EditLine *sel = NULL; private EditLine *sel = NULL;
@ -73,10 +70,9 @@ private void sig_handler(int);
private void private void
sig_handler(int signo) sig_handler(int signo)
{ {
int i, save_errno; int i;
sigset_t nset, oset; sigset_t nset, oset;
save_errno = errno;
(void) sigemptyset(&nset); (void) sigemptyset(&nset);
(void) sigaddset(&nset, signo); (void) sigaddset(&nset, signo);
(void) sigprocmask(SIG_BLOCK, &nset, &oset); (void) sigprocmask(SIG_BLOCK, &nset, &oset);
@ -110,7 +106,6 @@ sig_handler(int signo)
sigemptyset(&sel->el_signal->sig_action[i].sa_mask); sigemptyset(&sel->el_signal->sig_action[i].sa_mask);
(void) sigprocmask(SIG_SETMASK, &oset, NULL); (void) sigprocmask(SIG_SETMASK, &oset, NULL);
(void) kill(0, signo); (void) kill(0, signo);
errno = save_errno;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: sig.h,v 1.10 2016/02/16 15:53:48 christos Exp $ */ /* $NetBSD: sig.h,v 1.8 2009/02/19 15:20:22 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -43,6 +43,8 @@
#include <signal.h> #include <signal.h>
#include "histedit.h"
/* /*
* Define here all the signals we are going to handle * Define here all the signals we are going to handle
* The _DO macro is used to iterate in the source code * The _DO macro is used to iterate in the source code

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys.h,v 1.23 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: sys.h,v 1.17 2011/09/28 14:08:04 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -58,7 +58,7 @@
# define __END_DECLS # define __END_DECLS
# endif # endif
#endif #endif
#ifndef public #ifndef public
# define public /* Externally visible functions/variables */ # define public /* Externally visible functions/variables */
#endif #endif
@ -88,9 +88,14 @@ size_t strlcat(char *dst, const char *src, size_t size);
size_t strlcpy(char *dst, const char *src, size_t size); size_t strlcpy(char *dst, const char *src, size_t size);
#endif #endif
#ifndef HAVE_GETLINE #ifndef HAVE_FGETLN
#define getline libedit_getline #define fgetln libedit_fgetln
ssize_t getline(char **line, size_t *len, FILE *fp); char *fgetln(FILE *fp, size_t *len);
#endif
#ifndef HAVE_WCSDUP
#include <wchar.h>
wchar_t *wcsdup(const wchar_t *);
#endif #endif
#ifndef _DIAGASSERT #ifndef _DIAGASSERT
@ -105,18 +110,13 @@ ssize_t getline(char **line, size_t *len, FILE *fp);
typedef unsigned int u_int32_t; typedef unsigned int u_int32_t;
#endif #endif
#ifndef HAVE_SIZE_MAX #ifndef SIZE_T_MAX
#define SIZE_MAX ((size_t)-1) #define SIZE_T_MAX ((size_t)-1)
#endif #endif
#define REGEX /* Use POSIX.2 regular expression functions */ #define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 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) #if defined(__sun)
extern int tgetent(char *, const char *); extern int tgetent(char *, const char *);
extern int tgetflag(char *); extern int tgetflag(char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else #else
__RCSID("$NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -48,14 +48,12 @@ __FBSDID("$FreeBSD$");
* We have to declare a static variable here, since the * We have to declare a static variable here, since the
* termcap putchar routine does not take an argument! * termcap putchar routine does not take an argument!
*/ */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#ifdef HAVE_TERMCAP_H #ifdef HAVE_TERMCAP_H
#include <termcap.h> #include <termcap.h>
#endif #endif
@ -69,6 +67,9 @@ __FBSDID("$FreeBSD$");
#if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H) #if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H)
#include <term.h> #include <term.h>
#endif #endif
#include <sys/types.h>
#include <sys/ioctl.h>
#ifdef _REENTRANT #ifdef _REENTRANT
#include <pthread.h> #include <pthread.h>
@ -273,45 +274,31 @@ terminal_init(EditLine *el)
el->el_terminal.t_buf = el_malloc(TC_BUFSIZE * el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
sizeof(*el->el_terminal.t_buf)); sizeof(*el->el_terminal.t_buf));
if (el->el_terminal.t_buf == NULL) if (el->el_terminal.t_buf == NULL)
goto fail1; return -1;
el->el_terminal.t_cap = el_malloc(TC_BUFSIZE * el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
sizeof(*el->el_terminal.t_cap)); sizeof(*el->el_terminal.t_cap));
if (el->el_terminal.t_cap == NULL) if (el->el_terminal.t_cap == NULL)
goto fail2; return -1;
el->el_terminal.t_fkey = el_malloc(A_K_NKEYS * el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
sizeof(*el->el_terminal.t_fkey)); sizeof(*el->el_terminal.t_fkey));
if (el->el_terminal.t_fkey == NULL) if (el->el_terminal.t_fkey == NULL)
goto fail3; return -1;
el->el_terminal.t_loc = 0; el->el_terminal.t_loc = 0;
el->el_terminal.t_str = el_malloc(T_str * el->el_terminal.t_str = el_malloc(T_str *
sizeof(*el->el_terminal.t_str)); sizeof(*el->el_terminal.t_str));
if (el->el_terminal.t_str == NULL) if (el->el_terminal.t_str == NULL)
goto fail4; return -1;
(void) memset(el->el_terminal.t_str, 0, T_str * (void) memset(el->el_terminal.t_str, 0, T_str *
sizeof(*el->el_terminal.t_str)); sizeof(*el->el_terminal.t_str));
el->el_terminal.t_val = el_malloc(T_val * el->el_terminal.t_val = el_malloc(T_val *
sizeof(*el->el_terminal.t_val)); sizeof(*el->el_terminal.t_val));
if (el->el_terminal.t_val == NULL) if (el->el_terminal.t_val == NULL)
goto fail5; return -1;
(void) memset(el->el_terminal.t_val, 0, T_val * (void) memset(el->el_terminal.t_val, 0, T_val *
sizeof(*el->el_terminal.t_val)); sizeof(*el->el_terminal.t_val));
(void) terminal_set(el, NULL); (void) terminal_set(el, NULL);
terminal_init_arrow(el); terminal_init_arrow(el);
return 0; 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(): /* terminal_end():
@ -433,14 +420,14 @@ terminal_alloc_display(EditLine *el)
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1)); b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
if (b == NULL) if (b == NULL)
goto done; return -1;
for (i = 0; i < c->v; i++) { for (i = 0; i < c->v; i++) {
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1)); b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
if (b[i] == NULL) { if (b[i] == NULL) {
while (--i >= 0) while (--i >= 0)
el_free(b[i]); el_free(b[i]);
el_free(b); el_free(b);
goto done; return -1;
} }
} }
b[c->v] = NULL; b[c->v] = NULL;
@ -448,22 +435,19 @@ terminal_alloc_display(EditLine *el)
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1)); b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
if (b == NULL) if (b == NULL)
goto done; return -1;
for (i = 0; i < c->v; i++) { for (i = 0; i < c->v; i++) {
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1)); b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
if (b[i] == NULL) { if (b[i] == NULL) {
while (--i >= 0) while (--i >= 0)
el_free(b[i]); el_free(b[i]);
el_free(b); el_free(b);
goto done; return -1;
} }
} }
b[c->v] = NULL; b[c->v] = NULL;
el->el_vdisplay = b; el->el_vdisplay = b;
return 0; return 0;
done:
terminal_free_display(el);
return -1;
} }
@ -495,7 +479,7 @@ terminal_free_display(EditLine *el)
/* terminal_move_to_line(): /* terminal_move_to_line():
* move to line <where> (first line == 0) * move to line <where> (first line == 0)
* as efficiently as possible * as efficiently as possible
*/ */
protected void protected void
terminal_move_to_line(EditLine *el, int where) terminal_move_to_line(EditLine *el, int where)
@ -508,7 +492,8 @@ terminal_move_to_line(EditLine *el, int where)
if (where > el->el_terminal.t_size.v) { if (where > el->el_terminal.t_size.v) {
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: where is ridiculous: %d\r\n", __func__, where); "terminal_move_to_line: where is ridiculous: %d\r\n",
where);
#endif /* DEBUG_SCREEN */ #endif /* DEBUG_SCREEN */
return; return;
} }
@ -574,7 +559,8 @@ terminal_move_to_char(EditLine *el, int where)
if (where > el->el_terminal.t_size.h) { if (where > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: where is ridiculous: %d\r\n", __func__, where); "terminal_move_to_char: where is riduculous: %d\r\n",
where);
#endif /* DEBUG_SCREEN */ #endif /* DEBUG_SCREEN */
return; return;
} }
@ -610,7 +596,7 @@ terminal_move_to_char(EditLine *el, int where)
i < (where & ~0x7); i < (where & ~0x7);
i += 8) i += 8)
terminal__putc(el, terminal__putc(el,
'\t'); '\t');
/* then tab over */ /* then tab over */
el->el_cursor.h = where & ~0x7; el->el_cursor.h = where & ~0x7;
} }
@ -668,7 +654,7 @@ terminal_overwrite(EditLine *el, const Char *cp, size_t n)
if (n > (size_t)el->el_terminal.t_size.h) { if (n > (size_t)el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: n is ridiculous: %d\r\n", __func__, n); "terminal_overwrite: n is riduculous: %d\r\n", n);
#endif /* DEBUG_SCREEN */ #endif /* DEBUG_SCREEN */
return; return;
} }
@ -724,7 +710,7 @@ terminal_deletechars(EditLine *el, int num)
if (num > el->el_terminal.t_size.h) { if (num > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: num is ridiculous: %d\r\n", __func__, num); "terminal_deletechars: num is riduculous: %d\r\n", num);
#endif /* DEBUG_SCREEN */ #endif /* DEBUG_SCREEN */
return; return;
} }
@ -765,7 +751,7 @@ terminal_insertwrite(EditLine *el, Char *cp, int num)
if (num > el->el_terminal.t_size.h) { if (num > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN #ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: num is ridiculous: %d\r\n", __func__, num); "StartInsert: num is riduculous: %d\r\n", num);
#endif /* DEBUG_SCREEN */ #endif /* DEBUG_SCREEN */
return; return;
} }
@ -1255,13 +1241,13 @@ terminal_tputs(EditLine *el, const char *cap, int affcnt)
* Add a character * Add a character
*/ */
protected int protected int
terminal__putc(EditLine *el, wint_t c) terminal__putc(EditLine *el, Int c)
{ {
char buf[MB_LEN_MAX +1]; char buf[MB_LEN_MAX +1];
ssize_t i; ssize_t i;
if (c == (wint_t)MB_FILL_CHAR) if (c == (Int)MB_FILL_CHAR)
return 0; return 0;
i = ct_encode_char(buf, (size_t)MB_LEN_MAX, (Char)c); i = ct_encode_char(buf, (size_t)MB_LEN_MAX, c);
if (i <= 0) if (i <= 0)
return (int)i; return (int)i;
buf[i] = '\0'; buf[i] = '\0';
@ -1282,10 +1268,10 @@ terminal__flush(EditLine *el)
* Write the given character out, in a human readable form * Write the given character out, in a human readable form
*/ */
protected void protected void
terminal_writec(EditLine *el, wint_t c) terminal_writec(EditLine *el, Int c)
{ {
Char visbuf[VISUAL_WIDTH_MAX +1]; Char visbuf[VISUAL_WIDTH_MAX +1];
ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, (Char)c); ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c);
if (vcnt < 0) if (vcnt < 0)
vcnt = 0; vcnt = 0;
visbuf[vcnt] = '\0'; visbuf[vcnt] = '\0';
@ -1299,7 +1285,7 @@ terminal_writec(EditLine *el, wint_t c)
*/ */
protected int protected int
/*ARGSUSED*/ /*ARGSUSED*/
terminal_telltc(EditLine *el, int argc __attribute__((__unused__)), terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
const Char **argv __attribute__((__unused__))) const Char **argv __attribute__((__unused__)))
{ {
const struct termcapstr *t; const struct termcapstr *t;

View File

@ -1,4 +1,4 @@
/* $NetBSD: terminal.h,v 1.7 2016/02/16 15:53:48 christos Exp $ */ /* $NetBSD: terminal.h,v 1.4 2012/03/24 20:09:30 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,6 +41,8 @@
#ifndef _h_el_terminal #ifndef _h_el_terminal
#define _h_el_terminal #define _h_el_terminal
#include "histedit.h"
typedef struct { /* Symbolic function key bindings */ typedef struct { /* Symbolic function key bindings */
const Char *name; /* name of the key */ const Char *name; /* name of the key */
int key; /* Index in termcap table */ int key; /* Index in termcap table */
@ -103,8 +105,8 @@ protected int terminal_settc(EditLine *, int, const Char **);
protected int terminal_gettc(EditLine *, int, char **); protected int terminal_gettc(EditLine *, int, char **);
protected int terminal_telltc(EditLine *, int, const Char **); protected int terminal_telltc(EditLine *, int, const Char **);
protected int terminal_echotc(EditLine *, int, const Char **); protected int terminal_echotc(EditLine *, int, const Char **);
protected void terminal_writec(EditLine *, wint_t); protected void terminal_writec(EditLine *, Int);
protected int terminal__putc(EditLine *, wint_t); protected int terminal__putc(EditLine *, Int);
protected void terminal__flush(EditLine *); protected void terminal__flush(EditLine *);
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -47,9 +47,8 @@ __FBSDID("$FreeBSD$");
/* /*
* tokenize.c: Bourne shell like tokenizer * tokenize.c: Bourne shell like tokenizer
*/ */
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "histedit.h" #include "histedit.h"
#include "chartype.h" #include "chartype.h"
@ -416,10 +415,8 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line,
Char **p; Char **p;
tok->amax += AINCR; tok->amax += AINCR;
p = tok_realloc(tok->argv, tok->amax * sizeof(*p)); p = tok_realloc(tok->argv, tok->amax * sizeof(*p));
if (p == NULL) { if (p == NULL)
tok->amax -= AINCR;
return -1; return -1;
}
tok->argv = p; tok->argv = p;
} }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $ */ /* $NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $"); __RCSID("$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -48,13 +48,11 @@ __FBSDID("$FreeBSD$");
*/ */
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> /* for abort */
#include <string.h>
#include <strings.h> /* for ffs */
#include <unistd.h> /* for isatty */ #include <unistd.h> /* for isatty */
#include <strings.h> /* for ffs */
#include <stdlib.h> /* for abort */
#include "el.h" #include "el.h"
#include "parse.h" #include "tty.h"
typedef struct ttymodes_t { typedef struct ttymodes_t {
const char *m_name; const char *m_name;
@ -63,7 +61,7 @@ typedef struct ttymodes_t {
} ttymodes_t; } ttymodes_t;
typedef struct ttymap_t { typedef struct ttymap_t {
wint_t nch, och; /* Internal and termio rep of chars */ Int nch, och; /* Internal and termio rep of chars */
el_action_t bind[3]; /* emacs, vi, and vi-cmd */ el_action_t bind[3]; /* emacs, vi, and vi-cmd */
} ttymap_t; } ttymap_t;
@ -159,7 +157,7 @@ private const ttymap_t tty_map[] = {
{C_LNEXT, VLNEXT, {C_LNEXT, VLNEXT,
{ED_QUOTED_INSERT, ED_QUOTED_INSERT, ED_UNASSIGNED}}, {ED_QUOTED_INSERT, ED_QUOTED_INSERT, ED_UNASSIGNED}},
#endif /* VLNEXT */ #endif /* VLNEXT */
{(wint_t)-1, (wint_t)-1, {(Int)-1, (Int)-1,
{ED_UNASSIGNED, ED_UNASSIGNED, ED_UNASSIGNED}} {ED_UNASSIGNED, ED_UNASSIGNED, ED_UNASSIGNED}}
}; };
@ -500,7 +498,6 @@ tty_setup(EditLine *el)
{ {
int rst = 1; int rst = 1;
el->el_tty.t_initialized = 0;
if (el->el_flags & EDIT_DISABLED) if (el->el_flags & EDIT_DISABLED)
return 0; return 0;
@ -563,7 +560,6 @@ tty_setup(EditLine *el)
tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]); tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]);
tty_bind_char(el, 1); tty_bind_char(el, 1);
el->el_tty.t_initialized = 1;
return 0; return 0;
} }
@ -589,9 +585,6 @@ tty_end(EditLine *el)
if (el->el_flags & EDIT_DISABLED) if (el->el_flags & EDIT_DISABLED)
return; return;
if (el->el_tty.t_initialized)
return;
if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) { if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
#ifdef DEBUG_TTY #ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
@ -911,9 +904,9 @@ tty_bind_char(EditLine *el, int force)
dalt = NULL; dalt = NULL;
} }
for (tp = tty_map; tp->nch != (wint_t)-1; tp++) { for (tp = tty_map; tp->nch != (Int)-1; tp++) {
new[0] = (Char)t_n[tp->nch]; new[0] = t_n[tp->nch];
old[0] = (Char)t_o[tp->och]; old[0] = t_o[tp->och];
if (new[0] == old[0] && !force) if (new[0] == old[0] && !force)
continue; continue;
/* Put the old default binding back, and set the new binding */ /* Put the old default binding back, and set the new binding */
@ -985,7 +978,7 @@ tty_update_char(EditLine *el, int mode, int c) {
/* tty_rawmode(): /* tty_rawmode():
* Set terminal into 1 character at a time mode. * Set terminal into 1 character at a time mode.
*/ */
protected int protected int
tty_rawmode(EditLine *el) tty_rawmode(EditLine *el)
@ -1183,8 +1176,8 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv)
break; break;
default: default:
(void) fprintf(el->el_errfile, (void) fprintf(el->el_errfile,
"%s: Unknown switch `%lc'.\n", "%s: Unknown switch `" FCHAR "'.\n",
name, (wint_t)argv[0][1]); name, (Int)argv[0][1]);
return -1; return -1;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */ /* $NetBSD: tty.h,v 1.15 2014/05/19 19:54:12 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -41,6 +41,8 @@
#ifndef _h_el_tty #ifndef _h_el_tty
#define _h_el_tty #define _h_el_tty
#include "sys.h"
#include "histedit.h"
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
@ -473,9 +475,8 @@ typedef struct {
int t_tabs; int t_tabs;
int t_eight; int t_eight;
speed_t t_speed; speed_t t_speed;
unsigned char t_mode; int t_mode;
unsigned char t_vdisable; unsigned char t_vdisable;
unsigned char t_initialized;
} el_tty_t; } el_tty_t;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $ */ /* $NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -33,11 +33,16 @@
*/ */
#include "config.h" #include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <sys/wait.h>
#if !defined(lint) && !defined(SCCSID) #if !defined(lint) && !defined(SCCSID)
#if 0 #if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else #else
__RCSID("$NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $"); __RCSID("$NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $");
#endif #endif
#endif /* not lint && not SCCSID */ #endif /* not lint && not SCCSID */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -46,31 +51,21 @@ __FBSDID("$FreeBSD$");
/* /*
* vi.c: Vi mode commands. * vi.c: Vi mode commands.
*/ */
#include <sys/wait.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "el.h" #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_action(EditLine *, Int);
private el_action_t cv_paste(EditLine *, wint_t); private el_action_t cv_paste(EditLine *, Int);
/* cv_action(): /* cv_action():
* Handle vi actions. * Handle vi actions.
*/ */
private el_action_t private el_action_t
cv_action(EditLine *el, wint_t c) cv_action(EditLine *el, Int c)
{ {
if (el->el_chared.c_vcmd.action != NOP) { if (el->el_chared.c_vcmd.action != NOP) {
/* 'cc', 'dd' and (possibly) friends */ /* 'cc', 'dd' and (possibly) friends */
if (c != (wint_t)el->el_chared.c_vcmd.action) if (c != (Int)el->el_chared.c_vcmd.action)
return CC_ERROR; return CC_ERROR;
if (!(c & YANK)) if (!(c & YANK))
@ -97,7 +92,7 @@ cv_action(EditLine *el, wint_t c)
* Paste previous deletion before or after the cursor * Paste previous deletion before or after the cursor
*/ */
private el_action_t private el_action_t
cv_paste(EditLine *el, wint_t c) cv_paste(EditLine *el, Int c)
{ {
c_kill_t *k = &el->el_chared.c_kill; c_kill_t *k = &el->el_chared.c_kill;
size_t len = (size_t)(k->last - k->buf); size_t len = (size_t)(k->last - k->buf);
@ -129,7 +124,7 @@ cv_paste(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__))) vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_paste(el, 0); return cv_paste(el, 0);
@ -142,7 +137,7 @@ vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__))) vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_paste(el, 1); return cv_paste(el, 1);
@ -155,7 +150,7 @@ vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.buffer) if (el->el_line.cursor == el->el_line.buffer)
@ -180,7 +175,7 @@ vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.buffer) if (el->el_line.cursor == el->el_line.buffer)
@ -205,7 +200,7 @@ vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor >= el->el_line.lastchar - 1) if (el->el_line.cursor >= el->el_line.lastchar - 1)
@ -229,7 +224,7 @@ vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_next_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor >= el->el_line.lastchar - 1) if (el->el_line.cursor >= el->el_line.lastchar - 1)
@ -252,7 +247,7 @@ vi_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
* [~] * [~]
*/ */
protected el_action_t protected el_action_t
vi_change_case(EditLine *el, wint_t c) vi_change_case(EditLine *el, Int c)
{ {
int i; int i;
@ -284,7 +279,7 @@ vi_change_case(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__))) vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
{ {
/* /*
@ -301,7 +296,7 @@ vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__))) vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_line.cursor = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer;
@ -317,7 +312,7 @@ vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor >= el->el_line.lastchar) if (el->el_line.cursor >= el->el_line.lastchar)
@ -336,7 +331,7 @@ vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__))) vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_map.current = el->el_map.key; el->el_map.current = el->el_map.key;
@ -352,7 +347,7 @@ vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
c_delafter(el, el->el_state.argument); c_delafter(el, el->el_state.argument);
@ -367,7 +362,7 @@ vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__))) vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
cv_undo(el); cv_undo(el);
@ -385,7 +380,7 @@ vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__))) vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
{ {
cv_undo(el); cv_undo(el);
@ -403,7 +398,7 @@ vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_insert(EditLine *el, wint_t c __attribute__((__unused__))) vi_insert(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_map.current = el->el_map.key; el->el_map.current = el->el_map.key;
@ -418,7 +413,7 @@ vi_insert(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_add(EditLine *el, wint_t c __attribute__((__unused__))) vi_add(EditLine *el, Int c __attribute__((__unused__)))
{ {
int ret; int ret;
@ -443,7 +438,7 @@ vi_add(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__))) vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_map.current = el->el_map.key; el->el_map.current = el->el_map.key;
@ -459,7 +454,7 @@ vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__))) vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_action(el, DELETE); return cv_action(el, DELETE);
@ -472,7 +467,7 @@ vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.lastchar) if (el->el_line.cursor == el->el_line.lastchar)
@ -496,7 +491,7 @@ vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_end_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor == el->el_line.lastchar) if (el->el_line.cursor == el->el_line.lastchar)
@ -520,7 +515,7 @@ vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_undo(EditLine *el, wint_t c __attribute__((__unused__))) vi_undo(EditLine *el, Int c __attribute__((__unused__)))
{ {
c_undo_t un = el->el_chared.c_undo; c_undo_t un = el->el_chared.c_undo;
@ -547,7 +542,7 @@ vi_undo(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__))) vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
{ {
/* [Esc] cancels pending action */ /* [Esc] cancels pending action */
@ -571,7 +566,7 @@ vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__)))
* [0] * [0]
*/ */
protected el_action_t protected el_action_t
vi_zero(EditLine *el, wint_t c) vi_zero(EditLine *el, Int c)
{ {
if (el->el_state.doingarg) if (el->el_state.doingarg)
@ -587,12 +582,12 @@ vi_zero(EditLine *el, wint_t c)
/* vi_delete_prev_char(): /* vi_delete_prev_char():
* Vi move to previous character (backspace) * Vi move to previous character (backspace)
* [^H] in insert mode only * [^H] in insert mode only
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_line.cursor <= el->el_line.buffer) if (el->el_line.cursor <= el->el_line.buffer)
@ -610,7 +605,7 @@ vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_list_or_eof(EditLine *el, wint_t c) vi_list_or_eof(EditLine *el, Int c)
{ {
if (el->el_line.cursor == el->el_line.lastchar) { if (el->el_line.cursor == el->el_line.lastchar) {
@ -647,7 +642,7 @@ vi_list_or_eof(EditLine *el, wint_t c)
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__))) vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
{ {
Char *kp, *cp; Char *kp, *cp;
@ -668,7 +663,7 @@ vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__))) vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_search(el, ED_SEARCH_PREV_HISTORY); return cv_search(el, ED_SEARCH_PREV_HISTORY);
@ -681,7 +676,7 @@ vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_search_next(EditLine *el, wint_t c __attribute__((__unused__))) vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_search(el, ED_SEARCH_NEXT_HISTORY); return cv_search(el, ED_SEARCH_NEXT_HISTORY);
@ -694,7 +689,7 @@ vi_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__))) vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_search.patlen == 0) if (el->el_search.patlen == 0)
@ -710,7 +705,7 @@ vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
protected el_action_t protected el_action_t
vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__))) vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
{ {
if (el->el_search.patlen == 0) if (el->el_search.patlen == 0)
@ -728,7 +723,7 @@ vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_next_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0); return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
} }
@ -740,7 +735,7 @@ vi_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0); return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
} }
@ -752,7 +747,7 @@ vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1); return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
} }
@ -764,7 +759,7 @@ vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1); return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
} }
@ -776,7 +771,7 @@ vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_csearch(el, el->el_search.chadir, el->el_search.chacha, return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
@ -790,7 +785,7 @@ vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
{ {
el_action_t r; el_action_t r;
int dir = el->el_search.chadir; int dir = el->el_search.chadir;
@ -808,7 +803,7 @@ vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_match(EditLine *el, wint_t c __attribute__((__unused__))) vi_match(EditLine *el, Int c __attribute__((__unused__)))
{ {
const Char match_chars[] = STR("()[]{}"); const Char match_chars[] = STR("()[]{}");
Char *cp; Char *cp;
@ -855,7 +850,7 @@ vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__))) vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
cv_undo(el); cv_undo(el);
@ -869,7 +864,7 @@ vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_to_column(EditLine *el, wint_t c __attribute__((__unused__))) vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_line.cursor = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer;
@ -883,7 +878,7 @@ vi_to_column(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__))) vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
{ {
cv_yank(el, el->el_line.cursor, cv_yank(el, el->el_line.cursor,
@ -897,7 +892,7 @@ vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_yank(EditLine *el, wint_t c __attribute__((__unused__))) vi_yank(EditLine *el, Int c __attribute__((__unused__)))
{ {
return cv_action(el, YANK); return cv_action(el, YANK);
@ -909,7 +904,7 @@ vi_yank(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__))) vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
{ {
el->el_line.cursor = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer;
@ -927,7 +922,7 @@ vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_alias(EditLine *el, wint_t c __attribute__((__unused__))) vi_alias(EditLine *el, Int c __attribute__((__unused__)))
{ {
char alias_name[3]; char alias_name[3];
const char *alias_text; const char *alias_text;
@ -953,7 +948,7 @@ vi_alias(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__))) vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
{ {
int sv_event_no = el->el_history.eventno; int sv_event_no = el->el_history.eventno;
el_action_t rval; el_action_t rval;
@ -979,7 +974,7 @@ vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__)))
el->el_history.eventno = 1; el->el_history.eventno = 1;
if (hist_get(el) == CC_ERROR) if (hist_get(el) == CC_ERROR)
return CC_ERROR; return CC_ERROR;
el->el_history.eventno = 1 + el->el_history.ev.num el->el_history.eventno = 1 + el->el_history.ev.num
- el->el_state.argument; - el->el_state.argument;
if (el->el_history.eventno < 0) { if (el->el_history.eventno < 0) {
el->el_history.eventno = sv_event_no; el->el_history.eventno = sv_event_no;
@ -998,7 +993,7 @@ vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_histedit(EditLine *el, wint_t c __attribute__((__unused__))) vi_histedit(EditLine *el, Int c __attribute__((__unused__)))
{ {
int fd; int fd;
pid_t pid; pid_t pid;
@ -1082,7 +1077,7 @@ vi_histedit(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_history_word(EditLine *el, wint_t c __attribute__((__unused__))) vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
{ {
const Char *wp = HIST_FIRST(el); const Char *wp = HIST_FIRST(el);
const Char *wep, *wsp; const Char *wep, *wsp;
@ -1132,7 +1127,7 @@ vi_history_word(EditLine *el, wint_t c __attribute__((__unused__)))
*/ */
protected el_action_t protected el_action_t
/*ARGSUSED*/ /*ARGSUSED*/
vi_redo(EditLine *el, wint_t c __attribute__((__unused__))) vi_redo(EditLine *el, Int c __attribute__((__unused__)))
{ {
c_redo_t *r = &el->el_chared.c_redo; c_redo_t *r = &el->el_chared.c_redo;