From d803343ca3e2a419085e76fc9f04a6fbd14498b8 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 25 Jul 2009 22:32:12 +0000 Subject: [PATCH 1/1] ncurses 5.7 - patch 20090725 + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). --- NEWS | 5 +- dist.mk | 4 +- ncurses/base/lib_addch.c | 6 +- ncurses/base/lib_getch.c | 16 ++-- ncurses/tinfo/lib_options.c | 170 ++++++++++++++++++--------------- ncurses/tinfo/setbuf.c | 15 ++- ncurses/widechar/lib_add_wch.c | 7 +- 7 files changed, 129 insertions(+), 94 deletions(-) diff --git a/NEWS b/NEWS index 84566536..c3da4581 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1409 2009/07/19 00:09:05 tom Exp $ +-- $Id: NEWS,v 1.1410 2009/07/25 15:50:22 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,9 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20090725 + + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + 20090718 + fix a null-pointer check in _nc_format_slks() in lib_slk.c, from 20070704 changes. diff --git a/dist.mk b/dist.mk index 4d872f2e..f5a7b069 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.709 2009/07/15 23:12:22 tom Exp $ +# $Id: dist.mk,v 1.710 2009/07/25 15:38:47 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 7 -NCURSES_PATCH = 20090718 +NCURSES_PATCH = 20090725 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c index 61248f5d..fea78b1e 100644 --- a/ncurses/base/lib_addch.c +++ b/ncurses/base/lib_addch.c @@ -36,7 +36,7 @@ #include #include -MODULE_ID("$Id: lib_addch.c,v 1.119 2009/05/15 23:47:26 tom Exp $") +MODULE_ID("$Id: lib_addch.c,v 1.120 2009/07/25 14:38:19 tom Exp $") static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); @@ -263,7 +263,7 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch) #if NCURSES_SP_FUNCS #define DeriveSP() SCREEN *sp = _nc_screen_of(win); #else -#define DeriveSP() /*nothing*/ +#define DeriveSP() /*nothing */ #endif if_WIDEC({ DeriveSP(); @@ -449,7 +449,7 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch) switch (t) { case '\t': #if USE_REENTRANT - tabsize = sp->_TABSIZE; + tabsize = *ptrTabsize(sp); #else tabsize = TABSIZE; #endif diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c index ccfcc336..8609a906 100644 --- a/ncurses/base/lib_getch.c +++ b/ncurses/base/lib_getch.c @@ -42,26 +42,26 @@ #include -MODULE_ID("$Id: lib_getch.c,v 1.104 2009/07/04 20:41:13 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.106 2009/07/25 17:02:03 tom Exp $") #include #if USE_REENTRANT #define GetEscdelay(sp) *_nc_ptr_Escdelay(sp) -NCURSES_EXPORT(int *) -_nc_ptr_Escdelay(SCREEN *sp) -{ - return ptrEscdelay(sp); -} NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(ESCDELAY) (void) { return *(_nc_ptr_Escdelay(CURRENT_SCREEN)); } + +NCURSES_EXPORT(int *) +_nc_ptr_Escdelay(SCREEN *sp) +{ + return ptrEscdelay(sp); +} #else #define GetEscdelay(sp) ESCDELAY -NCURSES_EXPORT_VAR (int) - ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */ +NCURSES_EXPORT_VAR(int) ESCDELAY = 1000; #endif #if NCURSES_EXT_FUNCS diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index 908ee1b0..5411f7b3 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -42,54 +42,51 @@ #include -#include - #ifndef CUR #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_options.c,v 1.65 2009/07/04 18:14:31 tom Exp $") - -static int _nc_meta(SCREEN *, bool); +MODULE_ID("$Id: lib_options.c,v 1.69 2009/07/25 16:05:16 tom Exp $") NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) { -#if NCURSES_SP_FUNCS - SCREEN *sp = CURRENT_SCREEN; -#endif + int res = ERR; T((T_CALLED("idlok(%p,%d)"), win, flag)); if (win) { - _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region)); - returnCode(OK); - } else - returnCode(ERR); + SCREEN *sp = _nc_screen_of(win); + if (sp && IsTermInfo(sp)) { + sp->_nc_sp_idlok = + win->_idlok = (flag && (NCURSES_SP_NAME(has_il) (NCURSES_SP_ARG) + || change_scroll_region)); + res = OK; + } + } + returnCode(res); } NCURSES_EXPORT(void) idcok(WINDOW *win, bool flag) { -#if NCURSES_SP_FUNCS - SCREEN *sp = CURRENT_SCREEN; -#endif T((T_CALLED("idcok(%p,%d)"), win, flag)); - if (win) - _nc_idcok = win->_idcok = (flag && has_ic()); - + if (win) { + SCREEN *sp = _nc_screen_of(win); + sp->_nc_sp_idcok = win->_idcok = (flag && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)); + } returnVoid; } NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t) { - T((T_CALLED("halfdelay(%d)"), t)); + T((T_CALLED("halfdelay(%p,%d)"), SP_PARM, t)); - if (t < 1 || t > 255 || SP_PARM == 0) + if (t < 1 || t > 255 || !IsValidTIScreen(SP_PARM)) returnCode(ERR); - cbreak(); + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); SP_PARM->_cbreak = t + 1; returnCode(OK); } @@ -147,7 +144,7 @@ keypad(WINDOW *win, bool flag) if (win) { win->_use_keypad = flag; - returnCode(_nc_keypad(SP, flag)); + returnCode(_nc_keypad(_nc_screen_of(win), flag)); } else returnCode(ERR); } @@ -155,11 +152,33 @@ keypad(WINDOW *win, bool flag) NCURSES_EXPORT(int) meta(WINDOW *win GCC_UNUSED, bool flag) { - int result; + int result = ERR; + SCREEN *sp = (win == 0) ? CURRENT_SCREEN : _nc_screen_of(win); /* Ok, we stay relaxed and don't signal an error if win is NULL */ T((T_CALLED("meta(%p,%d)"), win, flag)); - result = _nc_meta(SP, flag); + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + + if (sp != 0) { + sp->_use_meta = flag; +#ifdef USE_TERM_DRIVER + if (IsTermInfo(sp)) { + if (flag) { + NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_on", meta_on); + } else { + NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_off", meta_off); + } + } +#else + if (flag) { + NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_on", meta_on); + } else { + NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_off", meta_off); + } +#endif + result = OK; + } returnCode(result); } @@ -168,32 +187,41 @@ meta(WINDOW *win GCC_UNUSED, bool flag) NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis) { - int result = ERR; - + int code = ERR; T((T_CALLED("curs_set(%p,%d)"), SP_PARM, vis)); + if (SP_PARM != 0 && vis >= 0 && vis <= 2) { int cursor = SP_PARM->_cursor; - + bool bBuiltIn = !IsTermInfo(SP_PARM); if (vis == cursor) { - result = cursor; + code = cursor; } else { - switch (vis) { - case 2: - result = _nc_putp_flush("cursor_visible", cursor_visible); - break; - case 1: - result = _nc_putp_flush("cursor_normal", cursor_normal); - break; - case 0: - result = _nc_putp_flush("cursor_invisible", cursor_invisible); - break; - } - if (result != ERR) - result = (cursor == -1 ? 1 : cursor); + if (!bBuiltIn) { + switch (vis) { + case 2: + code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx + "cursor_visible", + cursor_visible); + break; + case 1: + code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx + "cursor_normal", + cursor_normal); + break; + case 0: + code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx + "cursor_invisible", + cursor_invisible); + break; + } + } else + code = ERR; + if (code != ERR) + code = (cursor == -1 ? 1 : cursor); SP_PARM->_cursor = vis; } } - returnCode(result); + returnCode(code); } #if NCURSES_SP_FUNCS @@ -207,8 +235,8 @@ curs_set(int vis) NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd) { - T((T_CALLED("typeahead(%d)"), fd)); - if (SP_PARM != 0) { + T((T_CALLED("typeahead(%p, %d)"), SP_PARM, fd)); + if (IsValidTIScreen(SP_PARM)) { SP_PARM->_checkfd = fd; returnCode(OK); } else { @@ -244,6 +272,14 @@ has_key_internal(int keycode, TRIES * tp) || has_key_internal(keycode, tp->sibling)); } +#ifdef USE_TERM_DRIVER +NCURSES_EXPORT(int) +_nc_tinfo_has_key(SCREEN *sp, int keycode) +{ + return IsValidTIScreen(sp) ? + has_key_internal(keycode, sp->_keytry) : 0; +} +#else NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode) { @@ -258,27 +294,21 @@ has_key(int keycode) return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); } #endif +#endif #endif /* NCURSES_EXT_FUNCS */ -/* - * Internal entrypoints use SCREEN* parameter to obtain capabilities rather - * than cur_term. - */ -#undef CUR -#define CUR SP_TERMTYPE - NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx const char *name, const char *value) { - int rc = _nc_putp(name, value); + int rc = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx name, value); if (rc != ERR) { _nc_flush(); } return rc; } -#if NCURSES_SP_FUNCS +#if 0 && NCURSES_SP_FUNCS NCURSES_EXPORT(int) _nc_putp_flush(const char *name, const char *value) { @@ -318,10 +348,19 @@ _nc_keypad(SCREEN *sp, bool flag) } else #endif { +#ifdef USE_TERM_DRIVER + rc = CallDriver_1(sp, kpad, flag); + if (rc == OK) + sp->_keypad_on = flag; +#else if (flag) { - (void) _nc_putp_flush("keypad_xmit", keypad_xmit); + (void) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx + "keypad_xmit", + keypad_xmit); } else if (!flag && keypad_local) { - (void) _nc_putp_flush("keypad_local", keypad_local); + (void) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx + "keypad_local", + keypad_local); } if (flag && !sp->_tried) { @@ -330,27 +369,8 @@ _nc_keypad(SCREEN *sp, bool flag) } sp->_keypad_on = flag; rc = OK; +#endif } } return (rc); } - -static int -_nc_meta(SCREEN *sp, bool flag) -{ - int result = ERR; - - /* Ok, we stay relaxed and don't signal an error if win is NULL */ - - if (sp != 0) { - sp->_use_meta = flag; - - if (flag) { - _nc_putp("meta_on", meta_on); - } else { - _nc_putp("meta_off", meta_off); - } - result = OK; - } - return result; -} diff --git a/ncurses/tinfo/setbuf.c b/ncurses/tinfo/setbuf.c index 5610913d..f3be7f95 100644 --- a/ncurses/tinfo/setbuf.c +++ b/ncurses/tinfo/setbuf.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $") +MODULE_ID("$Id: setbuf.c,v 1.15 2009/05/23 22:13:44 tom Exp $") /* * If the output file descriptor is connected to a tty (the typical case) it @@ -102,6 +102,15 @@ MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $") NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered) { + int Cols; + int Lines; + + if (0 == SP_PARM) + return; + + Cols = *(ptrCols(SP_PARM)); + Lines = *(ptrLines(SP_PARM)); + /* optional optimization hack -- do before any output to ofp */ #if HAVE_SETVBUF || HAVE_SETBUFFER if (SP_PARM->_buffered != buffered) { @@ -116,7 +125,7 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered) setmode(ofp, O_BINARY); #endif if (buffered != 0) { - buf_len = min(LINES * (COLS + 6), 2800); + buf_len = min(Lines * (Cols + 6), 2800); if ((buf_ptr = SP_PARM->_setbuf) == 0) { if ((buf_ptr = typeMalloc(char, buf_len)) == NULL) return; @@ -155,6 +164,6 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered) NCURSES_EXPORT(void) _nc_set_buffer(FILE *ofp, bool buffered) { - return NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered); + NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered); } #endif diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c index c1c565c1..4d79114c 100644 --- a/ncurses/widechar/lib_add_wch.c +++ b/ncurses/widechar/lib_add_wch.c @@ -39,7 +39,7 @@ #include #endif -MODULE_ID("$Id: lib_add_wch.c,v 1.7 2009/07/04 21:59:25 tom Exp $") +MODULE_ID("$Id: lib_add_wch.c,v 1.8 2009/07/25 14:38:01 tom Exp $") /* clone/adapt lib_addch.c */ static const cchar_t blankchar = NewChar(BLANK_TEXT); @@ -308,6 +308,9 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch) NCURSES_SIZE_T x, y; wchar_t *s; int tabsize = 8; +#if USE_REENTRANT + SCREEN *sp = _nc_screen_of(win); +#endif /* * If we are using the alternate character set, forget about locale. @@ -328,7 +331,7 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch) switch (CharOf(ch)) { case '\t': #if USE_REENTRANT - tabsize = sp->_TABSIZE; + tabsize = *ptrTabsize(sp); #else tabsize = TABSIZE; #endif -- 2.44.0