From: Thomas E. Dickey Date: Sat, 29 Apr 2023 23:31:50 +0000 (+0000) Subject: ncurses 6.4 - patch 20230429 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=6fd6dd99d32385a01ca639d1d56b90b13e9c1d33 ncurses 6.4 - patch 20230429 + revise recent change to _nc_write_entry to isolate it to a Cygwin bug (cf: 20230311) + amend fix for wgetnstr, wgetn_wstr to use cbreak mode unless raw mode was set (cf: 20210522). + fix a few warnings from cppcheck, etc. + correct copy/paste error in nc_access.h (report by Werner Fink). --- diff --git a/NEWS b/NEWS index c4d2ccac..116c22da 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.3945 2023/04/24 22:48:50 tom Exp $ +-- $Id: NEWS,v 1.3948 2023/04/29 20:33:12 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -46,6 +46,14 @@ 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. +20230429 + + revise recent change to _nc_write_entry to isolate it to a Cygwin bug + (cf: 20230311) + + amend fix for wgetnstr, wgetn_wstr to use cbreak mode unless raw + mode was set (cf: 20210522). + + fix a few warnings from cppcheck, etc. + + correct copy/paste error in nc_access.h (report by Werner Fink). + 20230424 + check return value of _nc_save_str(), in special case for tic where extended capabilities are processed but the terminal description was diff --git a/VERSION b/VERSION index 32a99945..bfa0c7a3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.4 20230424 +5:0:10 6.4 20230429 diff --git a/dist.mk b/dist.mk index 683355a1..ed7d4e18 100644 --- a/dist.mk +++ b/dist.mk @@ -26,7 +26,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1540 2023/04/24 22:49:54 tom Exp $ +# $Id: dist.mk,v 1.1541 2023/04/29 10:21:08 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -38,7 +38,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 4 -NCURSES_PATCH = 20230424 +NCURSES_PATCH = 20230429 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/include/nc_access.h b/include/nc_access.h index 530e47a8..acdf2e0a 100644 --- a/include/nc_access.h +++ b/include/nc_access.h @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ -/* $Id: nc_access.h,v 1.4 2023/04/22 20:32:13 tom Exp $ */ +/* $Id: nc_access.h,v 1.5 2023/04/28 20:04:43 tom Exp $ */ #ifndef NC_ACCESS_included #define NC_ACCESS_included 1 @@ -57,15 +57,17 @@ extern NCURSES_EXPORT(int) _nc_env_access (void); */ #ifdef USE_ROOT_ACCESS -#define safe_fopen(name,mode) fopen(name,mode) +#define safe_fopen(name,mode) fopen(name,mode) +#define safe_open2(name,flags) open(name,flags) #define safe_open3(name,flags,mode) open(name,flags,mode) #else -#define safe_fopen(name,mode) fopen(name,mode) -#define safe_open3(name,flags,mode) open(name,flags,mode) -extern NCURSES_EXPORT(FILE *) _nc_safe_fopen (const char *, const char *); -extern NCURSES_EXPORT(int) _nc_safe_open3 (const char *, int, mode_t); +#define safe_fopen(name,mode) _nc_safe_fopen(name,mode) +#define safe_open2(name,flags) _nc_safe_open2(name,flags,0) +#define safe_open3(name,flags,mode) _nc_safe_open3(name,flags,mode) +extern NCURSES_EXPORT(FILE *) _nc_safe_fopen (const char *, const char *); +extern NCURSES_EXPORT(int) _nc_safe_open3 (const char *, int, mode_t); #endif diff --git a/ncurses/base/lib_echo.c b/ncurses/base/lib_echo.c index d8f57f29..de7832f4 100644 --- a/ncurses/base/lib_echo.c +++ b/ncurses/base/lib_echo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2023 Thomas E. Dickey * * Copyright 1998-2000,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -45,7 +45,7 @@ #include -MODULE_ID("$Id: lib_echo.c,v 1.9 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_echo.c,v 1.10 2023/04/29 18:57:12 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0) @@ -53,7 +53,7 @@ NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0) T((T_CALLED("echo(%p)"), (void *) SP_PARM)); if (0 == SP_PARM) returnCode(ERR); - SP_PARM->_echo = TRUE; + IsEcho(SP_PARM) = TRUE; returnCode(OK); } @@ -71,7 +71,7 @@ NCURSES_SP_NAME(noecho) (NCURSES_SP_DCL0) T((T_CALLED("noecho(%p)"), (void *) SP_PARM)); if (0 == SP_PARM) returnCode(ERR); - SP_PARM->_echo = FALSE; + IsEcho(SP_PARM) = FALSE; returnCode(OK); } diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c index 831ded9d..8e476791 100644 --- a/ncurses/base/lib_getch.c +++ b/ncurses/base/lib_getch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 1998-2015,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -44,7 +44,7 @@ #define NEED_KEY_EVENT #include -MODULE_ID("$Id: lib_getch.c,v 1.145 2022/12/24 22:38:38 tom Exp $") +MODULE_ID("$Id: lib_getch.c,v 1.146 2023/04/29 18:57:12 tom Exp $") #include @@ -298,8 +298,8 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) } else #endif #if USE_KLIBC_KBD - if (NC_ISATTY(sp->_ifd) && sp->_cbreak) { - ch = _read_kbd(0, 1, !sp->_raw); + if (NC_ISATTY(sp->_ifd) && IsCbreak(sp)) { + ch = _read_kbd(0, 1, !IsRaw(sp)); n = (ch == -1) ? -1 : 1; sp->_extended_key = (ch == 0); } else @@ -308,7 +308,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) #if defined(USE_TERM_DRIVER) int buf; # if defined(EXP_WIN32_DRIVER) - if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak) { + if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) { _nc_set_read_thread(TRUE); n = _nc_console_read(sp, _nc_console_handle(sp->_ifd), @@ -316,7 +316,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) _nc_set_read_thread(FALSE); } else # elif defined(_NC_WINDOWS) - if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak) + if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) n = _nc_mingw_console_read(sp, _nc_get_handle(sp->_ifd), &buf); @@ -479,8 +479,8 @@ _nc_wgetch(WINDOW *win, */ if (head == -1 && !sp->_notty && - !sp->_raw && - !sp->_cbreak && + !IsRaw(sp) && + !IsCbreak(sp) && !sp->_called_wgetch) { char buf[MAXCOLUMNS], *bufp; @@ -513,13 +513,13 @@ _nc_wgetch(WINDOW *win, recur_wrefresh(win); - if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) { + if (win->_notimeout || (win->_delay >= 0) || (IsCbreak(sp) > 1)) { if (head == -1) { /* fifo is empty */ int delay; TR(TRACE_IEVENT, ("timed delay in wgetch()")); - if (sp->_cbreak > 1) - delay = (sp->_cbreak - 1) * 100; + if (IsCbreak(sp) > 1) + delay = (IsCbreak(sp) - 1) * 100; else delay = win->_delay; @@ -638,7 +638,7 @@ _nc_wgetch(WINDOW *win, * However, we provide the same visual result as Solaris, moving the * cursor to the left. */ - if (sp->_echo && !IS_PAD(win)) { + if (IsEcho(sp) && !IS_PAD(win)) { chtype backup = (chtype) ((ch == KEY_BACKSPACE) ? '\b' : ch); if (backup < KEY_MIN) wechochar(win, backup); @@ -647,7 +647,7 @@ _nc_wgetch(WINDOW *win, /* * Simulate ICRNL mode */ - if ((ch == '\r') && sp->_nl) + if ((ch == '\r') && IsNl(sp)) ch = '\n'; /* Strip 8th-bit if so desired. We do this only for characters that diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c index 8ddf7651..cac21fc8 100644 --- a/ncurses/base/lib_getstr.c +++ b/ncurses/base/lib_getstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 2018-2021,2023 Thomas E. Dickey * * Copyright 1998-2011,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -42,7 +42,7 @@ #define NEED_KEY_EVENT #include -MODULE_ID("$Id: lib_getstr.c,v 1.38 2021/10/23 19:02:39 tom Exp $") +MODULE_ID("$Id: lib_getstr.c,v 1.39 2023/04/29 19:00:17 tom Exp $") /* * This wipes out the last character, no matter whether it was a tab, control @@ -78,7 +78,7 @@ wgetnstr_events(WINDOW *win, { SCREEN *sp = _nc_screen_of(win); TTY buf; - bool oldnl, oldecho, oldraw, oldcbreak; + TTY_FLAGS save_flags; char erasec; char killc; char *oldstr; @@ -94,13 +94,11 @@ wgetnstr_events(WINDOW *win, NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf); - oldnl = sp->_nl; - oldecho = sp->_echo; - oldraw = sp->_raw; - oldcbreak = sp->_cbreak; + save_flags = sp->_tty_flags; NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); - NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); + if (!save_flags._raw) + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); erasec = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG); killc = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG); @@ -122,7 +120,7 @@ wgetnstr_events(WINDOW *win, || ch == '\r' || ch == KEY_DOWN || ch == KEY_ENTER) { - if (oldecho == TRUE + if (save_flags._echo == TRUE && win->_cury == win->_maxy && win->_scroll) wechochar(win, (chtype) '\n'); @@ -138,18 +136,18 @@ wgetnstr_events(WINDOW *win, #endif if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) { if (str > oldstr) { - str = WipeOut(win, y, x, oldstr, str, oldecho); + str = WipeOut(win, y, x, oldstr, str, save_flags._echo); } } else if (ch == killc) { while (str > oldstr) { - str = WipeOut(win, y, x, oldstr, str, oldecho); + str = WipeOut(win, y, x, oldstr, str, save_flags._echo); } } else if (ch >= KEY_MIN || (str - oldstr >= maxlen)) { NCURSES_SP_NAME(beep) (NCURSES_SP_ARG); } else { *str++ = (char) ch; - if (oldecho == TRUE) { + if (save_flags._echo == TRUE) { int oldy = win->_cury; if (waddch(win, (chtype) ch) == ERR) { /* @@ -159,7 +157,7 @@ wgetnstr_events(WINDOW *win, */ win->_flags &= ~_WRAPPED; waddch(win, (chtype) ' '); - str = WipeOut(win, y, x, oldstr, str, oldecho); + str = WipeOut(win, y, x, oldstr, str, save_flags._echo); continue; } else if (IS_WRAPPED(win)) { /* @@ -190,11 +188,7 @@ wgetnstr_events(WINDOW *win, /* Restore with a single I/O call, to fix minor asymmetry between * raw/noraw, etc. */ - sp->_nl = oldnl; - sp->_echo = oldecho; - sp->_raw = oldraw; - sp->_cbreak = oldcbreak; - + sp->_tty_flags = save_flags; NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); *str = '\0'; diff --git a/ncurses/base/lib_nl.c b/ncurses/base/lib_nl.c index df07349f..417b257d 100644 --- a/ncurses/base/lib_nl.c +++ b/ncurses/base/lib_nl.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2023 Thomas E. Dickey * * Copyright 1998-2000,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -45,7 +45,7 @@ #include -MODULE_ID("$Id: lib_nl.c,v 1.13 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_nl.c,v 1.14 2023/04/29 18:51:49 tom Exp $") #ifdef __EMX__ #include @@ -57,7 +57,7 @@ NCURSES_SP_NAME(nl) (NCURSES_SP_DCL0) T((T_CALLED("nl(%p)"), (void *) SP_PARM)); if (0 == SP_PARM) returnCode(ERR); - SP_PARM->_nl = TRUE; + IsNl(SP_PARM) = TRUE; #ifdef __EMX__ _nc_flush(); _fsetmode(NC_OUTPUT(SP_PARM), "t"); @@ -79,7 +79,7 @@ NCURSES_SP_NAME(nonl) (NCURSES_SP_DCL0) T((T_CALLED("nonl(%p)"), (void *) SP_PARM)); if (0 == SP_PARM) returnCode(ERR); - SP_PARM->_nl = FALSE; + IsNl(SP_PARM) = FALSE; #ifdef __EMX__ _nc_flush(); _fsetmode(NC_OUTPUT(SP_PARM), "b"); diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c index 81eb3688..0c61cb7e 100644 --- a/ncurses/base/lib_restart.c +++ b/ncurses/base/lib_restart.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2023 Thomas E. Dickey * * Copyright 1998-2012,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: lib_restart.c,v 1.17 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx @@ -65,31 +65,28 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) { result = ERR; } else if (SP_PARM != 0) { - int saveecho = SP_PARM->_echo; - int savecbreak = SP_PARM->_cbreak; - int saveraw = SP_PARM->_raw; - int savenl = SP_PARM->_nl; + TTY_FLAGS save_flags = SP_PARM->_tty_flags; #ifdef USE_TERM_DRIVER SP_PARM->_term = new_term; #endif - if (saveecho) { + if (save_flags._echo) { NCURSES_SP_NAME(echo) (NCURSES_SP_ARG); } else { NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); } - if (savecbreak) { + if (save_flags._cbreak) { NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); - } else if (saveraw) { + } else if (save_flags._raw) { NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); } else { NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); } - if (savenl) { + if (save_flags._nl) { NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); } else { NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG); diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c index 70cf6fd8..e2647b54 100644 --- a/ncurses/base/lib_screen.c +++ b/ncurses/base/lib_screen.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2021 Thomas E. Dickey * + * Copyright 2019-2021,2023 Thomas E. Dickey * * Copyright 1998-2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -42,7 +42,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_screen.c,v 1.104 2021/10/23 17:12:16 tom Exp $") +MODULE_ID("$Id: lib_screen.c,v 1.105 2023/04/28 20:58:54 tom Exp $") #define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ @@ -90,7 +90,6 @@ typedef struct { typedef struct { const char name[17]; PARAM_TYPE type; - size_t size; size_t offset; } SCR_PARAMS; @@ -120,8 +119,7 @@ static const SCR_ATTRS scr_attrs[] = }; #undef DATA -#define sizeof2(type,name) sizeof(((type *)0)->name) -#define DATA(name, type) { { #name }, type, sizeof2(WINDOW, name), offsetof(WINDOW, name) } +#define DATA(name, type) { { #name }, type, offsetof(WINDOW, name) } static const SCR_PARAMS scr_params[] = { diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 1a74a811..294ec594 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.663 2023/04/22 15:11:52 tom Exp $ + * $Id: curses.priv.h,v 1.664 2023/04/29 19:10:30 tom Exp $ * * curses.priv.h * @@ -936,6 +936,19 @@ typedef enum { ewSuspend } ENDWIN; +typedef struct { + int _nl; /* True if NL -> CR/NL is on */ + int _raw; /* True if in raw mode */ + int _cbreak; /* 1 if in cbreak mode */ + /* > 1 if in halfdelay mode */ + int _echo; /* True if echo on */ +} TTY_FLAGS; + +#define IsNl(sp) (sp)->_tty_flags._nl +#define IsRaw(sp) (sp)->_tty_flags._raw +#define IsCbreak(sp) (sp)->_tty_flags._cbreak +#define IsEcho(sp) (sp)->_tty_flags._echo + /* * The SCREEN structure. */ @@ -986,11 +999,7 @@ typedef struct screen { int _cursrow; /* physical cursor row */ int _curscol; /* physical cursor column */ bool _notty; /* true if we cannot switch non-tty */ - int _nl; /* True if NL -> CR/NL is on */ - int _raw; /* True if in raw mode */ - int _cbreak; /* 1 if in cbreak mode */ - /* > 1 if in halfdelay mode */ - int _echo; /* True if echo on */ + TTY_FLAGS _tty_flags; int _use_meta; /* use the meta key? */ struct _SLK *_slk; /* ptr to soft key struct / NULL */ int slk_format; /* selected format for this screen */ @@ -1250,18 +1259,18 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #endif #define SP_PRE_INIT(sp) \ - sp->_cursrow = -1; \ - sp->_curscol = -1; \ - sp->_nl = TRUE; \ - sp->_raw = FALSE; \ - sp->_cbreak = 0; \ - sp->_echo = TRUE; \ - sp->_fifohead = -1; \ - sp->_endwin = ewSuspend; \ - sp->_cursor = -1; \ + sp->_cursrow = -1; \ + sp->_curscol = -1; \ + IsNl(sp) = TRUE; \ + IsRaw(sp) = FALSE; \ + IsCbreak(sp) = 0; \ + IsEcho(sp) = TRUE; \ + sp->_fifohead = -1; \ + sp->_endwin = ewSuspend; \ + sp->_cursor = -1; \ SP_INIT_WINDOWLIST(sp); \ - sp->_outch = NCURSES_OUTC_FUNC; \ - sp->jump = 0 \ + sp->_outch = NCURSES_OUTC_FUNC; \ + sp->jump = 0 \ /* usually in */ #ifndef UCHAR_MAX diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c index 724283ce..e971384f 100644 --- a/ncurses/tinfo/comp_expand.c +++ b/ncurses/tinfo/comp_expand.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2020-2021,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -36,7 +36,7 @@ #include #include -MODULE_ID("$Id: comp_expand.c,v 1.34 2021/09/04 10:29:15 tom Exp $") +MODULE_ID("$Id: comp_expand.c,v 1.35 2023/04/28 20:59:06 tom Exp $") #if 0 #define DEBUG_THIS(p) DEBUG(9, p) @@ -129,7 +129,6 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers) if (dst != 0 && *dst == R_BRACE && value < 127 - && value != '\\' /* FIXME */ && isprint((int) value)) { ch = (int) value; buffer[bufp++] = S_QUOTE; diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c index 71361c50..01c1f8b7 100644 --- a/ncurses/tinfo/comp_scan.c +++ b/ncurses/tinfo/comp_scan.c @@ -1,5 +1,5 @@ /**************************************************************************** -,* Copyright 2020-2021,2022 Thomas E. Dickey * +,* Copyright 2020-2022,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -51,7 +51,7 @@ #include #include -MODULE_ID("$Id: comp_scan.c,v 1.119 2022/08/07 00:20:26 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.120 2023/04/29 19:54:37 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -302,7 +302,7 @@ push_back(int c) /* push a character back onto the input stream */ { if (bufptr == bufstart) - _nc_syserr_abort("Can't backspace off beginning of line"); + _nc_syserr_abort("cannot backspace off beginning of line"); *--bufptr = (char) c; _nc_curr_col--; } diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index 017a34aa..6a8bb394 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2020-2021,2023 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -47,7 +47,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_options.c,v 1.82 2021/02/14 00:17:35 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.83 2023/04/29 18:56:12 tom Exp $") NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) @@ -92,7 +92,7 @@ NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t) returnCode(ERR); NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); - SP_PARM->_cbreak = t + 1; + IsCbreak(SP_PARM) = t + 1; returnCode(OK); } diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c index 1e47f3b6..499fce65 100644 --- a/ncurses/tinfo/lib_raw.c +++ b/ncurses/tinfo/lib_raw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -50,7 +50,7 @@ #include -MODULE_ID("$Id: lib_raw.c,v 1.26 2020/11/21 22:07:48 tom Exp $") +MODULE_ID("$Id: lib_raw.c,v 1.27 2023/04/29 18:56:30 tom Exp $") #if HAVE_SYS_TERMIO_H #include /* needed for ISC */ @@ -116,8 +116,8 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0) KbdSetStatus(&kbdinfo, 0); #endif if (SP_PARM) { - SP_PARM->_raw = TRUE; - SP_PARM->_cbreak = 1; + IsRaw(SP_PARM) = TRUE; + IsCbreak(SP_PARM) = 1; } termp->Nttyb = buf; } @@ -163,7 +163,7 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0) result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); if (result == OK) { if (SP_PARM) { - SP_PARM->_cbreak = 1; + IsCbreak(SP_PARM) = 1; } termp->Nttyb = buf; } @@ -255,8 +255,8 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0) KbdSetStatus(&kbdinfo, 0); #endif if (SP_PARM) { - SP_PARM->_raw = FALSE; - SP_PARM->_cbreak = 0; + IsRaw(SP_PARM) = FALSE; + IsCbreak(SP_PARM) = 0; } termp->Nttyb = buf; } @@ -298,7 +298,7 @@ NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0) result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); if (result == OK) { if (SP_PARM) { - SP_PARM->_cbreak = 0; + IsCbreak(SP_PARM) = 0; } termp->Nttyb = buf; } diff --git a/ncurses/tinfo/read_termcap.c b/ncurses/tinfo/read_termcap.c index c9696b70..9ff2b2ba 100644 --- a/ncurses/tinfo/read_termcap.c +++ b/ncurses/tinfo/read_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 2018-2021,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -57,7 +57,7 @@ #include #include -MODULE_ID("$Id: read_termcap.c,v 1.102 2021/09/04 10:29:15 tom Exp $") +MODULE_ID("$Id: read_termcap.c,v 1.103 2023/04/28 20:59:14 tom Exp $") #if !PURE_TERMINFO @@ -324,7 +324,7 @@ _nc_getent( if (fd >= 0) { (void) lseek(fd, (off_t) 0, SEEK_SET); } else if ((_nc_access(db_array[current], R_OK) < 0) - || (fd = open(db_array[current], O_RDONLY, 0)) < 0) { + || (fd = safe_open2(db_array[current], O_RDONLY)) < 0) { /* No error on unfound file. */ if (errno == ENOENT) continue; diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 15a0d815..156ce744 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -42,6 +42,8 @@ #include +MODULE_ID("$Id: write_entry.c,v 1.126 2023/04/29 20:30:57 tom Exp $") + #if 1 #define TRACE_OUT(p) DEBUG(2, p) #define TRACE_NUM(n) if (VALID_NUMERIC(Numbers[n])) { \ @@ -51,7 +53,15 @@ #define TRACE_NUM(n) /* nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.122 2023/04/17 08:08:08 tom Exp $") +/* + * FIXME: special case to work around Cygwin bug in link(), which updates + * the target file's timestamp. + */ +#if HAVE_LINK && !USE_SYMLINKS && !MIXEDCASE_FILENAMES && defined(__CYGWIN__) +#define LINK_TOUCHES 1 +#else +#define LINK_TOUCHES 0 +#endif static int total_written; static int total_parts; @@ -77,7 +87,7 @@ write_file(char *filename, TERMTYPE2 *tp) if (fp == 0) { perror(filename); - _nc_syserr_abort("can't open %s/%s", _nc_tic_dir(0), filename); + _nc_syserr_abort("cannot open %s/%s", _nc_tic_dir(0), filename); } actual = fwrite(buffer, sizeof(char), (size_t) offset, fp); @@ -468,10 +478,14 @@ _nc_write_entry(TERMTYPE2 *const tp) if (strcmp(filename, linkname) == 0) { _nc_warning("self-synonym ignored"); - } else if (stat(linkname, &statbuf) >= 0 && - statbuf.st_mtime > start_time) { + } +#if !LINK_TOUCHES + else if (stat(linkname, &statbuf) >= 0 && + statbuf.st_mtime < start_time) { _nc_warning("alias %s multiply defined.", ptr); - } else if (_nc_access(linkname, W_OK) == 0) + } +#endif + else if (_nc_access(linkname, W_OK) == 0) #if HAVE_LINK { int code; @@ -510,9 +524,9 @@ _nc_write_entry(TERMTYPE2 *const tp) write_file(linkname, tp); else { #if MIXEDCASE_FILENAMES - _nc_syserr_abort("can't link %s to %s", filename, linkname); + _nc_syserr_abort("cannot link %s to %s", filename, linkname); #else - _nc_warning("can't link %s to %s (errno=%d)", filename, + _nc_warning("cannot link %s to %s (errno=%d)", filename, linkname, errno); #endif } @@ -708,7 +722,7 @@ _nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit) unsigned last_str = STRWRITE; #if NCURSES_EXT_NUMBERS bool need_ints = FALSE; - size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t) = convert_32bit; + size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t); #else #define convert_numbers convert_shorts #endif diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c index 15e7397d..2c7a0b27 100644 --- a/ncurses/tty/lib_vidattr.c +++ b/ncurses/tty/lib_vidattr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2023 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -70,7 +70,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_vidattr.c,v 1.78 2020/05/27 23:56:32 tom Exp $") +MODULE_ID("$Id: lib_vidattr.c,v 1.79 2023/04/28 20:59:26 tom Exp $") #define doPut(mode) \ TPUTS_TRACE(#mode); \ @@ -249,6 +249,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx TurnOff(A_ITALIC, exit_italics_mode); } #endif + (void) turn_off; } PreviousAttr &= ALL_BUT_COLOR; } @@ -278,6 +279,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx } else if (turn_off & A_ITALIC) { TurnOff(A_ITALIC, exit_italics_mode); } + (void) turn_off; } #endif SetColorsIf((pair != 0) || fix_pair0, PreviousAttr); diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c index c4dec5c7..3b3bd522 100644 --- a/ncurses/widechar/lib_get_wstr.c +++ b/ncurses/widechar/lib_get_wstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 2018-2021,2023 Thomas E. Dickey * * Copyright 2002-2009,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_get_wstr.c,v 1.20 2021/10/23 19:02:59 tom Exp $") +MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $") static int wadd_wint(WINDOW *win, wint_t *src) @@ -88,7 +88,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) { SCREEN *sp = _nc_screen_of(win); TTY buf; - bool oldnl, oldecho, oldraw, oldcbreak; + TTY_FLAGS save_flags; wchar_t erasec = 0; wchar_t killc = 0; wint_t *oldstr = str; @@ -105,13 +105,11 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) _nc_get_tty_mode(&buf); - oldnl = sp->_nl; - oldecho = sp->_echo; - oldraw = sp->_raw; - oldcbreak = sp->_cbreak; + save_flags = sp->_tty_flags; NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); - NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); + if (!save_flags._raw) + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec); NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc); @@ -149,7 +147,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) * *getn_wstr() with \n should work either way. */ if (ch == KEY_DOWN || ch == KEY_ENTER) { - if (oldecho == TRUE + if (save_flags._echo == TRUE && win->_cury == win->_maxy && win->_scroll) wechochar(win, (chtype) '\n'); @@ -157,11 +155,11 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) } if (ch == KEY_LEFT || ch == KEY_BACKSPACE) { if (tmpstr > oldstr) { - tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho); + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); } } else if (ch == KEY_EOL) { while (tmpstr > oldstr) { - tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho); + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); } } else { beep(); @@ -171,7 +169,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) } else { *tmpstr++ = ch; *tmpstr = 0; - if (oldecho == TRUE) { + if (save_flags._echo == TRUE) { int oldy = win->_cury; if (wadd_wint(win, tmpstr - 1) == ERR) { @@ -181,7 +179,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) */ win->_flags &= ~_WRAPPED; waddch(win, (chtype) ' '); - tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho); + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); continue; } else if (IS_WRAPPED(win)) { /* @@ -211,11 +209,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) /* Restore with a single I/O call, to fix minor asymmetry between * raw/noraw, etc. */ - sp->_nl = oldnl; - sp->_echo = oldecho; - sp->_raw = oldraw; - sp->_cbreak = oldcbreak; - + sp->_tty_flags = save_flags; (void) _nc_set_tty_mode(&buf); *tmpstr = 0; diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c index 2d9531f1..f108b307 100644 --- a/ncurses/widechar/lib_vid_attr.c +++ b/ncurses/widechar/lib_vid_attr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2023 Thomas E. Dickey * * Copyright 2002-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -37,7 +37,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_vid_attr.c,v 1.30 2020/05/27 23:54:31 tom Exp $") +MODULE_ID("$Id: lib_vid_attr.c,v 1.31 2023/04/28 20:59:34 tom Exp $") #define doPut(mode) \ TPUTS_TRACE(#mode); \ @@ -181,6 +181,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx TurnOff(A_ITALIC, exit_italics_mode); } #endif + (void) turn_off; } previous_attr &= ALL_BUT_COLOR; previous_pair = 0; @@ -212,6 +213,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx } else if (turn_off & A_ITALIC) { TurnOff(A_ITALIC, exit_italics_mode); } + (void) turn_off; } #endif SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair); diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 621fe2e1..3986480e 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230424) unstable; urgency=low +ncurses6 (6.4+20230429) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Mon, 24 Apr 2023 03:48:00 -0400 + -- Thomas E. Dickey Fri, 28 Apr 2023 15:23:29 -0400 ncurses6 (5.9+20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 621fe2e1..3986480e 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230424) unstable; urgency=low +ncurses6 (6.4+20230429) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Mon, 24 Apr 2023 03:48:00 -0400 + -- Thomas E. Dickey Fri, 28 Apr 2023 15:23:29 -0400 ncurses6 (5.9+20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index 6c9806d8..dce75f44 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.4+20230424) unstable; urgency=low +ncurses6 (6.4+20230429) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Mon, 24 Apr 2023 03:48:00 -0400 + -- Thomas E. Dickey Fri, 28 Apr 2023 15:23:29 -0400 ncurses6 (5.9+20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index 179aff54..e108cf96 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.580 2023/04/24 07:48:00 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.581 2023/04/28 19:23:29 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "4" !define VERSION_YYYY "2023" -!define VERSION_MMDD "0424" +!define VERSION_MMDD "0429" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 2dcca8bc..ed9c7299 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.4 -Release: 20230424 +Release: 20230429 License: X11 Group: Development/Libraries URL: https://invisible-island.net/ncurses/ diff --git a/package/ncurses.spec b/package/ncurses.spec index 1c72cc53..1c6e41fa 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.4 -Release: 20230424 +Release: 20230429 License: X11 Group: Development/Libraries URL: https://invisible-island.net/ncurses/ diff --git a/package/ncursest.spec b/package/ncursest.spec index b5705374..7951e72a 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.4 -Release: 20230424 +Release: 20230429 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/test/test_tparm.c b/test/test_tparm.c index 7b59eee9..1c4e0d4c 100644 --- a/test/test_tparm.c +++ b/test/test_tparm.c @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: test_tparm.c,v 1.36 2023/04/23 23:20:43 tom Exp $ + * $Id: test_tparm.c,v 1.37 2023/04/28 23:12:00 tom Exp $ * * Exercise tparm/tiparm, either for all possible capabilities with fixed * parameters, or one capability with specific combinations of parameters. @@ -319,7 +319,7 @@ test_tparm(const char *name, const char *format, long *number, char **string) } } else #endif - result = tiparm(NS_9(format)); + result = tparm(NS_9(format)); total_tests++; if (result != NULL) { tputs(result, 1, output_func);