q3map2/help: only read terminal columns using ioctl on Posix systems
authorThomas Debesse <dev@illwieckz.net>
Mon, 3 May 2021 22:46:17 +0000 (00:46 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 3 May 2021 22:46:20 +0000 (00:46 +0200)
It does not work on Windows with MSYS2.

It is verified to work on Linux, FreeBSD and macOS.

tools/quake3/q3map2/help.c

index f4fd717b7ba9e856aa9c11c3bdcec29ac79c240e..60631e3d72f175a38c581b28a50df232ea8289ab 100644 (file)
 /* dependencies */
 #include "q3map2.h"
 
+#if GDEF_OS_POSIX
 #include <sys/ioctl.h>
+#endif // GDEF_OS_POSIX
+
 static unsigned terminalColumns = 80;
 
 struct HelpOption
@@ -463,11 +466,13 @@ void HelpMain(const char* arg)
        printf("       q3map2 -help [stage]\n");
        printf("       q3map2 -help all\n\n");
 
+#if GDEF_OS_POSIX
        struct winsize ws;
        ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
        if (ws.ws_col > 60) {
                terminalColumns = ws.ws_col;
        }
+#endif // GDEF_OS_POSIX
 
        HelpCommon();