From 9abdba3fd5946e4af117a297957fdbf11504f801 Mon Sep 17 00:00:00 2001 From: tgoodwin Date: Thu, 29 Oct 1998 14:15:41 +0000 Subject: Bug: the "null character ignored" warning was printed with the wrong line number. Fix by adding an offset argument to pr_error. Portability: work around readline's broken treatment of a non-blocking input file descriptor. --- input.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/input.c b/input.c index 4275e70..83bd60b 100644 --- a/input.c +++ b/input.c @@ -53,7 +53,7 @@ extern int gchar() { } while ((c = (*realgchar)()) == '\0') - pr_error("warning: null character ignored"); + pr_error("warning: null character ignored", 0); return c; } @@ -95,6 +95,8 @@ static int fdgchar() { while (1) { #if EDITLINE || READLINE if (interactive && istack->fd == 0 && isatty(0)) { + /* The readline library doesn't handle read() returning EAGAIN. */ + makeblocking(istack->fd); rlinebuf = rc_readline(prompt); if (rlinebuf == NULL) { chars_in = 0; @@ -110,19 +112,14 @@ static int fdgchar() { } } else #endif - -/* There is a possible problem here. POSIX allows read() interrupted -by a signal to return -1 and set errno == EINTR *even if some data have -successfully been read*. (It is also allowed to do the Right Thing, -and return a count of the partial read.) If you have such a broken -system, you lose. */ { ssize_t r; do { r = rc_read(istack->fd, inbuf + 2, BUFSIZE); sigchk(); if (errno == EAGAIN) { - makeblocking(istack->fd); + if (!makeblocking(istack->fd)) + panic("not O_NONBLOCK"); errno = EINTR; } } while (r < 0 && errno == EINTR); -- cgit v1.2.3