X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_set_term.c;h=83d0e7d01487a7954bb16e4f2b269828e2c12e64;hp=aef940122b95782b67fbac2450f6a52a35337230;hb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5;hpb=471bc007361fd4bc8d2fae060c7d5b09828ed541;ds=sidebyside diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index aef94012..83d0e7d0 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -47,7 +47,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_set_term.c,v 1.141 2012/07/07 20:37:40 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.146 2012/10/27 23:04:17 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); @@ -272,8 +261,8 @@ extract_fgbg(char *src, int *result) } #endif -#define ReturnScreenError() _nc_set_screen(0); \ - returnCode(ERR) +#define ReturnScreenError() { _nc_set_screen(0); \ + returnCode(ERR); } while (0) /* OS-independent screen initializations */ NCURSES_EXPORT(int) @@ -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); @@ -585,6 +582,9 @@ NCURSES_SP_NAME(_nc_setupscreen) ( NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_ARG); #if USE_WIDEC_SUPPORT _nc_init_wacs(); + if (_nc_wacs == 0) { + ReturnScreenError(); + } sp->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs(sp->_term));