summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-10-31 06:04:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-10-31 06:04:30 -0700
commit3bdf25732b26af5037c1bf05b6b09af8fe43f3c7 (patch)
treed67aad076954b32f2860562dbafb02be7c64ba9e /linenoise
parent50f2661a839a7f76856a5f13733b9a2a7843c135 (diff)
downloadtxr-3bdf25732b26af5037c1bf05b6b09af8fe43f3c7.tar.gz
txr-3bdf25732b26af5037c1bf05b6b09af8fe43f3c7.tar.bz2
txr-3bdf25732b26af5037c1bf05b6b09af8fe43f3c7.zip
linenoise: bugfix: incorrect tests for WEOF.
* linenoise/linenoise.c (complete_line, history_search, edit): The test c < 0 is not correct. Unlike EOF, WEOF isn't required to be negative, and in fact in the glibc environment, it isn't.
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index a35aa32d..9bec8212 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -583,7 +583,7 @@ static int complete_line(lino_t *ls, int substring) {
c = lino_os.getch_fn(ls->tty_ifs);
- if (c < 0) {
+ if (c == WEOF) {
if (errno == EINTR) {
handle_resize(ls, lt);
continue;
@@ -702,7 +702,7 @@ static int history_search(lino_t *l)
for (;;) {
c = lino_os.getch_fn(lc->tty_ifs);
- if (c < 0) {
+ if (c == WEOF) {
if (errno == EINTR) {
handle_resize(lc, l);
continue;
@@ -1952,12 +1952,12 @@ static int edit(lino_t *l, const wchar_t *prompt)
c = lino_os.getch_fn(l->tty_ifs);
- if (c < 0 && errno == EINTR) {
+ if (c == WEOF && errno == EINTR) {
handle_resize(l, 0);
continue;
}
- if (c < 0) {
+ if (c == WEOF) {
ret = l->len ? l->len : -1;
goto out;
}
@@ -2218,16 +2218,16 @@ static int edit(lino_t *l, const wchar_t *prompt)
/* Read the next two bytes representing the escape sequence.
* Use two calls to handle slow terminals returning the two
* chars at different times. */
- if ((seq[0] = lino_os.getch_fn(l->tty_ifs)) < 0)
+ if ((seq[0] = lino_os.getch_fn(l->tty_ifs)) == WEOF)
break;
- if ((seq[1] = lino_os.getch_fn(l->tty_ifs)) < 0)
+ if ((seq[1] = lino_os.getch_fn(l->tty_ifs)) == WEOF)
break;
/* ESC [ sequences. */
if (seq[0] == '[') {
if (seq[1] >= '0' && seq[1] <= '9') {
/* Extended escape, read additional byte. */
- if ((seq[2] = lino_os.getch_fn(l->tty_ifs)) < 0)
+ if ((seq[2] = lino_os.getch_fn(l->tty_ifs)) == WEOF)
break;
if (seq[2] == '~') {
switch(seq[1]) {