fix getColumns() for Buildroot same behaviour in ncurses (drv_size() in tinfo/tinfo_driver.c)
diff --git a/README.markdown b/README.markdown
index 6c693ed..75d7247 100644
--- a/README.markdown
+++ b/README.markdown
@@ -32,6 +32,7 @@ The library is currently less than 400 lines of code. In order to use it in your
* Linux text only console ($TERM = linux)
* Linux KDE terminal application ($TERM = xterm)
* Linux xterm ($TERM = xterm)
+ * Linux Buildroot ($TERM = vt100)
* Mac OS X iTerm ($TERM = xterm)
* Mac OS X default Terminal.app ($TERM = xterm)
* OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen)
diff --git a/linenoise.c b/linenoise.c
index 4632f7d..e156eb0 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -182,7 +182,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;
}