]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_ttyflags.c
ncurses 6.2 - patch 20210320
[ncurses.git] / ncurses / tinfo / lib_ttyflags.c
index 43bed3536cfc1d63c32d29ecedec1031394e6419..6363a805be9c44a038aa20b87f1d414b1e487c30 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 #define CUR SP_TERMTYPE
 #endif
 
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_ttyflags.c,v 1.30 2014/04/26 18:47:20 juergen Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.36 2020/09/05 22:54:47 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
 {
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
 {
+    TERMINAL *termp = TerminalOf(SP_PARM);
     int result = OK;
 
     int result = OK;
 
-    if (buf == 0 || SP_PARM == 0) {
+    if (buf == 0 || termp == 0) {
        result = ERR;
     } else {
        result = ERR;
     } else {
-       TERMINAL *termp = TerminalOf(SP_PARM);
 
 
-       if (0 == termp) {
-           result = ERR;
-       } else {
 #ifdef USE_TERM_DRIVER
 #ifdef USE_TERM_DRIVER
+       if (SP_PARM != 0) {
            result = CallDriver_2(SP_PARM, td_sgmode, FALSE, buf);
            result = CallDriver_2(SP_PARM, td_sgmode, FALSE, buf);
+       } else {
+           result = ERR;
+       }
 #else
 #else
-           for (;;) {
-               if (GET_TTY(termp->Filedes, buf) != 0) {
-                   if (errno == EINTR)
-                       continue;
-                   result = ERR;
-               }
-               break;
+       for (;;) {
+           if (GET_TTY(termp->Filedes, buf) != 0) {
+               if (errno == EINTR)
+                   continue;
+               result = ERR;
            }
            }
-#endif
+           break;
        }
        }
-
-       if (result == ERR)
-           memset(buf, 0, sizeof(*buf));
+#endif
 
        TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
                        termp ? termp->Filedes : -1,
                        _nc_trace_ttymode(buf)));
     }
 
        TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
                        termp ? termp->Filedes : -1,
                        _nc_trace_ttymode(buf)));
     }
+    if (result == ERR && buf != 0)
+       memset(buf, 0, sizeof(*buf));
+
     return (result);
 }
 
     return (result);
 }
 
@@ -141,7 +142,8 @@ NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0)
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("def_shell_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("def_shell_mode(%p) ->term %p"),
+       (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -154,6 +156,8 @@ NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0)
 #ifdef TERMIOS
            if (termp->Ottyb.c_oflag & OFLAGS_TABS)
                tab = back_tab = NULL;
 #ifdef TERMIOS
            if (termp->Ottyb.c_oflag & OFLAGS_TABS)
                tab = back_tab = NULL;
+#elif defined(EXP_WIN32_DRIVER)
+           /* noop */
 #else
            if (termp->Ottyb.sg_flags & XTABS)
                tab = back_tab = NULL;
 #else
            if (termp->Ottyb.sg_flags & XTABS)
                tab = back_tab = NULL;
@@ -179,7 +183,7 @@ NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0)
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("def_prog_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("def_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -191,6 +195,8 @@ NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0)
        if (_nc_get_tty_mode(&termp->Nttyb) == OK) {
 #ifdef TERMIOS
            termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
        if (_nc_get_tty_mode(&termp->Nttyb) == OK) {
 #ifdef TERMIOS
            termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
+#elif defined(EXP_WIN32_DRIVER)
+           /* noop */
 #else
            termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
 #endif
 #else
            termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
 #endif
@@ -215,7 +221,7 @@ NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0)
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("reset_prog_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("reset_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
@@ -247,7 +253,8 @@ NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0)
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
     int rc = ERR;
     TERMINAL *termp = TerminalOf(SP_PARM);
 
-    T((T_CALLED("reset_shell_mode(%p)"), (void *) SP_PARM));
+    T((T_CALLED("reset_shell_mode(%p) ->term %p"),
+       (void *) SP_PARM, (void *) termp));
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER
 
     if (termp != 0) {
 #ifdef USE_TERM_DRIVER