From abd0fa0c9dfde1e4895bcfe488b24c0ab9ad69f8 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 17 Mar 2011 16:39:06 +1000 Subject: 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(-) (limited to 'linenoise.c') diff --git a/linenoise.c b/linenoise.c index 038756b..0612219 100644 --- a/linenoise.c +++ b/linenoise.c @@ -174,7 +174,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; } -- cgit v1.1