From ad90da0a9b466577abf814e79fad82667e30d74e Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 17 Mar 2011 16:39:06 +1000 Subject: [PATCH] Fix line editing when columns unavailable Sometimes TIOCGWINSZ succeeds but returns columns=0 This makes line editing work rather badly. If this occurs, just behave as though TIOCGWINSZ had failed and assume 80 columns. Signed-off-by: Steve Bennett --- linenoise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linenoise.c b/linenoise.c index 4a62b48..9c84a12 100644 --- a/linenoise.c +++ b/linenoise.c @@ -197,7 +197,7 @@ static void linenoiseAtExit(void) { static int getColumns(void) { struct winsize ws; - if (ioctl(1, TIOCGWINSZ, &ws) == -1) return 80; + if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) return 80; return ws.ws_col; } -- 2.44.0