]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_ttyflags.c
ncurses 5.6 - patch 20080621
[ncurses.git] / ncurses / tinfo / lib_ttyflags.c
index 2cb9fd67b4dd2ed9f4835fefc0e8bfb3dd8dc7b3..0435bc9f0ce9e707b65c0d482798525a545c0e1c 100644 (file)
@@ -38,7 +38,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
-MODULE_ID("$Id: lib_ttyflags.c,v 1.16 2008/05/03 22:39:03 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.17 2008/06/21 20:53:06 tom Exp $")
 
 NCURSES_EXPORT(int)
 _nc_get_tty_mode(TTY * buf)
@@ -101,41 +101,49 @@ _nc_set_tty_mode(TTY * buf)
 NCURSES_EXPORT(int)
 def_shell_mode(void)
 {
-    T((T_CALLED("def_shell_mode()")));
+    int rc = ERR;
 
-    /*
-     * If XTABS was on, remove the tab and backtab capabilities.
-     */
+    T((T_CALLED("def_shell_mode()")));
 
-    if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
-       returnCode(ERR);
+    if (cur_term != 0) {
+       /*
+        * If XTABS was on, remove the tab and backtab capabilities.
+        */
+       if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) {
 #ifdef TERMIOS
-    if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
-       tab = back_tab = NULL;
+           if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
+               tab = back_tab = NULL;
 #else
-    if (cur_term->Ottyb.sg_flags & XTABS)
-       tab = back_tab = NULL;
+           if (cur_term->Ottyb.sg_flags & XTABS)
+               tab = back_tab = NULL;
 #endif
-    returnCode(OK);
+           rc = OK;
+       }
+    }
+    returnCode(rc);
 }
 
 NCURSES_EXPORT(int)
 def_prog_mode(void)
 {
-    T((T_CALLED("def_prog_mode()")));
+    int rc = ERR;
 
-    /*
-     * Turn off the XTABS bit in the tty structure if it was on.
-     */
+    T((T_CALLED("def_prog_mode()")));
 
-    if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
-       returnCode(ERR);
+    if (cur_term != 0) {
+       /*
+        * Turn off the XTABS bit in the tty structure if it was on.
+        */
+       if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) {
 #ifdef TERMIOS
-    cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
+           cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
 #else
-    cur_term->Nttyb.sg_flags &= ~XTABS;
+           cur_term->Nttyb.sg_flags &= ~XTABS;
 #endif
-    returnCode(OK);
+           rc = OK;
+       }
+    }
+    returnCode(rc);
 }
 
 NCURSES_EXPORT(int)