diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-08-13 10:21:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-08-13 10:21:26 +0000 |
commit | ca820ab699f269b08547b94921b70657ab627b27 (patch) | |
tree | 5b04cf7f0777c18934b51703231ed6db1e6e18d3 | |
parent | 6e815126a44700874e86111b635d1b9374b72749 (diff) |
Stop using a while loop for code that runs at most once,
and garbage collect an automatic variable that is no longer needed
and a comment that was probably contributed by Capt. Obvious.
No functional change.
OK millert@ martijn@
-rw-r--r-- | lib/libedit/read.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/libedit/read.c b/lib/libedit/read.c index cd1b57f2edd..8c00c664229 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.48 2021/08/12 10:31:15 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.49 2021/08/13 10:21:25 schwarze Exp $ */ /* $NetBSD: read.c,v 1.100 2016/05/24 19:31:27 christos Exp $ */ /*- @@ -209,13 +209,13 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, wchar_t *ch) static int read_char(EditLine *el, wchar_t *cp) { - ssize_t num_read; char cbuf[MB_LEN_MAX]; int cbp = 0; again: el->el_signal->sig_no = 0; - while ((num_read = read(el->el_infd, cbuf + cbp, 1)) == -1) { + switch (read(el->el_infd, cbuf + cbp, 1)) { + case -1: if (errno == EINTR) { switch (el->el_signal->sig_no) { case SIGCONT: @@ -230,12 +230,11 @@ read_char(EditLine *el, wchar_t *cp) } *cp = L'\0'; return -1; - } - - /* Test for EOF */ - if (num_read == 0) { + case 0: *cp = L'\0'; return 0; + default: + break; } for (;;) { |