diff options
Diffstat (limited to 'lib/libedit')
-rw-r--r-- | lib/libedit/read.c | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/lib/libedit/read.c b/lib/libedit/read.c index d2e73263e21..63dd846c196 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.44 2016/05/25 09:36:21 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.45 2021/08/09 09:11:26 schwarze Exp $ */ /* $NetBSD: read.c,v 1.100 2016/05/24 19:31:27 christos Exp $ */ /*- @@ -39,9 +39,10 @@ * read.c: Clean this junk up! This is horrible code. * Terminal read functions */ +#include <sys/ioctl.h> + #include <ctype.h> #include <errno.h> -#include <fcntl.h> #include <limits.h> #include <stdlib.h> #include <string.h> @@ -134,55 +135,16 @@ el_read_getfn(struct el_read_t *el_read) /* read__fixio(): * Try to recover from a read error */ -/* ARGSUSED */ static int -read__fixio(int fd __attribute__((__unused__)), int e) +read__fixio(int fd, int e) { + int zero = 0; switch (e) { - case -1: /* Make sure that the code is reachable */ - -#ifdef EWOULDBLOCK - case EWOULDBLOCK: -#ifndef TRY_AGAIN -#define TRY_AGAIN -#endif -#endif /* EWOULDBLOCK */ - -#if defined(POSIX) && defined(EAGAIN) -#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EAGAIN: -#ifndef TRY_AGAIN -#define TRY_AGAIN -#endif -#endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */ -#endif /* POSIX && EAGAIN */ - - e = 0; -#ifdef TRY_AGAIN -#if defined(F_SETFL) && defined(O_NDELAY) - if ((e = fcntl(fd, F_GETFL)) == -1) + if (ioctl(fd, FIONBIO, &zero) == -1) return -1; - - if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1) - return -1; - else - e = 1; -#endif /* F_SETFL && O_NDELAY */ - -#ifdef FIONBIO - { - int zero = 0; - - if (ioctl(fd, FIONBIO, &zero) == -1) - return -1; - else - e = 1; - } -#endif /* FIONBIO */ - -#endif /* TRY_AGAIN */ - return e ? 0 : -1; + return 0; case EINTR: return 0; |