]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_restart.c
ncurses 5.6 - patch 20080308
[ncurses.git] / ncurses / base / lib_restart.c
index 31719093140f3d4c7d9f17730db8552ca9fdfe4f..858ef65a645d7ef0a3313171aa3198d4fbc7f560 100644 (file)
 
 #include <term.h>              /* lines, columns, cur_term */
 
-MODULE_ID("$Id: lib_restart.c,v 1.7 2007/04/19 21:05:25 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.8 2007/10/13 19:59:47 tom Exp $")
 
 NCURSES_EXPORT(int)
 restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
 {
-    int saveecho = SP->_echo;
-    int savecbreak = SP->_cbreak;
-    int saveraw = SP->_raw;
-    int savenl = SP->_nl;
     int result;
 
     T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
 
     if (setupterm(termp, filenum, errret) != OK) {
        result = ERR;
-    } else {
+    } else if (SP != 0) {
+       int saveecho = SP->_echo;
+       int savecbreak = SP->_cbreak;
+       int saveraw = SP->_raw;
+       int savenl = SP->_nl;
 
        if (saveecho)
            echo();
@@ -92,6 +92,8 @@ restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
 #endif
 
        result = OK;
+    } else {
+       result = ERR;
     }
     returnCode(result);
 }