sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit c99d484c0e3619be44cb21f3b9f15d04a1e703c9
parent 5fadc79985c013fe96490029054ef46299a4483a
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu, 31 Aug 2017 18:31:52 +0200

Fix uiprompt to return NULL on error (cancelation)

Thanks to solene for spotting this!

Diffstat:
ui_ti.c | 6++++--
ui_txt.c | 7+++++--
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ui_ti.c b/ui_ti.c @@ -74,10 +74,12 @@ uiprompt(char *fmt, ...) putp(tparm(restore_cursor)); fflush(stdout); - if (r < 0) + if (r < 0) { clearerr(stdin); - else if (input[r - 1] == '\n') + clear(&input); + } else if (input[r - 1] == '\n') { input[--r] = '\0'; + } return input; } diff --git a/ui_txt.c b/ui_txt.c @@ -99,10 +99,13 @@ uiprompt(char *fmt, ...) fflush(stdout); - if ((r = getline(&input, &n, stdin)) < 0) + if ((r = getline(&input, &n, stdin)) < 0) { clearerr(stdin); - else if (input[r - 1] == '\n') + clear(&input); + putchar('\n'); + } else if (input[r - 1] == '\n') { input[--r] = '\0'; + } return input; }