]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 6.3 - patch 20220521
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 22 May 2022 00:12:22 +0000 (00:12 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 22 May 2022 00:12:22 +0000 (00:12 +0000)
+ 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().

25 files changed:
NEWS
VERSION
dist.mk
ncurses/base/lib_insnstr.c
ncurses/tinfo/free_ttype.c
ncurses/tinfo/lib_cur_term.c
package/debian-mingw/changelog
package/debian-mingw64/changelog
package/debian/changelog
package/mingw-ncurses.nsi
package/mingw-ncurses.spec
package/ncurses.spec
package/ncursest.spec
test/color_content.c
test/combine.c
test/demo_menus.c
test/demo_tabs.c
test/dup_field.c
test/move_field.c
test/padview.c
test/pair_content.c
test/test.priv.h
test/test_mouse.c
test/test_setupterm.c
test/test_termattrs.c

diff --git a/NEWS b/NEWS
index 364490a7b80d7cc7c41fb4138234ad36b59f9e8e..fd3e7b0605b6517b1fd1f4a339ea77b9aee6acd6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,7 +26,7 @@
 -- 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
@@ -46,6 +46,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.
 
+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.
diff --git a/VERSION b/VERSION
index ba8e643a3c0b2a24b9d729d3b2562c41573d7334..c8bff0a0ab3b5f2bbd4911c5d94cb12199bb78cd 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5:0:10 6.3     20220514
+5:0:10 6.3     20220521
diff --git a/dist.mk b/dist.mk
index d5a51323a516d0b0a9bf9e97952098e7596aa250..b517ae414cfdbacbef3c13fc3a6a8dd7e3843a85 100644 (file)
--- 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.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
@@ -38,7 +38,7 @@ SHELL = /bin/sh
 # 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)
index ff1ae573a576d73b07efb3f7418db0b481aaccf8..dd51a9cd18f9ab41436d57c3b8aa7a33230e7128 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -41,7 +41,7 @@
 #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)
@@ -70,6 +70,7 @@ 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);
index 7f0fbcc35f292b774c336cee9b73706d43bfc08b..973577636bcf45e37bcb9a0904704e55d32112c3 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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);
index 6ef62cb23dded441ab78f1f38259ab98a8a4b3ac..7d7e7f1577f9c86378178438ebc93cfad05c8fb5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -41,7 +41,7 @@
 #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).
@@ -147,7 +147,11 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *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)
index 13d69d31e3d076e412b92cad02087e4135f73fdc..bfb228b86c9f9fab67108c120620df25c990cf7f 100644 (file)
@@ -1,8 +1,8 @@
-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
 
index 13d69d31e3d076e412b92cad02087e4135f73fdc..bfb228b86c9f9fab67108c120620df25c990cf7f 100644 (file)
@@ -1,8 +1,8 @@
-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
 
index 733d47ad68d7e68f5740baa70f3423c6dd0b7247..c13c624ffa6e231456c8f83aad0b9620bb371dfe 100644 (file)
@@ -1,8 +1,8 @@
-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
 
index 88e6a31434c292a5b396b94720982e2d266c9db1..0d5bec04f71418862553e326378529f131f9811a 100644 (file)
@@ -1,4 +1,4 @@
-; $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
@@ -10,7 +10,7 @@
 !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
index 681da256ce97e8d3879b0004557b1083f95b622c..5d12868ecc608ff9000773666125c5dd1d3a6797 100644 (file)
@@ -3,7 +3,7 @@
 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
index b775866e28c9f450d8ed218376158897714d6901..ff86a976d459b6a69b5e142674c3e7cbacff39cf 100644 (file)
@@ -1,7 +1,7 @@
 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
index dd8f8afb5b26ce23d8d28dd600e5c5f257abd616..e765d60467e10b80ad5f60bf933febc3dd4497c9 100644 (file)
@@ -1,7 +1,7 @@
 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
index 6ed0ecf2e7323f8ce35c7a9a633b7558c55d4711..99627546131d507c16225b6287f4188c3b3a3cd6 100644 (file)
@@ -26,7 +26,7 @@
  * 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
@@ -328,5 +328,6 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
        finish_test();
     }
 
+    free(expected);
     ExitProgram(EXIT_SUCCESS);
 }
index 1025c9f2f25127f342544ce4d0c88db0c3f9fb98..7bc909745a2a5c2144b4e003878a6d798aaf8a0f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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>
 
@@ -252,8 +253,10 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
        case 'd':
            if (log_option)
                dump_window(stdscr);
+#if HAVE_SCR_DUMP
            else
                scr_dump(dump_log);
+#endif
            break;
        case 'h':
            if (left_at > ' ')
index 9f3b4d22d2a62f7dce6699dfa489d2042c98a63f..e0e4852ec92f5a25d7eebc4cf295cb2c666ef62a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -27,7 +27,7 @@
  * 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
@@ -308,7 +308,7 @@ menu_create(ITEM ** items, int count, int ncols, MenuNo number)
 }
 
 static void
-menu_destroy(MENU * m)
+menu_destroy(MENU * m, int itemsToo)
 {
     Trace(("menu_destroy %p", (void *) m));
     if (m != 0) {
@@ -331,18 +331,18 @@ menu_destroy(MENU * m)
                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
     }
 }
 
@@ -932,12 +932,12 @@ perform_menus(void)
 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
@@ -1004,6 +1004,7 @@ main(int argc, char *argv[])
     int c;
 
     setlocale(LC_ALL, "");
+    START_TRACE();
 
     while ((c = getopt(argc, argv, "fht:")) != -1) {
        switch (c) {
index f63850dfd6dce7738c266980ca47fb988c87aba2..6bd067eac86b0e4755655007698e4e109e564ed6 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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"
 
index eb87c90c559e9918d9542b0c2db0993a091e0648..05444f43a039d178f06242187aa39d2e05399a72 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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            *
@@ -26,9 +26,9 @@
  * 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>
@@ -38,7 +38,8 @@
 #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];
@@ -51,7 +52,6 @@ static struct {
     { 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" },
@@ -72,7 +72,8 @@ static struct {
     { 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* */
 
@@ -108,11 +109,6 @@ my_help_edit_field(void)
     free(msgs);
 }
 
-static void
-do_demo(FORM *form)
-{
-}
-
 static FIELD *
 make_label(const char *label, int frow, int fcol)
 {
@@ -147,28 +143,6 @@ erase_form(FORM *f)
     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 *
@@ -291,6 +265,55 @@ my_edit_field(FORM *form, int *result)
     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)
 {
index b5ec9438513b9d6e1a5eac386b96ba5cc6aede81..874b189bb3d694ad793c08db6ab7a5284a967e79 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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            *
@@ -26,7 +26,7 @@
  * 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 */
 
@@ -151,7 +143,6 @@ erase_form(FORM *f)
     werase(w);
     wrefresh(w);
     delwin(s);
-    delwin(w);
 }
 
 static FieldAttrs *
@@ -277,7 +268,7 @@ my_edit_field(FORM *form, int *result)
 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;
 }
@@ -309,13 +300,13 @@ do_demo(FORM *form)
 {
     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;
 
@@ -395,7 +386,6 @@ do_demo(FORM *form)
                refresh();
            }
        }
-       free(old_fields);
        free(new_fields);
     }
 }
index fb1d9fca176ee89329b7c172778f21dcfaf5c5a9..868dbfeda2142abe051f7fa96df96e0b317afab8 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -29,7 +29,7 @@
 /*
  * 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>
@@ -45,6 +45,7 @@ static GCC_NORETURN void finish(int sig);
 
 #define my_pair 1
 
+static WINDOW *global_pad;
 static int shift = 0;
 static bool try_color = FALSE;
 
@@ -69,6 +70,8 @@ static void
 finish(int sig)
 {
     endwin();
+    if (global_pad != NULL)
+       delwin(global_pad);
     ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
@@ -372,7 +375,8 @@ main(int argc, char *argv[])
      * 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) {
index adbd08299d2aa1c0101bc5e4ae1643e985918e29..35e2fc4b44bde72233652c0191d3c2fc4630dfb2 100644 (file)
@@ -26,7 +26,7 @@
  * 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
@@ -62,13 +62,20 @@ static struct timeval initial_time;
 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
@@ -231,7 +238,7 @@ usage(void)
     size_t n;
     for (n = 0; n < SIZEOF(msg); n++)
        fprintf(stderr, "%s\n", msg[n]);
-    ExitProgram(EXIT_FAILURE);
+    finish(EXIT_FAILURE);
 }
 
 int
@@ -314,5 +321,5 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
        finish_test();
     }
 
-    ExitProgram(EXIT_SUCCESS);
+    finish(EXIT_SUCCESS);
 }
index 8874d3358a73ff0ca0f4209104dcb90f1e3d955e..125477f169d9e389e9e3ee7e5810bf7784d5693b 100644 (file)
@@ -30,7 +30,7 @@
 /****************************************************************************
  *  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
@@ -553,8 +553,12 @@ extern int optind;
 /* 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 */
@@ -928,7 +932,7 @@ extern int TABSIZE;
 
 #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
index 8cb12d9fc6e17b25612ae2c912d5a7f24886e827..b24903d541454cbd0c9a895af5fcdbaea548d0e6 100644 (file)
@@ -22,7 +22,7 @@
  * 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
  *
@@ -194,9 +194,9 @@ main(int argc, char *argv[])
                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 |
index 9d582aa0ad55a1b6b0501d6ac5fa0e4fac47636e..0dc7494bda1a75d64b7f222c7b0466ce8ceff0ce 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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  *
@@ -30,7 +30,7 @@
 /*
  * 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.
  */
@@ -43,6 +43,46 @@ static bool f_opt = FALSE;
 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)
 {
@@ -104,6 +144,7 @@ test_setupterm(NCURSES_CONST char *name)
 #endif
        rc = setupterm(name, 0, f_opt ? NULL : &err);
     test_rc(name, rc, err);
+    save_curterm();
 }
 
 static void
@@ -128,7 +169,7 @@ usage(void)
     for (n = 0; n < SIZEOF(msg); ++n) {
        fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    finish(EXIT_FAILURE);
 }
 
 int
@@ -182,6 +223,7 @@ main(int argc, char *argv[])
     if (r_opt) {
        newterm("ansi", stdout, stdin);
        reset_shell_mode();
+       save_curterm();
     }
 
     if (a_opt) {
@@ -203,7 +245,7 @@ main(int argc, char *argv[])
        }
     }
 
-    ExitProgram(EXIT_SUCCESS);
+    finish(EXIT_SUCCESS);
 }
 
 #else /* !HAVE_TIGETSTR */
index fc22216a675a38212a1a273348c04ea88114fe4d..2464ddea8cd15fc56d112862364bb0b305b4d0f4 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * 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>