]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_setup.c
ncurses 6.3
[ncurses.git] / ncurses / tinfo / lib_setup.c
index 73e5a3231d259dd24ebc687d9967d53f56237b5d..0aaaa9303386f0049d0dffbdfa85a325d0c1b724 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.210 2020/09/06 21:03:33 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.214 2021/09/01 23:38:12 tom Exp $")
 
 /****************************************************************************
  *
@@ -66,7 +66,7 @@ MODULE_ID("$Id: lib_setup.c,v 1.210 2020/09/06 21:03:33 tom Exp $")
 #endif
 
 #if NEED_PTEM_H
- /* On SCO, they neglected to define struct winsize in termios.h -- it's only
+ /* On SCO, they neglected to define struct winsize in termios.h -- it is only
   * in termio.h and ptem.h (the former conflicts with other definitions).
   */
 # include <sys/stream.h>
@@ -663,12 +663,17 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 
     if (tname == 0) {
        tname = getenv("TERM");
-#if defined(USE_TERM_DRIVER) && !defined(EXP_WIN32_DRIVER)
+#if defined(EXP_WIN32_DRIVER)
+       if (!VALID_TERM_ENV(tname, NO_TERMINAL)) {
+           T(("Failure with TERM=%s", NonNull(tname)));
+           ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
+       }
+#elif defined(USE_TERM_DRIVER)
        if (!NonEmpty(tname))
            tname = "unknown";
 #else
-       if (!CHECK_TERM_ENV(tname, NO_TERMINAL)) {
-           T(("Failure with TERM=%s", tname));
+       if (!NonEmpty(tname)) {
+           T(("Failure with TERM=%s", NonNull(tname)));
            ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
        }
 #endif
@@ -690,6 +695,10 @@ TINFO_SETUP_TERM(TERMINAL **tp,
      */
     if (Filedes == STDOUT_FILENO && !NC_ISATTY(Filedes))
        Filedes = STDERR_FILENO;
+#if defined(EXP_WIN32_DRIVER)
+    if (Filedes != STDERR_FILENO && NC_ISATTY(Filedes))
+       _setmode(Filedes, _O_BINARY);
+#endif
 
     /*
      * Check if we have already initialized to use this terminal.  If so, we
@@ -793,6 +802,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
                ret_error1(status, "unknown terminal type.\n",
                           myname, free(myname));
            } else {
+               free(myname);
                ret_error0(status, "unexpected return-code\n");
            }
        }