ref_iterator_begin_fn(): fix docstring
[gitweb.git] / compat / winansi.c
index 56658ec4f804630fa15791f78fb5df9a8fc0ea69..793420f9d0d7732cb7dc2aa94845a22086fe7021 100644 (file)
@@ -510,6 +510,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
         */
        close(new_fd);
 
+       if (fd == 2)
+               setvbuf(stderr, NULL, _IONBF, BUFSIZ);
        fd_is_interactive[fd] |= FD_SWAPPED;
 
        return duplicate;
@@ -537,7 +539,7 @@ static void detect_msys_tty(int fd)
                        buffer, sizeof(buffer) - 2, &result)))
                return;
        name = nameinfo->Name.Buffer;
-       name[nameinfo->Name.Length] = 0;
+       name[nameinfo->Name.Length / sizeof(*name)] = 0;
 
        /*
         * Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
@@ -547,6 +549,8 @@ static void detect_msys_tty(int fd)
                        !wcsstr(name, L"-pty"))
                return;
 
+       if (fd == 2)
+               setvbuf(stderr, NULL, _IONBF, BUFSIZ);
        fd_is_interactive[fd] |= FD_MSYS;
 }