]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.9 - patch 20130216
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 17 Feb 2013 00:03:45 +0000 (00:03 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 17 Feb 2013 00:03:45 +0000 (00:03 +0000)
+ modify test/testcurs.c to work with mouse for ncurses as it does for
  pdcurses.
+ modify test/knight.c to work with mouse for pdcurses as it does for
  ncurses.
+ modify internal recursion in wgetch() which handles cooked mode to
  check if the call to wgetnstr() returned an error.  This can happen
  when both nocbreak() and nodelay() are set, for instance (report by
  Nils Christopher Brause) (cf: 960418).
+ fixes for issues found by Coverity:
  + add a check for valid position in ClearToEOS()
  + fix in lib_twait.c when --enable-wgetch-events is used, pointer
    use after free.
  + improve a limit-check in make_hash.c
  + fix a memory leak in hashed_db.c

13 files changed:
NEWS
dist.mk
ncurses/base/lib_getch.c
ncurses/tinfo/hashed_db.c
ncurses/tinfo/make_hash.c
ncurses/tty/lib_twait.c
ncurses/tty/tty_update.c
package/debian/changelog
package/ncurses.spec
test/bs.c
test/knight.c
test/ncurses.c
test/testcurs.c

diff --git a/NEWS b/NEWS
index e945c7fa5e366e7afd773012ab6c2b9c051355f1..b32bdd39b42d517c73771c31d4e89153deff1cd8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2021 2013/02/09 22:39:26 tom Exp $
+-- $Id: NEWS,v 1.2023 2013/02/16 21:51:17 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,22 @@ 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.
 
+20130216
+       + modify test/testcurs.c to work with mouse for ncurses as it does for
+         pdcurses.
+       + modify test/knight.c to work with mouse for pdcurses as it does for
+         ncurses.
+       + modify internal recursion in wgetch() which handles cooked mode to
+         check if the call to wgetnstr() returned an error.  This can happen
+         when both nocbreak() and nodelay() are set, for instance (report by
+         Nils Christopher Brause) (cf: 960418).
+       + fixes for issues found by Coverity:
+         + add a check for valid position in ClearToEOS()
+         + fix in lib_twait.c when --enable-wgetch-events is used, pointer
+           use after free.
+         + improve a limit-check in make_hash.c
+         + fix a memory leak in hashed_db.c
+
 20130209
        + modify test/configure script to make it simpler to override names
          of curses-related libraries, to help with linking with pdcurses in
diff --git a/dist.mk b/dist.mk
index fdb69c5ed7df5a2275ef0943b6e916656de145e1..69b7443a51a558d5ad4ae6e57f2af12bba8f2d9d 100644 (file)
--- 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.913 2013/02/09 17:27:48 tom Exp $
+# $Id: dist.mk,v 1.914 2013/02/16 16:48:32 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 = 9
-NCURSES_PATCH = 20130209
+NCURSES_PATCH = 20130216
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 575d112b81ad0764388ff9441ab17b688a44fa98..0a04ef5a6e1bf1728b98a2a14aa52b625f704879 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2012,2013 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            *
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.125 2012/08/04 17:11:37 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.126 2013/02/16 18:30:37 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -439,11 +439,11 @@ _nc_wgetch(WINDOW *win,
        /* ungetch in reverse order */
 #ifdef NCURSES_WGETCH_EVENTS
        rc = recur_wgetnstr(win, buf);
-       if (rc != KEY_EVENT)
+       if (rc != KEY_EVENT && rc != ERR)
            safe_ungetch(sp, '\n');
 #else
-       (void) recur_wgetnstr(win, buf);
-       safe_ungetch(sp, '\n');
+       if (recur_wgetnstr(win, buf) != ERR)
+           safe_ungetch(sp, '\n');
 #endif
        for (bufp = buf + strlen(buf); bufp > buf; bufp--)
            safe_ungetch(sp, bufp[-1]);
index 730458503d6944ddb8ae66906749bb7c6c36445f..1b3eb97dd92e3f6675fa1aa1f2fc1d9cc9cadf14 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2006-2008,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 2006-2011,2013 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            *
@@ -36,7 +36,7 @@
 
 #if USE_HASHED_DB
 
-MODULE_ID("$Id: hashed_db.c,v 1.15 2011/08/13 21:08:08 tom Exp $")
+MODULE_ID("$Id: hashed_db.c,v 1.16 2013/02/16 21:50:03 tom Exp $")
 
 #if HASHED_DB_API >= 2
 static DBC *cursor;
@@ -105,6 +105,8 @@ make_connection(DB * db, const char *path, bool modify)
        if (p->path != 0) {
            p->next = connections;
            connections = p;
+       } else {
+           free(p);
        }
     }
 }
index 83e8a6881d07bb710a72cd2d79754367b2babdb9..31f21005f4187c639084c3edc4e65e1cb66581bf 100644 (file)
@@ -44,7 +44,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: make_hash.c,v 1.11 2013/01/26 22:00:11 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.12 2013/02/16 21:27:50 tom Exp $")
 
 /*
  *     _nc_make_hash_table()
@@ -155,7 +155,7 @@ parse_columns(char *buffer)
 
     int col = 0;
 
-    if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
+    if (list == 0 && (list = typeCalloc(char *, (MAX_COLUMNS + 1))) == 0)
          return (0);
 
     if (*buffer != '#') {
index cb04679a62420906926e6c2e0d06ad0754b12c38..1d6cf10ecd820733189eedf71b49c3ca711d3a6d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2012,2013 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            *
@@ -75,7 +75,7 @@
 #endif
 #undef CUR
 
-MODULE_ID("$Id: lib_twait.c,v 1.65 2012/10/27 20:42:47 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.66 2013/02/16 20:52:07 tom Exp $")
 
 static long
 _nc_gettime(TimeType * t0, int first)
@@ -289,10 +289,6 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
            }
        }
     }
-
-    if (fds != fd_list)
-       free((char *) fds);
-
 #endif
 
 #elif defined(__BEOS__)
@@ -505,5 +501,10 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
        result |= TW_EVENT;
 #endif
 
+#ifdef NCURSES_WGETCH_EVENTS
+    if (fds != fd_list)
+       free((char *) fds);
+#endif
+
     return (result);
 }
index 3253e54937cb92e433bdb889a45b7717b8e5ed55..3addd02e745717ef290c12c7887c9e7b583cdc89 100644 (file)
@@ -82,7 +82,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.275 2013/01/20 00:34:46 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.276 2013/02/16 21:12:02 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -1118,6 +1118,11 @@ ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
     row = SP_PARM->_cursrow;
     col = SP_PARM->_curscol;
 
+    if (row < 0)
+       row = 0;
+    if (col < 0)
+       col = 0;
+
     UpdateAttrs(SP_PARM, blank);
     TPUTS_TRACE("clr_eos");
     NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
index c77c41d35192d2ecbcdd4b54e1c43e21cf0bef33..9b5d694c020ca74fb17cb32088e4cb7344a2cdc8 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20130209) unstable; urgency=low
+ncurses6 (5.9-20130216) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 09 Feb 2013 12:28:44 -0500
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Sat, 16 Feb 2013 11:48:20 -0500
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index b6d433430b69148279daf4a1bd5b5deba723565e..61b51ffbee0380bd3ae41c4ea06490346da73bd9 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Release: 5.9
-Version: 20130209
+Version: 20130216
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{release}-%{version}.tgz
index ebcabc42d3bfabd7f4b75d747e30e53e60c1bc83..9a43e6233bd2240ccce91967fe379d2f2429a830 100644 (file)
--- a/test/bs.c
+++ b/test/bs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2012,2013 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            *
@@ -34,7 +34,7 @@
  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
  * v2.1 with ncurses mouse support, September 1995
  *
- * $Id: bs.c,v 1.59 2012/12/16 00:20:49 tom Exp $
+ * $Id: bs.c,v 1.60 2013/02/16 19:54:37 tom Exp $
  */
 
 #include <test.priv.h>
@@ -956,7 +956,7 @@ cpufire(int x, int y)
     bool hit, sunk;
     ship_t *ss = NULL;
 
-    hit = board[PLAYER][x][y];
+    hit = (bool) board[PLAYER][x][y];
     hits[COMPUTER][x][y] = (hit ? MARK_HIT : MARK_MISS);
     MvPrintw(PROMPTLINE, 0,
             "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" :
index b1215fcc9d954bda9df593e87d437dcbc970147e..ae9d223441bfbc0ab3d1e14f0fcf1e550e72f53c 100644 (file)
@@ -33,7 +33,7 @@
  * Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995.  Mouse support
  * added September 20th 1995.
  *
- * $Id: knight.c,v 1.35 2013/02/03 00:16:59 tom Exp $
+ * $Id: knight.c,v 1.36 2013/02/16 19:53:08 tom Exp $
  */
 
 #include <test.priv.h>
@@ -130,6 +130,9 @@ init_program(void)
 #ifdef NCURSES_MOUSE_VERSION
     (void) mousemask(BUTTON1_CLICKED, (mmask_t *) NULL);
 #endif /* NCURSES_MOUSE_VERSION */
+#if defined(PDCURSES)
+    mouse_set(BUTTON1_RELEASED);
+#endif
 
     oldch = minus;
 }
@@ -577,8 +580,9 @@ play(void)
                nx = col + 1;
                break;
 
-#ifdef NCURSES_MOUSE_VERSION
+#ifdef KEY_MOUSE
            case KEY_MOUSE:
+#ifdef NCURSES_MOUSE_VERSION
                {
                    MEVENT myevent;
 
@@ -595,6 +599,24 @@ play(void)
                    }
                }
 #endif /* NCURSES_MOUSE_VERSION */
+#ifdef PDCURSES
+               {
+                   int test_y, test_x;
+                   request_mouse_pos();
+                   test_y = MOUSE_Y_POS + 0;
+                   test_x = MOUSE_X_POS + 1;
+                   if (test_y >= CY(0) && test_y <= CY(BDEPTH)
+                       && test_x >= CX(0) && test_x <= CX(BWIDTH)) {
+                       ny = CYINV(test_y);
+                       nx = CXINV(test_x);
+                       wmove(helpwin, 0, 0);
+                       wrefresh(helpwin);
+                       ungetch('\n');
+                   }
+                   break;
+               }
+#endif /* PDCURSES */
+#endif /* KEY_MOUSE */
 
            case KEY_B2:
            case '\n':
index b18205dcac490b6f6adbe081bdb98e808541493a..cea9090fcc87a191d53e7c16eefefa658d11371d 100644 (file)
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.387 2013/01/13 00:40:17 tom Exp $
+$Id: ncurses.c,v 1.388 2013/02/16 18:56:30 tom Exp $
 
 ***************************************************************************/
 
@@ -6922,7 +6922,7 @@ main(int argc, char *argv[])
     bkgdset(BLANK);
 
     /* tests, in general, will want these modes */
-    use_colors = monochrome ? FALSE : has_colors();
+    use_colors = (bool) (monochrome ? FALSE : has_colors());
 
     if (use_colors) {
        start_color();
index 8310f3f855915b4ef73d3d3d74801fc5f7ffb3c5..579b9977d8689d7df8e3bd5082dbd42169db2298 100644 (file)
@@ -6,7 +6,7 @@
  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
  *                  PDCurses or under Unix System V, R4
  *
- * $Id: testcurs.c,v 1.46 2012/11/24 19:38:20 tom Exp $
+ * $Id: testcurs.c,v 1.47 2013/02/16 20:29:04 tom Exp $
  */
 
 #include <test.priv.h>
@@ -341,6 +341,9 @@ inputTest(WINDOW *win)
     typeahead(-1);
 #endif
 
+#ifdef NCURSES_MOUSE_VERSION
+    mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+#endif
 #if defined(PDCURSES)
     mouse_set(ALL_MOUSE_EVENTS);
 #endif
@@ -355,8 +358,38 @@ inputTest(WINDOW *win)
            wprintw(win, "Key Pressed: %c", c);
        else
            wprintw(win, "Key Pressed: %s", unctrl(UChar(c)));
-#if defined(PDCURSES)
+#ifdef KEY_MOUSE
+#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, 037))
+#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED))
+#define ButtonDouble(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED))
+#define ButtonTriple(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED))
+#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED))
        if (c == KEY_MOUSE) {
+           MEVENT event;
+           int button = 0;
+
+           getmouse(&event);
+           if (ButtonChanged(1))
+               button = 1;
+           else if (ButtonChanged(2))
+               button = 2;
+           else if (ButtonChanged(3))
+               button = 3;
+           else
+               button = 0;
+           wmove(win, 4, 18);
+           wprintw(win, "Button %d: ", button);
+           if (ButtonPressed(button))
+               wprintw(win, "pressed: ");
+           else if (ButtonDouble(button))
+               wprintw(win, "double: ");
+           else if (ButtonTriple(button))
+               wprintw(win, "triple: ");
+           else
+               wprintw(win, "released: ");
+           wprintw(win, " Position: Y: %d X: %d", event.y, event.x);
+#if defined(NCURSES_MOUSE_VERSION)
+#elif defined(PDCURSES)
            int button = 0;
            request_mouse_pos();
            if (BUTTON_CHANGED(1))
@@ -378,8 +411,9 @@ inputTest(WINDOW *win)
            else
                wprintw(win, "released: ");
            wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
+#endif /* PDCURSES */
        }
-#endif
+#endif /* KEY_MOUSE */
        wrefresh(win);
        if (c == ' ')
            break;