From 1759abf3ae1a38b7578df7996346544b66e508ad Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 26 Jan 2000 16:43:25 +0000 Subject: Import ncurses-5.0-release to update the 5.0-prerelease that we had. --- contrib/ncurses/ncurses/Makefile.in | 6 +- contrib/ncurses/ncurses/base/lib_beep.c | 6 +- contrib/ncurses/ncurses/base/lib_color.c | 6 +- contrib/ncurses/ncurses/base/lib_flash.c | 6 +- contrib/ncurses/ncurses/base/lib_freeall.c | 4 +- contrib/ncurses/ncurses/base/lib_mouse.c | 4 +- contrib/ncurses/ncurses/base/lib_newwin.c | 4 +- contrib/ncurses/ncurses/base/lib_nl.c | 10 +-- contrib/ncurses/ncurses/base/safe_sprintf.c | 10 +-- contrib/ncurses/ncurses/base/version.c | 48 ++++++++++++ contrib/ncurses/ncurses/curses.priv.h | 7 +- contrib/ncurses/ncurses/llib-lncurses | 55 ++++++++------ contrib/ncurses/ncurses/modules | 3 +- contrib/ncurses/ncurses/tinfo/init_keytry.c | 13 +++- contrib/ncurses/ncurses/tinfo/lib_napms.c | 4 +- contrib/ncurses/ncurses/tinfo/lib_options.c | 8 +- contrib/ncurses/ncurses/tinfo/lib_termcap.c | 10 ++- contrib/ncurses/ncurses/tinfo/lib_tputs.c | 18 +++-- contrib/ncurses/ncurses/tinfo/lib_ttyflags.c | 4 +- contrib/ncurses/ncurses/tinfo/make_keys.c | 5 +- contrib/ncurses/ncurses/tty/lib_mvcur.c | 12 +-- contrib/ncurses/ncurses/tty/lib_tstp.c | 14 +++- contrib/ncurses/ncurses/tty/lib_twait.c | 81 +++++++++++++++----- contrib/ncurses/ncurses/tty/tty_update.c | 109 ++++++++++++++++----------- 24 files changed, 301 insertions(+), 146 deletions(-) create mode 100644 contrib/ncurses/ncurses/base/version.c (limited to 'contrib/ncurses/ncurses') diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in index 655022004e55..bed5ee95d2c2 100644 --- a/contrib/ncurses/ncurses/Makefile.in +++ b/contrib/ncurses/ncurses/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.62 1999/02/18 11:58:20 tom Exp $ +# $Id: Makefile.in,v 1.63 1999/09/01 22:35:53 tom Exp $ ############################################################################## # Copyright (c) 1998 Free Software Foundation, Inc. # # # @@ -210,8 +210,8 @@ mostlyclean :: clean :: mostlyclean -rm -f $(AUTO_SRC) - -rm -f make_keys - -rm -f make_hash + -rm -f make_keys$x + -rm -f make_hash$x distclean :: clean -rm -f Makefile diff --git a/contrib/ncurses/ncurses/base/lib_beep.c b/contrib/ncurses/ncurses/base/lib_beep.c index 9b89496608da..3428aaf69e16 100644 --- a/contrib/ncurses/ncurses/base/lib_beep.c +++ b/contrib/ncurses/ncurses/base/lib_beep.c @@ -42,7 +42,7 @@ #include #include /* beep, flash */ -MODULE_ID("$Id: lib_beep.c,v 1.6 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $") +MODULE_ID("$Id: lib_beep.c,v 1.7 1999/10/22 21:39:09 tom Exp $") /* * beep() @@ -62,11 +62,11 @@ int beep(void) if (bell) { TPUTS_TRACE("bell"); res = putp(bell); - fflush(SP->_ofp); + _nc_flush(); } else if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); - fflush(SP->_ofp); + _nc_flush(); } returnCode(res); diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c index cdc943adc6ee..297a14c36d6e 100644 --- a/contrib/ncurses/ncurses/base/lib_color.c +++ b/contrib/ncurses/ncurses/base/lib_color.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_color.c,v 1.35 1999/03/15 01:45:14 Alexander.V.Lukyanov Exp $") +MODULE_ID("$Id: lib_color.c,v 1.36 1999/10/03 00:20:37 Philippe.Blain Exp $") /* * These should be screen structure members. They need to be globals for @@ -345,7 +345,7 @@ bool has_colors(void) int color_content(short color, short *r, short *g, short *b) { T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b)); - if (color < 0 || color > COLORS) + if (color < 0 || color >= COLORS) returnCode(ERR); if (r) *r = SP->_color_table[color].red; @@ -358,7 +358,7 @@ int pair_content(short pair, short *f, short *b) { T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b)); - if ((pair < 0) || (pair > COLOR_PAIRS)) + if ((pair < 0) || (pair >= COLOR_PAIRS)) returnCode(ERR); if (f) *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK); if (b) *b = (SP->_color_pairs[pair] & C_MASK); diff --git a/contrib/ncurses/ncurses/base/lib_flash.c b/contrib/ncurses/ncurses/base/lib_flash.c index faf381f3a645..d0d607f6b0f8 100644 --- a/contrib/ncurses/ncurses/base/lib_flash.c +++ b/contrib/ncurses/ncurses/base/lib_flash.c @@ -42,7 +42,7 @@ #include #include /* beep, flash */ -MODULE_ID("$Id: lib_flash.c,v 1.3 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $") +MODULE_ID("$Id: lib_flash.c,v 1.4 1999/10/22 21:39:06 tom Exp $") /* * flash() @@ -62,11 +62,11 @@ int flash(void) if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); - fflush(SP->_ofp); + _nc_flush(); } else if (bell) { TPUTS_TRACE("bell"); res = putp(bell); - fflush(SP->_ofp); + _nc_flush(); } returnCode(res); diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c index e9a11ac36f26..324e7a282741 100644 --- a/contrib/ncurses/ncurses/base/lib_freeall.c +++ b/contrib/ncurses/ncurses/base/lib_freeall.c @@ -39,7 +39,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.14 1999/04/03 23:17:06 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.15 1999/10/22 21:40:10 tom Exp $") static void free_slk(SLK *p) { @@ -101,8 +101,6 @@ void _nc_freeall(void) free_slk(SP->_slk); FreeIfNeeded(SP->_color_pairs); FreeIfNeeded(SP->_color_table); - /* it won't free buffer anyway */ -/* _nc_set_buffer(SP->_ofp, FALSE);*/ #if !BROKEN_LINKER FreeAndNull(SP); #endif diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c index 0aefdf3d8219..d34d48342e4f 100644 --- a/contrib/ncurses/ncurses/base/lib_mouse.c +++ b/contrib/ncurses/ncurses/base/lib_mouse.c @@ -85,7 +85,7 @@ #endif #endif -MODULE_ID("$Id: lib_mouse.c,v 1.44 1999/07/24 21:10:48 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.45 1999/10/22 21:39:02 tom Exp $") #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT @@ -531,7 +531,7 @@ static void mouse_activate(bool on) #endif } } - (void) fflush(SP->_ofp); + _nc_flush(); } /************************************************************************** diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c index 61c0eb3ed548..d7fc02b3216e 100644 --- a/contrib/ncurses/ncurses/base/lib_newwin.c +++ b/contrib/ncurses/ncurses/base/lib_newwin.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: lib_newwin.c,v 1.20 1998/05/23 23:21:32 Alexander.V.Lukyanov Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.21 1999/10/03 00:42:03 tom Exp $") void _nc_freewin(WINDOW *win) { @@ -60,7 +60,7 @@ int i; if (! (win->_flags & _SUBWIN)) { for (i = 0; i <= win->_maxy && win->_line[i].text; i++) - free(win->_line[i].text); + FreeIfNeeded(win->_line[i].text); } free(win->_line); free(win); diff --git a/contrib/ncurses/ncurses/base/lib_nl.c b/contrib/ncurses/ncurses/base/lib_nl.c index d5c426632f5d..75d4a638148d 100644 --- a/contrib/ncurses/ncurses/base/lib_nl.c +++ b/contrib/ncurses/ncurses/base/lib_nl.c @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: lib_nl.c,v 1.3 1998/10/14 15:14:08 Alexander.V.Lukyanov Exp $") +MODULE_ID("$Id: lib_nl.c,v 1.4 1999/10/22 22:31:51 tom Exp $") #ifdef __EMX__ #include @@ -57,8 +57,8 @@ int nl(void) SP->_nl = TRUE; #ifdef __EMX__ - fflush(SP->_ofp); - _fsetmode(SP->_ofp, "t"); + _nc_flush(); + _fsetmode(NC_OUTPUT, "t"); #endif returnCode(OK); @@ -71,8 +71,8 @@ int nonl(void) SP->_nl = FALSE; #ifdef __EMX__ - fflush(SP->_ofp); - _fsetmode(SP->_ofp, "b"); + _nc_flush(); + _fsetmode(NC_OUTPUT, "b"); #endif returnCode(OK); diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c index 0809225cd94c..e4d525272627 100644 --- a/contrib/ncurses/ncurses/base/safe_sprintf.c +++ b/contrib/ncurses/ncurses/base/safe_sprintf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999 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 * @@ -33,7 +33,7 @@ #include #include -MODULE_ID("$Id: safe_sprintf.c,v 1.10 1999/02/27 19:56:37 tom Exp $") +MODULE_ID("$Id: safe_sprintf.c,v 1.11 1999/09/11 18:03:27 tom Exp $") #if USE_SAFE_SPRINTF @@ -112,7 +112,6 @@ _nc_printf_length(const char *fmt, va_list ap) case 'Z': /* FALLTHRU */ case 'h': /* FALLTHRU */ case 'l': /* FALLTHRU */ - case 'L': /* FALLTHRU */ done = FALSE; type = *fmt; break; @@ -134,10 +133,7 @@ _nc_printf_length(const char *fmt, va_list ap) case 'E': /* FALLTHRU */ case 'g': /* FALLTHRU */ case 'G': /* FALLTHRU */ - if (type == 'L') - VA_FLOAT(long double); - else - VA_FLOAT(double); + VA_FLOAT(double); used = 'f'; break; case 'c': diff --git a/contrib/ncurses/ncurses/base/version.c b/contrib/ncurses/ncurses/base/version.c new file mode 100644 index 000000000000..74d46ae9efa4 --- /dev/null +++ b/contrib/ncurses/ncurses/base/version.c @@ -0,0 +1,48 @@ +/**************************************************************************** + * Copyright (c) 1999 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 * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Thomas E. Dickey 1999 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: version.c,v 1.1 1999/10/23 13:28:49 tom Exp $") + +const char * +curses_version(void) +{ + static char my_version[80]; + + T((T_CALLED("curses_version()"))); + sprintf(my_version, "ncurses %d.%d.%d", + NCURSES_VERSION_MAJOR, + NCURSES_VERSION_MINOR, + NCURSES_VERSION_PATCH); + returnPtr(my_version); +} diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h index 02b81a4ccc93..76a923059e76 100644 --- a/contrib/ncurses/ncurses/curses.priv.h +++ b/contrib/ncurses/ncurses/curses.priv.h @@ -33,7 +33,7 @@ /* - * $Id: curses.priv.h,v 1.142 1999/07/04 01:21:35 tom Exp $ + * $Id: curses.priv.h,v 1.144 1999/10/22 23:15:37 tom Exp $ * * curses.priv.h * @@ -388,6 +388,8 @@ struct screen { /* hashes for old and new lines */ unsigned long *oldhash, *newhash; + + bool _cleanup; /* cleanup after int/quit signal */ }; extern SCREEN *_nc_screen_chain; @@ -734,6 +736,9 @@ extern int *_nc_oldnums; if ((SP->_buffered != 0) != flag) \ _nc_set_buffer(SP->_ofp, flag) +#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout) +#define _nc_flush() (void)fflush(NC_OUTPUT) + /* * On systems with a broken linker, define 'SP' as a function to force the * linker to pull in the data-only module with 'SP'. diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses index c30c6eb1cb9d..83a1e0e7d348 100644 --- a/contrib/ncurses/ncurses/llib-lncurses +++ b/contrib/ncurses/ncurses/llib-lncurses @@ -1209,7 +1209,7 @@ void filter(void) #undef newterm SCREEN *newterm( - char *term, + char *name, FILE *ofp, FILE *ifp) { return(*(SCREEN **)0); } @@ -1402,7 +1402,7 @@ int wnoutrefresh( #undef restartterm int restartterm( - char *term, + char *termp, int filenum, int *errret) { return(*(int *)0); } @@ -1520,7 +1520,7 @@ int wsetscrreg( #undef set_term SCREEN *set_term( - SCREEN *screen) + SCREEN *screenp) { return(*(SCREEN **)0); } #undef delscreen @@ -1938,6 +1938,8 @@ int use_default_colors(void) /* ./base/lib_freeall.c */ +#include + #undef _nc_freeall void _nc_freeall(void) { /* void */ } @@ -1958,17 +1960,8 @@ int resizeterm( int ToCols) { return(*(int *)0); } -/* ./trace/trace_tries.c */ - -#undef _nc_trace_tries -void _nc_trace_tries( - struct tries *tree) - { /* void */ } - /* ./trace/trace_xnames.c */ -#include - #undef _nc_trace_xnames void _nc_trace_xnames( TERMTYPE *tp) @@ -1996,6 +1989,12 @@ int _nc_remove_string( char *string) { return(*(int *)0); } +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } + /* ./base/wresize.c */ #undef wresize @@ -2013,6 +2012,15 @@ int _nc_access( int mode) { return(*(int *)0); } +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +void _nc_add_to_try( + struct tries **tree, + char *str, + unsigned short code) + { /* void */ } + /* ./tinfo/alloc_entry.c */ #undef _nc_init_entry @@ -2151,7 +2159,7 @@ void _nc_syserr_abort( char *_nc_tic_expand( const char *srcp, bool tic_format, - bool numbers) + int numbers) { return(*(char **)0); } /* ./tinfo/comp_hash.c */ @@ -2293,11 +2301,12 @@ char *_nc_home_terminfo(void) #include -#undef _nc_tinfo_fkeys -struct tinfo_fkeys _nc_tinfo_fkeys[]; - #endif +#undef _nc_tinfo_fkeysf +struct tinfo_fkeys *_nc_tinfo_fkeysf(void) + { return(*(struct tinfo_fkeys **)0); } + #undef _nc_init_keytry void _nc_init_keytry(void) { /* void */ } @@ -2341,12 +2350,12 @@ TERMINAL *cur_term; #undef set_curterm TERMINAL *set_curterm( - TERMINAL *term) + TERMINAL *termp) { return(*(TERMINAL **)0); } #undef del_curterm int del_curterm( - TERMINAL *term) + TERMINAL *termp) { return(*(int *)0); } /* ./tinfo/lib_data.c */ @@ -2835,13 +2844,11 @@ char *_nc_trace_buf( size_t want) { return(*(char **)0); } -/* ./tinfo/add_tries.c */ +/* ./trace/trace_tries.c */ -#undef _nc_add_to_try -void _nc_add_to_try( - struct tries **tree, - char *str, - unsigned short code) +#undef _nc_trace_tries +void _nc_trace_tries( + struct tries *tree) { /* void */ } /* ./unctrl.c */ diff --git a/contrib/ncurses/ncurses/modules b/contrib/ncurses/ncurses/modules index 5bb8227270c5..4b9c5dfecefb 100644 --- a/contrib/ncurses/ncurses/modules +++ b/contrib/ncurses/ncurses/modules @@ -1,4 +1,4 @@ -# $Id: modules,v 1.69 1999/07/18 02:38:37 tom Exp $ +# $Id: modules,v 1.70 1999/10/23 12:39:12 tom Exp $ ############################################################################## # Copyright (c) 1998,1999 Free Software Foundation, Inc. # # # @@ -130,6 +130,7 @@ lib_print lib $(tinfo) ../include/term.h resizeterm lib $(base) ../include/term.h trace_xnames lib $(trace) ../include/term.h $(INCDIR)/term_entry.h tries lib $(base) +version lib $(base) wresize lib $(base) ../include/term.h # Support for termcap (and tic, etc.), which can be a separate library diff --git a/contrib/ncurses/ncurses/tinfo/init_keytry.c b/contrib/ncurses/ncurses/tinfo/init_keytry.c index 77102e5dd197..a720da181e5e 100644 --- a/contrib/ncurses/ncurses/tinfo/init_keytry.c +++ b/contrib/ncurses/ncurses/tinfo/init_keytry.c @@ -32,7 +32,7 @@ /* cursor_visible,cursor_normal,cursor_invisible */ #include /* struct tinfo_fkeys */ -MODULE_ID("$Id: init_keytry.c,v 1.1 1999/02/18 22:39:11 tom Exp $") +MODULE_ID("$Id: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $") /* ** _nc_init_keytry() @@ -41,12 +41,23 @@ MODULE_ID("$Id: init_keytry.c,v 1.1 1999/02/18 22:39:11 tom Exp $") ** */ +#ifdef BROKEN_LINKER +#undef _nc_tinfo_fkeys +#endif + /* LINT_PREPRO #if 0*/ #include /* LINT_PREPRO #endif*/ +#ifdef BROKEN_LINKER +struct tinfo_fkeys *_nc_tinfo_fkeysf(void) +{ + return _nc_tinfo_fkeys; +} +#endif + void _nc_init_keytry(void) { size_t n; diff --git a/contrib/ncurses/ncurses/tinfo/lib_napms.c b/contrib/ncurses/ncurses/tinfo/lib_napms.c index 6f786c2f092a..a85304bf1cb6 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_napms.c +++ b/contrib/ncurses/ncurses/tinfo/lib_napms.c @@ -58,7 +58,7 @@ #endif #endif -MODULE_ID("$Id: lib_napms.c,v 1.5 1999/06/06 00:42:47 R.Lindsay.Todd Exp $") +MODULE_ID("$Id: lib_napms.c,v 1.6 1999/10/21 23:01:41 tom Exp $") int napms(int ms) { @@ -71,8 +71,6 @@ int napms(int ms) ts.tv_nsec = (ms % 1000) * 1000000; nanosleep(&ts, NULL); } -#elif HAVE_USLEEP - usleep(1000*(unsigned)ms); #elif USE_FUNC_POLL { struct pollfd fds[1]; diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c index 654e0edaa7aa..0bc14156d674 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_options.c +++ b/contrib/ncurses/ncurses/tinfo/lib_options.c @@ -44,7 +44,7 @@ #include /* keypad_xmit, keypad_local, meta_on, meta_off */ /* cursor_visible,cursor_normal,cursor_invisible */ -MODULE_ID("$Id: lib_options.c,v 1.35 1999/07/04 00:18:28 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.36 1999/10/22 21:38:57 tom Exp $") int idlok(WINDOW *win, bool flag) { @@ -193,7 +193,7 @@ int cursor = SP->_cursor; break; } SP->_cursor = vis; - (void) fflush(SP->_ofp); + _nc_flush(); returnCode(cursor==-1 ? 1 : cursor); } @@ -244,13 +244,13 @@ int _nc_keypad(bool flag) { TPUTS_TRACE("keypad_xmit"); putp(keypad_xmit); - (void) fflush(SP->_ofp); + _nc_flush(); } else if (! flag && keypad_local) { TPUTS_TRACE("keypad_local"); putp(keypad_local); - (void) fflush(SP->_ofp); + _nc_flush(); } if (flag && !SP->_tried) { diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c index 488b3c9a2c29..8238b368eea3 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c +++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c @@ -39,7 +39,7 @@ #define __INTERNAL_CAPS_VISIBLE #include -MODULE_ID("$Id: lib_termcap.c,v 1.28 1999/02/27 22:12:58 tom Exp $") +MODULE_ID("$Id: lib_termcap.c,v 1.29 1999/09/05 01:06:43 tom Exp $") /* some of the code in here was contributed by: @@ -162,7 +162,7 @@ int i; * ***************************************************************************/ -char *tgetstr(NCURSES_CONST char *id, char **area GCC_UNUSED) +char *tgetstr(NCURSES_CONST char *id, char **area) { int i; @@ -175,6 +175,12 @@ int i; if (!strncmp(id, capname, 2)) { T(("found match : %s", _nc_visbuf(tp->Strings[i]))); /* setupterm forces cancelled strings to null */ + if (area != 0 + && *area != 0 + && VALID_STRING(tp->Strings[i])) { + (void) strcpy(*area, tp->Strings[i]); + *area += strlen(*area) + 1; + } returnPtr(tp->Strings[i]); } } diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c index 4ce176b77a44..d3fd46276e6e 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c @@ -46,9 +46,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.39 1999/02/25 10:44:29 tom Exp $") - -#define OUTPUT ((SP != 0) ? SP->_ofp : stdout) +MODULE_ID("$Id: lib_tputs.c,v 1.41 1999/10/22 23:31:24 tom Exp $") char PC; /* used by termcap library */ speed_t ospeed; /* used by termcap library */ @@ -70,7 +68,7 @@ int delay_output(int ms) for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) my_outch(PC); if (my_outch == _nc_outch) - (void) fflush(OUTPUT); + _nc_flush(); } returnCode(OK); @@ -82,7 +80,17 @@ int _nc_outch(int ch) _nc_outchars++; #endif /* TRACE */ - putc(ch, OUTPUT); + if (SP != 0 + && SP->_cleanup) { + char tmp = ch; + /* + * POSIX says write() is safe in a signal handler, but the + * buffered I/O is not. + */ + write(fileno(NC_OUTPUT), &tmp, 1); + } else { + putc(ch, NC_OUTPUT); + } return OK; } diff --git a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c index 79397f466c5e..0e57c512b20f 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c +++ b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c @@ -38,7 +38,7 @@ #include #include /* cur_term */ -MODULE_ID("$Id: lib_ttyflags.c,v 1.2 1999/07/24 22:36:12 tom Exp $") +MODULE_ID("$Id: lib_ttyflags.c,v 1.3 1999/10/22 21:38:55 tom Exp $") #undef tabs @@ -133,7 +133,7 @@ int reset_shell_mode(void) if (SP) { _nc_keypad(FALSE); - fflush(SP->_ofp); + _nc_flush(); NC_BUFFERED(FALSE); } returnCode(_nc_set_tty_mode(&cur_term->Ottyb)); diff --git a/contrib/ncurses/ncurses/tinfo/make_keys.c b/contrib/ncurses/ncurses/tinfo/make_keys.c index e62738503dcf..a1fd1d0b66f8 100644 --- a/contrib/ncurses/ncurses/tinfo/make_keys.c +++ b/contrib/ncurses/ncurses/tinfo/make_keys.c @@ -37,7 +37,7 @@ */ #include -MODULE_ID("$Id: make_keys.c,v 1.6 1999/02/22 16:55:20 tom Exp $") +MODULE_ID("$Id: make_keys.c,v 1.7 1999/09/11 17:32:57 Jeffrey.Honig Exp $") #include @@ -103,6 +103,9 @@ int main(int argc, char *argv[]) "", "/* This file was generated by MAKE_KEYS */", "", + "#ifdef BROKEN_LINKER", + "static", + "#endif", "struct tinfo_fkeys _nc_tinfo_fkeys[] = {", 0 }; diff --git a/contrib/ncurses/ncurses/tty/lib_mvcur.c b/contrib/ncurses/ncurses/tty/lib_mvcur.c index 9eca0269390e..955eb8c6cd84 100644 --- a/contrib/ncurses/ncurses/tty/lib_mvcur.c +++ b/contrib/ncurses/ncurses/tty/lib_mvcur.c @@ -153,7 +153,7 @@ #include #include -MODULE_ID("$Id: lib_mvcur.c,v 1.57 1999/06/26 22:16:04 tom Exp $") +MODULE_ID("$Id: lib_mvcur.c,v 1.60 1999/10/03 01:08:27 Alexander.V.Lukyanov Exp $") #define STRLEN(s) (s != 0) ? strlen(s) : 0 @@ -246,10 +246,10 @@ int _nc_msec_cost(const char *const cap, int affcnt) { if (isdigit(*cp)) number = number * 10 + (*cp - '0'); - else if (*cp == '.') - number += (*++cp - 10) / 10.0; else if (*cp == '*') number *= affcnt; + else if (*cp == '.' && (*++cp != '>') && isdigit(*cp)) + number += (*cp - '0') / 10.0; } cum_cost += number * 10; @@ -734,6 +734,7 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw) { char use[OPT_SIZE], *sp; int tactic = 0, newcost, usecost = INFINITY; + int t5_cr_cost; #if defined(MAIN) || defined(NCURSES_TEST) struct timeval before, after; @@ -817,13 +818,14 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw) * tactic #5: use left margin for wrap to right-hand side, * unless strange wrap behavior indicated by xenl might hose us. */ + t5_cr_cost = (xold>0 ? SP->_cr_cost : 0); if (auto_left_margin && !eat_newline_glitch && yold > 0 && cursor_left && ((newcost=relative_move(NULL, yold-1, screen_columns-1, ynew, xnew, ovw)) != INFINITY) - && SP->_cr_cost + SP->_cub1_cost + newcost + newcost < usecost) + && t5_cr_cost + SP->_cub1_cost + newcost < usecost) { tactic = 5; - usecost = SP->_cr_cost + SP->_cub1_cost + newcost; + usecost = t5_cr_cost + SP->_cub1_cost + newcost; } /* diff --git a/contrib/ncurses/ncurses/tty/lib_tstp.c b/contrib/ncurses/ncurses/tty/lib_tstp.c index c241993f0312..6fb912cf5096 100644 --- a/contrib/ncurses/ncurses/tty/lib_tstp.c +++ b/contrib/ncurses/ncurses/tty/lib_tstp.c @@ -48,7 +48,7 @@ #define _POSIX_SOURCE #endif -MODULE_ID("$Id: lib_tstp.c,v 1.19 1999/07/24 22:47:20 tom Exp $") +MODULE_ID("$Id: lib_tstp.c,v 1.20 1999/10/22 23:11:09 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -199,13 +199,16 @@ static void tstp(int dummy GCC_UNUSED) static void cleanup(int sig) { + static int nested; + /* * Actually, doing any sort of I/O from within an signal handler is * "unsafe". But we'll _try_ to clean up the screen and terminal * settings on the way out. */ - if (sig == SIGINT - || sig == SIGQUIT) { + if (!nested++ + && (sig == SIGINT + || sig == SIGQUIT)) { #if HAVE_SIGACTION || HAVE_SIGVEC sigaction_t act; sigemptyset(&act.sa_mask); @@ -219,6 +222,11 @@ static void cleanup(int sig) SCREEN *scan = _nc_screen_chain; while(scan) { + if (SP != 0 + && SP->_ofp != 0 + && isatty(fileno(SP->_ofp))) { + SP->_cleanup = TRUE; + } set_term(scan); endwin(); if (SP) diff --git a/contrib/ncurses/ncurses/tty/lib_twait.c b/contrib/ncurses/ncurses/tty/lib_twait.c index 40bd2cd3044f..f095c9b53c0c 100644 --- a/contrib/ncurses/ncurses/tty/lib_twait.c +++ b/contrib/ncurses/ncurses/tty/lib_twait.c @@ -40,6 +40,10 @@ ** comments, none of the original code remains - T.Dickey). */ +#ifdef __BEOS__ +#include +#endif + #include #if USE_FUNC_POLL @@ -57,28 +61,32 @@ # endif #endif -#ifdef __BEOS__ -/* BeOS select() only works on sockets. Use the tty hack instead */ -#include -#define select check_select -#endif - -MODULE_ID("$Id: lib_twait.c,v 1.32 1998/06/06 22:44:14 tom Exp $") +MODULE_ID("$Id: lib_twait.c,v 1.34 1999/10/16 21:25:10 tom Exp $") -static int _nc_gettime(void) +static long _nc_gettime(bool first) { - int res; + long res; #if HAVE_GETTIMEOFDAY # define PRECISE_GETTIME 1 - struct timeval t; - gettimeofday(&t, (struct timezone *)0); - res = t.tv_sec*1000 + t.tv_usec/1000; + static struct timeval t0; + struct timeval t1; + gettimeofday(&t1, (struct timezone *)0); + if (first) { + t0 = t1; + } + res = (t1.tv_sec - t0.tv_sec) * 1000 + + (t1.tv_usec - t0.tv_usec) / 1000; #else # define PRECISE_GETTIME 0 - res = time(0)*1000; + static time_t t0; + time_t t1 = time((time_t*)0); + if (first) { + t0 = t1; + } + res = (t1 - t0) * 1000; #endif - T(("time: %d msec", res)); + T(("%s time: %ld msec", first ? "get" : "elapsed", res)); return res; } @@ -104,18 +112,19 @@ int result; #if USE_FUNC_POLL struct pollfd fds[2]; +#elif defined(__BEOS__) #elif HAVE_SELECT static fd_set set; #endif -int starttime, returntime; +long starttime, returntime; T(("start twait: %d milliseconds, mode: %d", milliseconds, mode)); #if PRECISE_GETTIME retry: #endif - starttime = _nc_gettime(); + starttime = _nc_gettime(TRUE); count = 0; @@ -133,6 +142,40 @@ retry: } result = poll(fds, count, milliseconds); +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * FIXME: the return values from the ioctl aren't very clear if we get + * interrupted. + */ + result = 0; + if (mode & 1) { + bigtime_t d; + bigtime_t useconds = milliseconds * 1000; + int n, howmany; + + if (useconds == 0) /* we're here to go _through_ the loop */ + useconds = 1; + + for (d = 0; d < useconds; d += 5000) { + n = 0; + howmany = ioctl(0, 'ichr', &n); + if (howmany >= 0 && n > 0) { + result = 1; + break; + } + if (useconds > 1) + snooze(5000); + milliseconds -= 5; + } + } else if (milliseconds > 0) { + snooze(milliseconds * 1000); + milliseconds = 0; + } #elif HAVE_SELECT /* * select() modifies the fd_set arguments; do this in the @@ -160,10 +203,10 @@ retry: } #endif - returntime = _nc_gettime(); + returntime = _nc_gettime(FALSE); if (milliseconds >= 0) - milliseconds -= returntime-starttime; + milliseconds -= (returntime - starttime); #if PRECISE_GETTIME /* @@ -203,6 +246,8 @@ retry: count++; } } +#elif defined(__BEOS__) + result = 1; /* redundant, but simple */ #elif HAVE_SELECT if ((mode & 2) && (fd = SP->_mouse_fd) >= 0 diff --git a/contrib/ncurses/ncurses/tty/tty_update.c b/contrib/ncurses/ncurses/tty/tty_update.c index 4118d357f561..a5a640f8663c 100644 --- a/contrib/ncurses/ncurses/tty/tty_update.c +++ b/contrib/ncurses/ncurses/tty/tty_update.c @@ -42,6 +42,10 @@ * *-----------------------------------------------------------------*/ +#ifdef __BEOS__ +#include +#endif + #include #if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES @@ -67,15 +71,9 @@ #endif #endif -#ifdef __BEOS__ -/* BeOS select() only works on sockets. Use the tty hack instead */ -#include -#define select check_select -#endif - #include -MODULE_ID("$Id: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.117 1999/10/22 23:28:46 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -97,10 +95,10 @@ MODULE_ID("$Id: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $") static inline chtype ClrBlank ( WINDOW *win ); static int ClrBottom(int total); -static int InsStr( chtype *line, int count ); static void ClearScreen( chtype blank ); static void ClrUpdate( void ); static void DelChar( int count ); +static void InsStr( chtype *line, int count ); static void TransformLine( int const lineno ); #ifdef POSITION_DEBUG @@ -110,29 +108,40 @@ static void TransformLine( int const lineno ); * ****************************************************************************/ -void position_check(int expected_y, int expected_x, char *legend) +static void position_check(int expected_y, int expected_x, char *legend) /* check to see if the real cursor position matches the virtual */ { - static char buf[9]; + char buf[20]; int y, x; - if (_nc_tracing) + if (!_nc_tracing || (expected_y < 0 && expected_x < 0)) return; memset(buf, '\0', sizeof(buf)); - (void) write(1, "\033[6n", 4); /* only works on ANSI-compatibles */ - (void) read(0, (void *)buf, 8); + putp("\033[6n"); /* only works on ANSI-compatibles */ + _nc_flush(); + (void) read(0, buf, sizeof(buf)-1); _tracef("probe returned %s", _nc_visbuf(buf)); /* try to interpret as a position report */ - if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) + if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) { _tracef("position probe failed in %s", legend); - else if (y - 1 != expected_y || x - 1 != expected_x) - _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", - y-1, x-1, expected_y, expected_x, legend); - else - _tracef("position matches OK in %s", legend); + } else { + if (expected_x < 0) + expected_x = x - 1; + if (expected_y < 0) + expected_y = y - 1; + if (y - 1 != expected_y || x - 1 != expected_x) { + beep(); + _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", + y-1, x-1, expected_y, expected_x, legend); + } else { + _tracef("position matches OK in %s", legend); + } + } } +#else +#define position_check(expected_y, expected_x, legend) /* nothing */ #endif /* POSITION_DEBUG */ /**************************************************************************** @@ -148,9 +157,7 @@ static inline void GoTo(int const row, int const col) TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)", row, col, SP->_cursrow, SP->_curscol)); -#ifdef POSITION_DEBUG position_check(SP->_cursrow, SP->_curscol, "GoTo"); -#endif /* POSITION_DEBUG */ /* * Force restore even if msgr is on when we're in an alternate @@ -168,6 +175,7 @@ static inline void GoTo(int const row, int const col) mvcur(SP->_cursrow, SP->_curscol, row, col); SP->_cursrow = row; SP->_curscol = col; + position_check(SP->_cursrow, SP->_curscol, "GoTo2"); } static inline void PutAttrChar(chtype ch) @@ -179,10 +187,14 @@ static inline void PutAttrChar(chtype ch) _tracechtype(ch), SP->_cursrow, SP->_curscol)); UpdateAttrs(ch); - putc((int)TextOf(ch), SP->_ofp); + if (SP->_cleanup) { + _nc_outch((int)TextOf(ch)); + } else { + putc((int)TextOf(ch), SP->_ofp); /* macro's fastest... */ #ifdef TRACE - _nc_outchars++; + _nc_outchars++; #endif /* TRACE */ + } SP->_curscol++; if (char_padding) { TPUTS_TRACE("char_padding"); @@ -212,6 +224,21 @@ static bool check_pending(void) { have_pending = TRUE; } +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * FIXME: the return values from the ioctl aren't very clear if we get + * interrupted. + */ + int n = 0; + int howmany = ioctl(0, 'ichr', &n); + if (howmany >= 0 && n > 0) { + have_pending = TRUE; + } #elif HAVE_SELECT fd_set fdset; struct timeval ktimeout; @@ -229,7 +256,7 @@ static bool check_pending(void) } if (have_pending) { SP->_fifohold = 5; - fflush(SP->_ofp); + _nc_flush(); } return FALSE; } @@ -261,6 +288,8 @@ static void PutCharLR(chtype const ch) putp(exit_am_mode); PutAttrChar(ch); + SP->_curscol--; + position_check(SP->_cursrow, SP->_curscol, "exit_am_mode"); TPUTS_TRACE("enter_am_mode"); putp(enter_am_mode); @@ -307,6 +336,7 @@ static void wrap_cursor(void) { SP->_curscol--; } + position_check(SP->_cursrow, SP->_curscol, "wrap_cursor"); } static inline void PutChar(chtype const ch) @@ -320,9 +350,7 @@ static inline void PutChar(chtype const ch) if (SP->_curscol >= screen_columns) wrap_cursor(); -#ifdef POSITION_DEBUG position_check(SP->_cursrow, SP->_curscol, "PutChar"); -#endif /* POSITION_DEBUG */ } /* @@ -753,7 +781,7 @@ struct tms before, after; */ UpdateAttrs(A_NORMAL); - fflush(SP->_ofp); + _nc_flush(); curscr->_attrs = newscr->_attrs; /* curscr->_bkgd = newscr->_bkgd; */ @@ -901,13 +929,14 @@ chtype blank = newscr->_line[total-1].text[last-1]; /* lower right char */ if ((tstLine == 0) || (last > (int)lenLine)) { tstLine = typeRealloc(chtype, last, tstLine); + if (tstLine != 0) { + lenLine = last; + for (col = 0; col < last; col++) + tstLine[col] = blank; + } } if (tstLine != 0) { - lenLine = last; - for (col = 0; col < last; col++) - tstLine[col] = blank; - for (row = total-1; row >= 0; row--) { if (memcmp(tstLine, newscr->_line[row].text, length)) break; @@ -1212,9 +1241,7 @@ static void ClearScreen(chtype blank) TPUTS_TRACE("clear_screen"); putp(clear_screen); SP->_cursrow = SP->_curscol = 0; -#ifdef POSITION_DEBUG position_check(SP->_cursrow, SP->_curscol, "ClearScreen"); -#endif /* POSITION_DEBUG */ } else if (clr_eos) { SP->_cursrow = SP->_curscol = -1; GoTo(0,0); @@ -1252,7 +1279,7 @@ static void ClearScreen(chtype blank) ** */ -static int InsStr(chtype *line, int count) +static void InsStr(chtype *line, int count) { T(("InsStr(%p,%d) called", line, count)); @@ -1267,7 +1294,6 @@ static int InsStr(chtype *line, int count) line++; count--; } - return(OK); } else if (enter_insert_mode && exit_insert_mode) { TPUTS_TRACE("enter_insert_mode"); putp(enter_insert_mode); @@ -1283,7 +1309,6 @@ static int InsStr(chtype *line, int count) } TPUTS_TRACE("exit_insert_mode"); putp(exit_insert_mode); - return(OK); } else { while (count) { TPUTS_TRACE("insert_character"); @@ -1297,8 +1322,8 @@ static int InsStr(chtype *line, int count) line++; count--; } - return(OK); } + position_check(SP->_cursrow, SP->_curscol, "InsStr"); } /* @@ -1332,14 +1357,8 @@ static void DelChar(int count) void _nc_outstr(const char *str) { - FILE *ofp = SP ? SP->_ofp : stdout; - - (void) fputs(str, ofp); - (void) fflush(ofp); - -#ifdef TRACE - _nc_outchars += strlen(str); -#endif /* TRACE */ + (void) putp(str); + _nc_flush(); } /* -- cgit v1.2.3