Commit f3a4e0629ce69056c84734cfac70268956cb804f

antirez 2014-03-12T13:12:29

Merge branch 'master' of git://github.com/antirez/linenoise

diff --git a/README.markdown b/README.markdown
index d98107b..a58ac2b 100644
--- a/README.markdown
+++ b/README.markdown
@@ -35,6 +35,7 @@ The library is currently less than 1000 lines of code. In order to use it in you
  * 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 186b25a..f8c4283 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -206,7 +206,7 @@ static void disableRawMode(int fd) {
 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;
 }
 
@@ -505,7 +505,7 @@ static void refreshLine(struct linenoiseState *l) {
 /* Insert the character 'c' at cursor current position.
  *
  * On error writing to the terminal -1 is returned, otherwise 0. */
-int linenoiseEditInsert(struct linenoiseState *l, int c) {
+int linenoiseEditInsert(struct linenoiseState *l, char c) {
     if (l->len < l->buflen) {
         if (l->len == l->pos) {
             l->buf[l->pos] = c;