+ improve memory-leak checking in several test-programs.
+ set trailing null on string passed from winsnstr() to wins_nwstr().
+ modify del_curterm() to fix memory-leak introduced by change to
copy_termtype().
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
--- $Id: NEWS,v 1.3807 2022/05/14 22:56:52 tom Exp $
+-- $Id: NEWS,v 1.3809 2022/05/21 21:10:54 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
+20220521
+ + improve memory-leak checking in several test-programs.
+ + set trailing null on string passed from winsnstr() to wins_nwstr().
+ + modify del_curterm() to fix memory-leak introduced by change to
+ copy_termtype().
+
20220514
+ further improvements to test/test_mouse.c; compare with ncurses test
program menu A/a.
-5:0:10 6.3 20220514
+5:0:10 6.3 20220521
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: dist.mk,v 1.1480 2022/05/14 13:23:05 tom Exp $
+# $Id: dist.mk,v 1.1481 2022/05/21 15:40:09 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 6
NCURSES_MINOR = 3
-NCURSES_PATCH = 20220514
+NCURSES_PATCH = 20220521
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2022 Thomas E. Dickey *
* Copyright 2004-2009,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insnstr.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_insnstr.c,v 1.8 2022/05/21 17:35:15 tom Exp $")
NCURSES_EXPORT(int)
winsnstr(WINDOW *win, const char *s, int n)
init_mb(state);
n3 = mbstowcs(buffer, s, nn);
if (n3 != (size_t) (-1)) {
+ buffer[n3] = '\0';
code = wins_nwstr(win, buffer, (int) n3);
}
free(buffer);
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2022 Thomas E. Dickey *
* Copyright 1999-2011,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <tic.h>
-MODULE_ID("$Id: free_ttype.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.20 2022/05/15 12:42:13 tom Exp $")
static void
really_free_termtype(TERMTYPE2 *ptr, bool freeStrings)
{
- T(("_nc_free_termtype(%s)", ptr->term_names));
+ T(("really_free_termtype(%s) %d", ptr->term_names, freeStrings));
if (freeStrings) {
FreeIfNeeded(ptr->str_table);
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+,* Copyright 2020-2021,2022 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <termcap.h> /* ospeed */
#include <tic.h> /* VALID_STRING */
-MODULE_ID("$Id: lib_cur_term.c,v 1.45 2021/11/20 23:19:41 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.48 2022/05/21 22:58:20 tom Exp $")
#undef CUR
#define CUR TerminalType(termp).
);
#if NCURSES_EXT_NUMBERS
+#if NCURSES_EXT_COLORS
_nc_free_termtype(&termp->type);
+#else
+ _nc_free_termtype2(&termp->type);
+#endif
#endif
_nc_free_termtype2(&TerminalType(termp));
if (termp == cur)
-ncurses6 (6.3+20220514) unstable; urgency=low
+ncurses6 (6.3+20220521) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 14 May 2022 09:23:05 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 15 May 2022 08:43:22 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.3+20220514) unstable; urgency=low
+ncurses6 (6.3+20220521) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 14 May 2022 09:23:05 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 15 May 2022 08:43:22 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.3+20220514) unstable; urgency=low
+ncurses6 (6.3+20220521) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 14 May 2022 09:23:05 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 15 May 2022 08:43:22 -0400
ncurses6 (5.9-20120608) unstable; urgency=low
-; $Id: mingw-ncurses.nsi,v 1.520 2022/05/14 13:23:05 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.521 2022/05/21 15:40:09 tom Exp $\r
\r
; TODO add examples\r
; TODO bump ABI to 6\r
!define VERSION_MAJOR "6"\r
!define VERSION_MINOR "3"\r
!define VERSION_YYYY "2022"\r
-!define VERSION_MMDD "0514"\r
+!define VERSION_MMDD "0521"\r
!define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
\r
!define MY_ABI "5"\r
Summary: shared libraries for terminal handling
Name: mingw32-ncurses6
Version: 6.3
-Release: 20220514
+Release: 20220521
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
Summary: shared libraries for terminal handling
Name: ncurses6
Version: 6.3
-Release: 20220514
+Release: 20220521
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
Summary: Curses library with POSIX thread support.
Name: ncursest6
Version: 6.3
-Release: 20220514
+Release: 20220521
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
* authorization. *
****************************************************************************/
/*
- * $Id: color_content.c,v 1.13 2022/04/16 18:26:40 tom Exp $
+ * $Id: color_content.c,v 1.14 2022/05/21 20:00:04 tom Exp $
*/
#define NEED_TIME_H
finish_test();
}
+ free(expected);
ExitProgram(EXIT_SUCCESS);
}
/****************************************************************************
- * Copyright 2021 Thomas E. Dickey *
+ * Copyright 2021,2022 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: combine.c,v 1.17 2021/12/18 21:04:00 tom Exp $
+ * $Id: combine.c,v 1.19 2022/05/21 23:19:31 tom Exp $
*/
#include <test.priv.h>
#if USE_WIDEC_SUPPORT
+#include <wctype.h>
#include <dump_window.h>
#include <popup_msg.h>
case 'd':
if (log_option)
dump_window(stdscr);
+#if HAVE_SCR_DUMP
else
scr_dump(dump_log);
+#endif
break;
case 'h':
if (left_at > ' ')
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2021,2022 Thomas E. Dickey *
* Copyright 2003-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* authorization. *
****************************************************************************/
/*
- * $Id: demo_menus.c,v 1.73 2021/05/08 19:41:08 tom Exp $
+ * $Id: demo_menus.c,v 1.76 2022/05/15 13:54:48 tom Exp $
*
* Demonstrate a variety of functions from the menu library.
* Thomas Dickey - 2005/4/9
}
static void
-menu_destroy(MENU * m)
+menu_destroy(MENU * m, int itemsToo)
{
Trace(("menu_destroy %p", (void *) m));
if (m != 0) {
Trace(("freeing blob %p", blob));
free((void *) blob);
}
- free(items);
- items = 0;
}
-#ifdef TRACE
- if ((count > 0) && (m == mpTrace)) {
- ITEM **ip = items;
- if (ip != 0) {
- while (*ip)
- free(*ip++);
+ if (count > 0 && itemsToo) {
+ if (itemsToo & 1) {
+ ITEM **ip = items;
+ if (ip != 0) {
+ while (*ip)
+ free_item(*ip++);
+ }
}
+ if (itemsToo & 2)
+ free(items);
}
-#endif
}
}
static void
destroy_menus(void)
{
- menu_destroy(mpFile);
- menu_destroy(mpSelect);
+ menu_destroy(mpFile, 1);
+ menu_destroy(mpSelect, 3);
#ifdef TRACE
- menu_destroy(mpTrace);
+ menu_destroy(mpTrace, 1);
#endif
- menu_destroy(mpBanner);
+ menu_destroy(mpBanner, 1);
}
#if HAVE_RIPOFFLINE
int c;
setlocale(LC_ALL, "");
+ START_TRACE();
while ((c = getopt(argc, argv, "fht:")) != -1) {
switch (c) {
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2022 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
/*
* Author: Thomas E. Dickey
*
- * $Id: demo_tabs.c,v 1.5 2020/02/02 23:34:34 tom Exp $
+ * $Id: demo_tabs.c,v 1.6 2022/05/15 13:04:57 tom Exp $
*
* A simple demo of tabs in curses.
*/
+#define USE_CURSES
#define USE_TINFO
#include "test.priv.h"
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2022 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: dup_field.c,v 1.2 2021/03/27 23:41:57 tom Exp $
+ * $Id: dup_field.c,v 1.6 2022/05/21 20:59:26 tom Exp $
*
- * Demonstrate move_field().
+ * Demonstrate dup_field().
*/
#include <test.priv.h>
#include <edit_field.h>
#include <popup_msg.h>
-#define MY_DEMO EDIT_FIELD('f')
+#define DO_DEMO CTRL('F') /* actual key for toggling demo-mode */
+#define MY_DEMO EDIT_FIELD('f') /* internal request-code */
static char empty[] = "";
static FIELD *all_fields[100];
{ CTRL('A'), REQ_BEG_FIELD, "go to beginning of field" },
{ CTRL('D'), REQ_DOWN_FIELD, "move downward to field" },
{ CTRL('E'), REQ_END_FIELD, "go to end of field" },
- { CTRL('G'), MY_DEMO, "move current field with cursor keys" },
{ CTRL('H'), REQ_DEL_PREV, "delete previous character" },
{ CTRL('I'), REQ_NEXT_FIELD, "go to next field" },
{ CTRL('K'), REQ_CLR_EOF, "clear to end of field" },
{ KEY_NEXT, REQ_NEXT_FIELD, "go to next field" },
{ KEY_PREVIOUS, REQ_PREV_FIELD, "go to previous field" },
{ KEY_RIGHT, REQ_RIGHT_CHAR, "move right 1 character" },
- { KEY_UP, REQ_UP_CHAR, "move up 1 character" }
+ { KEY_UP, REQ_UP_CHAR, "move up 1 character" },
+ { DO_DEMO, MY_DEMO, "duplicate current field" }
};
/* *INDENT-ON* */
free(msgs);
}
-static void
-do_demo(FORM *form)
-{
-}
-
static FIELD *
make_label(const char *label, int frow, int fcol)
{
werase(w);
wrefresh(w);
delwin(s);
- delwin(w);
-}
-
-static int
-my_form_driver(FORM *form, int c)
-{
- switch (c) {
- case MY_QUIT:
- if (form_driver(form, REQ_VALIDATION) == E_OK)
- return (TRUE);
- break;
- case MY_HELP:
- my_help_edit_field();
- break;
- case MY_DEMO:
- do_demo(form);
- break;
- default:
- beep();
- break;
- }
- return (FALSE);
}
static FieldAttrs *
return status;
}
+static FIELD **
+copy_fields(FIELD **source, FIELD *extra, size_t length)
+{
+ FIELD **target = typeCalloc(FIELD *, length + 1);
+ memcpy(target, source, length * sizeof(FIELD *));
+ target[length] = extra;
+ return target;
+}
+
+static void
+do_demo(FORM *form)
+{
+ int count = field_count(form);
+ FIELD *my_field = current_field(form);
+ FIELD **old_fields = form_fields(form);
+
+ if (count > 0 && old_fields != NULL && my_field != NULL) {
+ FIELD **new_fields = copy_fields(old_fields,
+ dup_field(my_field,
+ form_field_row(my_field)
+ + 1,
+ form_field_col(my_field)),
+ (size_t) count);
+ if (new_fields != NULL)
+ set_form_fields(form, new_fields);
+ }
+}
+
+static int
+my_form_driver(FORM *form, int c)
+{
+ switch (c) {
+ case MY_QUIT:
+ if (form_driver(form, REQ_VALIDATION) == E_OK)
+ return (TRUE);
+ break;
+ case MY_HELP:
+ my_help_edit_field();
+ break;
+ case MY_DEMO:
+ do_demo(form);
+ break;
+ default:
+ beep();
+ break;
+ }
+ return (FALSE);
+}
+
static void
demo_forms(void)
{
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2022 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: move_field.c,v 1.9 2021/06/12 21:30:34 tom Exp $
+ * $Id: move_field.c,v 1.13 2022/05/21 20:59:46 tom Exp $
*
* Demonstrate move_field().
*/
#include <edit_field.h>
#include <popup_msg.h>
-#ifdef HAVE_NETBSD_FORM_H
-#define form_field_row(field) (field)->form_row
-#define form_field_col(field) (field)->form_col
-#else /* e.g., SVr4, ncurses */
-#define form_field_row(field) (field)->frow
-#define form_field_col(field) (field)->fcol
-#endif
-
#define DO_DEMO CTRL('F') /* actual key for toggling demo-mode */
#define MY_DEMO EDIT_FIELD('f') /* internal request-code */
werase(w);
wrefresh(w);
delwin(s);
- delwin(w);
}
static FieldAttrs *
static FIELD **
copy_fields(FIELD **source, size_t length)
{
- FIELD **target = calloc(length + 1, sizeof(FIELD *));
+ FIELD **target = typeCalloc(FIELD *, length + 1);
memcpy(target, source, length * sizeof(FIELD *));
return target;
}
{
int count = field_count(form);
FIELD *my_field = current_field(form);
+ FIELD **old_fields = form_fields(form);
- if (count > 0 && my_field != NULL) {
+ if (count > 0 && old_fields != NULL && my_field != NULL) {
size_t needed = (size_t) count;
- FIELD **old_fields = copy_fields(form_fields(form), needed);
- FIELD **new_fields = copy_fields(form_fields(form), needed);
+ FIELD **new_fields = copy_fields(old_fields, needed);
- if (old_fields != NULL && new_fields != NULL) {
+ if (new_fields != NULL) {
bool found = FALSE;
int ch;
refresh();
}
}
- free(old_fields);
free(new_fields);
}
}
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2021,2022 Thomas E. Dickey *
* Copyright 2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
/*
* clone of view.c, using pads
*
- * $Id: padview.c,v 1.18 2021/06/12 23:16:31 tom Exp $
+ * $Id: padview.c,v 1.19 2022/05/15 14:36:23 tom Exp $
*/
#include <test.priv.h>
#define my_pair 1
+static WINDOW *global_pad;
static int shift = 0;
static bool try_color = FALSE;
finish(int sig)
{
endwin();
+ if (global_pad != NULL)
+ delwin(global_pad);
ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
* Do this after starting color, otherwise the pad's background will be
* uncolored after the ncurses 6.1.20181208 fixes.
*/
- my_pad = read_file(fname = argv[optind]);
+ global_pad =
+ my_pad = read_file(fname = argv[optind]);
my_row = 0;
while (!done) {
* authorization. *
****************************************************************************/
/*
- * $Id: pair_content.c,v 1.15 2022/04/16 18:27:24 tom Exp $
+ * $Id: pair_content.c,v 1.16 2022/05/15 15:46:28 tom Exp $
*/
#define NEED_TIME_H
static struct timeval finish_time;
#endif
+static void
+finish(int code)
+{
+ free(expected);
+ ExitProgram(code);
+}
+
static void
failed(const char *msg)
{
printw("%s", msg);
getch();
endwin();
- ExitProgram(EXIT_FAILURE);
+ finish(EXIT_FAILURE);
}
#if USE_EXTENDED_COLOR
size_t n;
for (n = 0; n < SIZEOF(msg); n++)
fprintf(stderr, "%s\n", msg[n]);
- ExitProgram(EXIT_FAILURE);
+ finish(EXIT_FAILURE);
}
int
finish_test();
}
- ExitProgram(EXIT_SUCCESS);
+ finish(EXIT_SUCCESS);
}
/****************************************************************************
* Author: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $Id: test.priv.h,v 1.199 2022/04/09 21:32:05 tom Exp $ */
+/* $Id: test.priv.h,v 1.201 2022/05/21 20:37:38 tom Exp $ */
#ifndef __TEST_PRIV_H
#define __TEST_PRIV_H 1
/* workaround, to build against NetBSD's variant of the form library */
#ifdef HAVE_NETBSD_FORM_H
#define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
-#else
+#define form_field_row(field) (field)->form_row
+#define form_field_col(field) (field)->form_col
+#else /* e.g., SVr4, ncurses */
#define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
+#define form_field_row(field) (field)->frow
+#define form_field_col(field) (field)->fcol
#endif
/* workaround, to build against NetBSD's variant of the form library */
#if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
#include <nc_alloc.h>
-#if HAVE_EXIT_TERMINFO && (defined(USE_TERMINFO) || defined(USE_TINFO))
+#if HAVE_EXIT_TERMINFO && !defined(USE_CURSES) && (defined(USE_TERMINFO) || defined(USE_TINFO))
#undef ExitProgram
#define ExitProgram(code) exit_terminfo(code)
#elif HAVE_EXIT_CURSES
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************/
/*
- * $Id: test_mouse.c,v 1.18 2022/05/15 00:20:27 tom Exp $
+ * $Id: test_mouse.c,v 1.19 2022/05/15 16:41:20 tom Exp $
*
* Author: Leonid S Usov
*
unsigned btn;
mmask_t events;
#if NCURSES_MOUSE_VERSION > 1
- const int max_btn = 5;
+ const unsigned max_btn = 5;
#else
- const int max_btn = 4;
+ const unsigned max_btn = 4;
#endif
const mmask_t btn_mask = (NCURSES_BUTTON_RELEASED |
NCURSES_BUTTON_PRESSED |
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2022 Thomas E. Dickey *
* Copyright 2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
/*
* Author: Thomas E. Dickey
*
- * $Id: test_setupterm.c,v 1.10 2020/02/02 23:34:34 tom Exp $
+ * $Id: test_setupterm.c,v 1.12 2022/05/15 16:36:00 tom Exp $
*
* A simple demo of setupterm/restartterm.
*/
static bool n_opt = FALSE;
static bool r_opt = FALSE;
+#if NO_LEAKS
+static TERMINAL **saved_terminals;
+static size_t num_saved;
+static size_t max_saved;
+
+static void
+finish(int code)
+{
+ size_t n;
+ for (n = 0; n < num_saved; ++n)
+ del_curterm(saved_terminals[n]);
+ free(saved_terminals);
+ ExitProgram(code);
+}
+
+static void
+save_curterm(void)
+{
+ size_t n;
+ bool found = FALSE;
+ for (n = 0; n < num_saved; ++n) {
+ if (saved_terminals[n] == cur_term) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (!found) {
+ if (num_saved + 1 >= max_saved) {
+ max_saved += 100;
+ saved_terminals = typeRealloc(TERMINAL *, max_saved, saved_terminals);
+ }
+ saved_terminals[num_saved++] = cur_term;
+ }
+}
+
+#else
+#define finish(code) ExitProgram(code)
+#define save_curterm() /* nothing */
+#endif
+
static void
test_rc(NCURSES_CONST char *name, int actual_rc, int actual_err)
{
#endif
rc = setupterm(name, 0, f_opt ? NULL : &err);
test_rc(name, rc, err);
+ save_curterm();
}
static void
for (n = 0; n < SIZEOF(msg); ++n) {
fprintf(stderr, "%s\n", msg[n]);
}
- ExitProgram(EXIT_FAILURE);
+ finish(EXIT_FAILURE);
}
int
if (r_opt) {
newterm("ansi", stdout, stdin);
reset_shell_mode();
+ save_curterm();
}
if (a_opt) {
}
}
- ExitProgram(EXIT_SUCCESS);
+ finish(EXIT_SUCCESS);
}
#else /* !HAVE_TIGETSTR */
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2022 Thomas E. Dickey *
* Copyright 2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* authorization. *
****************************************************************************/
/*
- * $Id: test_termattrs.c,v 1.3 2020/02/02 23:34:34 tom Exp $
+ * $Id: test_termattrs.c,v 1.4 2022/05/15 15:55:30 tom Exp $
*
* Demonstrate the termattrs and term_attrs functions.
*/
+#define USE_CURSES
#define USE_TINFO
#include <test.priv.h>