Skip to content

Commit ce5ca1f

Browse files
committed
fixup! mingw: make isatty() recognize MSys pseudo terminals (/dev/pty*)
1 parent 7d57fb4 commit ce5ca1f

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

compat/winansi.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
#include <wingdi.h>
88
#include <winreg.h>
99

10-
#ifdef USE_NTDLL
11-
#include <winternl.h>
12-
#include <ntstatus.h>
13-
#endif
14-
1510
/*
1611
ANSI codes used by git: m, K
1712
@@ -536,9 +531,12 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
536531
return old_handle;
537532
}
538533

539-
#ifdef USE_NTDLL
534+
#ifdef DETECT_MSYS_TTY
540535

541-
static void msystty_init(int fd)
536+
#include <winternl.h>
537+
#include <ntstatus.h>
538+
539+
static void detect_msys_tty(int fd)
542540
{
543541
ULONG result;
544542
BYTE buffer[1024];
@@ -570,8 +568,6 @@ static void msystty_init(int fd)
570568
_pioinfo(fd)->osflags |= FDEV;
571569
}
572570

573-
#else
574-
#define msystty_init(fd) (void)0
575571
#endif
576572

577573
void winansi_init(void)
@@ -583,10 +579,12 @@ void winansi_init(void)
583579
con1 = is_console(1);
584580
con2 = is_console(2);
585581
if (!con1 && !con2) {
582+
#ifdef DETECT_MSYS_TTY
586583
/* check if stdin / stdout / stderr are msys pty pipes */
587-
msystty_init(0);
588-
msystty_init(1);
589-
msystty_init(2);
584+
detect_msys_tty(0);
585+
detect_msys_tty(1);
586+
detect_msys_tty(2);
587+
#endif
590588
return;
591589
}
592590

config.mak.uname

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ else
548548
BASIC_LDFLAGS += -Wl,--large-address-aware
549549
endif
550550
CC = gcc
551-
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DUSE_NTDLL
551+
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY
552552
EXTLIBS += -lntdll
553553
INSTALL = /bin/install
554554
NO_R_TO_GCC_LINKER = YesPlease

0 commit comments

Comments
 (0)