]> git.lizzy.rs Git - linenoise.git/commitdiff
Bug fix. Ensure that current->cols is initialized
authorAndreas Kupries <andreask@activestate.com>
Fri, 18 Oct 2013 20:38:07 +0000 (13:38 -0700)
committerSteve Bennett <steveb@workware.net.au>
Mon, 21 Oct 2013 01:03:26 +0000 (11:03 +1000)
Even when both stdin/stdout are redirected (which prevents the raw mode from getting set).

linenoise.c

index 7c6eb995d1fa100fad768bb27ae3295dcc643aa9..87513cc7e1e39d7efcd25d66e4ebac4262941f54 100644 (file)
@@ -221,6 +221,7 @@ static int enableRawMode(struct current *current) {
     struct termios raw;
 
     current->fd = STDIN_FILENO;
+    current->cols = 0;
 
     if (!isatty(current->fd) || isUnsupportedTerm() ||
         tcgetattr(current->fd, &orig_termios) == -1) {
@@ -254,8 +255,6 @@ fatal:
         goto fatal;
     }
     rawmode = 1;
-
-    current->cols = 0;
     return 0;
 }