From 26522e4669dbf45cba32138b5d81c6c292e88e60 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 30 May 2009 23:24:28 +0000 Subject: [PATCH] ncurses 5.7 - patch 20090530 + fix an infinite recursion when adding a legacy-coding 8-bit value using insch() (report by Clemens Ladisch). + free home-terminfo string in del_curterm() (patch by Dan Weber). + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). --- NEWS | 8 +++++++- dist.mk | 4 ++-- ncurses/base/lib_dft_fgbg.c | 6 +++--- ncurses/base/lib_getch.c | 9 +++++++-- ncurses/base/lib_insch.c | 33 +++++++++++++++++++-------------- ncurses/base/lib_insnstr.c | 8 +++++--- ncurses/curses.priv.h | 33 +++++++++++++++++++++++++-------- ncurses/tinfo/lib_cur_term.c | 6 +++++- ncurses/tinfo/lib_data.c | 6 ++++-- ncurses/tinfo/lib_setup.c | 23 ++++++++++++++--------- ncurses/widechar/lib_ins_wch.c | 8 +++++--- test/demo_forms.c | 9 ++++++--- 12 files changed, 102 insertions(+), 51 deletions(-) diff --git a/NEWS b/NEWS index 98b5d4d2..4da6e362 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.1389 2009/05/23 22:48:27 tom Exp $ +-- $Id: NEWS,v 1.1392 2009/05/30 19:19:59 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,12 @@ 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. +20090530 + + fix an infinite recursion when adding a legacy-coding 8-bit value + using insch() (report by Clemens Ladisch). + + free home-terminfo string in del_curterm() (patch by Dan Weber). + + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + 20090523 + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). diff --git a/dist.mk b/dist.mk index f52e386d..22884a3d 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.701 2009/05/23 18:08:28 tom Exp $ +# $Id: dist.mk,v 1.702 2009/05/30 13:36:52 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 = 20090523 +NCURSES_PATCH = 20090530 # 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_dft_fgbg.c b/ncurses/base/lib_dft_fgbg.c index eda19761..b72c0b94 100644 --- a/ncurses/base/lib_dft_fgbg.c +++ b/ncurses/base/lib_dft_fgbg.c @@ -37,7 +37,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_dft_fgbg.c,v 1.23 2009/05/23 23:04:15 tom Exp $") +MODULE_ID("$Id: lib_dft_fgbg.c,v 1.24 2009/05/30 20:00:00 tom Exp $") /* * Modify the behavior of color-pair 0 so that the library doesn't assume that @@ -69,8 +69,8 @@ NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg) T((T_CALLED("assume_default_colors(%p,%d,%d)"), SP_PARM, fg, bg)); #ifdef USE_TERM_DRIVER - if (SP_PARM != 0) - code = CallDriver_2(SP_PARM, defaultcolors, fg, bg); + if (sp != 0) + code = CallDriver_2(sp, defaultcolors, fg, bg); #else if ((orig_pair || orig_colors) && !initialize_pair) { diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c index 63e64fa4..e228355a 100644 --- a/ncurses/base/lib_getch.c +++ b/ncurses/base/lib_getch.c @@ -42,16 +42,21 @@ #include -MODULE_ID("$Id: lib_getch.c,v 1.102 2009/04/18 20:32:33 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.103 2009/05/30 15:50:47 tom Exp $") #include #if USE_REENTRANT #define GetEscdelay(sp) (sp)->_ESCDELAY +NCURSES_EXPORT(int *) +_nc_ptr_Escdelay(SCREEN *sp) +{ + return ptrEscdelay(sp); +} NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(ESCDELAY) (void) { - return SP ? GetEscdelay(SP) : 1000; + return *_nc_ptr_Escdelay(CURRENT_SCREEN); } #else #define GetEscdelay(sp) ESCDELAY diff --git a/ncurses/base/lib_insch.c b/ncurses/base/lib_insch.c index d813740e..e88b945a 100644 --- a/ncurses/base/lib_insch.c +++ b/ncurses/base/lib_insch.c @@ -43,22 +43,19 @@ #include #include -MODULE_ID("$Id: lib_insch.c,v 1.27 2009/04/18 23:53:33 tom Exp $") +MODULE_ID("$Id: lib_insch.c,v 1.29 2009/05/30 16:45:16 tom Exp $") /* * Insert the given character, updating the current location to simplify * inserting a string. */ NCURSES_EXPORT(int) -_nc_insert_ch(WINDOW *win, chtype ch) +_nc_insert_ch(SCREEN *sp, WINDOW *win, chtype ch) { int code = OK; NCURSES_CH_T wch; int count; NCURSES_CONST char *s; -#if NCURSES_SP_FUNCS || USE_REENTRANT - SCREEN *sp = _nc_screen_of(win); -#endif int tabsize = #if USE_REENTRANT sp->_TABSIZE @@ -66,10 +63,11 @@ _nc_insert_ch(WINDOW *win, chtype ch) TABSIZE #endif ; + switch (ch) { case '\t': for (count = (tabsize - (win->_curx % tabsize)); count > 0; count--) { - if ((code = _nc_insert_ch(win, ' ')) != OK) + if ((code = _nc_insert_ch(sp, win, ' ')) != OK) break; } break; @@ -85,7 +83,9 @@ _nc_insert_ch(WINDOW *win, chtype ch) WINDOW_EXT(win, addch_used) == 0 && #endif is8bits(ChCharOf(ch)) && - isprint(ChCharOf(ch))) { + (isprint(ChCharOf(ch)) || + (ChAttrOf(ch) & A_ALTCHARSET) || + (sp != 0 && sp->_legacy_coding && !iscntrl(ChCharOf(ch))))) { if (win->_curx <= win->_maxx) { struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T *end = &(line->text[win->_curx]); @@ -104,7 +104,7 @@ _nc_insert_ch(WINDOW *win, chtype ch) } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) { s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch)); while (*s != '\0') { - code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s)); + code = _nc_insert_ch(sp, win, ChAttrOf(ch) | UChar(*s)); if (code != OK) break; ++s; @@ -124,11 +124,16 @@ _nc_insert_ch(WINDOW *win, chtype ch) /* handle EILSEQ */ if (is8bits(ch)) { s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch)); - while (*s != '\0') { - code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s)); - if (code != OK) - break; - ++s; + if (strlen(s) > 1) { + while (*s != '\0') { + code = _nc_insert_ch(sp, win, + ChAttrOf(ch) | UChar(*s)); + if (code != OK) + break; + ++s; + } + } else { + code = ERR; } } else { code = ERR; @@ -154,7 +159,7 @@ winsch(WINDOW *win, chtype c) oy = win->_cury; ox = win->_curx; - code = _nc_insert_ch(win, c); + code = _nc_insert_ch(_nc_screen_of(win), win, c); win->_curx = ox; win->_cury = oy; diff --git a/ncurses/base/lib_insnstr.c b/ncurses/base/lib_insnstr.c index b6ddfde3..16d94595 100644 --- a/ncurses/base/lib_insnstr.c +++ b/ncurses/base/lib_insnstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2004 Free Software Foundation, Inc. * + * Copyright (c) 2004,2009 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 * @@ -40,7 +40,7 @@ #include #include -MODULE_ID("$Id: lib_insnstr.c,v 1.1 2004/02/28 23:44:56 tom Exp $") +MODULE_ID("$Id: lib_insnstr.c,v 1.2 2009/05/30 14:53:49 tom Exp $") NCURSES_EXPORT(int) winsnstr(WINDOW *win, const char *s, int n) @@ -54,10 +54,12 @@ winsnstr(WINDOW *win, const char *s, int n) T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n)); if (win != 0 && str != 0) { + SCREEN *sp = _nc_screen_of(win); + oy = win->_cury; ox = win->_curx; for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { - _nc_insert_ch(win, (chtype) UChar(*cp)); + _nc_insert_ch(sp, win, (chtype) UChar(*cp)); } win->_curx = ox; win->_cury = oy; diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index f6d4c47b..71277786 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.417 2009/05/23 23:01:44 tom Exp $ + * $Id: curses.priv.h,v 1.420 2009/05/30 15:53:46 tom Exp $ * * curses.priv.h * @@ -374,17 +374,31 @@ extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *); #define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p) #if USE_REENTRANT -NCURSES_EXPORT(int *) _nc_ptr_Lines (void); -NCURSES_EXPORT(int *) _nc_ptr_Cols (void); + +NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *); +NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *); +NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *); +NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); + #define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES)) #define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS)) -#define SET_LINES(value) *_nc_ptr_Lines() = value -#define SET_COLS(value) *_nc_ptr_Cols() = value +#define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE)) +#define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY)) + +#define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value +#define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value +#define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value +#define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value + #else + #define ptrLines(sp) &LINES #define ptrCols(sp) &COLS #define SET_LINES(value) LINES = value #define SET_COLS(value) COLS = value +#define SET_TABSIZE(value) TABSIZE = value +#define SET_ESCDELAY(value) ESCDELAY = value + #endif #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \ @@ -760,6 +774,8 @@ typedef struct { chtype *real_acs_map; int _LINES; int _COLS; + int _TABSIZE; + int _ESCDELAY; TERMINAL *_cur_term; #ifdef TRACE long _outchars; @@ -1622,7 +1638,7 @@ extern NCURSES_EXPORT(bool) _nc_reset_colors(void); extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *)); /* lib_insch.c */ -extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype); +extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype); /* lib_mvcur.c */ #define INFINITY 1000000 /* cost: too high to use */ @@ -1651,6 +1667,9 @@ extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool); extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); +/* lib_set_term.c */ +extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); + /* lib_tstp.c */ #if USE_SIGWINCH extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *); @@ -1832,8 +1851,6 @@ extern NCURSES_EXPORT(int) _nc_format_slks (SCREEN *, int); #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) -extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int)); - /* * Common error messages */ diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index 5dc53fca..26e8dc8d 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -40,7 +40,7 @@ #include /* TTY, cur_term */ #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.21 2009/04/18 21:02:22 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.22 2009/05/30 13:55:19 tom Exp $") #undef CUR #define CUR termp->type. @@ -98,6 +98,10 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp) if (termp != 0) { _nc_free_termtype(&(termp->type)); FreeIfNeeded(termp->_termname); +#if USE_HOME_TERMINFO + if (_nc_globals.home_terminfo != 0) + FreeAndNull(_nc_globals.home_terminfo); +#endif free(termp); if (termp == cur_term) set_curterm(0); diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c index e84209d4..1f912d9a 100644 --- a/ncurses/tinfo/lib_data.c +++ b/ncurses/tinfo/lib_data.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 * @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_data.c,v 1.52 2008/08/23 22:16:15 tom Exp $") +MODULE_ID("$Id: lib_data.c,v 1.53 2009/05/30 15:59:25 tom Exp $") /* * OS/2's native linker complains if we don't initialize public data when @@ -225,6 +225,8 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { NULL, /* real_acs_map */ 0, /* LINES */ 0, /* COLS */ + 8, /* TABSIZE */ + 1000, /* ESCDELAY */ 0, /* cur_term */ #ifdef TRACE 0L, /* _outchars */ diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 9968083c..b01df6a2 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -54,7 +54,7 @@ #include /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_setup.c,v 1.114 2009/04/18 23:52:03 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.116 2009/05/30 20:39:21 tom Exp $") /**************************************************************************** * @@ -117,35 +117,40 @@ NCURSES_PUBLIC_VAR(ttytype) (void) return cur_term ? cur_term->type.term_names : empty; } NCURSES_EXPORT(int *) -_nc_ptr_Lines(void) +_nc_ptr_Lines(SCREEN *sp) { - return ptrLines(CURRENT_SCREEN); + return ptrLines(sp); } NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(LINES) (void) { - return *_nc_ptr_Lines(); + return *_nc_ptr_Lines(CURRENT_SCREEN); } NCURSES_EXPORT(int *) -_nc_ptr_Cols(void) +_nc_ptr_Cols(SCREEN *sp) { - return ptrCols(CURRENT_SCREEN); + return ptrCols(sp); } NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(COLS) (void) { - return *_nc_ptr_Cols(); + return *_nc_ptr_Cols(CURRENT_SCREEN); +} +NCURSES_EXPORT(int *) +_nc_ptr_Tabsize(SCREEN *sp) +{ + return ptrTabsize(sp); } NCURSES_EXPORT(int) NCURSES_PUBLIC_VAR(TABSIZE) (void) { - return SP ? SP->_TABSIZE : 8; + return *_nc_ptr_Tabsize(CURRENT_SCREEN); } #else NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = ""; NCURSES_EXPORT_VAR(int) LINES = 0; NCURSES_EXPORT_VAR(int) COLS = 0; -NCURSES_EXPORT_VAR(int) TABSIZE = 0; +NCURSES_EXPORT_VAR(int) TABSIZE = 8; #endif #if NCURSES_EXT_FUNCS diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c index c3d0420e..ef9e1b0a 100644 --- a/ncurses/widechar/lib_ins_wch.c +++ b/ncurses/widechar/lib_ins_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2002-2003,2005 Free Software Foundation, Inc. * + * Copyright (c) 2002-2005,2009 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 * @@ -39,7 +39,7 @@ #include -MODULE_ID("$Id: lib_ins_wch.c,v 1.8 2005/12/03 20:24:19 tom Exp $") +MODULE_ID("$Id: lib_ins_wch.c,v 1.9 2009/05/30 14:52:42 tom Exp $") /* * Insert the given character, updating the current location to simplify @@ -112,6 +112,8 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) n = wcslen(wstr); code = OK; if (n > 0) { + SCREEN *sp = _nc_screen_of(win); + oy = win->_cury; ox = win->_curx; for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { @@ -129,7 +131,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) code = _nc_insert_wch(win, &tmp_cchar); } else { /* tabs, other ASCII stuff */ - code = _nc_insert_ch(win, (chtype) (*cp)); + code = _nc_insert_ch(sp, win, (chtype) (*cp)); } if (code != OK) break; diff --git a/test/demo_forms.c b/test/demo_forms.c index 5940e796..cbfc64b4 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2003-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 2003-2008,2009 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 * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_forms.c,v 1.31 2008/12/20 19:23:00 tom Exp $ + * $Id: demo_forms.c,v 1.32 2009/05/30 16:52:42 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -451,8 +451,11 @@ demo_forms(void) free_form(form); } - for (c = 0; f[c] != 0; c++) + for (c = 0; f[c] != 0; c++) { + void *ptr = field_userptr(f[c]); + free(ptr); free_field(f[c]); + } noraw(); nl(); -- 2.44.0