diff options
| author | tgoodwin <tgoodwin> | 1998-10-29 14:15:41 +0000 |
|---|---|---|
| committer | Toby Goodwin <toby@paccrat.org> | 2015-05-16 21:23:12 +0100 |
| commit | 9abdba3fd5946e4af117a297957fdbf11504f801 (patch) | |
| tree | 94f417ace7c13cc0bec5ff83f247621c9c9d0961 | |
| parent | 600c45ab9ac6bf6a0257997d4c21d49c868ec0bb (diff) | |
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.
| -rw-r--r-- | input.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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); |