X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_set_term.c;h=83d0e7d01487a7954bb16e4f2b269828e2c12e64;hp=c67cf8c1a9e374b7250235e9a8482a45ba9af8b0;hb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5;hpb=bd75bb126bdbd8300fe73e8e8b2fe97bd07eef75 diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index c67cf8c1..83d0e7d0 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -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.139 2011/06/14 22:50:58 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) @@ -284,7 +273,7 @@ NCURSES_SP_NAME(_nc_setupscreen) ( int slines, int scolumns, FILE *output, - bool filtered, + int filtered, int slk_format) { char *env; @@ -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)); @@ -619,6 +619,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; @@ -695,7 +696,7 @@ NCURSES_EXPORT(int) _nc_setupscreen(int slines GCC_UNUSED, int scolumns GCC_UNUSED, FILE *output, - bool filtered, + int filtered, int slk_format) { SCREEN *sp = 0;