summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/chartype.c4
-rw-r--r--lib/libedit/chartype.h4
-rw-r--r--lib/libedit/el.c3
-rw-r--r--lib/libedit/el.h5
-rw-r--r--lib/libedit/eln.c5
-rw-r--r--lib/libedit/read.c27
-rw-r--r--lib/libedit/read.h6
-rw-r--r--lib/libedit/readline.c23
8 files changed, 36 insertions, 41 deletions
diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c
index f06732113a1..9e40e484acc 100644
--- a/lib/libedit/chartype.c
+++ b/lib/libedit/chartype.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chartype.c,v 1.8 2016/03/20 23:48:27 schwarze Exp $ */
+/* $OpenBSD: chartype.c,v 1.9 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: chartype.c,v 1.6 2011/07/28 00:48:21 christos Exp $ */
/*-
@@ -209,7 +209,7 @@ ct_encode_char(char *dst, size_t len, Char c)
size_t
/*ARGSUSED*/
-ct_mbrtowc(char *wc, const char *s, size_t n,
+ct_mbrtowc(wchar_t *wc, const char *s, size_t n,
void *mbs __attribute__((__unused__))) {
if (s == NULL)
return 0;
diff --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h
index 2e48c5472cb..b7e65f1f150 100644
--- a/lib/libedit/chartype.h
+++ b/lib/libedit/chartype.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: chartype.h,v 1.10 2016/03/20 23:48:27 schwarze Exp $ */
+/* $OpenBSD: chartype.h,v 1.11 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: chartype.h,v 1.5 2010/04/15 00:55:57 christos Exp $ */
/*-
@@ -109,7 +109,7 @@
#else /* NARROW */
-size_t ct_mbrtowc(char *, const char *, size_t, void *);
+size_t ct_mbrtowc(wchar_t *, const char *, size_t, void *);
#define ct_wctob(w) ((int)(w))
#define ct_wctomb error
#define ct_wctomb_reset
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index b4e542d3507..a377c5fe4be 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: el.c,v 1.28 2016/03/20 23:48:27 schwarze Exp $ */
+/* $OpenBSD: el.c,v 1.29 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */
/*-
@@ -286,7 +286,6 @@ FUN(el,set)(EditLine *el, int op, ...)
{
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
rv = el_read_setfn(el, rc);
- el->el_flags &= ~NARROW_READ;
break;
}
diff --git a/lib/libedit/el.h b/lib/libedit/el.h
index 38b31fd8223..e2258d7a1be 100644
--- a/lib/libedit/el.h
+++ b/lib/libedit/el.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: el.h,v 1.16 2016/03/20 23:48:27 schwarze Exp $ */
-/* $NetBSD: el.h,v 1.33 2016/02/17 19:47:49 christos Exp $ */
+/* $OpenBSD: el.h,v 1.17 2016/03/21 17:28:10 schwarze Exp $ */
+/* $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -58,7 +58,6 @@
#define UNBUFFERED 0x08
#define CHARSET_IS_UTF8 0x10
#define NARROW_HISTORY 0x40
-#define NARROW_READ 0x80
typedef unsigned char el_action_t; /* Index to command array */
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c
index f2e62ae278b..8160637437d 100644
--- a/lib/libedit/eln.c
+++ b/lib/libedit/eln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eln.c,v 1.10 2016/03/21 15:25:39 schwarze Exp $ */
+/* $OpenBSD: eln.c,v 1.11 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */
/*-
@@ -236,10 +236,8 @@ el_set(EditLine *el, int op, ...)
el->el_flags |= NARROW_HISTORY;
break;
}
- /* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */
ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
- el->el_flags |= NARROW_READ;
break;
case EL_CLIENTDATA: /* void * */
ret = el_wset(el, op, va_arg(ap, void *));
@@ -330,7 +328,6 @@ el_get(EditLine *el, int op, ...)
break;
}
- /* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */
ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
break;
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 9a90b243d57..45c72de3b1d 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.27 2016/03/21 15:25:39 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.28 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: read.c,v 1.81 2016/02/16 22:53:14 christos Exp $ */
/*-
@@ -53,7 +53,7 @@
private int read__fixio(int, int);
private int read_preread(EditLine *);
-private int read_char(EditLine *, Char *);
+private int read_char(EditLine *, wchar_t *);
private int read_getcmd(EditLine *, el_action_t *, Char *);
private void read_pop(c_macro_t *);
@@ -298,7 +298,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
* Read a character from the tty.
*/
private int
-read_char(EditLine *el, Char *cp)
+read_char(EditLine *el, wchar_t *cp)
{
ssize_t num_read;
int tried = 0;
@@ -325,14 +325,14 @@ read_char(EditLine *el, Char *cp)
tried = 1;
} else {
errno = e;
- *cp = '\0';
+ *cp = L'\0';
return -1;
}
}
/* Test for EOF */
if (num_read == 0) {
- *cp = '\0';
+ *cp = L'\0';
return 0;
}
@@ -366,7 +366,7 @@ read_char(EditLine *el, Char *cp)
if ((el->el_flags & CHARSET_IS_UTF8) == 0 ||
cbp >= MB_LEN_MAX) {
errno = EILSEQ;
- *cp = '\0';
+ *cp = L'\0';
return -1;
}
/* Incomplete sequence, read another byte. */
@@ -401,7 +401,6 @@ el_wgetc(EditLine *el, wchar_t *cp)
{
int num_read;
c_macro_t *ma = &el->el_chared.c_macro;
- Char cp_temp;
terminal__flush(el);
for (;;) {
@@ -437,14 +436,9 @@ el_wgetc(EditLine *el, wchar_t *cp)
#ifdef DEBUG_READ
(void) fprintf(el->el_errfile, "Reading a character\n");
#endif /* DEBUG_READ */
- num_read = (*el->el_read.read_char)(el, &cp_temp);
+ num_read = (*el->el_read.read_char)(el, cp);
if (num_read < 0)
el->el_errno = errno;
- *cp = cp_temp;
-#ifdef WIDECHAR
- if (el->el_flags & NARROW_READ)
- *cp = *(char *)(void *)cp;
-#endif
#ifdef DEBUG_READ
(void) fprintf(el->el_errfile, "Got it %lc\n", *cp);
#endif /* DEBUG_READ */
@@ -487,6 +481,7 @@ FUN(el,gets)(EditLine *el, int *nread)
int retval;
el_action_t cmdnum = 0;
int num; /* how many chars we have read at NL */
+ wchar_t wc;
Char ch, *cp;
int crlf = 0;
int nrb;
@@ -502,7 +497,8 @@ FUN(el,gets)(EditLine *el, int *nread)
size_t idx;
cp = el->el_line.buffer;
- while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+ while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+ *cp = (Char)wc;
/* make sure there is space for next character */
if (cp + 1 >= el->el_line.limit) {
idx = (cp - el->el_line.buffer);
@@ -554,7 +550,8 @@ FUN(el,gets)(EditLine *el, int *nread)
terminal__flush(el);
- while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+ while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+ *cp = (Char)wc;
/* make sure there is space next character */
if (cp + 1 >= el->el_line.limit) {
idx = (cp - el->el_line.buffer);
diff --git a/lib/libedit/read.h b/lib/libedit/read.h
index ca23f5b681b..0643d733a80 100644
--- a/lib/libedit/read.h
+++ b/lib/libedit/read.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: read.h,v 1.4 2016/03/20 23:48:27 schwarze Exp $ */
-/* $NetBSD: read.h,v 1.8 2016/02/17 19:47:49 christos Exp $ */
+/* $OpenBSD: read.h,v 1.5 2016/03/21 17:28:10 schwarze Exp $ */
+/* $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#ifndef _h_el_read
#define _h_el_read
-typedef int (*el_rfunc_t)(EditLine *, Char *);
+typedef int (*el_rfunc_t)(EditLine *, wchar_t *);
typedef struct el_read_t {
el_rfunc_t read_char; /* Function to read a character */
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index 25b3fb34d7a..5686053ed84 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readline.c,v 1.18 2016/03/20 23:48:27 schwarze Exp $ */
+/* $OpenBSD: readline.c,v 1.19 2016/03/21 17:28:10 schwarze Exp $ */
/* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */
/*-
@@ -159,13 +159,13 @@ static jmp_buf topbuf;
static unsigned char _el_rl_complete(EditLine *, int);
static unsigned char _el_rl_tstp(EditLine *, int);
static char *_get_prompt(EditLine *);
-static int _getc_function(EditLine *, char *);
+static int _getc_function(EditLine *, wchar_t *);
static HIST_ENTRY *_move_history(int);
static int _history_expand_command(const char *, size_t, size_t,
char **);
static char *_rl_compat_sub(const char *, const char *,
const char *, int);
-static int _rl_event_read_char(EditLine *, char *);
+static int _rl_event_read_char(EditLine *, wchar_t *);
static void _rl_update_pos(void);
@@ -202,14 +202,14 @@ _move_history(int op)
*/
static int
/*ARGSUSED*/
-_getc_function(EditLine *el, char *c)
+_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
{
int i;
i = (*rl_getc_function)(NULL);
if (i == -1)
return 0;
- *c = i;
+ *c = (wchar_t)i;
return 1;
}
@@ -2031,12 +2031,14 @@ rl_stuff_char(int c)
}
static int
-_rl_event_read_char(EditLine *el, char *cp)
+_rl_event_read_char(EditLine *el, wchar_t *wc)
{
+ char ch;
int n;
ssize_t num_read = 0;
- *cp = '\0';
+ ch = '\0';
+ *wc = L'\0';
while (rl_event_hook) {
(*rl_event_hook)();
@@ -2045,7 +2047,7 @@ _rl_event_read_char(EditLine *el, char *cp)
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
return -1;
if (n)
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
else
num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY)
@@ -2053,12 +2055,12 @@ _rl_event_read_char(EditLine *el, char *cp)
return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
return -1;
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
if (fcntl(el->el_infd, F_SETFL, n))
return -1;
#else
/* not non-blocking, but what you gonna do? */
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
return -1;
#endif
@@ -2070,6 +2072,7 @@ _rl_event_read_char(EditLine *el, char *cp)
}
if (!rl_event_hook)
el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
+ *wc = (wchar_t)ch;
return (int)num_read;
}