]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_set_term.c
ncurses 5.9 - patch 20120826
[ncurses.git] / ncurses / base / lib_set_term.c
index b60242ded6d66b71597e0480453badcd65c803aa..03dff27947f2f99c484ed98da72935f5d6d48b8c 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 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            *
@@ -47,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_set_term.c,v 1.140 2011/10/22 16:10:43 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.144 2012/08/26 21:11:49 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -188,18 +188,7 @@ delscreen(SCREEN *sp)
        FreeIfNeeded(sp->_acs_map);
        FreeIfNeeded(sp->_screen_acs_map);
 
-       /*
-        * If the associated output stream has been closed, we can discard the
-        * set-buffer.  Limit the error check to EBADF, since fflush may fail
-        * for other reasons than trying to operate upon a closed stream.
-        */
-       if (sp->_ofp != 0
-           && sp->_setbuf != 0
-           && fflush(sp->_ofp) != 0
-           && errno == EBADF) {
-           free(sp->_setbuf);
-       }
-
+       NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
        NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
        free(sp);
 
@@ -383,7 +372,15 @@ NCURSES_SP_NAME(_nc_setupscreen) (
     sp->_lines = (NCURSES_SIZE_T) slines;
     sp->_lines_avail = (NCURSES_SIZE_T) slines;
     sp->_columns = (NCURSES_SIZE_T) scolumns;
+
+    fflush(output);
+    sp->_ofd = output ? fileno(output) : -1;
     sp->_ofp = output;
+    sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns));
+    if ((sp->out_buffer = malloc(sp->out_limit)) == 0)
+       sp->out_limit = 0;
+    sp->out_inuse = 0;
+
     SP_PRE_INIT(sp);
     SetNoPadding(sp);
 
@@ -619,6 +616,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
 #endif
 #if USE_SIZECHANGE
     sp->_resize = NCURSES_SP_NAME(resizeterm);
+    sp->_ungetch = safe_ungetch;
 #endif
 
     NewScreen(sp)->_clear = TRUE;