summaryrefslogtreecommitdiffstats
path: root/lib/libedit/read.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-03-21 15:25:39 +0000
committerschwarze <schwarze@openbsd.org>2016-03-21 15:25:39 +0000
commitdf2a7d38ac6d7be674243167b8355d7145815c50 (patch)
treedeb15bfcf56e167db66cf85c080b235ad5938fd3 /lib/libedit/read.c
parentOn Octeon systems, U-Boot provides a list of usable memory regions. Use (diff)
downloadwireguard-openbsd-df2a7d38ac6d7be674243167b8355d7145815c50.tar.xz
wireguard-openbsd-df2a7d38ac6d7be674243167b8355d7145815c50.zip
Reduce the FUN() macro madness by no longer applying it to el_[w]getc(3).
Always use el_wgetc(3) internally. In the !WIDECHAR case, casting the result to (Char) is safe because the function returns a byte rather than a character in that case. No functional change except for fixing a printf(3) format string issue when compiled with DEBUG_READ and WIDECHAR. OK czarkoff@
Diffstat (limited to 'lib/libedit/read.c')
-rw-r--r--lib/libedit/read.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 794d47c694d..9a90b243d57 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.26 2016/03/21 00:11:56 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.27 2016/03/21 15:25:39 schwarze Exp $ */
/* $NetBSD: read.c,v 1.81 2016/02/16 22:53:14 christos Exp $ */
/*-
@@ -238,14 +238,16 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
{
static const Char meta = (Char)0x80;
el_action_t cmd;
+ wchar_t wc;
int num;
el->el_errno = 0;
do {
- if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
+ if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */
el->el_errno = num == 0 ? 0 : errno;
return 0; /* not OKCMD */
}
+ *ch = (Char)wc;
#ifdef KANJI
if ((*ch & meta)) {
@@ -391,14 +393,15 @@ read_pop(c_macro_t *ma)
ma->offset = 0;
}
-/* el_getc():
- * Read a character
+/* el_wgetc():
+ * Read a wide character
*/
public int
-FUN(el,getc)(EditLine *el, Char *cp)
+el_wgetc(EditLine *el, wchar_t *cp)
{
int num_read;
c_macro_t *ma = &el->el_chared.c_macro;
+ Char cp_temp;
terminal__flush(el);
for (;;) {
@@ -434,15 +437,16 @@ FUN(el,getc)(EditLine *el, Char *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);
+ num_read = (*el->el_read.read_char)(el, &cp_temp);
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 %c\n", *cp);
+ (void) fprintf(el->el_errfile, "Got it %lc\n", *cp);
#endif /* DEBUG_READ */
return num_read;
}