]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080804
authorThomas E. Dickey <dickey@invisible-island.net>
Tue, 5 Aug 2008 01:06:16 +0000 (01:06 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Tue, 5 Aug 2008 01:06:16 +0000 (01:06 +0000)
+ modify _nc_panelhook() data to account for a permanent memory leak.
+ fix memory leaks in test/demo_menus
+ fix most warnings from Klocwork tool (report by Larry Zhou).
+ modify configure script CF_XOPEN_SOURCE macro to add case for
  "dragonfly" from xterm #236 changes.
+ modify configure script --with-hashed-db to let $LIBS override the
  search for the db library (prompted by report by Samson Pierre).

63 files changed:
NEWS
aclocal.m4
c++/cursespad.cc
c++/demo.cc
configure
dist.mk
form/frm_def.c
include/capdefaults.c
include/nc_panel.h
menu/m_driver.c
misc/ncu-indent
ncurses/base/lib_freeall.c
ncurses/base/lib_getch.c
ncurses/base/lib_newterm.c
ncurses/base/lib_set_term.c
ncurses/base/lib_slkrefr.c
ncurses/curses.priv.h
ncurses/tinfo/captoinfo.c
ncurses/tinfo/comp_scan.c
ncurses/tinfo/home_terminfo.c
ncurses/tinfo/lib_acs.c
ncurses/tinfo/lib_setup.c
ncurses/tinfo/lib_tparm.c
ncurses/tinfo/lib_ttyflags.c
ncurses/tinfo/make_keys.c
ncurses/tinfo/name_match.c
ncurses/tinfo/parse_entry.c
ncurses/tinfo/read_entry.c
ncurses/tinfo/write_entry.c
ncurses/trace/lib_trace.c
ncurses/trace/lib_traceatr.c
ncurses/trace/lib_tracebits.c
ncurses/trace/lib_tracechr.c
ncurses/trace/lib_tracedmp.c
ncurses/trace/lib_tracemse.c
ncurses/trace/trace_buf.c
ncurses/trace/trace_tries.c
ncurses/trace/varargs.c
ncurses/trace/visbuf.c
ncurses/tty/hardscroll.c
panel/p_new.c
progs/dump_entry.c
progs/infocmp.c
progs/progs.priv.h
progs/tic.c
progs/toe.c
progs/tset.c
test/blue.c
test/bs.c
test/cardfile.c
test/demo_defkey.c
test/demo_forms.c
test/demo_menus.c
test/demo_panels.c
test/ditto.c
test/gdc.c
test/hanoi.c
test/knight.c
test/ncurses.c
test/newdemo.c
test/testcurs.c
test/view.c
test/xmas.c

diff --git a/NEWS b/NEWS
index 9ed4a8a974e40a2da184ecea7a4766a73c908c36..d554a553cbb7f48bcf4eb12776db9ec84b07cced 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1256 2008/07/26 19:33:40 tom Exp $
+-- $Id: NEWS,v 1.1261 2008/08/04 18:22:11 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,15 @@ 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.
 
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20080804
+       + modify _nc_panelhook() data to account for a permanent memory leak.
+       + fix memory leaks in test/demo_menus
+       + fix most warnings from Klocwork tool (report by Larry Zhou).
+       + modify configure script CF_XOPEN_SOURCE macro to add case for
+         "dragonfly" from xterm #236 changes.
+       + modify configure script --with-hashed-db to let $LIBS override the
+         search for the db library (prompted by report by Samson Pierre).
+
 20080726
        + build-fixes for gcc 4.3.1 (changes to gnat "warnings", and C inlining
          thresholds).
 20080726
        + build-fixes for gcc 4.3.1 (changes to gnat "warnings", and C inlining
          thresholds).
index a37d3c3a339bb7121b8ff2d2870fa0daea54c52b..0c15200e20bdfc1daf7c0f266b7c0a30d957661c 100644 (file)
@@ -28,7 +28,7 @@ dnl***************************************************************************
 dnl
 dnl Author: Thomas E. Dickey 1995-on
 dnl
 dnl
 dnl Author: Thomas E. Dickey 1995-on
 dnl
-dnl $Id: aclocal.m4,v 1.450 2008/07/26 21:57:19 tom Exp $
+dnl $Id: aclocal.m4,v 1.451 2008/08/04 10:26:11 tom Exp $
 dnl Macros used in NCURSES auto-configuration script.
 dnl
 dnl These macros are maintained separately from NCURSES.  The copyright on
 dnl Macros used in NCURSES auto-configuration script.
 dnl
 dnl These macros are maintained separately from NCURSES.  The copyright on
@@ -1715,7 +1715,7 @@ fi
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_HASHED_DB_LIBS version: 7 updated: 2007/12/01 15:01:37
+dnl CF_HASHED_DB_LIBS version: 8 updated: 2008/08/04 06:18:06
 dnl -----------------
 dnl Given that we have the header and version for hashed database, find the
 dnl library information.
 dnl -----------------
 dnl Given that we have the header and version for hashed database, find the
 dnl library information.
@@ -1723,7 +1723,7 @@ AC_DEFUN([CF_HASHED_DB_LIBS],
 [
 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
 cf_cv_hashed_db_libs=unknown
 [
 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
 cf_cv_hashed_db_libs=unknown
-for cf_db_libs in db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
+for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
 do
        cf_save_libs="$LIBS"
        if test -n "$cf_db_libs"; then
 do
        cf_save_libs="$LIBS"
        if test -n "$cf_db_libs"; then
@@ -5228,7 +5228,7 @@ CF_NO_LEAKS_OPTION(valgrind,
        [USE_VALGRIND])
 ])dnl
 dnl ---------------------------------------------------------------------------
        [USE_VALGRIND])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 25 updated: 2007/01/29 18:36:38
+dnl CF_XOPEN_SOURCE version: 26 updated: 2008/07/27 11:26:57
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality,
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality,
@@ -5248,7 +5248,7 @@ case $host_os in #(vi
 aix[[45]]*) #(vi
        CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
        ;;
 aix[[45]]*) #(vi
        CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
        ;;
-freebsd*) #(vi
+freebsd*|dragonfly*) #(vi
        # 5.x headers associate
        #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
        #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
        # 5.x headers associate
        #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
        #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
index 3685c5e5b35fc4c4977a6130ba2703c7d238d546..28c58fab36acaae85ff1016ecc5effdf639cf842 100644 (file)
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * 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 @@
 #include <etip.h>
 #include <cursesw.h>
 
 #include <etip.h>
 #include <cursesw.h>
 
-MODULE_ID("$Id: cursespad.cc,v 1.12 2007/04/07 18:43:54 tom Exp $")
+MODULE_ID("$Id: cursespad.cc,v 1.13 2008/08/04 18:59:22 tom Exp $")
 
 NCursesPad::NCursesPad(int nlines, int ncols)
   : NCursesWindow(),
 
 NCursesPad::NCursesPad(int nlines, int ncols)
   : NCursesWindow(),
@@ -212,6 +212,7 @@ void NCursesPad::setSubWindow(NCursesWindow& sub)
 {
   if (static_cast<NCursesWindow*>(0) == viewWin)
     err_handler("Pad has no viewport");
 {
   if (static_cast<NCursesWindow*>(0) == viewWin)
     err_handler("Pad has no viewport");
+  assert(viewWin != 0);
   if (!viewWin->isDescendant(sub))
     THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR));
   viewSub = &sub;
   if (!viewWin->isDescendant(sub))
     THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR));
   viewSub = &sub;
index 8fa19ad2652c0595d751fc1b1d990ff2cd539c61..ddd5f2b3e10d5ca6a86d14cc573cdcb5590c97ab 100644 (file)
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +35,7 @@
  *   Demo code for NCursesMenu and NCursesForm written by
  *   Juergen Pfeifer
  *
  *   Demo code for NCursesMenu and NCursesForm written by
  *   Juergen Pfeifer
  *
- * $Id: demo.cc,v 1.36 2007/04/07 20:24:49 tom Exp $
+ * $Id: demo.cc,v 1.38 2008/08/04 17:16:57 tom Exp $
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
@@ -312,6 +312,7 @@ public:
     Soft_Label_Key_Set* S = new Soft_Label_Key_Set;
     for(int i=1; i <= S->labels(); i++) {
       char buf[8];
     Soft_Label_Key_Set* S = new Soft_Label_Key_Set;
     for(int i=1; i <= S->labels(); i++) {
       char buf[8];
+      assert(i < 100);
       ::sprintf(buf, "Frm%02d", i);
       (*S)[i] = buf;                                      // Text
       (*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
       ::sprintf(buf, "Frm%02d", i);
       (*S)[i] = buf;                                      // Text
       (*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
@@ -319,6 +320,7 @@ public:
     NCursesApplication::getApplication()->push(*S);
     F();
     NCursesApplication::getApplication()->pop();
     NCursesApplication::getApplication()->push(*S);
     F();
     NCursesApplication::getApplication()->pop();
+    delete S;
     return FALSE;
   }
 };
     return FALSE;
   }
 };
@@ -530,6 +532,7 @@ void TestApplication::init_labels(Soft_Label_Key_Set& S) const
 {
   for(int i=1; i <= S.labels(); i++) {
     char buf[8];
 {
   for(int i=1; i <= S.labels(); i++) {
     char buf[8];
+    assert(i < 100);
     ::sprintf(buf, "Key%02d", i);
     S[i] = buf;                                      // Text
     S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
     ::sprintf(buf, "Key%02d", i);
     S[i] = buf;                                      // Text
     S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
index 890a9d362b58c2a23cb1cdce6326bc7c185de743..0eee83a2b0085721bece326e553509f9af38a58e 100755 (executable)
--- a/configure
+++ b/configure
@@ -6178,7 +6178,7 @@ case $host_os in #(vi
 aix[45]*) #(vi
        CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
        ;;
 aix[45]*) #(vi
        CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
        ;;
-freebsd*) #(vi
+freebsd*|dragonfly*) #(vi
        # 5.x headers associate
        #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
        #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
        # 5.x headers associate
        #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
        #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
@@ -13937,7 +13937,7 @@ if test "${cf_cv_hashed_db_libs+set}" = set; then
 else
 
 cf_cv_hashed_db_libs=unknown
 else
 
 cf_cv_hashed_db_libs=unknown
-for cf_db_libs in db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
+for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
 do
        cf_save_libs="$LIBS"
        if test -n "$cf_db_libs"; then
 do
        cf_save_libs="$LIBS"
        if test -n "$cf_db_libs"; then
diff --git a/dist.mk b/dist.mk
index 43fbf143a9e5ceed26bf604a58bf256cc4dea622..a17315defa582082eee644e3dea02689d85105f7 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.652 2008/07/26 17:36:20 tom Exp $
+# $Id: dist.mk,v 1.654 2008/08/04 23:50:26 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
 # 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 = 6
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
-NCURSES_PATCH = 20080726
+NCURSES_PATCH = 20080804
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index c2044a39dccd153e579825150c1e5e90fa502bcb..e6897514ffddfe9cd24e9ed37f4668764d0c67e3 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +32,7 @@
 
 #include "form.priv.h"
 
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_def.c,v 1.22 2007/10/13 19:31:17 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.23 2008/08/04 00:07:55 tom Exp $")
 
 /* this can't be readonly */
 static FORM default_form =
 
 /* this can't be readonly */
 static FORM default_form =
@@ -234,8 +234,16 @@ Connect_Fields(FORM *form, FIELD **fields)
          fields[j]->page = page_nr;
          fld = Insert_Field_By_Position(fields[j], fld);
        }
          fields[j]->page = page_nr;
          fld = Insert_Field_By_Position(fields[j], fld);
        }
-      form->page[page_nr].smin = fld->index;
-      form->page[page_nr].smax = fld->sprev->index;
+      if (fld)
+       {
+         form->page[page_nr].smin = fld->index;
+         form->page[page_nr].smax = fld->sprev->index;
+       }
+      else
+       {
+         form->page[page_nr].smin = 0;
+         form->page[page_nr].smax = 0;
+       }
     }
   RETURN(E_OK);
 }
     }
   RETURN(E_OK);
 }
index 071f9e17cdbb427da028f3724274285eea1d8706..33f2fe8f029909a71105646fa442b822e74d4937 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
  ****************************************************************************/
 
-/* $Id: capdefaults.c,v 1.12 2000/01/02 02:34:56 tom Exp $ */
+/* $Id: capdefaults.c,v 1.13 2008/08/04 12:33:42 tom Exp $ */
 
     /*
      * Compute obsolete capabilities.  The reason this is an include file is
 
     /*
      * Compute obsolete capabilities.  The reason this is an include file is
      */
 {
     char *sp;
      */
 {
     char *sp;
-    int capval;
+    short capval;
 
 
-#define EXTRACT_DELAY(str)     (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
+#define EXTRACT_DELAY(str) \
+       (short) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
 
     /* current (4.4BSD) capabilities marked obsolete */
     if (VALID_STRING(carriage_return)
 
     /* current (4.4BSD) capabilities marked obsolete */
     if (VALID_STRING(carriage_return)
@@ -73,8 +75,8 @@
        magic_cookie_glitch_ul = magic_cookie_glitch;
 
     /* totally obsolete capabilities */
        magic_cookie_glitch_ul = magic_cookie_glitch;
 
     /* totally obsolete capabilities */
-    linefeed_is_newline = VALID_STRING(newline)
-       && (strcmp("\n", newline) == 0);
+    linefeed_is_newline = (char) (VALID_STRING(newline)
+                                 && (strcmp("\n", newline) == 0));
     if (VALID_STRING(cursor_left)
        && (capval = EXTRACT_DELAY(cursor_left)))
        backspace_delay = capval;
     if (VALID_STRING(cursor_left)
        && (capval = EXTRACT_DELAY(cursor_left)))
        backspace_delay = capval;
index bb1f6745ac0cad4ffe58eb0e2213666700956d95..6578577ee9887d4ac1738a75795d685d9692b07d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  ****************************************************************************/
 
 /****************************************************************************
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author: Juergen Pfeifer                        1997                     *
+ *     and: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 
 /*
  ****************************************************************************/
 
 
 /*
- * $Id: nc_panel.h,v 1.3 2000/12/10 02:04:35 tom Exp $
+ * $Id: nc_panel.h,v 1.5 2008/08/04 18:26:46 tom Exp $
  *
  *     nc_panel.h
  *
  *
  *     nc_panel.h
  *
@@ -54,6 +54,9 @@ struct panelhook {
   struct panel*   top_panel;
   struct panel*   bottom_panel;
   struct panel*   stdscr_pseudo_panel;
   struct panel*   top_panel;
   struct panel*   bottom_panel;
   struct panel*   stdscr_pseudo_panel;
+#if NO_LEAKS
+  int (*destroy)(struct panel *);
+#endif
 };
 
 /* Retrieve the panelhook of the current screen */
 };
 
 /* Retrieve the panelhook of the current screen */
index 27f9fbad49fb2f4a1a4d03a6bad2f4c9592991f0..d418e6a2255767f35060c46ee2ef9ea618f977ea 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_driver.c,v 1.26 2008/07/05 20:54:33 tom Exp $")
+MODULE_ID("$Id: m_driver.c,v 1.27 2008/08/03 22:08:22 tom Exp $")
 
 /* Macros */
 
 
 /* Macros */
 
@@ -303,7 +303,7 @@ menu_driver(MENU * menu, int c)
          else
            {
              my_top_row += rdiff;
          else
            {
              my_top_row += rdiff;
-             while (rdiff-- > 0 && item != (ITEM *) 0)
+             while (rdiff-- > 0 && item != 0 && item->down != 0)
                item = item->down;
            }
          break;
                item = item->down;
            }
          break;
@@ -316,7 +316,7 @@ menu_driver(MENU * menu, int c)
          else
            {
              my_top_row -= rdiff;
          else
            {
              my_top_row -= rdiff;
-             while (rdiff-- && item != (ITEM *) 0)
+             while (rdiff-- > 0 && item != 0 && item->up != 0)
                item = item->up;
            }
          break;
                item = item->up;
            }
          break;
index 1e1c7fffaeb20dfa0bb7d203126c990bde13f448..862a108a3b3185cc9c59b0c371f49abe73ff7f41 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #****************************************************************************
 #!/bin/sh
 #****************************************************************************
-#* Copyright (c) 2001-2005,2006 Thomas E. Dickey                            *
+#* Copyright (c) 2001-2006,2008 Thomas E. Dickey                            *
 #*                                                                          *
 #* Permission is hereby granted, free of charge, to any person obtaining a  *
 #* copy of this software and associated documentation files (the            *
 #*                                                                          *
 #* 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 @@
 #* sale, use or other dealings in this Software without prior written       *
 #* authorization.                                                           *
 #****************************************************************************/
 #* sale, use or other dealings in this Software without prior written       *
 #* authorization.                                                           *
 #****************************************************************************/
-# $Id: ncu-indent,v 1.16 2006/02/18 17:02:22 tom Exp $
+# $Id: ncu-indent,v 1.17 2008/08/03 15:46:44 tom Exp $
 NOOP=no
 OPTS='
 --blank-lines-after-procedures
 NOOP=no
 OPTS='
 --blank-lines-after-procedures
@@ -87,6 +87,7 @@ do
                rm -f "$save" "$test"
                mv "$name" "$save"
                sed \
                rm -f "$save" "$test"
                mv "$name" "$save"
                sed \
+                       -e '/EMPTY_MODULE(/s/)$/);/' \
                        -e '/MODULE_ID(/s/)$/);/' \
                        -e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
                        -e 's,\<GCC_PRINTFLIKE(,;//GCC_PRINTFLIKE(,' \
                        -e '/MODULE_ID(/s/)$/);/' \
                        -e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
                        -e 's,\<GCC_PRINTFLIKE(,;//GCC_PRINTFLIKE(,' \
@@ -98,6 +99,7 @@ do
                # ${INDENT_PROG-indent} --version
                ${INDENT_PROG-indent} -npro $OPTS "$name"
                sed \
                # ${INDENT_PROG-indent} --version
                ${INDENT_PROG-indent} -npro $OPTS "$name"
                sed \
+                       -e '/EMPTY_MODULE(/s/);$/)/' \
                        -e '/MODULE_ID(/s/);$/)/' \
                        -e 's,;[        ]*//GCC_NORETURN;, GCC_NORETURN;,' \
                        -e 's,;[        ]*//GCC_PRINTFLIKE(, GCC_PRINTFLIKE(,' \
                        -e '/MODULE_ID(/s/);$/)/' \
                        -e 's,;[        ]*//GCC_NORETURN;, GCC_NORETURN;,' \
                        -e 's,;[        ]*//GCC_PRINTFLIKE(, GCC_PRINTFLIKE(,' \
index b06123d2593fa09288fe93beeea1987dc54ca115..bb8bd5aa142ecf0386c9c42dedcd0f992826f513 100644 (file)
@@ -40,7 +40,7 @@
 extern int malloc_errfd;       /* FIXME */
 #endif
 
 extern int malloc_errfd;       /* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.49 2008/06/21 21:26:33 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.50 2008/08/04 18:29:12 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
@@ -58,6 +58,9 @@ _nc_freeall(void)
        if (SP->_oldnum_list != 0) {
            FreeAndNull(SP->_oldnum_list);
        }
        if (SP->_oldnum_list != 0) {
            FreeAndNull(SP->_oldnum_list);
        }
+       if (SP->_panelHook.destroy != 0) {
+           SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+       }
     }
 #endif
     if (SP != 0) {
     }
 #endif
     if (SP != 0) {
index 56e2a3a874d1de3d1f3efc021493b19f7527c3f0..c7ca7aaa43084bc40c0b3d66de092381cbee9860 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.96 2008/06/28 23:29:20 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.97 2008/08/03 22:56:42 tom Exp $")
 
 #include <fifo_defs.h>
 
 
 #include <fifo_defs.h>
 
@@ -284,23 +284,27 @@ recur_wgetnstr(WINDOW *win, char *buf)
     SCREEN *sp = _nc_screen_of(win);
     int rc;
 
     SCREEN *sp = _nc_screen_of(win);
     int rc;
 
+    if (sp != 0) {
 #ifdef USE_PTHREADS
 #ifdef USE_PTHREADS
-    if (sp != SP) {
-       SCREEN *save_SP;
-
-       /* temporarily switch to the window's screen to get cooked input */
-       _nc_lock_global(curses);
-       save_SP = SP;
-       _nc_set_screen(sp);
-       rc = recur_wgetnstr(win, buf);
-       _nc_set_screen(save_SP);
-       _nc_unlock_global(curses);
-    } else
+       if (sp != SP) {
+           SCREEN *save_SP;
+
+           /* temporarily switch to the window's screen to get cooked input */
+           _nc_lock_global(curses);
+           save_SP = SP;
+           _nc_set_screen(sp);
+           rc = recur_wgetnstr(win, buf);
+           _nc_set_screen(save_SP);
+           _nc_unlock_global(curses);
+       } else
 #endif
 #endif
-    {
-       sp->_called_wgetch = TRUE;
-       rc = wgetnstr(win, buf, MAXCOLUMNS);
-       sp->_called_wgetch = FALSE;
+       {
+           sp->_called_wgetch = TRUE;
+           rc = wgetnstr(win, buf, MAXCOLUMNS);
+           sp->_called_wgetch = FALSE;
+       }
+    } else {
+       rc = ERR;
     }
     return rc;
 }
     }
     return rc;
 }
index 3e6034c271f11bc2b01d656f9effd48e25458dfc..c467a60871ee8a2cc3d4531c875346e9673ffe90 100644 (file)
@@ -48,7 +48,7 @@
 #include <term.h>              /* clear_screen, cup & friends, cur_term */
 #include <tic.h>
 
 #include <term.h>              /* clear_screen, cup & friends, cur_term */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_newterm.c,v 1.71 2008/06/21 20:55:11 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.72 2008/08/03 22:49:49 tom Exp $")
 
 #ifndef ONLCR                  /* Allows compilation under the QNX 4.2 OS */
 #define ONLCR 0
 
 #ifndef ONLCR                  /* Allows compilation under the QNX 4.2 OS */
 #define ONLCR 0
@@ -158,6 +158,7 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
            _nc_set_screen(current);
            result = 0;
        } else {
            _nc_set_screen(current);
            result = 0;
        } else {
+           assert(SP != 0);
            /*
             * In setupterm() we did a set_curterm(), but it was before we set
             * SP.  So the "current" screen's terminal pointer was overwritten
            /*
             * In setupterm() we did a set_curterm(), but it was before we set
             * SP.  So the "current" screen's terminal pointer was overwritten
index 6fbf6ad76f4f6c80e0abe4167ecd0b7d282da7c4..aff432bb9fd1a3dc8fde612794d5fd9afae79dc1 100644 (file)
@@ -44,7 +44,7 @@
 #include <term.h>              /* cur_term */
 #include <tic.h>
 
 #include <term.h>              /* cur_term */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_set_term.c,v 1.115 2008/06/28 15:33:52 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.117 2008/08/04 18:11:12 tom Exp $")
 
 NCURSES_EXPORT(SCREEN *)
 set_term(SCREEN *screenp)
 
 NCURSES_EXPORT(SCREEN *)
 set_term(SCREEN *screenp)
@@ -359,11 +359,10 @@ _nc_setupscreen(int slines GCC_UNUSED,
      * Allow those assumed/default color assumptions to be overridden at
      * runtime:
      */
      * Allow those assumed/default color assumptions to be overridden at
      * runtime:
      */
-    if (getenv("NCURSES_ASSUMED_COLORS") != 0) {
-       char *p = getenv("NCURSES_ASSUMED_COLORS");
+    if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
        int fg, bg;
        char sep1, sep2;
        int fg, bg;
        char sep1, sep2;
-       int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+       int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
        if (count >= 1) {
            SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
            if (count >= 3) {
        if (count >= 1) {
            SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
            if (count >= 3) {
@@ -419,11 +418,6 @@ _nc_setupscreen(int slines GCC_UNUSED,
     SP->_mouse_wrap = no_mouse_wrap;
     SP->_mouse_fd = -1;
 
     SP->_mouse_wrap = no_mouse_wrap;
     SP->_mouse_fd = -1;
 
-    /* initialize the panel hooks */
-    SP->_panelHook.top_panel = (struct panel *) 0;
-    SP->_panelHook.bottom_panel = (struct panel *) 0;
-    SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
-
     /*
      * If we've no magic cookie support, we suppress attributes that xmc would
      * affect, i.e., the attributes that affect the rendition of a space.
     /*
      * If we've no magic cookie support, we suppress attributes that xmc would
      * affect, i.e., the attributes that affect the rendition of a space.
index c8ca28b9dd84387d2e9d1a22a7ad8963f2967f43..20a2198e2d74f4f190956dac7c0572b0bf23c519 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* num_labels, label_*, plab_norm */
 
 #include <curses.priv.h>
 #include <term.h>              /* num_labels, label_*, plab_norm */
 
-MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.16 2008/08/03 22:40:27 tom Exp $")
 
 /*
  * Write the soft labels to the soft-key window.
 
 /*
  * Write the soft labels to the soft-key window.
@@ -61,7 +61,7 @@ slk_intern_refresh(SLK * slk)
                    }
                } else {
                    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
                    }
                } else {
                    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
-                   if (SP && SP->_slk) {
+                   if (SP->_slk) {
                        wattrset(slk->win, AttrOf(SP->_slk->attr));
                    }
                    waddstr(slk->win, slk->ent[i].form_text);
                        wattrset(slk->win, AttrOf(SP->_slk->attr));
                    }
                    waddstr(slk->win, slk->ent[i].form_text);
index c6fda33d745d77961c6088da4c9c55dc828fbd87..5a39028ff54137acbae25728687fbcaa11a42a27 100644 (file)
@@ -34,7 +34,7 @@
 
 
 /*
 
 
 /*
- * $Id: curses.priv.h,v 1.386 2008/06/28 15:27:47 tom Exp $
+ * $Id: curses.priv.h,v 1.387 2008/08/03 15:39:29 tom Exp $
  *
  *     curses.priv.h
  *
  *
  *     curses.priv.h
  *
@@ -1307,7 +1307,7 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
 extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
 
 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
 extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
 
-#define empty_module(name) \
+#define EMPTY_MODULE(name) \
 extern NCURSES_EXPORT(void) name (void); \
        NCURSES_EXPORT(void) name (void) { }
 
 extern NCURSES_EXPORT(void) name (void); \
        NCURSES_EXPORT(void) name (void) { }
 
index 0e3baa845693268f84b1023dd6617649cce86d4b..ef68b04d5d90f4920a2f0cc82d218cbe0079bcd4 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -93,7 +93,7 @@
 #include <ctype.h>
 #include <tic.h>
 
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.49 2006/12/16 19:16:53 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.51 2008/08/03 18:35:47 tom Exp $")
 
 #define MAX_PUSHED     16      /* max # args we can push onto the stack */
 
 
 #define MAX_PUSHED     16      /* max # args we can push onto the stack */
 
@@ -149,7 +149,7 @@ static void
 push(void)
 /* push onstack on to the stack */
 {
 push(void)
 /* push onstack on to the stack */
 {
-    if (stackptr > MAX_PUSHED)
+    if (stackptr >= MAX_PUSHED)
        _nc_warning("string too complex to convert");
     else
        stack[stackptr++] = onstack;
        _nc_warning("string too complex to convert");
     else
        stack[stackptr++] = onstack;
@@ -788,6 +788,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
            }                   /* endswitch (*str) */
        }                       /* endelse (*str == '%') */
 
            }                   /* endswitch (*str) */
        }                       /* endelse (*str == '%') */
 
+       /*
+        * 'str' always points to the end of what was scanned in this step,
+        * but that may not be the end of the string.
+        */
+       assert(str != 0);
        if (*str == '\0')
            break;
 
        if (*str == '\0')
            break;
 
index e937f7eb5adac719db9787a2b771260d098d5838..140960a8c239b5f6fcbf799fa79a4fb991e74a73 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -51,7 +51,7 @@
 #include <term_entry.h>
 #include <tic.h>
 
 #include <term_entry.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_scan.c,v 1.78 2006/12/16 19:17:01 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.82 2008/08/04 20:25:03 tom Exp $")
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
@@ -203,6 +203,7 @@ next_char(void)
                    result = typeRealloc(char, allocated, result);
                    if (result == 0)
                        return (EOF);
                    result = typeRealloc(char, allocated, result);
                    if (result == 0)
                        return (EOF);
+                   bufstart = result;
                }
                if (used == 0)
                    _nc_curr_file_pos = ftell(yyin);
                }
                if (used == 0)
                    _nc_curr_file_pos = ftell(yyin);
@@ -293,6 +294,15 @@ eat_escaped_newline(int ch)
     return ch;
 }
 
     return ch;
 }
 
+#define TOK_BUF_SIZE MAX_ENTRY_SIZE
+
+#define OkToAdd() \
+       ((tok_ptr - tok_buf) < (TOK_BUF_SIZE - 2))
+
+#define AddCh(ch) \
+       *tok_ptr++ = ch; \
+       *tok_ptr = '\0'
+
 /*
  *     int
  *     get_token()
 /*
  *     int
  *     get_token()
@@ -330,12 +340,12 @@ NCURSES_EXPORT(int)
 _nc_get_token(bool silent)
 {
     static const char terminfo_punct[] = "@%&*!#";
 _nc_get_token(bool silent)
 {
     static const char terminfo_punct[] = "@%&*!#";
-    static char *buffer;
+    static char *tok_buf;
 
     char *after_list;
     char *after_name;
     char *numchk;
 
     char *after_list;
     char *after_name;
     char *numchk;
-    char *ptr;
+    char *tok_ptr;
     char *s;
     char numbuf[80];
     int ch;
     char *s;
     char numbuf[80];
     int ch;
@@ -367,10 +377,10 @@ _nc_get_token(bool silent)
     if (end_of_stream()) {
        yyin = 0;
        next_char();            /* frees its allocated memory */
     if (end_of_stream()) {
        yyin = 0;
        next_char();            /* frees its allocated memory */
-       if (buffer != 0) {
-           if (_nc_curr_token.tk_name == buffer)
+       if (tok_buf != 0) {
+           if (_nc_curr_token.tk_name == tok_buf)
                _nc_curr_token.tk_name = 0;
                _nc_curr_token.tk_name = 0;
-           FreeAndNull(buffer);
+           FreeAndNull(tok_buf);
        }
        return (EOF);
     }
        }
        return (EOF);
     }
@@ -426,15 +436,15 @@ _nc_get_token(bool silent)
            goto start_token;
        }
 
            goto start_token;
        }
 
-       if (buffer == 0)
-           buffer = typeMalloc(char, MAX_ENTRY_SIZE);
+       if (tok_buf == 0)
+           tok_buf = typeMalloc(char, TOK_BUF_SIZE);
 
 #ifdef TRACE
        old_line = _nc_curr_line;
        old_col = _nc_curr_col;
 #endif
 
 #ifdef TRACE
        old_line = _nc_curr_line;
        old_col = _nc_curr_col;
 #endif
-       ptr = buffer;
-       *(ptr++) = ch;
+       tok_ptr = tok_buf;
+       AddCh(ch);
 
        if (first_column) {
            _nc_comment_start = token_start;
 
        if (first_column) {
            _nc_comment_start = token_start;
@@ -448,9 +458,9 @@ _nc_get_token(bool silent)
                if (ch == EOF) {
                    _nc_err_abort(MSG_NO_INPUTS);
                } else if (ch == '|') {
                if (ch == EOF) {
                    _nc_err_abort(MSG_NO_INPUTS);
                } else if (ch == '|') {
-                   after_list = ptr;
+                   after_list = tok_ptr;
                    if (after_name == 0)
                    if (after_name == 0)
-                       after_name = ptr;
+                       after_name = tok_ptr;
                } else if (ch == ':' && last_char() != ',') {
                    _nc_syntax = SYN_TERMCAP;
                    separator = ':';
                } else if (ch == ':' && last_char() != ',') {
                    _nc_syntax = SYN_TERMCAP;
                    separator = ':';
@@ -474,9 +484,14 @@ _nc_get_token(bool silent)
                } else
                    ch = eat_escaped_newline(ch);
 
                } else
                    ch = eat_escaped_newline(ch);
 
-               *ptr++ = ch;
+               if (OkToAdd()) {
+                   AddCh(ch);
+               } else {
+                   ch = EOF;
+                   break;
+               }
            }
            }
-           ptr[0] = '\0';
+           *tok_ptr = '\0';
            if (_nc_syntax == ERR) {
                /*
                 * Grrr...what we ought to do here is barf, complaining that
            if (_nc_syntax == ERR) {
                /*
                 * Grrr...what we ought to do here is barf, complaining that
@@ -488,9 +503,11 @@ _nc_get_token(bool silent)
                separator = ':';
            } else if (_nc_syntax == SYN_TERMINFO) {
                /* throw away trailing /, *$/ */
                separator = ':';
            } else if (_nc_syntax == SYN_TERMINFO) {
                /* throw away trailing /, *$/ */
-               for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
+               for (--tok_ptr;
+                    iswhite(*tok_ptr) || *tok_ptr == ',';
+                    tok_ptr--)
                    continue;
                    continue;
-               ptr[1] = '\0';
+               tok_ptr[1] = '\0';
            }
 
            /*
            }
 
            /*
@@ -501,7 +518,7 @@ _nc_get_token(bool silent)
            if (after_name != 0) {
                ch = *after_name;
                *after_name = '\0';
            if (after_name != 0) {
                ch = *after_name;
                *after_name = '\0';
-               _nc_set_type(buffer);
+               _nc_set_type(tok_buf);
                *after_name = ch;
            }
 
                *after_name = ch;
            }
 
@@ -517,7 +534,7 @@ _nc_get_token(bool silent)
                        _nc_warning("older tic versions may treat the description field as an alias");
                }
            } else {
                        _nc_warning("older tic versions may treat the description field as an alias");
                }
            } else {
-               after_list = buffer + strlen(buffer);
+               after_list = tok_buf + strlen(tok_buf);
                DEBUG(1, ("missing description"));
            }
 
                DEBUG(1, ("missing description"));
            }
 
@@ -526,7 +543,7 @@ _nc_get_token(bool silent)
             * rdist and some termcap tools.  Slashes are a no-no.  Other
             * special characters can be dangerous due to shell expansion.
             */
             * rdist and some termcap tools.  Slashes are a no-no.  Other
             * special characters can be dangerous due to shell expansion.
             */
-           for (s = buffer; s < after_list; ++s) {
+           for (s = tok_buf; s < after_list; ++s) {
                if (isspace(UChar(*s))) {
                    if (!silent)
                        _nc_warning("whitespace in name or alias field");
                if (isspace(UChar(*s))) {
                    if (!silent)
                        _nc_warning("whitespace in name or alias field");
@@ -542,7 +559,7 @@ _nc_get_token(bool silent)
                }
            }
 
                }
            }
 
-           _nc_curr_token.tk_name = buffer;
+           _nc_curr_token.tk_name = tok_buf;
            type = NAMES;
        } else {
            if (had_newline && _nc_syntax == SYN_TERMCAP) {
            type = NAMES;
        } else {
            if (had_newline && _nc_syntax == SYN_TERMCAP) {
@@ -559,23 +576,28 @@ _nc_get_token(bool silent)
                            break;
                    }
                }
                            break;
                    }
                }
-               *(ptr++) = ch;
+               if (OkToAdd()) {
+                   AddCh(ch);
+               } else {
+                   ch = EOF;
+                   break;
+               }
            }
 
            }
 
-           *ptr++ = '\0';
+           *tok_ptr++ = '\0';  /* separate name/value in buffer */
            switch (ch) {
            case ',':
            case ':':
                if (ch != separator)
                    _nc_err_abort("Separator inconsistent with syntax");
            switch (ch) {
            case ',':
            case ':':
                if (ch != separator)
                    _nc_err_abort("Separator inconsistent with syntax");
-               _nc_curr_token.tk_name = buffer;
+               _nc_curr_token.tk_name = tok_buf;
                type = BOOLEAN;
                break;
            case '@':
                if ((ch = next_char()) != separator && !silent)
                    _nc_warning("Missing separator after `%s', have %s",
                type = BOOLEAN;
                break;
            case '@':
                if ((ch = next_char()) != separator && !silent)
                    _nc_warning("Missing separator after `%s', have %s",
-                               buffer, unctrl((chtype) ch));
-               _nc_curr_token.tk_name = buffer;
+                               tok_buf, unctrl((chtype) ch));
+               _nc_curr_token.tk_name = tok_buf;
                type = CANCEL;
                break;
 
                type = CANCEL;
                break;
 
@@ -590,21 +612,21 @@ _nc_get_token(bool silent)
                number = strtol(numbuf, &numchk, 0);
                if (!silent) {
                    if (numchk == numbuf)
                number = strtol(numbuf, &numchk, 0);
                if (!silent) {
                    if (numchk == numbuf)
-                       _nc_warning("no value given for `%s'", buffer);
+                       _nc_warning("no value given for `%s'", tok_buf);
                    if ((*numchk != '\0') || (ch != separator))
                        _nc_warning("Missing separator");
                }
                    if ((*numchk != '\0') || (ch != separator))
                        _nc_warning("Missing separator");
                }
-               _nc_curr_token.tk_name = buffer;
+               _nc_curr_token.tk_name = tok_buf;
                _nc_curr_token.tk_valnumber = number;
                type = NUMBER;
                break;
 
            case '=':
                _nc_curr_token.tk_valnumber = number;
                type = NUMBER;
                break;
 
            case '=':
-               ch = _nc_trans_string(ptr, buffer + MAX_ENTRY_SIZE);
+               ch = _nc_trans_string(tok_ptr, tok_buf + TOK_BUF_SIZE);
                if (!silent && ch != separator)
                    _nc_warning("Missing separator");
                if (!silent && ch != separator)
                    _nc_warning("Missing separator");
-               _nc_curr_token.tk_name = buffer;
-               _nc_curr_token.tk_valstring = ptr;
+               _nc_curr_token.tk_name = tok_buf;
+               _nc_curr_token.tk_valstring = tok_ptr;
                type = STRING;
                break;
 
                type = STRING;
                break;
 
@@ -713,8 +735,15 @@ _nc_trans_string(char *ptr, char *last)
     bool long_warning = FALSE;
 
     while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
     bool long_warning = FALSE;
 
     while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
-       if (ptr == (last - 1))
+       if (ptr >= (last - 1)) {
+           if (c != EOF) {
+               while ((c = next_char()) != separator && c != EOF) {
+                   ;
+               }
+               ch = c;
+           }
            break;
            break;
+       }
        if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
            break;
        if (ch == '^' && last_ch != '%') {
        if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
            break;
        if (ch == '^' && last_ch != '%') {
index 92c26705a016fb2b7ebaf12a7fbc4f9fac82f3c1..4521c4a8da685295fd04338a1841daa88f806630 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -37,9 +37,7 @@
 #include <curses.priv.h>
 #include <tic.h>
 
 #include <curses.priv.h>
 #include <tic.h>
 
-MODULE_ID("$Id: home_terminfo.c,v 1.10 2007/04/21 23:11:53 tom Exp $")
-
-#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
+MODULE_ID("$Id: home_terminfo.c,v 1.11 2008/08/03 23:43:11 tom Exp $")
 
 /* ncurses extension...fall back on user's private directory */
 
 
 /* ncurses extension...fall back on user's private directory */
 
@@ -54,9 +52,9 @@ _nc_home_terminfo(void)
 
     if (use_terminfo_vars()) {
        if (MyBuffer == 0) {
 
     if (use_terminfo_vars()) {
        if (MyBuffer == 0) {
-           if ((home = getenv("HOME")) != 0
-               && my_length <= PATH_MAX) {
-               MyBuffer = typeMalloc(char, my_length);
+           if ((home = getenv("HOME")) != 0) {
+               unsigned want = (strlen(home) + sizeof(PRIVATE_INFO));
+               MyBuffer = typeMalloc(char, want);
                if (MyBuffer == 0)
                    _nc_err_abort(MSG_NO_MEMORY);
                (void) sprintf(MyBuffer, PRIVATE_INFO, home);
                if (MyBuffer == 0)
                    _nc_err_abort(MSG_NO_MEMORY);
                (void) sprintf(MyBuffer, PRIVATE_INFO, home);
index 6a24285460b3401cc78d078e121f595c7f6bf37d..3f20c43aa08202fbe317eed71d3513f314a6b72e 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +35,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* ena_acs, acs_chars */
 
 #include <curses.priv.h>
 #include <term.h>              /* ena_acs, acs_chars */
 
-MODULE_ID("$Id: lib_acs.c,v 1.34 2007/09/29 20:37:13 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.35 2008/08/03 22:59:48 tom Exp $")
 
 #if BROKEN_LINKER || USE_REENTRANT
 #define MyBuffer _nc_prescreen.real_acs_map
 
 #if BROKEN_LINKER || USE_REENTRANT
 #define MyBuffer _nc_prescreen.real_acs_map
@@ -72,7 +72,8 @@ _nc_init_acs(void)
        for (j = 1; j < ACS_LEN; ++j) {
            real_map[j] = 0;
            fake_map[j] = A_ALTCHARSET | j;
        for (j = 1; j < ACS_LEN; ++j) {
            real_map[j] = 0;
            fake_map[j] = A_ALTCHARSET | j;
-           SP->_screen_acs_map[j] = FALSE;
+           if (SP)
+               SP->_screen_acs_map[j] = FALSE;
        }
     } else {
        for (j = 1; j < ACS_LEN; ++j) {
        }
     } else {
        for (j = 1; j < ACS_LEN; ++j) {
index dddf808fd07236a05169fb13096ff5749547beae..8cfaf12c5348f9cdbb7dcdcd75792145ebf5ea27 100644 (file)
@@ -53,7 +53,7 @@
 
 #include <term.h>              /* lines, columns, cur_term */
 
 
 #include <term.h>              /* lines, columns, cur_term */
 
-MODULE_ID("$Id: lib_setup.c,v 1.110 2008/07/12 18:40:23 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.111 2008/08/03 22:42:33 tom Exp $")
 
 /****************************************************************************
  *
 
 /****************************************************************************
  *
@@ -394,14 +394,16 @@ do_prototype(TERMINAL * termp)
     char proto;
     char *tmp;
 
     char proto;
     char *tmp;
 
-    tmp = getenv("CC");
-    CC = *tmp;
-    proto = *command_character;
+    if ((tmp = getenv("CC")) != 0) {
+       if ((CC = *tmp) != 0) {
+           proto = *command_character;
 
 
-    for_each_string(i, &(termp->type)) {
-       for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
-           if (*tmp == proto)
-               *tmp = CC;
+           for_each_string(i, &(termp->type)) {
+               for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
+                   if (*tmp == proto)
+                       *tmp = CC;
+               }
+           }
        }
     }
 }
        }
     }
 }
index d11fcf80cfbfd66f2dde42f6a7dfbc7396ded591..dce6973af02dc365510473243fbb064ca02934dc 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +43,7 @@
 #include <term.h>
 #include <tic.h>
 
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.74 2007/09/29 20:37:13 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.75 2008/08/03 22:37:22 tom Exp $")
 
 /*
  *     char *
 
 /*
  *     char *
@@ -504,8 +504,12 @@ tparam_internal(const char *string, va_list ap)
     TPS(stack_ptr) = 0;
     if (popcount == 0) {
        popcount = number;
     TPS(stack_ptr) = 0;
     if (popcount == 0) {
        popcount = number;
-       for (i = number - 1; i >= 0; i--)
-           npush(param[i]);
+       for (i = number - 1; i >= 0; i--) {
+           if (p_is_s[i])
+               spush(p_is_s[i]);
+           else
+               npush(param[i]);
+       }
     }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_CALLS)) {
     }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_CALLS)) {
index 0435bc9f0ce9e707b65c0d482798525a545c0e1c..a2b38a3327f12e3ca264a85e9afafc59b68f314c 100644 (file)
@@ -38,7 +38,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
-MODULE_ID("$Id: lib_ttyflags.c,v 1.17 2008/06/21 20:53:06 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.18 2008/08/03 22:10:44 tom Exp $")
 
 NCURSES_EXPORT(int)
 _nc_get_tty_mode(TTY * buf)
 
 NCURSES_EXPORT(int)
 _nc_get_tty_mode(TTY * buf)
@@ -65,7 +65,8 @@ _nc_get_tty_mode(TTY * buf)
            memset(buf, 0, sizeof(*buf));
 
        TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
            memset(buf, 0, sizeof(*buf));
 
        TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
-                       cur_term->Filedes, _nc_trace_ttymode(buf)));
+                       cur_term ? cur_term->Filedes : -1,
+                       _nc_trace_ttymode(buf)));
     }
     return (result);
 }
     }
     return (result);
 }
@@ -93,7 +94,8 @@ _nc_set_tty_mode(TTY * buf)
            }
        }
        TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
            }
        }
        TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
-                       cur_term->Filedes, _nc_trace_ttymode(buf)));
+                       cur_term ? cur_term->Filedes : -1,
+                       _nc_trace_ttymode(buf)));
     }
     return (result);
 }
     }
     return (result);
 }
index 00367185a45c4158debc5de005bd66a224bce442..c084f87fb94375774cb1fdb4cac9497c2f9fe94b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
+ *  Author: Thomas E. Dickey                    1997-on                     *
  ****************************************************************************/
 
 /*
  ****************************************************************************/
 
 /*
@@ -39,7 +39,7 @@
 #define USE_TERMLIB 1
 #include <curses.priv.h>
 
 #define USE_TERMLIB 1
 #include <curses.priv.h>
 
-MODULE_ID("$Id: make_keys.c,v 1.13 2007/01/07 00:00:14 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.14 2008/08/03 21:57:22 tom Exp $")
 
 #include <names.c>
 
 
 #include <names.c>
 
@@ -71,14 +71,20 @@ static void
 make_keys(FILE *ifp, FILE *ofp)
 {
     char buffer[BUFSIZ];
 make_keys(FILE *ifp, FILE *ofp)
 {
     char buffer[BUFSIZ];
-    char from[BUFSIZ];
-    char to[BUFSIZ];
+    char from[256];
+    char to[256];
     int maxlen = 16;
     int maxlen = 16;
+    int scanned;
 
     while (fgets(buffer, sizeof(buffer), ifp) != 0) {
        if (*buffer == '#')
            continue;
 
     while (fgets(buffer, sizeof(buffer), ifp) != 0) {
        if (*buffer == '#')
            continue;
-       if (sscanf(buffer, "%s %s", to, from) == 2) {
+
+       to[sizeof(to) - 1] = '\0';
+       from[sizeof(from) - 1] = '\0';
+
+       scanned = sscanf(buffer, "%255s %255s", to, from);
+       if (scanned == 2) {
            int code = lookup(from);
            if (code == UNKNOWN)
                continue;
            int code = lookup(from);
            if (code == UNKNOWN)
                continue;
index c8d728faa7c4bf1c650f1f4d4c371efee94a2de6..d576901fa2e93f8bffbea1424eb7de34e8e9c800 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1999-2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2007,2008 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            *
  *                                                                          *
  * 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 <dickey@clark.net> 1999                        *
+ *  Author: Thomas E. Dickey                    1999-on                     *
  ****************************************************************************/
 
 #include <curses.priv.h>
 #include <term.h>
 #include <tic.h>
 
  ****************************************************************************/
 
 #include <curses.priv.h>
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: name_match.c,v 1.16 2007/04/21 21:28:13 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.17 2008/08/03 19:49:33 tom Exp $")
 
 /*
  *     _nc_first_name(char *names)
 
 /*
  *     _nc_first_name(char *names)
@@ -53,18 +53,21 @@ _nc_first_name(const char *const sp)
     if (sp == 0) {
        if (FirstName != 0)
            FreeAndNull(FirstName);
     if (sp == 0) {
        if (FirstName != 0)
            FreeAndNull(FirstName);
-       return 0;
-    }
+    } else
 #endif
 #endif
+    {
+       if (FirstName == 0)
+           FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
 
 
-    if (FirstName == 0)
-       FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
-    for (n = 0; n < MAX_NAME_SIZE; n++) {
-       if ((FirstName[n] = sp[n]) == '\0'
-           || (FirstName[n] == '|'))
-           break;
+       if (FirstName != 0) {
+           for (n = 0; n < MAX_NAME_SIZE; n++) {
+               if ((FirstName[n] = sp[n]) == '\0'
+                   || (FirstName[n] == '|'))
+                   break;
+           }
+           FirstName[n] = '\0';
+       }
     }
     }
-    FirstName[n] = '\0';
     return (FirstName);
 }
 
     return (FirstName);
 }
 
index 375ce8ff9957a29be6bb847a884e237635f7ac72..45f9c64c26ab1b99f5f63e33baa93d9bb3f5ffc5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -48,7 +48,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.65 2007/08/11 16:19:02 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.67 2008/08/03 20:10:45 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
 
 #ifdef LINT
 static short const parametrized[] =
@@ -245,6 +245,9 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
 
     entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
 
 
     entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
 
+    if (entryp->tterm.str_table == 0)
+       return (ERR);
+
     DEBUG(1, ("Starting '%s'", ptr));
 
     /*
     DEBUG(1, ("Starting '%s'", ptr));
 
     /*
@@ -372,26 +375,28 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
                 * type, this will do the job.
                 */
 
                 * type, this will do the job.
                 */
 
-               /* tell max_attributes from arrow_key_map */
                if (token_type == NUMBER
                    && !strcmp("ma", _nc_curr_token.tk_name)) {
                if (token_type == NUMBER
                    && !strcmp("ma", _nc_curr_token.tk_name)) {
+                   /* tell max_attributes from arrow_key_map */
                    entry_ptr = _nc_find_type_entry("ma", NUMBER,
                                                    _nc_get_table(_nc_syntax
                                                                  != 0));
                    entry_ptr = _nc_find_type_entry("ma", NUMBER,
                                                    _nc_get_table(_nc_syntax
                                                                  != 0));
+                   assert(entry_ptr != 0);
 
 
-                   /* map terminfo's string MT to MT */
                } else if (token_type == STRING
                           && !strcmp("MT", _nc_curr_token.tk_name)) {
                } else if (token_type == STRING
                           && !strcmp("MT", _nc_curr_token.tk_name)) {
+                   /* map terminfo's string MT to MT */
                    entry_ptr = _nc_find_type_entry("MT", STRING,
                                                    _nc_get_table(_nc_syntax
                                                                  != 0));
                    entry_ptr = _nc_find_type_entry("MT", STRING,
                                                    _nc_get_table(_nc_syntax
                                                                  != 0));
+                   assert(entry_ptr != 0);
 
 
-                   /* treat strings without following "=" as empty strings */
                } else if (token_type == BOOLEAN
                           && entry_ptr->nte_type == STRING) {
                } else if (token_type == BOOLEAN
                           && entry_ptr->nte_type == STRING) {
+                   /* treat strings without following "=" as empty strings */
                    token_type = STRING;
                    token_type = STRING;
-                   /* we couldn't recover; skip this token */
                } else {
                } else {
+                   /* we couldn't recover; skip this token */
                    if (!silent) {
                        const char *type_name;
                        switch (entry_ptr->nte_type) {
                    if (!silent) {
                        const char *type_name;
                        switch (entry_ptr->nte_type) {
@@ -785,11 +790,12 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
             base = cp + 1) {
            size_t len = cp - base;
 
             base = cp + 1) {
            size_t len = cp - base;
 
-           for (ap = ko_xlate; ap->from; ap++)
+           for (ap = ko_xlate; ap->from; ap++) {
                if (len == strlen(ap->from)
                    && strncmp(ap->from, base, len) == 0)
                    break;
                if (len == strlen(ap->from)
                    && strncmp(ap->from, base, len) == 0)
                    break;
-           if (!ap->to) {
+           }
+           if (!(ap->from && ap->to)) {
                _nc_warning("unknown capability `%.*s' in ko string",
                            (int) len, base);
                continue;
                _nc_warning("unknown capability `%.*s' in ko string",
                            (int) len, base);
                continue;
index 532e5a35ac94d9a891a0c633a619ee72bd800f75..b4ea61ca194ef59b1486267faab230fc53784136 100644 (file)
@@ -42,7 +42,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: read_entry.c,v 1.101 2008/07/12 20:23:13 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.102 2008/08/03 19:33:04 tom Exp $")
 
 #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
 
 
 #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
 
@@ -313,6 +313,8 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
        }
 
        if (need) {
        }
 
        if (need) {
+           if (ext_str_count >= (MAX_ENTRY_SIZE * 2))
+                 return (TGETENT_NO);
            if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
                  return (TGETENT_NO);
            TR(TRACE_DATABASE,
            if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
                  return (TGETENT_NO);
            TR(TRACE_DATABASE,
index 12172deefd86a706b612e915c4a5e31f0471ad8e..b53bb210230d7070b821f85b4c838c4283a09bca 100644 (file)
@@ -54,7 +54,7 @@
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
 #define TRACE_OUT(p)           /*nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.71 2008/07/05 20:06:25 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.72 2008/08/03 19:24:00 tom Exp $")
 
 static int total_written;
 
 
 static int total_written;
 
@@ -275,6 +275,9 @@ _nc_write_entry(TERMTYPE *const tp)
     char *first_name, *other_names;
     char *ptr;
 
     char *first_name, *other_names;
     char *ptr;
 
+    assert(strlen(tp->term_names) != 0);
+    assert(strlen(tp->term_names) < sizeof(name_list));
+
     (void) strcpy(name_list, tp->term_names);
     DEBUG(7, ("Name list = '%s'", name_list));
 
     (void) strcpy(name_list, tp->term_names);
     DEBUG(7, ("Name list = '%s'", name_list));
 
@@ -354,7 +357,7 @@ _nc_write_entry(TERMTYPE *const tp)
        start_time = 0;
     }
 
        start_time = 0;
     }
 
-    if (strlen(first_name) > sizeof(filename) - 3)
+    if (strlen(first_name) >= sizeof(filename) - 3)
        _nc_warning("terminal name too long.");
 
     sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
        _nc_warning("terminal name too long.");
 
     sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
@@ -382,6 +385,7 @@ _nc_write_entry(TERMTYPE *const tp)
     }
     while (*other_names != '\0') {
        ptr = other_names++;
     }
     while (*other_names != '\0') {
        ptr = other_names++;
+       assert(ptr < buffer + sizeof(buffer) - 1);
        while (*other_names != '|' && *other_names != '\0')
            other_names++;
 
        while (*other_names != '|' && *other_names != '\0')
            other_names++;
 
@@ -691,9 +695,17 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
        if (even_boundary(nextfree))
            return (ERR);
 
        if (even_boundary(nextfree))
            return (ERR);
 
-       nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
+       nextfree = compute_offsets(tp->Strings + STRCOUNT,
+                                  tp->ext_Strings,
+                                  offsets);
        TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
        TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
-       nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
+
+       if (tp->ext_Strings >= SIZEOF(offsets))
+           return (ERR);
+
+       nextfree += compute_offsets(tp->ext_Names,
+                                   extcnt,
+                                   offsets + tp->ext_Strings);
        TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
        strmax = tp->ext_Strings + extcnt;
 
        TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
        strmax = tp->ext_Strings + extcnt;
 
index 00a570e835c1e542c0127a61c85b51cfebc9418c..da4e5dce0cd3f500e5fe4c025aa82d960b2ca966 100644 (file)
@@ -46,7 +46,7 @@
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.67 2008/06/07 20:49:56 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.68 2008/08/03 22:22:57 tom Exp $")
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
@@ -95,10 +95,13 @@ trace(const unsigned int tracelevel)
        const char *mode = _nc_globals.init_trace ? "ab" : "wb";
 
        if (TracePath[0] == '\0') {
        const char *mode = _nc_globals.init_trace ? "ab" : "wb";
 
        if (TracePath[0] == '\0') {
-           if (getcwd(TracePath, sizeof(TracePath) - 12) == 0) {
+           int size = sizeof(TracePath) - 12;
+           if (getcwd(TracePath, size) == 0) {
                perror("curses: Can't get working directory");
                exit(EXIT_FAILURE);
            }
                perror("curses: Can't get working directory");
                exit(EXIT_FAILURE);
            }
+           TracePath[size] = '\0';
+           assert(strlen(TracePath) <= size);
            strcat(TracePath, "/trace");
            if (_nc_is_dir_path(TracePath)) {
                strcat(TracePath, ".log");
            strcat(TracePath, "/trace");
            if (_nc_is_dir_path(TracePath)) {
                strcat(TracePath, ".log");
index 566e75454cf5e7c2e0f1dd211f00e383b665a523..45a03cea05feb194988e2455077354e2244f03b5 100644 (file)
@@ -39,7 +39,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* acs_chars */
 
 #include <curses.priv.h>
 #include <term.h>              /* acs_chars */
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.60 2008/05/31 16:53:15 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.63 2008/08/03 16:24:53 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -75,8 +75,6 @@ color_of(int c)
 NCURSES_EXPORT(char *)
 _traceattr2(int bufnum, chtype newmode)
 {
 NCURSES_EXPORT(char *)
 _traceattr2(int bufnum, chtype newmode)
 {
-    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
-    char temp[80];
     static const struct {
        unsigned int val;
        const char *name;
     static const struct {
        unsigned int val;
        const char *name;
@@ -117,47 +115,54 @@ _traceattr2(int bufnum, chtype newmode)
 #endif /* !USE_TERMLIB */
     ;
     size_t n;
 #endif /* !USE_TERMLIB */
     ;
     size_t n;
-    unsigned save_nc_tracing = _nc_tracing;
-    _nc_tracing = 0;
+    char temp[80];
+    char *result = _nc_trace_buf(bufnum, BUFSIZ);
+
+    if (result != 0) {
+       unsigned save_nc_tracing = _nc_tracing;
 
 
-    strcpy(buf, l_brace);
+       _nc_tracing = 0;
 
 
-    for (n = 0; n < SIZEOF(names); n++) {
-       if ((newmode & names[n].val) != 0) {
-           if (buf[1] != '\0')
-               buf = _nc_trace_bufcat(bufnum, "|");
-           buf = _nc_trace_bufcat(bufnum, names[n].name);
+       strcpy(result, l_brace);
 
 
-           if (names[n].val == A_COLOR) {
-               short pairnum = PAIR_NUMBER(newmode);
+       for (n = 0; n < SIZEOF(names); n++) {
+           if ((newmode & names[n].val) != 0) {
+               if (result[1] != '\0')
+                   result = _nc_trace_bufcat(bufnum, "|");
+               result = _nc_trace_bufcat(bufnum, names[n].name);
+
+               if (names[n].val == A_COLOR) {
+                   short pairnum = PAIR_NUMBER(newmode);
 #ifdef USE_TERMLIB
 #ifdef USE_TERMLIB
-               /* pair_content lives in libncurses */
-               (void) sprintf(temp, "{%d}", pairnum);
-#else
-               short fg, bg;
-
-               if (pair_content(pairnum, &fg, &bg) == OK) {
-                   (void) sprintf(temp,
-                                  "{%d = {%s, %s}}",
-                                  pairnum,
-                                  COLOR_OF(fg),
-                                  COLOR_OF(bg));
-               } else {
+                   /* pair_content lives in libncurses */
                    (void) sprintf(temp, "{%d}", pairnum);
                    (void) sprintf(temp, "{%d}", pairnum);
-               }
+#else
+                   short fg, bg;
+
+                   if (pair_content(pairnum, &fg, &bg) == OK) {
+                       (void) sprintf(temp,
+                                      "{%d = {%s, %s}}",
+                                      pairnum,
+                                      COLOR_OF(fg),
+                                      COLOR_OF(bg));
+                   } else {
+                       (void) sprintf(temp, "{%d}", pairnum);
+                   }
 #endif
 #endif
-               buf = _nc_trace_bufcat(bufnum, temp);
+                   result = _nc_trace_bufcat(bufnum, temp);
+               }
            }
        }
            }
        }
-    }
-    if (ChAttrOf(newmode) == A_NORMAL) {
-       if (buf[1] != '\0')
-           (void) _nc_trace_bufcat(bufnum, "|");
-       (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
-    }
+       if (ChAttrOf(newmode) == A_NORMAL) {
+           if (result != 0 && result[1] != '\0')
+               (void) _nc_trace_bufcat(bufnum, "|");
+           (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
+       }
 
 
-    _nc_tracing = save_nc_tracing;
-    return (_nc_trace_bufcat(bufnum, r_brace));
+       _nc_tracing = save_nc_tracing;
+       result = _nc_trace_bufcat(bufnum, r_brace);
+    }
+    return result;
 }
 
 NCURSES_EXPORT(char *)
 }
 
 NCURSES_EXPORT(char *)
@@ -181,50 +186,48 @@ _nc_altcharset_name(attr_t attr, chtype ch)
        unsigned int val;
        const char *name;
     } ALT_NAMES;
        unsigned int val;
        const char *name;
     } ALT_NAMES;
+    static const ALT_NAMES names[] =
+    {
+       {'l', "ACS_ULCORNER"},  /* upper left corner */
+       {'m', "ACS_LLCORNER"},  /* lower left corner */
+       {'k', "ACS_URCORNER"},  /* upper right corner */
+       {'j', "ACS_LRCORNER"},  /* lower right corner */
+       {'t', "ACS_LTEE"},      /* tee pointing right */
+       {'u', "ACS_RTEE"},      /* tee pointing left */
+       {'v', "ACS_BTEE"},      /* tee pointing up */
+       {'w', "ACS_TTEE"},      /* tee pointing down */
+       {'q', "ACS_HLINE"},     /* horizontal line */
+       {'x', "ACS_VLINE"},     /* vertical line */
+       {'n', "ACS_PLUS"},      /* large plus or crossover */
+       {'o', "ACS_S1"},        /* scan line 1 */
+       {'s', "ACS_S9"},        /* scan line 9 */
+       {'`', "ACS_DIAMOND"},   /* diamond */
+       {'a', "ACS_CKBOARD"},   /* checker board (stipple) */
+       {'f', "ACS_DEGREE"},    /* degree symbol */
+       {'g', "ACS_PLMINUS"},   /* plus/minus */
+       {'~', "ACS_BULLET"},    /* bullet */
+       {',', "ACS_LARROW"},    /* arrow pointing left */
+       {'+', "ACS_RARROW"},    /* arrow pointing right */
+       {'.', "ACS_DARROW"},    /* arrow pointing down */
+       {'-', "ACS_UARROW"},    /* arrow pointing up */
+       {'h', "ACS_BOARD"},     /* board of squares */
+       {'i', "ACS_LANTERN"},   /* lantern symbol */
+       {'0', "ACS_BLOCK"},     /* solid square block */
+       {'p', "ACS_S3"},        /* scan line 3 */
+       {'r', "ACS_S7"},        /* scan line 7 */
+       {'y', "ACS_LEQUAL"},    /* less/equal */
+       {'z', "ACS_GEQUAL"},    /* greater/equal */
+       {'{', "ACS_PI"},        /* Pi */
+       {'|', "ACS_NEQUAL"},    /* not equal */
+       {'}', "ACS_STERLING"},  /* UK pound sign */
+       {'\0', (char *) 0}
+    };
 
     const char *result = 0;
 
     if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
        char *cp;
        char *found = 0;
 
     const char *result = 0;
 
     if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
        char *cp;
        char *found = 0;
-       /* *INDENT-OFF* */
-       static const ALT_NAMES names[] =
-       {
-           { 'l', "ACS_ULCORNER" },    /* upper left corner */
-           { 'm', "ACS_LLCORNER" },    /* lower left corner */
-           { 'k', "ACS_URCORNER" },    /* upper right corner */
-           { 'j', "ACS_LRCORNER" },    /* lower right corner */
-           { 't', "ACS_LTEE" },        /* tee pointing right */
-           { 'u', "ACS_RTEE" },        /* tee pointing left */
-           { 'v', "ACS_BTEE" },        /* tee pointing up */
-           { 'w', "ACS_TTEE" },        /* tee pointing down */
-           { 'q', "ACS_HLINE" },       /* horizontal line */
-           { 'x', "ACS_VLINE" },       /* vertical line */
-           { 'n', "ACS_PLUS" },        /* large plus or crossover */
-           { 'o', "ACS_S1" },          /* scan line 1 */
-           { 's', "ACS_S9" },          /* scan line 9 */
-           { '`', "ACS_DIAMOND" },     /* diamond */
-           { 'a', "ACS_CKBOARD" },     /* checker board (stipple) */
-           { 'f', "ACS_DEGREE" },      /* degree symbol */
-           { 'g', "ACS_PLMINUS" },     /* plus/minus */
-           { '~', "ACS_BULLET" },      /* bullet */
-           { ',', "ACS_LARROW" },      /* arrow pointing left */
-           { '+', "ACS_RARROW" },      /* arrow pointing right */
-           { '.', "ACS_DARROW" },      /* arrow pointing down */
-           { '-', "ACS_UARROW" },      /* arrow pointing up */
-           { 'h', "ACS_BOARD" },       /* board of squares */
-           { 'i', "ACS_LANTERN" },     /* lantern symbol */
-           { '0', "ACS_BLOCK" },       /* solid square block */
-           { 'p', "ACS_S3" },          /* scan line 3 */
-           { 'r', "ACS_S7" },          /* scan line 7 */
-           { 'y', "ACS_LEQUAL" },      /* less/equal */
-           { 'z', "ACS_GEQUAL" },      /* greater/equal */
-           { '{', "ACS_PI" },          /* Pi */
-           { '|', "ACS_NEQUAL" },      /* not equal */
-           { '}', "ACS_STERLING" },    /* UK pound sign */
-           { '\0', (char *) 0 }
-       };
-       /* *INDENT-OFF* */
        const ALT_NAMES *sp;
 
        for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
        const ALT_NAMES *sp;
 
        for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
@@ -250,31 +253,35 @@ NCURSES_EXPORT(char *)
 _tracechtype2(int bufnum, chtype ch)
 {
     const char *found;
 _tracechtype2(int bufnum, chtype ch)
 {
     const char *found;
+    char *result = _nc_trace_buf(bufnum, BUFSIZ);
 
 
-    strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace);
-    if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
-       (void) _nc_trace_bufcat(bufnum, found);
-    } else
-       (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int)ChCharOf(ch)));
+    if (result != 0) {
+       strcpy(result, l_brace);
+       if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
+           (void) _nc_trace_bufcat(bufnum, found);
+       } else
+           (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int) ChCharOf(ch)));
 
 
-    if (ChAttrOf(ch) != A_NORMAL) {
-       (void) _nc_trace_bufcat(bufnum, " | ");
-       (void) _nc_trace_bufcat(bufnum,
-               _traceattr2(bufnum + 20, ChAttrOf(ch)));
-    }
+       if (ChAttrOf(ch) != A_NORMAL) {
+           (void) _nc_trace_bufcat(bufnum, " | ");
+           (void) _nc_trace_bufcat(bufnum,
+                                   _traceattr2(bufnum + 20, ChAttrOf(ch)));
+       }
 
 
-    return (_nc_trace_bufcat(bufnum, r_brace));
+       result = _nc_trace_bufcat(bufnum, r_brace);
+    }
+    return result;
 }
 
 NCURSES_EXPORT(char *)
 }
 
 NCURSES_EXPORT(char *)
-_tracechtype (chtype ch)
+_tracechtype(chtype ch)
 {
     return _tracechtype2(0, ch);
 }
 
 /* Trace 'chtype' return-values */
 NCURSES_EXPORT(chtype)
 {
     return _tracechtype2(0, ch);
 }
 
 /* Trace 'chtype' return-values */
 NCURSES_EXPORT(chtype)
-_nc_retrace_chtype (chtype code)
+_nc_retrace_chtype(chtype code)
 {
     T((T_RETURN("%s"), _tracechtype(code)));
     return code;
 {
     T((T_RETURN("%s"), _tracechtype(code)));
     return code;
@@ -282,63 +289,70 @@ _nc_retrace_chtype (chtype code)
 
 #if USE_WIDEC_SUPPORT
 NCURSES_EXPORT(char *)
 
 #if USE_WIDEC_SUPPORT
 NCURSES_EXPORT(char *)
-_tracecchar_t2 (int bufnum, const cchar_t *ch)
+_tracecchar_t2(int bufnum, const cchar_t *ch)
 {
 {
-    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+    char *result = _nc_trace_buf(bufnum, BUFSIZ);
     attr_t attr;
     const char *found;
 
     attr_t attr;
     const char *found;
 
-    strcpy(buf, l_brace);
-    if (ch != 0) {
-       attr = AttrOfD(ch);
-       if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
-           (void) _nc_trace_bufcat(bufnum, found);
-           attr &= ~A_ALTCHARSET;
-       } else if (isWidecExt(CHDEREF(ch))) {
-           (void) _nc_trace_bufcat(bufnum, "{NAC}");
-           attr &= ~A_CHARTEXT;
-       } else {
-           PUTC_DATA;
-           int n;
-
-           PUTC_INIT;
-           (void) _nc_trace_bufcat(bufnum, "{ ");
-           for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
-               PUTC_ch = ch->chars[PUTC_i];
-               if (PUTC_ch == L'\0')
-                   break;
-               PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
-               if (PUTC_n <= 0) {
-                   if (PUTC_ch != L'\0') {
-                       /* it could not be a multibyte sequence */
-                       (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, UChar(ch->chars[PUTC_i])));
+    if (result != 0) {
+       strcpy(result, l_brace);
+       if (ch != 0) {
+           attr = AttrOfD(ch);
+           if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
+               (void) _nc_trace_bufcat(bufnum, found);
+               attr &= ~A_ALTCHARSET;
+           } else if (isWidecExt(CHDEREF(ch))) {
+               (void) _nc_trace_bufcat(bufnum, "{NAC}");
+               attr &= ~A_CHARTEXT;
+           } else {
+               PUTC_DATA;
+               int n;
+
+               PUTC_INIT;
+               (void) _nc_trace_bufcat(bufnum, "{ ");
+               for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+                   PUTC_ch = ch->chars[PUTC_i];
+                   if (PUTC_ch == L'\0')
+                       break;
+                   PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+                   if (PUTC_n <= 0) {
+                       if (PUTC_ch != L'\0') {
+                           /* it could not be a multibyte sequence */
+                           (void) _nc_trace_bufcat(bufnum,
+                                                   _nc_tracechar(SP,
+                                                                 UChar(ch->chars[PUTC_i])));
+                       }
+                       break;
+                   }
+                   for (n = 0; n < PUTC_n; n++) {
+                       if (n)
+                           (void) _nc_trace_bufcat(bufnum, ", ");
+                       (void) _nc_trace_bufcat(bufnum,
+                                               _nc_tracechar(SP,
+                                                             UChar(PUTC_buf[n])));
                    }
                    }
-                   break;
-               }
-               for (n = 0; n < PUTC_n; n++) {
-                   if (n)
-                       (void) _nc_trace_bufcat(bufnum, ", ");
-                   (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, UChar(PUTC_buf[n])));
                }
                }
+               (void) _nc_trace_bufcat(bufnum, " }");
+           }
+           if (attr != A_NORMAL) {
+               (void) _nc_trace_bufcat(bufnum, " | ");
+               (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
            }
            }
-           (void) _nc_trace_bufcat(bufnum, " }");
-       }
-       if (attr != A_NORMAL) {
-           (void) _nc_trace_bufcat(bufnum, " | ");
-           (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
        }
        }
-    }
 
 
-    return (_nc_trace_bufcat(bufnum, r_brace));
+       result = _nc_trace_bufcat(bufnum, r_brace);
+    }
+    return result;
 }
 
 NCURSES_EXPORT(char *)
 }
 
 NCURSES_EXPORT(char *)
-_tracecchar_t (const cchar_t *ch)
+_tracecchar_t(const cchar_t *ch)
 {
     return _tracecchar_t2(0, ch);
 }
 #endif
 
 #else
 {
     return _tracecchar_t2(0, ch);
 }
 #endif
 
 #else
-empty_module(_nc_lib_traceatr)
+EMPTY_MODULE(_nc_lib_traceatr)
 #endif /* TRACE */
 #endif /* TRACE */
index de2394c39225353c2f43fb91c7fb43a65922eb2e..cc441b391e5b2722ad82ca7a2589cde97895d407 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +35,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
-MODULE_ID("$Id: lib_tracebits.c,v 1.15 2007/06/30 16:14:20 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.17 2008/08/03 16:09:26 tom Exp $")
 
 #if SVR4_TERMIO && !defined(_POSIX_SOURCE)
 #define _POSIX_SOURCE
 
 #if SVR4_TERMIO && !defined(_POSIX_SOURCE)
 #define _POSIX_SOURCE
@@ -165,58 +165,52 @@ _nc_trace_ttymode(TTY * tty)
                        8 + sizeof(cflags) +
                        8 + sizeof(lflags) +
                        8);
                        8 + sizeof(cflags) +
                        8 + sizeof(lflags) +
                        8);
+    if (buf != 0) {
 
 
-    if (tty->c_iflag & ALLIN)
-       lookup_bits(buf, iflags, "iflags", tty->c_iflag);
+       if (tty->c_iflag & ALLIN)
+           lookup_bits(buf, iflags, "iflags", tty->c_iflag);
 
 
-    if (tty->c_oflag & ALLOUT)
-       lookup_bits(buf, oflags, "oflags", tty->c_oflag);
+       if (tty->c_oflag & ALLOUT)
+           lookup_bits(buf, oflags, "oflags", tty->c_oflag);
 
 
-    if (tty->c_cflag & ALLCTRL)
-       lookup_bits(buf, cflags, "cflags", tty->c_cflag);
+       if (tty->c_cflag & ALLCTRL)
+           lookup_bits(buf, cflags, "cflags", tty->c_cflag);
 
 #if defined(CS5) && defined(CS8)
 
 #if defined(CS5) && defined(CS8)
-    {
-       static struct {
-           const char *name;
-           int value;
-       } csizes[] = {
-           {
-               "CS5 ", CS5
-           },
+       {
+           static struct {
+               int value;
+               const char *name;
+           } csizes[] = {
+#define CS_DATA(name) { name, #name " " }
+               CS_DATA(CS5),
 #ifdef CS6
 #ifdef CS6
-           {
-               "CS6 ", CS6
-           },
+                   CS_DATA(CS6),
 #endif
 #ifdef CS7
 #endif
 #ifdef CS7
-           {
-               "CS7 ", CS7
-           },
+                   CS_DATA(CS7),
 #endif
 #endif
-           {
-               "CS8 ", CS8
-           },
-       };
-       const char *result = "CSIZE? ";
-       int value = (tty->c_cflag & CSIZE);
-       unsigned n;
+                   CS_DATA(CS8),
+           };
+           const char *result = "CSIZE? ";
+           int value = (tty->c_cflag & CSIZE);
+           unsigned n;
 
 
-       if (value != 0) {
-           for (n = 0; n < SIZEOF(csizes); n++) {
-               if (csizes[n].value == value) {
-                   result = csizes[n].name;
-                   break;
+           if (value != 0) {
+               for (n = 0; n < SIZEOF(csizes); n++) {
+                   if (csizes[n].value == value) {
+                       result = csizes[n].name;
+                       break;
+                   }
                }
            }
                }
            }
+           strcat(buf, result);
        }
        }
-       strcat(buf, result);
-    }
 #endif
 
 #endif
 
-    if (tty->c_lflag & ALLLOCAL)
-       lookup_bits(buf, lflags, "lflags", tty->c_lflag);
-
+       if (tty->c_lflag & ALLLOCAL)
+           lookup_bits(buf, lflags, "lflags", tty->c_lflag);
+    }
 #else
     /* reference: ttcompat(4M) on SunOS 4.1 */
 #ifndef EVENP
 #else
     /* reference: ttcompat(4M) on SunOS 4.1 */
 #ifndef EVENP
@@ -253,9 +247,10 @@ _nc_trace_ttymode(TTY * tty)
 
     buf = _nc_trace_buf(0,
                        8 + sizeof(cflags));
 
     buf = _nc_trace_buf(0,
                        8 + sizeof(cflags));
-
-    if (tty->sg_flags & ALLCTRL) {
-       lookup_bits(buf, cflags, "cflags", tty->sg_flags);
+    if (buf != 0) {
+       if (tty->sg_flags & ALLCTRL) {
+           lookup_bits(buf, cflags, "cflags", tty->sg_flags);
+       }
     }
 #endif
     return (buf);
     }
 #endif
     return (buf);
@@ -267,5 +262,5 @@ _nc_tracebits(void)
     return _nc_trace_ttymode(&(cur_term->Nttyb));
 }
 #else
     return _nc_trace_ttymode(&(cur_term->Nttyb));
 }
 #else
-empty_module(_nc_tracebits)
+EMPTY_MODULE(_nc_tracebits)
 #endif /* TRACE */
 #endif /* TRACE */
index 990f11ce85319becb379596d31a18af6a7f708a5..79cf03b4870cfb96e4f88dac050648b2be7eec24 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.18 2008/06/28 15:52:05 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.19 2008/08/03 15:39:29 tom Exp $")
 
 #ifdef TRACE
 
 
 #ifdef TRACE
 
@@ -78,5 +78,5 @@ _tracechar(int ch)
     return _nc_tracechar(SP, ch);
 }
 #else
     return _nc_tracechar(SP, ch);
 }
 #else
-empty_module(_nc_lib_tracechr)
+EMPTY_MODULE(_nc_lib_tracechr)
 #endif
 #endif
index d56d1a5d48b09ec621a3d27442a049bc1bc4e6f8..6fd795c3d91faae2e1fe880369d1e9b15bcf126c 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +39,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.29 2007/06/30 23:01:19 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.30 2008/08/03 15:44:31 tom Exp $")
 
 #ifdef TRACE
 
 
 #ifdef TRACE
 
@@ -180,5 +180,5 @@ _tracedump(const char *name, WINDOW *win)
 }
 
 #else
 }
 
 #else
-empty_module(_nc_lib_tracedmp)
+EMPTY_MODULE(_nc_lib_tracedmp)
 #endif /* TRACE */
 #endif /* TRACE */
index 3b060894eba8d9681c5fd8c40a51b1576d975e0f..74cc177d51bb841bb08cdeda14c5e2e6adebcb07 100644 (file)
@@ -38,7 +38,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracemse.c,v 1.14 2008/05/31 17:20:25 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.15 2008/08/03 15:39:29 tom Exp $")
 
 #ifdef TRACE
 
 
 #ifdef TRACE
 
@@ -121,5 +121,5 @@ _tracemouse(MEVENT const *ep)
 }
 
 #else /* !TRACE */
 }
 
 #else /* !TRACE */
-empty_module(_nc_lib_tracemouse)
+EMPTY_MODULE(_nc_lib_tracemouse)
 #endif
 #endif
index 7bf91c674df3369a13c7fc575c191e65aeef2e6e..6345acc035fc48c37b8bf4b1c24a15b3ee9d93d6 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
+ *  Author: Thomas E. Dickey                 1997-on                        *
  ****************************************************************************/
 /*
  *     trace_buf.c - Tracing/Debugging buffers (attributes)
  ****************************************************************************/
 /*
  *     trace_buf.c - Tracing/Debugging buffers (attributes)
@@ -35,7 +35,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_buf.c,v 1.13 2007/04/21 22:50:08 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.14 2008/08/03 15:13:56 tom Exp $")
 
 #define MyList _nc_globals.tracebuf_ptr
 #define MySize _nc_globals.tracebuf_used
 
 #define MyList _nc_globals.tracebuf_ptr
 #define MySize _nc_globals.tracebuf_used
@@ -48,29 +48,35 @@ _nc_trace_alloc(int bufnum, size_t want)
     if (bufnum >= 0) {
        if ((size_t) (bufnum + 1) > MySize) {
            size_t need = (bufnum + 1) * 2;
     if (bufnum >= 0) {
        if ((size_t) (bufnum + 1) > MySize) {
            size_t need = (bufnum + 1) * 2;
-           if ((MyList = typeRealloc(TRACEBUF, need, MyList)) == 0)
-               return (0);
-           while (need > MySize)
-               MyList[MySize++].text = 0;
+           if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
+               while (need > MySize)
+                   MyList[MySize++].text = 0;
+           }
        }
 
        }
 
-       if (MyList[bufnum].text == 0
-           || want > MyList[bufnum].size) {
-           MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
-           if (MyList[bufnum].text != 0)
-               MyList[bufnum].size = want;
+       if (MyList != 0) {
+           if (MyList[bufnum].text == 0
+               || want > MyList[bufnum].size) {
+               MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
+               if (MyList[bufnum].text != 0)
+                   MyList[bufnum].size = want;
+           }
+           result = MyList[bufnum].text;
        }
        }
-
-       result = MyList[bufnum].text;
     }
 #if NO_LEAKS
     else {
        if (MySize) {
     }
 #if NO_LEAKS
     else {
        if (MySize) {
-           while (MySize--) {
-               if (MyList[MySize].text != 0)
-                   free(MyList[MySize].text);
+           if (MyList) {
+               while (MySize--) {
+                   if (MyList[MySize].text != 0) {
+                       free(MyList[MySize].text);
+                   }
+               }
+               free(MyList);
+               MyList = 0;
            }
            }
-           free(MyList);
+           MySize = 0;
        }
     }
 #endif
        }
     }
 #endif
@@ -96,10 +102,13 @@ NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
     char *buffer = _nc_trace_alloc(bufnum, 0);
 _nc_trace_bufcat(int bufnum, const char *value)
 {
     char *buffer = _nc_trace_alloc(bufnum, 0);
-    size_t have = strlen(buffer);
+    if (buffer != 0) {
+       size_t have = strlen(buffer);
 
 
-    buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
-    (void) strcpy(buffer + have, value);
+       buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
+       if (buffer != 0)
+           (void) strcpy(buffer + have, value);
 
 
+    }
     return buffer;
 }
     return buffer;
 }
index 0aa0b227d7d0d111b65380d9438732885b08410c..f813aba1582548415ccd542a572fe5afb5a5f53a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1999-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +35,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_tries.c,v 1.12 2007/04/21 21:55:41 tom Exp $")
+MODULE_ID("$Id: trace_tries.c,v 1.13 2008/08/03 15:43:30 tom Exp $")
 
 #ifdef TRACE
 #define my_buffer _nc_globals.tracetry_buf
 
 #ifdef TRACE
 #define my_buffer _nc_globals.tracetry_buf
@@ -74,5 +74,5 @@ _nc_trace_tries(TRIES * tree)
 }
 
 #else
 }
 
 #else
-empty_module(_nc_trace_tries)
+EMPTY_MODULE(_nc_trace_tries)
 #endif
 #endif
index 5e63d21a2cc5e5d99e840ccc763f091dcbbd42ea..f4ee46710abb74d347ace47536f71e9d6235e26b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2001-2003,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 2001-2007,2008 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            *
  *                                                                          *
  * 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 @@
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-MODULE_ID("$Id: varargs.c,v 1.6 2007/07/14 15:51:27 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.7 2008/08/03 15:42:49 tom Exp $")
 
 #ifdef TRACE
 
 
 #ifdef TRACE
 
@@ -180,5 +180,5 @@ _nc_varargs(const char *fmt, va_list ap)
     return (MyBuffer);
 }
 #else
     return (MyBuffer);
 }
 #else
-empty_module(_nc_varargs)
+EMPTY_MODULE(_nc_varargs)
 #endif
 #endif
index ed3d5bb4e2f0eee6c99b888379d6d3d22292e9a7..bf9fb14720034b0e19438fc95c7278419adda5f7 100644 (file)
 #include <tic.h>
 #include <ctype.h>
 
 #include <tic.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: visbuf.c,v 1.27 2008/07/05 23:19:59 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.32 2008/08/04 23:07:39 tom Exp $")
 
 
-#define NormalLen(len) (unsigned) ((len + 1) * 4)
-#define WideLen(len)   (unsigned) ((len + 1) * 4 * MB_CUR_MAX)
+#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4)
+#define WideLen(len)   (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX)
 
 #ifdef TRACE
 static const char d_quote[] = StringOf(D_QUOTE);
 
 #ifdef TRACE
 static const char d_quote[] = StringOf(D_QUOTE);
@@ -58,9 +58,9 @@ _nc_vischar(char *tp, unsigned c)
 {
     if (c == '"' || c == '\\') {
        *tp++ = '\\';
 {
     if (c == '"' || c == '\\') {
        *tp++ = '\\';
-       *tp++ = c;
+       *tp++ = (char) c;
     } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
     } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
-       *tp++ = c;
+       *tp++ = (char) c;
     } else if (c == '\n') {
        *tp++ = '\\';
        *tp++ = 'n';
     } else if (c == '\n') {
        *tp++ = '\\';
        *tp++ = 'n';
@@ -80,7 +80,7 @@ _nc_vischar(char *tp, unsigned c)
     } else if (is7bits(c) && iscntrl(UChar(c))) {
        *tp++ = '\\';
        *tp++ = '^';
     } else if (is7bits(c) && iscntrl(UChar(c))) {
        *tp++ = '\\';
        *tp++ = '^';
-       *tp++ = '@' + c;
+       *tp++ = (char) ('@' + c);
     } else {
        sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c));
        tp += strlen(tp);
     } else {
        sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c));
        tp += strlen(tp);
@@ -92,7 +92,7 @@ _nc_vischar(char *tp, unsigned c)
 static const char *
 _nc_visbuf2n(int bufnum, const char *buf, int len)
 {
 static const char *
 _nc_visbuf2n(int bufnum, const char *buf, int len)
 {
-    char *vbuf;
+    const char *vbuf;
     char *tp;
     int c;
 
     char *tp;
     int c;
 
@@ -102,23 +102,27 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
        return ("(cancelled)");
 
     if (len < 0)
        return ("(cancelled)");
 
     if (len < 0)
-       len = strlen(buf);
+       len = (int) strlen(buf);
 
 #ifdef TRACE
 
 #ifdef TRACE
-    tp = vbuf = _nc_trace_buf(bufnum, NormalLen(len));
+    vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len));
 #else
     {
        static char *mybuf[4];
        mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
 #else
     {
        static char *mybuf[4];
        mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
-       tp = vbuf = mybuf[bufnum];
+       vbuf = tp = mybuf[bufnum];
     }
 #endif
     }
 #endif
-    *tp++ = D_QUOTE;
-    while ((--len >= 0) && (c = *buf++) != '\0') {
-       tp = _nc_vischar(tp, UChar(c));
+    if (tp != 0) {
+       *tp++ = D_QUOTE;
+       while ((--len >= 0) && (c = *buf++) != '\0') {
+           tp = _nc_vischar(tp, UChar(c));
+       }
+       *tp++ = D_QUOTE;
+       *tp++ = '\0';
+    } else {
+       vbuf = ("(_nc_visbuf2n failed)");
     }
     }
-    *tp++ = D_QUOTE;
-    *tp++ = '\0';
     return (vbuf);
 }
 
     return (vbuf);
 }
 
@@ -159,7 +163,7 @@ _nc_wchstrlen(const cchar_t *s)
 static const char *
 _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
 {
 static const char *
 _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
 {
-    char *vbuf;
+    const char *vbuf;
     char *tp;
     wchar_t c;
 
     char *tp;
     wchar_t c;
 
@@ -167,31 +171,35 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
        return ("(null)");
 
     if (len < 0)
        return ("(null)");
 
     if (len < 0)
-       len = wcslen(buf);
+       len = (int) wcslen(buf);
 
 #ifdef TRACE
 
 #ifdef TRACE
-    tp = vbuf = _nc_trace_buf(bufnum, WideLen(len));
+    vbuf = tp = _nc_trace_buf(bufnum, WideLen(len));
 #else
     {
        static char *mybuf[2];
        mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
 #else
     {
        static char *mybuf[2];
        mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
-       tp = vbuf = mybuf[bufnum];
+       vbuf = tp = mybuf[bufnum];
     }
 #endif
     }
 #endif
-    *tp++ = D_QUOTE;
-    while ((--len >= 0) && (c = *buf++) != '\0') {
-       char temp[CCHARW_MAX + 80];
-       int j = wctomb(temp, c), k;
-       if (j <= 0) {
-           sprintf(temp, "\\u%08X", (unsigned) c);
-           j = strlen(temp);
-       }
-       for (k = 0; k < j; ++k) {
-           tp = _nc_vischar(tp, UChar(temp[k]));
+    if (tp != 0) {
+       *tp++ = D_QUOTE;
+       while ((--len >= 0) && (c = *buf++) != '\0') {
+           char temp[CCHARW_MAX + 80];
+           int j = wctomb(temp, c), k;
+           if (j <= 0) {
+               sprintf(temp, "\\u%08X", (unsigned) c);
+               j = (int) strlen(temp);
+           }
+           for (k = 0; k < j; ++k) {
+               tp = _nc_vischar(tp, UChar(temp[k]));
+           }
        }
        }
+       *tp++ = D_QUOTE;
+       *tp++ = '\0';
+    } else {
+       vbuf = ("(_nc_viswbuf2n failed)");
     }
     }
-    *tp++ = D_QUOTE;
-    *tp++ = '\0';
     return (vbuf);
 }
 
     return (vbuf);
 }
 
@@ -244,71 +252,73 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
     int first;
     const char *found;
 
     int first;
     const char *found;
 
+    if (result != 0) {
 #if USE_WIDEC_SUPPORT
 #if USE_WIDEC_SUPPORT
-    if (len < 0)
-       len = _nc_wchstrlen(buf);
+       if (len < 0)
+           len = _nc_wchstrlen(buf);
 #endif /* USE_WIDEC_SUPPORT */
 
 #endif /* USE_WIDEC_SUPPORT */
 
-    /*
-     * Display one or more strings followed by attributes.
-     */
-    first = 0;
-    while (first < len) {
-       attr_t attr = AttrOf(buf[first]);
-       int last = len - 1;
-       int j;
-
-       for (j = first + 1; j < len; ++j) {
-           if (!SameAttrOf(buf[j], buf[first])) {
-               last = j - 1;
-               break;
+       /*
+        * Display one or more strings followed by attributes.
+        */
+       first = 0;
+       while (first < len) {
+           attr_t attr = AttrOf(buf[first]);
+           int last = len - 1;
+           int j;
+
+           for (j = first + 1; j < len; ++j) {
+               if (!SameAttrOf(buf[j], buf[first])) {
+                   last = j - 1;
+                   break;
+               }
            }
            }
-       }
 
 
-       result = _nc_trace_bufcat(bufnum, l_brace);
-       result = _nc_trace_bufcat(bufnum, d_quote);
-       for (j = first; j <= last; ++j) {
-           found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
-           if (found != 0) {
-               result = _nc_trace_bufcat(bufnum, found);
-               attr &= ~A_ALTCHARSET;
-           } else
+           result = _nc_trace_bufcat(bufnum, l_brace);
+           result = _nc_trace_bufcat(bufnum, d_quote);
+           for (j = first; j <= last; ++j) {
+               found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
+               if (found != 0) {
+                   result = _nc_trace_bufcat(bufnum, found);
+                   attr &= ~A_ALTCHARSET;
+               } else
 #if USE_WIDEC_SUPPORT
 #if USE_WIDEC_SUPPORT
-           if (!isWidecExt(buf[j])) {
-               PUTC_DATA;
-
-               PUTC_INIT;
-               for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
-                   int k;
-
-                   PUTC_ch = buf[j].chars[PUTC_i];
-                   if (PUTC_ch == L'\0')
-                       break;
-                   PUTC_n = wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
-                   if (PUTC_n <= 0)
-                       break;
-                   for (k = 0; k < PUTC_n; k++) {
-                       char temp[80];
-                       _nc_vischar(temp, UChar(PUTC_buf[k]));
-                       result = _nc_trace_bufcat(bufnum, temp);
+               if (!isWidecExt(buf[j])) {
+                   PUTC_DATA;
+
+                   PUTC_INIT;
+                   for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+                       int k;
+
+                       PUTC_ch = buf[j].chars[PUTC_i];
+                       if (PUTC_ch == L'\0')
+                           break;
+                       PUTC_n = (int) wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
+                       if (PUTC_n <= 0)
+                           break;
+                       for (k = 0; k < PUTC_n; k++) {
+                           char temp[80];
+                           _nc_vischar(temp, UChar(PUTC_buf[k]));
+                           result = _nc_trace_bufcat(bufnum, temp);
+                       }
                    }
                }
                    }
                }
-           }
 #else
 #else
-           {
-               char temp[80];
-               _nc_vischar(temp, UChar(buf[j]));
-               result = _nc_trace_bufcat(bufnum, temp);
-           }
+               {
+                   char temp[80];
+                   _nc_vischar(temp, UChar(buf[j]));
+                   result = _nc_trace_bufcat(bufnum, temp);
+               }
 #endif /* USE_WIDEC_SUPPORT */
 #endif /* USE_WIDEC_SUPPORT */
+           }
+           result = _nc_trace_bufcat(bufnum, d_quote);
+           if (attr != A_NORMAL) {
+               result = _nc_trace_bufcat(bufnum, " | ");
+               result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
+           }
+           result = _nc_trace_bufcat(bufnum, r_brace);
+           first = last + 1;
        }
        }
-       result = _nc_trace_bufcat(bufnum, d_quote);
-       if (attr != A_NORMAL) {
-           result = _nc_trace_bufcat(bufnum, " | ");
-           result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
-       }
-       result = _nc_trace_bufcat(bufnum, r_brace);
-       first = last + 1;
     }
     return result;
 }
     }
     return result;
 }
index 7d8979a4f51b12a6071533bcd02bae6bdb1c782e..2c40997fb6b1c090f5932458b2e72736f61d1b78 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +29,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Alexander V Lukyanov                    1997-1998               *
  ****************************************************************************/
 
 /******************************************************************************
  ****************************************************************************/
 
 /******************************************************************************
@@ -145,7 +147,7 @@ AUTHOR
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.41 2007/09/29 21:48:36 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -270,13 +272,14 @@ _nc_linedump(void)
     char *buf = 0;
     size_t want = (screen_lines + 1) * 4;
 
     char *buf = 0;
     size_t want = (screen_lines + 1) * 4;
 
-    buf = typeMalloc(char, want);
+    if ((buf = typeMalloc(char, want)) != 0) {
 
 
-    (void) strcpy(buf, "virt");
-    for (n = 0; n < screen_lines; n++)
-       (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
-    TR(TRACE_UPDATE | TRACE_MOVE, (buf));
-    free(buf);
+       (void) strcpy(buf, "virt");
+       for (n = 0; n < screen_lines; n++)
+           (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
+       TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+       free(buf);
+    }
 }
 #endif /* defined(TRACE) || defined(SCROLLDEBUG) */
 
 }
 #endif /* defined(TRACE) || defined(SCROLLDEBUG) */
 
index 3e48e3696735dc71c8958a741f41041a92cc615e..2719316888e082a3d0dbffbe9b173e997e59300e 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2005,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +29,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1997-1999               *
+ *     and: Thomas E. Dickey                        2000-on                 *
  ****************************************************************************/
 
 /* p_new.c
  ****************************************************************************/
 
 /* p_new.c
@@ -36,7 +38,7 @@
  */
 #include "panel.priv.h"
 
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_new.c,v 1.8 2005/02/19 16:41:03 tom Exp $")
+MODULE_ID("$Id: p_new.c,v 1.10 2008/08/04 18:25:48 tom Exp $")
 
 #ifdef TRACE
 static char *stdscr_id;
 
 #ifdef TRACE
 static char *stdscr_id;
@@ -54,6 +56,9 @@ root_panel(void)
     {
 
       assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
     {
 
       assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
+#if NO_LEAKS
+      _nc_panelhook()->destroy = del_panel;
+#endif
       _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
       if (_nc_stdscr_pseudo_panel != 0)
        {
       _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
       if (_nc_stdscr_pseudo_panel != 0)
        {
index 83231f3a7e1e7ab0f65520b225d5e463ec133f63..bd2422008bf71dd13d4eadf34b7f68be2acf4e48 100644 (file)
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey 1996 on                                        *
+ *     and: Thomas E. Dickey                        1996 on                 *
  ****************************************************************************/
 
 #define __INTERNAL_CAPS_VISIBLE
  ****************************************************************************/
 
 #define __INTERNAL_CAPS_VISIBLE
 #include "termsort.c"          /* this C file is generated */
 #include <parametrized.h>      /* so is this */
 
 #include "termsort.c"          /* this C file is generated */
 #include <parametrized.h>      /* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.83 2008/07/12 21:06:33 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.88 2008/08/04 12:36:12 tom Exp $")
 
 #define INDENT                 8
 #define DISCARD(string) string = ABSENT_STRING
 #define PRINTF (void) printf
 
 
 #define INDENT                 8
 #define DISCARD(string) string = ABSENT_STRING
 #define PRINTF (void) printf
 
+#define OkIndex(index,array) ((int)(index) >= 0 && (int)(index) < (int) SIZEOF(array))
+
 typedef struct {
     char *text;
     size_t used;
 typedef struct {
     char *text;
     size_t used;
@@ -140,6 +142,11 @@ _nc_leaks_dump_entry(void)
 }
 #endif
 
 }
 #endif
 
+#define NameTrans(check,result) \
+           if (OkIndex(np->nte_index, check) \
+               && check[np->nte_index]) \
+               return (result[np->nte_index])
+
 NCURSES_CONST char *
 nametrans(const char *name)
 /* translate a capability name from termcap to terminfo */
 NCURSES_CONST char *
 nametrans(const char *name)
 /* translate a capability name from termcap to terminfo */
@@ -149,18 +156,15 @@ nametrans(const char *name)
     if ((np = _nc_find_entry(name, _nc_get_hash_table(0))) != 0)
        switch (np->nte_type) {
        case BOOLEAN:
     if ((np = _nc_find_entry(name, _nc_get_hash_table(0))) != 0)
        switch (np->nte_type) {
        case BOOLEAN:
-           if (bool_from_termcap[np->nte_index])
-               return (boolcodes[np->nte_index]);
+           NameTrans(bool_from_termcap, boolcodes);
            break;
 
        case NUMBER:
            break;
 
        case NUMBER:
-           if (num_from_termcap[np->nte_index])
-               return (numcodes[np->nte_index]);
+           NameTrans(num_from_termcap, numcodes);
            break;
 
        case STRING:
            break;
 
        case STRING:
-           if (str_from_termcap[np->nte_index])
-               return (strcodes[np->nte_index]);
+           NameTrans(str_from_termcap, strcodes);
            break;
        }
 
            break;
        }
 
@@ -352,7 +356,7 @@ version_filter(PredType type, PredIdx idx)
        }
        break;
 
        }
        break;
 
-#define is_termcap(type) (idx < (int) sizeof(type##_from_termcap) && \
+#define is_termcap(type) (OkIndex(idx, type##_from_termcap) && \
                          type##_from_termcap[idx])
 
     case V_BSD:                /* BSD */
                          type##_from_termcap[idx])
 
     case V_BSD:                /* BSD */
@@ -389,22 +393,22 @@ force_wrap(void)
 static void
 wrap_concat(const char *src)
 {
 static void
 wrap_concat(const char *src)
 {
-    int need = strlen(src);
-    int want = strlen(separator) + need;
+    unsigned need = strlen(src);
+    unsigned want = strlen(separator) + need;
 
     if (column > INDENT
 
     if (column > INDENT
-       && column + want > width) {
+       && column + (int) want > width) {
        force_wrap();
     }
     strcpy_DYN(&outbuf, src);
     strcpy_DYN(&outbuf, separator);
        force_wrap();
     }
     strcpy_DYN(&outbuf, src);
     strcpy_DYN(&outbuf, separator);
-    column += need;
+    column += (int) need;
 }
 
 #define IGNORE_SEP_TRAIL(first,last,sep_trail) \
        if ((size_t)(last - first) > sizeof(sep_trail)-1 \
         && !strncmp(first, sep_trail, sizeof(sep_trail)-1)) \
 }
 
 #define IGNORE_SEP_TRAIL(first,last,sep_trail) \
        if ((size_t)(last - first) > sizeof(sep_trail)-1 \
         && !strncmp(first, sep_trail, sizeof(sep_trail)-1)) \
-               first += sizeof(sep_trail)-2
+               first += sizeof(sep_trail)-2
 
 /* Returns the nominal length of the buffer assuming it is termcap format,
  * i.e., the continuation sequence is treated as a single character ":".
 
 /* Returns the nominal length of the buffer assuming it is termcap format,
  * i.e., the continuation sequence is treated as a single character ":".
@@ -448,7 +452,7 @@ static bool
 has_params(const char *src)
 {
     bool result = FALSE;
 has_params(const char *src)
 {
     bool result = FALSE;
-    int len = strlen(src);
+    int len = (int) strlen(src);
     int n;
     bool ifthen = FALSE;
     bool params = FALSE;
     int n;
     bool ifthen = FALSE;
     bool params = FALSE;
@@ -553,6 +557,7 @@ fmt_complex(char *src, int level)
 }
 
 #define SAME_CAP(n,cap) (&tterm->Strings[n] == &cap)
 }
 
 #define SAME_CAP(n,cap) (&tterm->Strings[n] == &cap)
+#define EXTRA_CAP 20
 
 int
 fmt_entry(TERMTYPE *tterm,
 
 int
 fmt_entry(TERMTYPE *tterm,
@@ -563,7 +568,7 @@ fmt_entry(TERMTYPE *tterm,
          int numbers)
 {
     PredIdx i, j;
          int numbers)
 {
     PredIdx i, j;
-    char buffer[MAX_TERMINFO_LENGTH];
+    char buffer[MAX_TERMINFO_LENGTH + EXTRA_CAP];
     char *capability;
     NCURSES_CONST char *name;
     int predval, len;
     char *capability;
     NCURSES_CONST char *name;
     int predval, len;
@@ -589,13 +594,14 @@ fmt_entry(TERMTYPE *tterm,
     } else {
        strcpy_DYN(&outbuf, tterm->term_names);
        strcpy_DYN(&outbuf, separator);
     } else {
        strcpy_DYN(&outbuf, tterm->term_names);
        strcpy_DYN(&outbuf, separator);
-       column = outbuf.used;
+       column = (int) outbuf.used;
        force_wrap();
     }
 
     for_each_boolean(j, tterm) {
        i = BoolIndirect(j);
        name = ExtBoolname(tterm, i, bool_names);
        force_wrap();
     }
 
     for_each_boolean(j, tterm) {
        i = BoolIndirect(j);
        name = ExtBoolname(tterm, i, bool_names);
+       assert(strlen(name) < sizeof(buffer) - EXTRA_CAP);
 
        if (!version_filter(BOOLEAN, i))
            continue;
 
        if (!version_filter(BOOLEAN, i))
            continue;
@@ -619,6 +625,7 @@ fmt_entry(TERMTYPE *tterm,
     for_each_number(j, tterm) {
        i = NumIndirect(j);
        name = ExtNumname(tterm, i, num_names);
     for_each_number(j, tterm) {
        i = NumIndirect(j);
        name = ExtNumname(tterm, i, num_names);
+       assert(strlen(name) < sizeof(buffer) - EXTRA_CAP);
 
        if (!version_filter(NUMBER, i))
            continue;
 
        if (!version_filter(NUMBER, i))
            continue;
@@ -641,9 +648,9 @@ fmt_entry(TERMTYPE *tterm,
     if (column != INDENT)
        force_wrap();
 
     if (column != INDENT)
        force_wrap();
 
-    len += num_bools
-       + num_values * 2
-       + strlen(tterm->term_names) + 1;
+    len += (int) (num_bools
+                 + num_values * 2
+                 + strlen(tterm->term_names) + 1);
     if (len & 1)
        len++;
 
     if (len & 1)
        len++;
 
@@ -664,6 +671,8 @@ fmt_entry(TERMTYPE *tterm,
     for_each_string(j, tterm) {
        i = StrIndirect(j);
        name = ExtStrname(tterm, i, str_names);
     for_each_string(j, tterm) {
        i = StrIndirect(j);
        name = ExtStrname(tterm, i, str_names);
+       assert(strlen(name) < sizeof(buffer) - EXTRA_CAP);
+
        capability = tterm->Strings[i];
 
        if (!version_filter(STRING, i))
        capability = tterm->Strings[i];
 
        if (!version_filter(STRING, i))
@@ -762,7 +771,7 @@ fmt_entry(TERMTYPE *tterm,
                } else {
                    sprintf(buffer, "%s=%s", name, cv);
                }
                } else {
                    sprintf(buffer, "%s=%s", name, cv);
                }
-               len += strlen(capability) + 1;
+               len += (int) strlen(capability) + 1;
                WRAP_CONCAT;
            } else {
                char *src = _nc_tic_expand(capability,
                WRAP_CONCAT;
            } else {
                char *src = _nc_tic_expand(capability,
@@ -778,7 +787,7 @@ fmt_entry(TERMTYPE *tterm,
                } else {
                    strcpy_DYN(&tmpbuf, src);
                }
                } else {
                    strcpy_DYN(&tmpbuf, src);
                }
-               len += strlen(capability) + 1;
+               len += (int) strlen(capability) + 1;
                wrap_concat(tmpbuf.text);
                outcount = TRUE;
            }
                wrap_concat(tmpbuf.text);
                outcount = TRUE;
            }
@@ -787,7 +796,7 @@ fmt_entry(TERMTYPE *tterm,
        if (capability != tterm->Strings[i])
            free(capability);
     }
        if (capability != tterm->Strings[i])
            free(capability);
     }
-    len += num_strings * 2;
+    len += (int) (num_strings * 2);
 
     /*
      * This piece of code should be an effective inverse of the functions
 
     /*
      * This piece of code should be an effective inverse of the functions
@@ -920,7 +929,7 @@ kill_labels(TERMTYPE *tterm, int target)
        sprintf(name, "lf%d", n);
        if ((cap = find_string(tterm, name)) != ABSENT_STRING
            && kill_string(tterm, cap)) {
        sprintf(name, "lf%d", n);
        if ((cap = find_string(tterm, name)) != ABSENT_STRING
            && kill_string(tterm, cap)) {
-           target -= (strlen(cap) + 5);
+           target -= (int) (strlen(cap) + 5);
            ++result;
            if (target < 0)
                break;
            ++result;
            if (target < 0)
                break;
@@ -945,7 +954,7 @@ kill_fkeys(TERMTYPE *tterm, int target)
        sprintf(name, "kf%d", n);
        if ((cap = find_string(tterm, name)) != ABSENT_STRING
            && kill_string(tterm, cap)) {
        sprintf(name, "kf%d", n);
        if ((cap = find_string(tterm, name)) != ABSENT_STRING
            && kill_string(tterm, cap)) {
-           target -= (strlen(cap) + 5);
+           target -= (int) (strlen(cap) + 5);
            ++result;
            if (target < 0)
                break;
            ++result;
            if (target < 0)
                break;
@@ -1145,7 +1154,7 @@ show_entry(void)
     trim_trailing();
     (void) fputs(outbuf.text, stdout);
     putchar('\n');
     trim_trailing();
     (void) fputs(outbuf.text, stdout);
     putchar('\n');
-    return outbuf.used;
+    return (int) outbuf.used;
 }
 
 void
 }
 
 void
@@ -1244,15 +1253,15 @@ repair_acsc(TERMTYPE *tp)
            for (n = 0; acs_chars[n] != 0; n++) {
                source = UChar(acs_chars[n]);
                if ((target = (unsigned char) acs_chars[n + 1]) != 0) {
            for (n = 0; acs_chars[n] != 0; n++) {
                source = UChar(acs_chars[n]);
                if ((target = (unsigned char) acs_chars[n + 1]) != 0) {
-                   mapped[source] = target;
+                   mapped[source] = (char) target;
                    n++;
                } else {
                    n++;
                } else {
-                   extra = source;
+                   extra = (char) source;
                }
            }
            for (n = m = 0; n < sizeof(mapped); n++) {
                if (mapped[n]) {
                }
            }
            for (n = m = 0; n < sizeof(mapped); n++) {
                if (mapped[n]) {
-                   acs_chars[m++] = n;
+                   acs_chars[m++] = (char) n;
                    acs_chars[m++] = mapped[n];
                }
            }
                    acs_chars[m++] = mapped[n];
                }
            }
index 8680df35d34f5990063ec05dd7e13d45d4b09b9a..a34153edbe98b4d84394b03e252848dce36812aa 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <dump_entry.h>
 
 
 #include <dump_entry.h>
 
-MODULE_ID("$Id: infocmp.c,v 1.96 2008/01/19 21:08:07 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.102 2008/08/04 13:05:18 tom Exp $")
 
 #define L_CURL "{"
 #define R_CURL "}"
 
 #define L_CURL "{"
 #define R_CURL "}"
@@ -568,37 +568,41 @@ same_param(const char *table, const char *param, unsigned length)
 static char *
 lookup_params(const assoc * table, char *dst, char *src)
 {
 static char *
 lookup_params(const assoc * table, char *dst, char *src)
 {
+    char *result = 0;
     const char *ep = strtok(src, ";");
     const char *ep = strtok(src, ";");
-    const assoc *ap;
 
 
-    do {
-       bool found = FALSE;
+    if (ep != 0) {
+       const assoc *ap;
 
 
-       for (ap = table; ap->from; ap++) {
-           size_t tlen = strlen(ap->from);
+       do {
+           bool found = FALSE;
 
 
-           if (same_param(ap->from, ep, tlen)) {
-               (void) strcat(dst, ap->to);
-               found = TRUE;
-               break;
+           for (ap = table; ap->from; ap++) {
+               size_t tlen = strlen(ap->from);
+
+               if (same_param(ap->from, ep, tlen)) {
+                   (void) strcat(dst, ap->to);
+                   found = TRUE;
+                   break;
+               }
            }
            }
-       }
 
 
-       if (!found)
-           (void) strcat(dst, ep);
-       (void) strcat(dst, ";");
-    } while
-       ((ep = strtok((char *) 0, ";")));
+           if (!found)
+               (void) strcat(dst, ep);
+           (void) strcat(dst, ";");
+       } while
+           ((ep = strtok((char *) 0, ";")));
 
 
-    dst[strlen(dst) - 1] = '\0';
+       dst[strlen(dst) - 1] = '\0';
 
 
-    return dst;
+       result = dst;
+    }
+    return result;
 }
 
 static void
 analyze_string(const char *name, const char *cap, TERMTYPE *tp)
 {
 }
 
 static void
 analyze_string(const char *name, const char *cap, TERMTYPE *tp)
 {
-    char buf[MAX_TERMINFO_LENGTH];
     char buf2[MAX_TERMINFO_LENGTH];
     const char *sp;
     const assoc *ap;
     char buf2[MAX_TERMINFO_LENGTH];
     const char *sp;
     const assoc *ap;
@@ -608,7 +612,6 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
        return;
     (void) printf("%s: ", name);
 
        return;
     (void) printf("%s: ", name);
 
-    buf[0] = '\0';
     for (sp = cap; *sp; sp++) {
        int i;
        int csi;
     for (sp = cap; *sp; sp++) {
        int i;
        int csi;
@@ -656,7 +659,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
        if (!expansion) {
            csi = skip_csi(sp);
            for (ap = std_caps; ap->from; ap++) {
        if (!expansion) {
            csi = skip_csi(sp);
            for (ap = std_caps; ap->from; ap++) {
-               size_t adj = csi ? 2 : 0;
+               size_t adj = (size_t)(csi ? 2 : 0);
 
                len = strlen(ap->from);
                if (csi && skip_csi(ap->from) != csi)
 
                len = strlen(ap->from);
                if (csi && skip_csi(ap->from) != csi)
@@ -665,7 +668,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
                    && strncmp(ap->from + adj, sp + csi, len - adj) == 0) {
                    expansion = ap->to;
                    len -= adj;
                    && strncmp(ap->from + adj, sp + csi, len - adj) == 0) {
                    expansion = ap->to;
                    len -= adj;
-                   len += csi;
+                   len += (size_t) csi;
                    break;
                }
            }
                    break;
                }
            }
@@ -675,13 +678,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && (len = strspn(sp + csi, "0123456789;"))
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && (len = strspn(sp + csi, "0123456789;"))
-           && (next = csi + len)
+           && (len < sizeof(buf3))
+           && (next = (size_t) csi + len)
            && ((sp[next] == 'h') || (sp[next] == 'l'))) {
 
            (void) strcpy(buf2, (sp[next] == 'h') ? "ECMA+" : "ECMA-");
            (void) strncpy(buf3, sp + csi, len);
            buf3[len] = '\0';
            && ((sp[next] == 'h') || (sp[next] == 'l'))) {
 
            (void) strcpy(buf2, (sp[next] == 'h') ? "ECMA+" : "ECMA-");
            (void) strncpy(buf3, sp + csi, len);
            buf3[len] = '\0';
-           len += csi + 1;
+           len += (size_t) csi + 1;
 
            expansion = lookup_params(std_modes, buf2, buf3);
        }
 
            expansion = lookup_params(std_modes, buf2, buf3);
        }
@@ -691,13 +695,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
            && (csi = skip_csi(sp)) != 0
            && sp[csi] == '?'
            && (len = strspn(sp + csi + 1, "0123456789;"))
            && (csi = skip_csi(sp)) != 0
            && sp[csi] == '?'
            && (len = strspn(sp + csi + 1, "0123456789;"))
-           && (next = csi + 1 + len)
+           && (len < sizeof(buf3))
+           && (next = (size_t) csi + 1 + len)
            && ((sp[next] == 'h') || (sp[next] == 'l'))) {
 
            (void) strcpy(buf2, (sp[next] == 'h') ? "DEC+" : "DEC-");
            (void) strncpy(buf3, sp + csi + 1, len);
            buf3[len] = '\0';
            && ((sp[next] == 'h') || (sp[next] == 'l'))) {
 
            (void) strcpy(buf2, (sp[next] == 'h') ? "DEC+" : "DEC-");
            (void) strncpy(buf3, sp + csi + 1, len);
            buf3[len] = '\0';
-           len += csi + 2;
+           len += (size_t) csi + 2;
 
            expansion = lookup_params(private_modes, buf2, buf3);
        }
 
            expansion = lookup_params(private_modes, buf2, buf3);
        }
@@ -706,13 +711,14 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && (len = strspn(sp + csi, "0123456789;")) != 0
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && (len = strspn(sp + csi, "0123456789;")) != 0
-           && (next = csi + len)
+           && (len < sizeof(buf3))
+           && (next = (size_t) csi + len)
            && sp[next] == 'm') {
 
            (void) strcpy(buf2, "SGR:");
            (void) strncpy(buf3, sp + csi, len);
            buf3[len] = '\0';
            && sp[next] == 'm') {
 
            (void) strcpy(buf2, "SGR:");
            (void) strncpy(buf3, sp + csi, len);
            buf3[len] = '\0';
-           len += csi + 1;
+           len += (size_t) csi + 1;
 
            expansion = lookup_params(ecma_highlights, buf2, buf3);
        }
 
            expansion = lookup_params(ecma_highlights, buf2, buf3);
        }
@@ -720,7 +726,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && sp[csi] == 'm') {
        if (!expansion
            && (csi = skip_csi(sp)) != 0
            && sp[csi] == 'm') {
-           len = csi + 1;
+           len = (size_t) csi + 1;
            (void) strcpy(buf2, "SGR:");
            strcat(buf2, ecma_highlights[0].to);
            expansion = buf2;
            (void) strcpy(buf2, "SGR:");
            strcat(buf2, ecma_highlights[0].to);
            expansion = buf2;
@@ -738,7 +744,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
                if (strncmp(buf2, sp + csi, len) == 0)
                    expansion = "RSR";
            }
                if (strncmp(buf2, sp + csi, len) == 0)
                    expansion = "RSR";
            }
-           len += csi;
+           len += (size_t) csi;
        }
 
        /* now check for home-down */
        }
 
        /* now check for home-down */
@@ -755,22 +761,21 @@ analyze_string(const char *name, const char *cap, TERMTYPE *tp)
                    expansion = "LL";
                }
            }
                    expansion = "LL";
                }
            }
-           len += csi;
+           len += (size_t) csi;
        }
 
        /* now look at the expansion we got, if any */
        if (expansion) {
        }
 
        /* now look at the expansion we got, if any */
        if (expansion) {
-           (void) sprintf(buf + strlen(buf), "{%s}", expansion);
+           printf("{%s}", expansion);
            sp += len - 1;
            sp += len - 1;
-           continue;
        } else {
            /* couldn't match anything */
            buf2[0] = *sp;
            buf2[1] = '\0';
        } else {
            /* couldn't match anything */
            buf2[0] = *sp;
            buf2[1] = '\0';
-           (void) strcat(buf, TIC_EXPAND(buf2));
+           fputs(TIC_EXPAND(buf2), stdout);
        }
     }
        }
     }
-    (void) printf("%s\n", buf);
+    putchar('\n');
 }
 
 /***************************************************************************
 }
 
 /***************************************************************************
@@ -789,6 +794,7 @@ file_comparison(int argc, char *argv[])
     ENTRY *qp, *rp;
     int i, n;
 
     ENTRY *qp, *rp;
     int i, n;
 
+    memset(heads, 0, sizeof(heads));
     dump_init((char *) 0, F_LITERAL, S_TERMINFO, 0, itrace, FALSE);
 
     for (n = 0; n < argc && n < MAXCOMPARE; n++) {
     dump_init((char *) 0, F_LITERAL, S_TERMINFO, 0, itrace, FALSE);
 
     for (n = 0; n < argc && n < MAXCOMPARE; n++) {
@@ -1059,7 +1065,6 @@ static void
 dump_initializers(TERMTYPE *term)
 {
     unsigned n;
 dump_initializers(TERMTYPE *term)
 {
     unsigned n;
-    int size;
     const char *str = 0;
 
     printf("\nstatic char %s[] = \"%s\";\n\n",
     const char *str = 0;
 
     printf("\nstatic char %s[] = \"%s\";\n\n",
@@ -1138,10 +1143,6 @@ dump_initializers(TERMTYPE *term)
     }
     (void) printf("%s;\n", R_CURL);
 
     }
     (void) printf("%s;\n", R_CURL);
 
-    size = (sizeof(TERMTYPE)
-           + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0]))
-           + (NUM_NUMBERS(term) * sizeof(term->Numbers[0])));
-
     (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
 
     for_each_string(n, term) {
     (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
 
     for_each_string(n, term) {
@@ -1283,8 +1284,8 @@ main(int argc, char *argv[])
     _nc_progname = _nc_rootname(argv[0]);
 
     /* make sure we have enough space to add two terminal entries */
     _nc_progname = _nc_rootname(argv[0]);
 
     /* make sure we have enough space to add two terminal entries */
-    myargv = typeCalloc(char *, argc + 3);
-    memcpy(myargv, argv, sizeof(char *) * argc);
+    myargv = typeCalloc(char *, (size_t)(argc + 3));
+    memcpy(myargv, argv, (sizeof(char *) * (size_t) argc));
     argv = myargv;
 
     while ((c = getopt(argc,
     argv = myargv;
 
     while ((c = getopt(argc,
index d445c3366591f7438b8421c6ae83190e1dabd8ec..f0ea4608227d394f7ce842ec8880bb2711ccf13d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -30,7 +30,7 @@
  *  Author: Thomas E. Dickey                    1997-on                     *
  ****************************************************************************/
 /*
  *  Author: Thomas E. Dickey                    1997-on                     *
  ****************************************************************************/
 /*
- * $Id: progs.priv.h,v 1.33 2007/10/13 20:33:53 tom Exp $
+ * $Id: progs.priv.h,v 1.34 2008/08/03 17:43:05 tom Exp $
  *
  *     progs.priv.h
  *
  *
  *     progs.priv.h
  *
@@ -90,6 +90,7 @@
 # endif
 #endif
 
 # endif
 #endif
 
+#include <assert.h>
 #include <errno.h>
 
 #if DECL_ERRNO
 #include <errno.h>
 
 #if DECL_ERRNO
index 84781026e51c66b40385c61442e06304eafecc88..31045a63a2a2d6a104d979798b74ca681a44aabe 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey 1996 on                                        *
+ *     and: Thomas E. Dickey                        1996 on                 *
  ****************************************************************************/
 
 /*
  ****************************************************************************/
 
 /*
@@ -44,7 +44,7 @@
 #include <dump_entry.h>
 #include <transform.h>
 
 #include <dump_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tic.c,v 1.133 2007/07/21 17:45:59 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.135 2008/08/04 12:43:40 tom Exp $")
 
 const char *_nc_progname = "tic";
 
 
 const char *_nc_progname = "tic";
 
@@ -85,9 +85,25 @@ x\
 ] \
 source-file\n";
 
 ] \
 source-file\n";
 
+#if NO_LEAKS
+static void
+free_namelist(char **src)
+{
+    if (src != 0) {
+       int n;
+       for (n = 0; src[n] != 0; ++n)
+           free(src[n]);
+       free(src);
+    }
+}
+#endif
+
 static void
 static void
-cleanup(void)
+cleanup(char **namelst)
 {
 {
+#if NO_LEAKS
+    free_namelist(namelst);
+#endif
     if (tmp_fp != 0)
        fclose(tmp_fp);
     if (to_remove != 0) {
     if (tmp_fp != 0)
        fclose(tmp_fp);
     if (to_remove != 0) {
@@ -103,7 +119,7 @@ static void
 failed(const char *msg)
 {
     perror(msg);
 failed(const char *msg)
 {
     perror(msg);
-    cleanup();
+    cleanup((char **) 0);
     ExitProgram(EXIT_FAILURE);
 }
 
     ExitProgram(EXIT_FAILURE);
 }
 
@@ -178,7 +194,7 @@ write_it(ENTRY * ep)
            d = result;
            t = s;
            while ((ch = *t++) != 0) {
            d = result;
            t = s;
            while ((ch = *t++) != 0) {
-               *d++ = ch;
+               *d++ = (char) ch;
                if (ch == '\\') {
                    *d++ = *t++;
                } else if ((ch == '%')
                if (ch == '\\') {
                    *d++ = *t++;
                } else if ((ch == '%')
@@ -192,7 +208,7 @@ write_it(ENTRY * ep)
                        && value < 127
                        && isprint((int) value)) {
                        *d++ = S_QUOTE;
                        && value < 127
                        && isprint((int) value)) {
                        *d++ = S_QUOTE;
-                       *d++ = (int) value;
+                       *d++ = (char) value;
                        *d++ = S_QUOTE;
                        t = (v + 1);
                    }
                        *d++ = S_QUOTE;
                        t = (v + 1);
                    }
@@ -280,7 +296,7 @@ put_translate(int c)
            putchar(c);
            in_name = FALSE;
        } else if (c != '>') {
            putchar(c);
            in_name = FALSE;
        } else if (c != '>') {
-           namebuf[used++] = c;
+           namebuf[used++] = (char) c;
        } else {                /* ah! candidate name! */
            char *up;
            NCURSES_CONST char *tp;
        } else {                /* ah! candidate name! */
            char *up;
            NCURSES_CONST char *tp;
@@ -353,19 +369,6 @@ open_input(const char *filename)
     return fp;
 }
 
     return fp;
 }
 
-#if NO_LEAKS
-static void
-free_namelist(char **src)
-{
-    if (src != 0) {
-       int n;
-       for (n = 0; src[n] != 0; ++n)
-           free(src[n]);
-       free(src);
-    }
-}
-#endif
-
 /* Parse the "-e" option-value into a list of names */
 static char **
 make_namelist(char *src)
 /* Parse the "-e" option-value into a list of names */
 static char **
 make_namelist(char *src)
@@ -558,7 +561,8 @@ main(int argc, char *argv[])
            break;
        case 'V':
            puts(curses_version());
            break;
        case 'V':
            puts(curses_version());
-           return EXIT_SUCCESS;
+           cleanup(namelst);
+           ExitProgram(EXIT_SUCCESS);
        case 'c':
            check_only = TRUE;
            break;
        case 'c':
            check_only = TRUE;
            break;
@@ -628,7 +632,7 @@ main(int argc, char *argv[])
     if (namelst && (!infodump && !capdump)) {
        (void) fprintf(stderr,
                       "Sorry, -e can't be used without -I or -C\n");
     if (namelst && (!infodump && !capdump)) {
        (void) fprintf(stderr,
                       "Sorry, -e can't be used without -I or -C\n");
-       cleanup();
+       cleanup(namelst);
        ExitProgram(EXIT_FAILURE);
     }
 #endif /* HAVE_BIG_CORE */
        ExitProgram(EXIT_FAILURE);
     }
 #endif /* HAVE_BIG_CORE */
@@ -671,7 +675,7 @@ main(int argc, char *argv[])
                    _nc_progname,
                    _nc_progname,
                    usage_string);
                    _nc_progname,
                    _nc_progname,
                    usage_string);
-           cleanup();
+           cleanup(namelst);
            ExitProgram(EXIT_FAILURE);
        }
     }
            ExitProgram(EXIT_FAILURE);
        }
     }
@@ -705,7 +709,7 @@ main(int argc, char *argv[])
     /* do use resolution */
     if (check_only || (!infodump && !capdump) || forceresolve) {
        if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
     /* do use resolution */
     if (check_only || (!infodump && !capdump) || forceresolve) {
        if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
-           cleanup();
+           cleanup(namelst);
            ExitProgram(EXIT_FAILURE);
        }
     }
            ExitProgram(EXIT_FAILURE);
        }
     }
@@ -799,10 +803,7 @@ main(int argc, char *argv[])
        else
            fprintf(log_fp, "No entries written\n");
     }
        else
            fprintf(log_fp, "No entries written\n");
     }
-#if NO_LEAKS
-    free_namelist(namelst);
-#endif
-    cleanup();
+    cleanup(namelst);
     ExitProgram(EXIT_SUCCESS);
 }
 
     ExitProgram(EXIT_SUCCESS);
 }
 
@@ -835,15 +836,19 @@ check_acs(TERMTYPE *tp)
            }
            mapped[UChar(p[0])] = p[1];
        }
            }
            mapped[UChar(p[0])] = p[1];
        }
+
        if (mapped[UChar('I')] && !mapped[UChar('i')]) {
            _nc_warning("acsc refers to 'I', which is probably an error");
        }
        if (mapped[UChar('I')] && !mapped[UChar('i')]) {
            _nc_warning("acsc refers to 'I', which is probably an error");
        }
+
        for (p = boxes, q = missing; *p != '\0'; ++p) {
            if (!mapped[UChar(p[0])]) {
                *q++ = p[0];
            }
        for (p = boxes, q = missing; *p != '\0'; ++p) {
            if (!mapped[UChar(p[0])]) {
                *q++ = p[0];
            }
-           *q = '\0';
        }
        }
+       *q = '\0';
+
+       assert(strlen(missing) <= strlen(boxes));
        if (*missing != '\0' && strcmp(missing, boxes)) {
            _nc_warning("acsc is missing some line-drawing mapping: %s", missing);
        }
        if (*missing != '\0' && strcmp(missing, boxes)) {
            _nc_warning("acsc is missing some line-drawing mapping: %s", missing);
        }
@@ -887,10 +892,10 @@ check_colors(TERMTYPE *tp)
     }
 }
 
     }
 }
 
-static int
+static char
 keypad_final(const char *string)
 {
 keypad_final(const char *string)
 {
-    int result = '\0';
+    char result = '\0';
 
     if (VALID_STRING(string)
        && *string++ == '\033'
 
     if (VALID_STRING(string)
        && *string++ == '\033'
@@ -918,6 +923,7 @@ keypad_index(const char *string)
     return result;
 }
 
     return result;
 }
 
+#define MAX_KP 5
 /*
  * Do a quick sanity-check for vt100-style keypads to see if the 5-key keypad
  * is mapped inconsistently.
 /*
  * Do a quick sanity-check for vt100-style keypads to see if the 5-key keypad
  * is mapped inconsistently.
@@ -932,8 +938,8 @@ check_keypad(TERMTYPE *tp)
        VALID_STRING(key_b2) &&
        VALID_STRING(key_c1) &&
        VALID_STRING(key_c3)) {
        VALID_STRING(key_b2) &&
        VALID_STRING(key_c1) &&
        VALID_STRING(key_c3)) {
-       char final[6];
-       int list[5];
+       char final[MAX_KP + 1];
+       int list[MAX_KP];
        int increase = 0;
        int j, k, kk;
        int last;
        int increase = 0;
        int j, k, kk;
        int last;
@@ -947,6 +953,7 @@ check_keypad(TERMTYPE *tp)
        final[5] = '\0';
 
        /* special case: legacy coding using 1,2,3,0,. on the bottom */
        final[5] = '\0';
 
        /* special case: legacy coding using 1,2,3,0,. on the bottom */
+       assert(strlen(final) <= MAX_KP);
        if (!strcmp(final, "qsrpn"))
            return;
 
        if (!strcmp(final, "qsrpn"))
            return;
 
@@ -957,22 +964,22 @@ check_keypad(TERMTYPE *tp)
        list[4] = keypad_index(key_c3);
 
        /* check that they're all vt100 keys */
        list[4] = keypad_index(key_c3);
 
        /* check that they're all vt100 keys */
-       for (j = 0; j < 5; ++j) {
+       for (j = 0; j < MAX_KP; ++j) {
            if (list[j] < 0) {
                return;
            }
        }
 
        /* check if they're all in increasing order */
            if (list[j] < 0) {
                return;
            }
        }
 
        /* check if they're all in increasing order */
-       for (j = 1; j < 5; ++j) {
+       for (j = 1; j < MAX_KP; ++j) {
            if (list[j] > list[j - 1]) {
                ++increase;
            }
        }
            if (list[j] > list[j - 1]) {
                ++increase;
            }
        }
-       if (increase != 4) {
+       if (increase != (MAX_KP - 1)) {
            show[0] = '\0';
 
            show[0] = '\0';
 
-           for (j = 0, last = -1; j < 5; ++j) {
+           for (j = 0, last = -1; j < MAX_KP; ++j) {
                for (k = 0, kk = -1, test = 100; k < 5; ++k) {
                    if (list[k] > last &&
                        list[k] < test) {
                for (k = 0, kk = -1, test = 100; k < 5; ++k) {
                    if (list[k] > last &&
                        list[k] < test) {
@@ -981,6 +988,7 @@ check_keypad(TERMTYPE *tp)
                    }
                }
                last = test;
                    }
                }
                last = test;
+               assert(strlen(show) < (MAX_KP * 4));
                switch (kk) {
                case 0:
                    strcat(show, " ka1");
                switch (kk) {
                case 0:
                    strcat(show, " ka1");
index 38b85cb362ed0918fd1975b29fabdce782a21c11..855fb2955cd648e57f6793b90b80382dc8692ba9 100644 (file)
@@ -44,7 +44,7 @@
 #include <hashed_db.h>
 #endif
 
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: toe.c,v 1.48 2008/01/05 20:41:26 tom Exp $")
+MODULE_ID("$Id: toe.c,v 1.50 2008/08/03 17:12:05 tom Exp $")
 
 #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
 
 
 #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
 
@@ -163,6 +163,7 @@ typelist(int eargc, char *eargv[],
     for (i = 0; i < eargc; i++) {
 #if USE_DATABASE
        if (_nc_is_dir_path(eargv[i])) {
     for (i = 0; i < eargc; i++) {
 #if USE_DATABASE
        if (_nc_is_dir_path(eargv[i])) {
+           char *cwd_buf = 0;
            DIR *termdir;
            DIRENT *subdir;
 
            DIR *termdir;
            DIRENT *subdir;
 
@@ -177,20 +178,30 @@ typelist(int eargc, char *eargv[],
 
            while ((subdir = readdir(termdir)) != 0) {
                size_t len = NAMLEN(subdir);
 
            while ((subdir = readdir(termdir)) != 0) {
                size_t len = NAMLEN(subdir);
-               char buf[PATH_MAX];
+               size_t cwd_len = len + strlen(eargv[i]) + 3;
                char name_1[PATH_MAX];
                DIR *entrydir;
                DIRENT *entry;
 
                char name_1[PATH_MAX];
                DIR *entrydir;
                DIRENT *entry;
 
+               cwd_buf = typeRealloc(char, cwd_len, cwd_buf);
+               if (cwd_buf == 0) {
+                   perror("realloc cwd_buf");
+                   continue;
+               }
+
                strncpy(name_1, subdir->d_name, len)[len] = '\0';
                if (isDotname(name_1))
                    continue;
 
                strncpy(name_1, subdir->d_name, len)[len] = '\0';
                if (isDotname(name_1))
                    continue;
 
-               (void) sprintf(buf, "%s/%s/", eargv[i], name_1);
-               if (chdir(buf) != 0)
+               (void) sprintf(cwd_buf, "%s/%.*s/", eargv[i], (int) len, name_1);
+               if (chdir(cwd_buf) != 0)
                    continue;
 
                entrydir = opendir(".");
                    continue;
 
                entrydir = opendir(".");
+               if (entrydir == 0) {
+                   perror(cwd_buf);
+                   continue;
+               }
                while ((entry = readdir(entrydir)) != 0) {
                    char name_2[PATH_MAX];
                    TERMTYPE lterm;
                while ((entry = readdir(entrydir)) != 0) {
                    char name_2[PATH_MAX];
                    TERMTYPE lterm;
@@ -222,6 +233,8 @@ typelist(int eargc, char *eargv[],
                closedir(entrydir);
            }
            closedir(termdir);
                closedir(entrydir);
            }
            closedir(termdir);
+           if (cwd_buf != 0)
+               free(cwd_buf);
        }
 #if USE_HASHED_DB
        else {
        }
 #if USE_HASHED_DB
        else {
index 3d6091224979776fd8d5c415d51464cad0718035..1c1480a2d50136292345ec2b5cca99dca7ab74a1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -104,7 +104,7 @@ char *ttyname(int fd);
 #include <dump_entry.h>
 #include <transform.h>
 
 #include <dump_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tset.c,v 1.70 2007/10/13 22:22:04 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.73 2008/08/04 12:47:05 tom Exp $")
 
 extern char **environ;
 
 
 extern char **environ;
 
@@ -168,7 +168,7 @@ failed(const char *msg)
     char temp[BUFSIZ];
     unsigned len = strlen(_nc_progname) + 2;
 
     char temp[BUFSIZ];
     unsigned len = strlen(_nc_progname) + 2;
 
-    if (len < sizeof(temp) - 12) {
+    if ((int) len < (int) sizeof(temp) - 12) {
        strcpy(temp, _nc_progname);
        strcat(temp, ": ");
     } else {
        strcpy(temp, _nc_progname);
        strcat(temp, ": ");
     } else {
@@ -440,11 +440,15 @@ add_mapping(const char *port, char *arg)
        mapp->conditional = ~mapp->conditional & (EQ | GT | LT);
 
     /* If user specified a port with an option flag, set it. */
        mapp->conditional = ~mapp->conditional & (EQ | GT | LT);
 
     /* If user specified a port with an option flag, set it. */
-  done:if (port) {
-       if (mapp->porttype)
-         badmopt:err("illegal -m option format: %s", copy);
+  done:
+    if (port) {
+       if (mapp->porttype) {
+         badmopt:
+           err("illegal -m option format: %s", copy);
+       }
        mapp->porttype = port;
     }
        mapp->porttype = port;
     }
+    free(copy);
 #ifdef MAPDEBUG
     (void) printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
     (void) printf("type: %s\n", mapp->type);
 #ifdef MAPDEBUG
     (void) printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
     (void) printf("type: %s\n", mapp->type);
@@ -780,16 +784,16 @@ reset_mode(void)
 #ifdef NLDLY
                      | NLDLY
 #endif
 #ifdef NLDLY
                      | NLDLY
 #endif
-#ifdef CRDLY 
+#ifdef CRDLY
                      | CRDLY
 #endif
                      | CRDLY
 #endif
-#ifdef TABDLY 
+#ifdef TABDLY
                      | TABDLY
 #endif
                      | TABDLY
 #endif
-#ifdef BSDLY 
+#ifdef BSDLY
                      | BSDLY
 #endif
                      | BSDLY
 #endif
-#ifdef VTDLY 
+#ifdef VTDLY
                      | VTDLY
 #endif
 #ifdef FFDLY
                      | VTDLY
 #endif
 #ifdef FFDLY
@@ -1128,9 +1132,9 @@ usage(void)
 static char
 arg_to_char(void)
 {
 static char
 arg_to_char(void)
 {
-    return (optarg[0] == '^' && optarg[1] != '\0')
-       ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1]))
-       : optarg[0];
+    return (char) ((optarg[0] == '^' && optarg[1] != '\0')
+                  ? ((optarg[1] == '?') ? '\177' : CTRL(optarg[1]))
+                  : optarg[0]);
 }
 
 int
 }
 
 int
@@ -1218,9 +1222,9 @@ main(int argc, char **argv)
     can_restore = TRUE;
     original = oldmode = mode;
 #ifdef TERMIOS
     can_restore = TRUE;
     original = oldmode = mode;
 #ifdef TERMIOS
-    ospeed = cfgetospeed(&mode);
+    ospeed = (NCURSES_OSPEED) cfgetospeed(&mode);
 #else
 #else
-    ospeed = mode.sg_ospeed;
+    ospeed = (NCURSES_OSPEED) mode.sg_ospeed;
 #endif
 
     if (!strcmp(_nc_progname, PROG_RESET)) {
 #endif
 
     if (!strcmp(_nc_progname, PROG_RESET)) {
@@ -1293,7 +1297,7 @@ main(int argc, char **argv)
         * environmental variable SHELL ending in "csh".
         */
        if ((var = getenv("SHELL")) != 0
         * environmental variable SHELL ending in "csh".
         */
        if ((var = getenv("SHELL")) != 0
-           && ((len = strlen(leaf = _nc_basename(var))) >= 3)
+           && ((len = (int) strlen(leaf = _nc_basename(var))) >= 3)
            && !strcmp(leaf + len - 3, "csh"))
            p = "set noglob;\nsetenv TERM %s;\nunset noglob;\n";
        else
            && !strcmp(leaf + len - 3, "csh"))
            p = "set noglob;\nsetenv TERM %s;\nunset noglob;\n";
        else
index 0f15d01dce81958668ec971753a0760b697dbe94..dac0c761618f8fb2cd5f68c39e86cace1d0d5496 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@
  * results, use the ncurses(3) library.  On non-Intel machines, SVr4 curses is
  * just as good.
  *
  * results, use the ncurses(3) library.  On non-Intel machines, SVr4 curses is
  * just as good.
  *
- * $Id: blue.c,v 1.29 2006/05/20 15:38:18 tom Exp $
+ * $Id: blue.c,v 1.30 2008/08/03 18:20:27 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -173,6 +173,7 @@ deal_cards(void)
 {
     int ptr, card = 0, value, csuit, crank, suit, aces[4];
 
 {
     int ptr, card = 0, value, csuit, crank, suit, aces[4];
 
+    memset(aces, 0, sizeof(aces));
     for (suit = HEARTS; suit <= CLUBS; suit++) {
        ptr = freeptr[suit];
        grid[ptr++] = NOCARD;   /* 1st card space is blank */
     for (suit = HEARTS; suit <= CLUBS; suit++) {
        ptr = freeptr[suit];
        grid[ptr++] = NOCARD;   /* 1st card space is blank */
index 4d32c70672d568ea17ddc0dce46a571cadd2c79f..f9572beb9e6de46ec7d243214717bf2bae981917 100644 (file)
--- a/test/bs.c
+++ b/test/bs.c
@@ -34,7 +34,7 @@
  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
  * v2.1 with ncurses mouse support, September 1995
  *
  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
  * v2.1 with ncurses mouse support, September 1995
  *
- * $Id: bs.c,v 1.46 2008/07/05 20:56:25 tom Exp $
+ * $Id: bs.c,v 1.47 2008/08/03 18:30:28 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -465,6 +465,7 @@ initgame(void)
            (void) clearok(stdscr, TRUE);
            (void) refresh();
        } else if (c == 'r') {
            (void) clearok(stdscr, TRUE);
            (void) refresh();
        } else if (c == 'r') {
+           assert(ss != 0);
            prompt(1, "Random-placing your %s", ss->name);
            randomplace(PLAYER, ss);
            placeship(PLAYER, ss, TRUE);
            prompt(1, "Random-placing your %s", ss->name);
            randomplace(PLAYER, ss);
            placeship(PLAYER, ss, TRUE);
@@ -480,6 +481,7 @@ initgame(void)
                }
            error((char *) NULL);
        } else if (strchr("hjkl8462", c)) {
                }
            error((char *) NULL);
        } else if (strchr("hjkl8462", c)) {
+           assert(ss != 0);
            ss->x = curx;
            ss->y = cury;
 
            ss->x = curx;
            ss->y = cury;
 
index a0034728fd113b0df66c3d15599d0b87d9202b1e..68ae4fe0526e1721b40bd04a368d6ebf8b5fe295 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: cardfile.c,v 1.33 2008/04/12 22:05:53 tom Exp $
+ * $Id: cardfile.c,v 1.35 2008/08/05 00:42:24 tom Exp $
  *
  * File format: text beginning in column 1 is a title; other text is content.
  */
  *
  * File format: text beginning in column 1 is a title; other text is content.
  */
@@ -133,12 +133,13 @@ add_content(CARD * card, const char *content)
 
     content = skip(content);
     if ((total = strlen(content)) != 0) {
 
     content = skip(content);
     if ((total = strlen(content)) != 0) {
-       if ((offset = strlen(card->content)) != 0) {
+       if (card->content != 0 && (offset = strlen(card->content)) != 0) {
            total += 1 + offset;
            card->content = typeRealloc(char, total + 1, card->content);
            if (card->content)
                strcpy(card->content + offset++, " ");
        } else {
            total += 1 + offset;
            card->content = typeRealloc(char, total + 1, card->content);
            if (card->content)
                strcpy(card->content + offset++, " ");
        } else {
+           offset = 0;
            if (card->content != 0)
                free(card->content);
            card->content = typeMalloc(char, total + 1);
            if (card->content != 0)
                free(card->content);
            card->content = typeMalloc(char, total + 1);
index e49ac2980346a536690ef5eb63404ec018ef3e51..195ef544dea1ae9070bbe071c16aae08ac3cadb1 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_defkey.c,v 1.18 2008/04/12 22:06:12 tom Exp $
+ * $Id: demo_defkey.c,v 1.19 2008/08/04 16:24:47 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2002/11/23
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2002/11/23
@@ -76,6 +76,7 @@ visichar(int ch)
     static char temp[10];
 
     ch = UChar(ch);
     static char temp[10];
 
     ch = UChar(ch);
+    assert(ch >= 0 && ch < 256);
     if (ch == '\\') {
        strcpy(temp, "\\\\");
     } else if (ch == '\033') {
     if (ch == '\\') {
        strcpy(temp, "\\\\");
     } else if (ch == '\033') {
index a4b0724f601a4145a8690766d2b359806a6395bc..e3691a6b1aa33b109c8c739b7002dfe699045923 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2003-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 2003-2007,2008 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            *
  *                                                                          *
  * 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.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_forms.c,v 1.24 2007/07/21 17:45:09 tom Exp $
+ * $Id: demo_forms.c,v 1.25 2008/08/04 15:45:04 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
@@ -316,7 +316,7 @@ demo_forms(void)
 {
     WINDOW *w;
     FORM *form;
 {
     WINDOW *w;
     FORM *form;
-    FIELD *f[100];
+    FIELD *f[100];             // FIXME memset to zero
     int finished = 0, c;
     unsigned n = 0;
     int pg;
     int finished = 0, c;
     unsigned n = 0;
     int pg;
@@ -334,6 +334,7 @@ demo_forms(void)
     refresh();
 
     /* describe the form */
     refresh();
 
     /* describe the form */
+    memset(f, 0, sizeof(f));
     for (pg = 0; pg < 4; ++pg) {
        char label[80];
        sprintf(label, "Sample Form Page %d", pg + 1);
     for (pg = 0; pg < 4; ++pg) {
        char label[80];
        sprintf(label, "Sample Form Page %d", pg + 1);
@@ -398,31 +399,32 @@ demo_forms(void)
 
     f[n++] = (FIELD *) 0;
 
 
     f[n++] = (FIELD *) 0;
 
-    form = new_form(f);
+    if ((form = new_form(f)) != 0) {
 
 
-    display_form(form);
+       display_form(form);
 
 
-    w = form_win(form);
-    also = newwin(getmaxy(stdscr) - getmaxy(w), COLS, getmaxy(w), 0);
-    show_current_field(also, form);
+       w = form_win(form);
+       also = newwin(getmaxy(stdscr) - getmaxy(w), COLS, getmaxy(w), 0);
+       show_current_field(also, form);
 
 
-    while (!finished) {
-       switch (edit_field(form, &c)) {
-       case E_OK:
-           break;
-       case E_UNKNOWN_COMMAND:
-           finished = my_form_driver(form, c);
-           break;
-       default:
-           beep();
-           break;
+       while (!finished) {
+           switch (edit_field(form, &c)) {
+           case E_OK:
+               break;
+           case E_UNKNOWN_COMMAND:
+               finished = my_form_driver(form, c);
+               break;
+           default:
+               beep();
+               break;
+           }
+           show_current_field(also, form);
        }
        }
-       show_current_field(also, form);
-    }
 
 
-    erase_form(form);
+       erase_form(form);
 
 
-    free_form(form);
+       free_form(form);
+    }
     for (c = 0; f[c] != 0; c++)
        free_field(f[c]);
     noraw();
     for (c = 0; f[c] != 0; c++)
        free_field(f[c]);
     noraw();
index 34d582ed4a20afa2e7536eca7772ab5e703a9a5b..fc7c89358ac3e467ad9cf111d8990e44e09819ab 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_menus.c,v 1.24 2008/04/12 22:03:33 tom Exp $
+ * $Id: demo_menus.c,v 1.27 2008/08/04 15:37:52 tom Exp $
  *
  * Demonstrate a variety of functions from the menu library.
  * Thomas Dickey - 2005/4/9
  *
  * Demonstrate a variety of functions from the menu library.
  * Thomas Dickey - 2005/4/9
@@ -256,23 +256,35 @@ menu_create(ITEM ** items, int count, int ncols, MenuNo number)
 static void
 menu_destroy(MENU * m)
 {
 static void
 menu_destroy(MENU * m)
 {
-    ITEM **ip;
     int count;
 
     int count;
 
+    Trace(("menu_destroy %p", m));
     if (m != 0) {
     if (m != 0) {
-       delwin(menu_sub(m));
-       delwin(menu_win(m));
+       ITEM **items = menu_items(m);
+       const char *blob = 0;
 
 
-       ip = menu_items(m);
        count = item_count(m);
        count = item_count(m);
+       Trace(("menu_destroy %p count %d", m, count));
+       if ((count > 0) && (m == mpSelect)) {
+           blob = item_name(*items);
+       }
 
 
+       unpost_menu(m);
        free_menu(m);
        free_menu(m);
-#if 0
-       if (count > 0) {
-           while (*ip) {
-               Trace(("freeing item %d:%d", ip - menu_items(m), count));
-               free_item(*ip++);
+
+       /* free the extra data allocated in build_select_menu() */
+       if ((count > 0) && (m == mpSelect)) {
+           if (blob) {
+               Trace(("freeing blob %p", blob));
+               free((char *) blob);
            }
            }
+           free(items);
+       }
+#ifdef TRACE
+       if ((count > 0) && (m == mpTrace)) {
+           ITEM **ip = items;
+           while (*ip)
+               free(*ip++);
        }
 #endif
     }
        }
 #endif
     }
@@ -340,6 +352,7 @@ build_select_menu(MenuNo number, char *filename)
 
     ITEM **ip;
     CONST_MENUS char **ap = 0;
 
     ITEM **ip;
     CONST_MENUS char **ap = 0;
+    CONST_MENUS char **myList = 0;
     unsigned count = 0;
 
     if (filename != 0) {
     unsigned count = 0;
 
     if (filename != 0) {
@@ -347,12 +360,13 @@ build_select_menu(MenuNo number, char *filename)
        if (stat(filename, &sb) == 0
            && (sb.st_mode & S_IFMT) == S_IFREG
            && sb.st_size != 0) {
        if (stat(filename, &sb) == 0
            && (sb.st_mode & S_IFMT) == S_IFREG
            && sb.st_size != 0) {
-           unsigned size = sb.st_size;
+           size_t size = (size_t) sb.st_size;
            unsigned j, k;
            char *blob = typeMalloc(char, size + 1);
            CONST_MENUS char **list = typeCalloc(CONST_MENUS char *, size + 1);
 
            items = typeCalloc(ITEM *, size + 1);
            unsigned j, k;
            char *blob = typeMalloc(char, size + 1);
            CONST_MENUS char **list = typeCalloc(CONST_MENUS char *, size + 1);
 
            items = typeCalloc(ITEM *, size + 1);
+           Trace(("build_select_menu blob=%p, items=%p", blob, items));
            if (blob != 0 && list != 0) {
                FILE *fp = fopen(filename, "r");
                if (fp != 0) {
            if (blob != 0 && list != 0) {
                FILE *fp = fopen(filename, "r");
                if (fp != 0) {
@@ -374,7 +388,7 @@ build_select_menu(MenuNo number, char *filename)
                        }
                        list[k] = 0;
                        count = k;
                        }
                        list[k] = 0;
                        count = k;
-                       ap = list;
+                       ap = myList = list;
                    }
                    fclose(fp);
                }
                    }
                    fclose(fp);
                }
@@ -393,6 +407,8 @@ build_select_menu(MenuNo number, char *filename)
     *ip = 0;
 
     mpSelect = menu_create(items, (int) count, 1, number);
     *ip = 0;
 
     mpSelect = menu_create(items, (int) count, 1, number);
+    if (myList != 0)
+       free(myList);
 }
 
 static int
 }
 
 static int
index 396d76c60d0d985720b44a2927d68274c2941fbc..55593c03bc20b041c3c761722e03b44e8e8055b2 100755 (executable)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_panels.c,v 1.31 2008/07/05 23:13:47 tom Exp $
+ * $Id: demo_panels.c,v 1.33 2008/08/04 13:33:48 tom Exp $
  *
  * Demonstrate a variety of functions from the panel library.
  */
  *
  * Demonstrate a variety of functions from the panel library.
  */
@@ -212,9 +212,9 @@ mkpanel(short color, int rows, int cols, int tly, int tlx)
        if ((pan = new_panel(win)) == 0) {
            delwin(win);
        } else if (use_colors) {
        if ((pan = new_panel(win)) == 0) {
            delwin(win);
        } else if (use_colors) {
-           short fg = ((color == COLOR_BLUE)
-                       ? COLOR_WHITE
-                       : COLOR_BLACK);
+           short fg = (short) ((color == COLOR_BLUE)
+                               ? COLOR_WHITE
+                               : COLOR_BLACK);
            short bg = color;
 
            init_pair(color, fg, bg);
            short bg = color;
 
            init_pair(color, fg, bg);
@@ -253,8 +253,8 @@ my_create_panel(PANEL ** pans, int which, FillPanel myFill)
 {
     PANEL *pan = 0;
     int code;
 {
     PANEL *pan = 0;
     int code;
-    int pair = which;
-    short fg = (pair == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK;
+    short pair = (short) which;
+    short fg = (short) ((pair == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK);
     short bg = pair;
     int x0, y0, x1, y1;
 
     short bg = pair;
     int x0, y0, x1, y1;
 
@@ -369,7 +369,8 @@ static void
 fill_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
 fill_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
-    int num = ((const char *) panel_userptr(pan))[1];
+    const char *userptr = (const char *) panel_userptr(pan);
+    int num = (userptr && *userptr) ? userptr[1] : '?';
     int y, x;
 
     wmove(win, 1, 1);
     int y, x;
 
     wmove(win, 1, 1);
@@ -388,7 +389,8 @@ static void
 fill_unboxed(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
 fill_unboxed(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
-    int num = ((const char *) panel_userptr(pan))[1];
+    const char *userptr = (const char *) panel_userptr(pan);
+    int num = (userptr && *userptr) ? userptr[1] : '?';
     int y, x;
 
     for (y = 0; y < getmaxy(win); y++) {
     int y, x;
 
     for (y = 0; y < getmaxy(win); y++) {
@@ -634,7 +636,7 @@ get_command(PANEL * px[MAX_PANELS + 1], char *buffer, int limit)
 
     if (log_in != 0) {
        if (fgets(buffer, limit - 3, log_in) != 0) {
 
     if (log_in != 0) {
        if (fgets(buffer, limit - 3, log_in) != 0) {
-           length = strlen(buffer);
+           length = (int) strlen(buffer);
            while (length > 0 && isspace(UChar(buffer[length - 1])))
                buffer[--length] = '\0';
            waddstr(win, buffer);
            while (length > 0 && isspace(UChar(buffer[length - 1])))
                buffer[--length] = '\0';
            waddstr(win, buffer);
@@ -664,22 +666,22 @@ get_command(PANEL * px[MAX_PANELS + 1], char *buffer, int limit)
                    } else if (isdigit(UChar(c0))) {
                        wprintw(win, " %c", ch);
                        buffer[length++] = ' ';
                    } else if (isdigit(UChar(c0))) {
                        wprintw(win, " %c", ch);
                        buffer[length++] = ' ';
-                       buffer[length++] = c0 = ch;
+                       buffer[length++] = (char) (c0 = ch);
                    } else {
                        wprintw(win, "%c", ch);
                    } else {
                        wprintw(win, "%c", ch);
-                       buffer[length++] = c0 = ch;
+                       buffer[length++] = (char) (c0 = ch);
                    }
                } else if (ok_digit(ch)) {
                    if (isalpha(UChar(c0))) {
                        wprintw(win, "%c", ch);
                    }
                } else if (ok_digit(ch)) {
                    if (isalpha(UChar(c0))) {
                        wprintw(win, "%c", ch);
-                       buffer[length++] = c0 = ch;
+                       buffer[length++] = (char) (c0 = ch);
                    } else {
                        beep();
                    }
                } else if (ch == ' ') {
                    if (isdigit(UChar(c0))) {
                        wprintw(win, "%c", ch);
                    } else {
                        beep();
                    }
                } else if (ch == ' ') {
                    if (isdigit(UChar(c0))) {
                        wprintw(win, "%c", ch);
-                       buffer[length++] = c0 = ch;
+                       buffer[length++] = (char) (c0 = ch);
                    } else {
                        beep();
                    }
                    } else {
                        beep();
                    }
@@ -715,7 +717,7 @@ demo_panels(InitPanel myInit, FillPanel myFill)
     memset(px, 0, sizeof(px));
 
     while (get_command(px, buffer, sizeof(buffer))) {
     memset(px, 0, sizeof(px));
 
     while (get_command(px, buffer, sizeof(buffer))) {
-       int limit = strlen(buffer);
+       int limit = (int) strlen(buffer);
        for (itmp = 0; itmp < limit; itmp += 3) {
            do_panel(px, buffer + itmp, myFill);
        }
        for (itmp = 0; itmp < limit; itmp += 3) {
            do_panel(px, buffer + itmp, myFill);
        }
index 9d1116c279eaa1e8e38802b1b17b4b0402fa72ae..b8aebac93c5678f28f94604b4354e52006bfe3c4 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey (1998-on)
  *
 /*
  * Author: Thomas E. Dickey (1998-on)
  *
- * $Id: ditto.c,v 1.30 2008/06/14 23:00:26 tom Exp $
+ * $Id: ditto.c,v 1.32 2008/08/04 13:21:41 tom Exp $
  *
  * The program illustrates how to set up multiple screens from a single
  * program.
  *
  * The program illustrates how to set up multiple screens from a single
  * program.
@@ -151,10 +151,11 @@ open_tty(char *path)
     int amaster;
     int aslave;
     char slave_name[1024];
     int amaster;
     int aslave;
     char slave_name[1024];
-    char s_option[1024];
+    char s_option[sizeof(slave_name) + 80];
     char *leaf;
 
     char *leaf;
 
-    if (openpty(&amaster, &aslave, slave_name, 0, 0) != 0)
+    if (openpty(&amaster, &aslave, slave_name, 0, 0) != 0
+       || strlen(slave_name) > sizeof(slave_name) - 1)
        failed("openpty");
     if ((leaf = strrchr(slave_name, '/')) == 0) {
        errno = EISDIR;
        failed("openpty");
     if ((leaf = strrchr(slave_name, '/')) == 0) {
        errno = EISDIR;
@@ -166,6 +167,8 @@ open_tty(char *path)
        _exit(0);
     }
     fp = fdopen(amaster, "r+");
        _exit(0);
     }
     fp = fdopen(amaster, "r+");
+    if (fp == 0)
+       failed(path);
 #else
     struct stat sb;
 
 #else
     struct stat sb;
 
@@ -180,6 +183,7 @@ open_tty(char *path)
        failed(path);
     printf("opened %s\n", path);
 #endif
        failed(path);
     printf("opened %s\n", path);
 #endif
+    assert(fp != 0);
     return fp;
 }
 
     return fp;
 }
 
@@ -195,8 +199,8 @@ init_screen(SCREEN *sp GCC_UNUSED, void *arg)
     scrollok(stdscr, TRUE);
     box(stdscr, 0, 0);
 
     scrollok(stdscr, TRUE);
     box(stdscr, 0, 0);
 
-    target->windows = typeCalloc(WINDOW *, target->length);
-    target->peeks = typeCalloc(PEEK, target->length);
+    target->windows = typeCalloc(WINDOW *, (size_t) target->length);
+    target->peeks = typeCalloc(PEEK, (size_t) target->length);
 
     high = (LINES - 2) / target->length;
     wide = (COLS - 2);
 
     high = (LINES - 2) / target->length;
     wide = (COLS - 2);
@@ -290,7 +294,7 @@ write_screen(SCREEN *sp GCC_UNUSED, void *arg GCC_UNUSED)
        while ((ch = peek_fifo(fifo, peek)) > 0) {
            changed = TRUE;
 
        while ((ch = peek_fifo(fifo, peek)) > 0) {
            changed = TRUE;
 
-           waddch(win, ch);
+           waddch(win, (chtype) ch);
            wnoutrefresh(win);
        }
     }
            wnoutrefresh(win);
        }
     }
@@ -357,7 +361,7 @@ main(int argc, char *argv[])
     if (argc <= 1)
        usage();
 
     if (argc <= 1)
        usage();
 
-    if ((data = typeCalloc(DITTO, argc)) == 0)
+    if ((data = typeCalloc(DITTO, (size_t) argc)) == 0)
        failed("calloc data");
 
     for (j = 0; j < argc; j++) {
        failed("calloc data");
 
     for (j = 0; j < argc; j++) {
index 7aa2e0cadacbf694c27720b5f28049f5f07fcb5b..ef220fed59ba7f6ead313bc6f46622c56f247336 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +33,7 @@
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
  *
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
  *
- * $Id: gdc.c,v 1.29 2007/07/21 17:45:09 tom Exp $
+ * $Id: gdc.c,v 1.31 2008/08/03 23:58:42 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -85,13 +85,14 @@ drawbox(bool scrolling)
     mvaddch(YBASE - 1, XBASE + XLENGTH, ACS_URCORNER);
 
     mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
     mvaddch(YBASE - 1, XBASE + XLENGTH, ACS_URCORNER);
 
     mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
-    mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
-    for (n = 0; n < XLENGTH; n++) {
-       if (!scrolling)
-           bottom[n] &= ~A_COLOR;
-       bottom[n] = ACS_HLINE | (bottom[n] & (A_ATTRIBUTES | A_COLOR));
+    if ((mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH)) != ERR) {
+       for (n = 0; n < XLENGTH; n++) {
+           if (!scrolling)
+               bottom[n] &= ~A_COLOR;
+           bottom[n] = ACS_HLINE | (bottom[n] & (A_ATTRIBUTES | A_COLOR));
+       }
+       mvaddchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
     }
     }
-    mvaddchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
     mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER);
 
     move(YBASE, XBASE - 1);
     mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER);
 
     move(YBASE, XBASE - 1);
@@ -186,6 +187,7 @@ main(int argc, char *argv[])
     }
     if (optind < argc) {
        count = atoi(argv[optind++]);
     }
     if (optind < argc) {
        count = atoi(argv[optind++]);
+       assert(count >= 0);
     }
     if (optind < argc)
        usage();
     }
     if (optind < argc)
        usage();
index a763dce8eb2cec0f27042c4846788e3bc56dcc79..bd0fb10e1f8e9a3aaca0067f3aca82357921ae4e 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,7 +41,7 @@
  *
  *     Date: 05.Nov.90
  *
  *
  *     Date: 05.Nov.90
  *
- * $Id: hanoi.c,v 1.25 2006/04/22 22:41:22 tom Exp $
+ * $Id: hanoi.c,v 1.27 2008/08/04 10:57:59 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -81,6 +81,7 @@ static int TileColour[] =
     COLOR_RED,                 /* Length 19 */
 };
 static int NMoves = 0;
     COLOR_RED,                 /* Length 19 */
 };
 static int NMoves = 0;
+static bool AutoFlag = FALSE;
 
 static void InitTiles(int NTiles);
 static void DisplayTiles(void);
 
 static void InitTiles(int NTiles);
 static void DisplayTiles(void);
@@ -95,7 +96,6 @@ int
 main(int argc, char **argv)
 {
     int NTiles, FromCol, ToCol;
 main(int argc, char **argv)
 {
     int NTiles, FromCol, ToCol;
-    bool AutoFlag = 0;
 
     setlocale(LC_ALL, "");
 
 
     setlocale(LC_ALL, "");
 
@@ -246,15 +246,18 @@ DisplayTiles(void)
     /* Draw tiles */
     for (peg = 0; peg < NPEGS; peg++) {
        for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
     /* Draw tiles */
     for (peg = 0; peg < NPEGS; peg++) {
        for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
-           memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]);
-           TileBuf[Pegs[peg].Length[SlotNo]] = '\0';
-           if (has_colors())
-               attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo])));
-           else
-               attrset(A_REVERSE);
-           mvaddstr(BASELINE - (SlotNo + 1),
-                    (int) (PegPos[peg] - Pegs[peg].Length[SlotNo] / 2),
-                    TileBuf);
+           unsigned len = Pegs[peg].Length[SlotNo];
+           if (len < sizeof(TileBuf) - 1 && len < (unsigned) PegPos[peg]) {
+               memset(TileBuf, ' ', len);
+               TileBuf[len] = '\0';
+               if (has_colors())
+                   attrset(COLOR_PAIR(LENTOIND(len)));
+               else
+                   attrset(A_REVERSE);
+               mvaddstr(BASELINE - (SlotNo + 1),
+                        (int) (PegPos[peg] - len / 2),
+                        TileBuf);
+           }
        }
     }
     attrset(A_NORMAL);
        }
     }
     attrset(A_NORMAL);
@@ -278,7 +281,8 @@ GetMove(int *From, int *To)
        return TRUE;
     *To -= ('0' + 1);
     refresh();
        return TRUE;
     *To -= ('0' + 1);
     refresh();
-    napms(500);
+    if (!AutoFlag)
+       napms(500);
 
     move(STATUSLINE, 0);
     clrtoeol();
 
     move(STATUSLINE, 0);
     clrtoeol();
index af0ca8ab945052b0ae516fbd5d7783ace8ef1149..f9ba1dc25bf083ea9ee73cdd40f5af87fec9c48c 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +33,7 @@
  * Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995.  Mouse support
  * added September 20th 1995.
  *
  * Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995.  Mouse support
  * added September 20th 1995.
  *
- * $Id: knight.c,v 1.27 2006/04/22 22:41:22 tom Exp $
+ * $Id: knight.c,v 1.28 2008/08/03 23:04:26 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -383,7 +383,7 @@ drawmove(chtype tchar, int oldy, int oldx, int row, int column)
        mark_possibles(oldy, oldx, ' ');
     }
 
        mark_possibles(oldy, oldx, ' ');
     }
 
-    if (row != -1 && column != -1) {
+    if (row >= 0 && column >= 0) {
        markcell(trail, row, column);
        mark_possibles(row, column, minus);
        board[row][column] = TRUE;
        markcell(trail, row, column);
        mark_possibles(row, column, minus);
        board[row][column] = TRUE;
index b55031fe4b41c0321dbd8d6ac877e72c8fa23ed7..05e754e973a570a482dcdb82c6886af496027585 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).
 
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.315 2008/07/05 23:26:35 tom Exp $
+$Id: ncurses.c,v 1.324 2008/08/04 16:27:54 tom Exp $
 
 ***************************************************************************/
 
 
 ***************************************************************************/
 
@@ -212,7 +212,7 @@ wGetstring(WINDOW *win, char *buffer, int limit)
     getyx(win, y0, x0);
     wattrset(win, A_REVERSE);
 
     getyx(win, y0, x0);
     wattrset(win, A_REVERSE);
 
-    x = strlen(buffer);
+    x = (int) strlen(buffer);
     while (!done) {
        if (x > (int) strlen(buffer))
            x = (int) strlen(buffer);
     while (!done) {
        if (x > (int) strlen(buffer))
            x = (int) strlen(buffer);
@@ -254,10 +254,10 @@ wGetstring(WINDOW *win, char *buffer, int limit)
                beep();
            } else if ((int) strlen(buffer) < limit) {
                int j;
                beep();
            } else if ((int) strlen(buffer) < limit) {
                int j;
-               for (j = strlen(buffer) + 1; j > x; --j) {
+               for (j = (int) strlen(buffer) + 1; j > x; --j) {
                    buffer[j] = buffer[j - 1];
                }
                    buffer[j] = buffer[j - 1];
                }
-               buffer[x++] = ch;
+               buffer[x++] = (char) ch;
            } else {
                flash();
            }
            } else {
                flash();
            }
@@ -343,7 +343,7 @@ wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
     getyx(win, y0, x0);
     wattrset(win, A_REVERSE);
 
     getyx(win, y0, x0);
     wattrset(win, A_REVERSE);
 
-    x = wcslen(buffer);
+    x = (int) wcslen(buffer);
     while (!done) {
        if (x > (int) wcslen(buffer))
            x = (int) wcslen(buffer);
     while (!done) {
        if (x > (int) wcslen(buffer))
            x = (int) wcslen(buffer);
@@ -422,10 +422,10 @@ wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
                beep();
            } else if ((int) wcslen(buffer) < limit) {
                int j;
                beep();
            } else if ((int) wcslen(buffer) < limit) {
                int j;
-               for (j = wcslen(buffer) + 1; j > x; --j) {
+               for (j = (int) wcslen(buffer) + 1; j > x; --j) {
                    buffer[j] = buffer[j - 1];
                }
                    buffer[j] = buffer[j - 1];
                }
-               buffer[x++] = ch;
+               buffer[x++] = (wchar_t) ch;
            } else {
                beep();
            }
            } else {
                beep();
            }
@@ -583,7 +583,7 @@ wgetch_help(WINDOW *win, bool flags[])
     printw("Type any key to see its %s value.  Also:\n",
           flags['k'] ? "keypad" : "literal");
     for (n = 0; n < SIZEOF(help); ++n) {
     printw("Type any key to see its %s value.  Also:\n",
           flags['k'] ? "keypad" : "literal");
     for (n = 0; n < SIZEOF(help); ++n) {
-       int row = 1 + (n % chk);
+       int row = 1 + (int) (n % chk);
        int col = (n >= chk) ? COLS / 2 : 0;
        int flg = ((strstr(help[n], "toggle") != 0)
                   && (flags[UChar(*help[n])] != FALSE));
        int col = (n >= chk) ? COLS / 2 : 0;
        int flg = ((strstr(help[n], "toggle") != 0)
                   && (flags[UChar(*help[n])] != FALSE));
@@ -635,6 +635,8 @@ remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win)
 {
     unsigned need = (level + 1) * 2;
 
 {
     unsigned need = (level + 1) * 2;
 
+    assert(level < COLS);
+
     if (winstack == 0) {
        len_winstack = 20;
        winstack = typeMalloc(WINSTACK, len_winstack);
     if (winstack == 0) {
        len_winstack = 20;
        winstack = typeMalloc(WINSTACK, len_winstack);
@@ -812,7 +814,7 @@ wgetch_test(unsigned level, WINDOW *win, int delay)
 #endif
                (void) waddstr(win, keyname(c));
            } else if (c > 0x80) {
 #endif
                (void) waddstr(win, keyname(c));
            } else if (c > 0x80) {
-               unsigned c2 = (c & 0x7f);
+               unsigned c2 = (unsigned) (c & 0x7f);
                if (isprint(c2))
                    (void) wprintw(win, "M-%c", UChar(c2));
                else
                if (isprint(c2))
                    (void) wprintw(win, "M-%c", UChar(c2));
                else
@@ -931,13 +933,14 @@ wcstos(const wchar_t *src)
     const wchar_t *tmp = src;
 
     memset(&state, 0, sizeof(state));
     const wchar_t *tmp = src;
 
     memset(&state, 0, sizeof(state));
-    if ((need = wcsrtombs(0, &tmp, 0, &state)) > 0) {
-       unsigned have = need;
-       result = typeCalloc(char, have + 1);
-       tmp = src;
-       if (wcsrtombs(result, &tmp, have, &state) != have) {
-           free(result);
-           result = 0;
+    if ((need = (int) wcsrtombs(0, &tmp, 0, &state)) > 0) {
+       unsigned have = (unsigned) need;
+       if ((result = typeCalloc(char, have + 1)) != 0) {
+           tmp = src;
+           if (wcsrtombs(result, &tmp, have, &state) != have) {
+               free(result);
+               result = 0;
+           }
        }
     }
     return result;
        }
     }
     return result;
@@ -996,7 +999,9 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
                wprintw(win, "wgetn_wstr returns an error.");
            } else {
                int n;
                wprintw(win, "wgetn_wstr returns an error.");
            } else {
                int n;
-               for (n = 0; (wchar_buf[n] = wint_buf[n]) != 0; ++n) ;
+               for (n = 0; (wchar_buf[n] = (wchar_t) wint_buf[n]) != 0; ++n) {
+                   ;
+               }
                if ((temp = wcstos(wchar_buf)) != 0) {
                    wprintw(win, "I saw %d characters:\n\t`%s'.",
                            (int) wcslen(wchar_buf), temp);
                if ((temp = wcstos(wchar_buf)) != 0) {
                    wprintw(win, "I saw %d characters:\n\t`%s'.",
                            (int) wcslen(wchar_buf), temp);
@@ -1072,7 +1077,7 @@ wget_wch_test(unsigned level, WINDOW *win, int delay)
                if (c < 256 && iscntrl(c)) {
                    (void) wprintw(win, "%s (control character)", unctrl(c));
                } else {
                if (c < 256 && iscntrl(c)) {
                    (void) wprintw(win, "%s (control character)", unctrl(c));
                } else {
-                   wchar_t c2 = c;
+                   wchar_t c2 = (wchar_t) c;
                    waddnwstr(win, &c2, 1);
                    (void) wprintw(win, " = %#x (printable character)", c);
                }
                    waddnwstr(win, &c2, 1);
                    (void) wprintw(win, " = %#x (printable character)", c);
                }
@@ -1204,22 +1209,22 @@ cycle_color_attr(int ch, short *fg, short *bg, short *tx)
     if (use_colors) {
        switch (ch) {
        case 'f':
     if (use_colors) {
        switch (ch) {
        case 'f':
-           *fg = (*fg + 1);
+           *fg = (short) (*fg + 1);
            break;
        case 'F':
            break;
        case 'F':
-           *fg = (*fg - 1);
+           *fg = (short) (*fg - 1);
            break;
        case 'b':
            break;
        case 'b':
-           *bg = (*bg + 1);
+           *bg = (short) (*bg + 1);
            break;
        case 'B':
            break;
        case 'B':
-           *bg = (*bg - 1);
+           *bg = (short) (*bg - 1);
            break;
        case 't':
            break;
        case 't':
-           *tx = (*tx + 1);
+           *tx = (short) (*tx + 1);
            break;
        case 'T':
            break;
        case 'T':
-           *tx = (*tx - 1);
+           *tx = (short) (*tx - 1);
            break;
        default:
            beep();
            break;
        default:
            beep();
@@ -1227,17 +1232,17 @@ cycle_color_attr(int ch, short *fg, short *bg, short *tx)
            break;
        }
        if (*fg >= COLORS)
            break;
        }
        if (*fg >= COLORS)
-           *fg = min_colors;
+           *fg = (short) min_colors;
        if (*fg < min_colors)
        if (*fg < min_colors)
-           *fg = COLORS - 1;
+           *fg = (short) (COLORS - 1);
        if (*bg >= COLORS)
        if (*bg >= COLORS)
-           *bg = min_colors;
+           *bg = (short) min_colors;
        if (*bg < min_colors)
        if (*bg < min_colors)
-           *bg = COLORS - 1;
+           *bg = (short) (COLORS - 1);
        if (*tx >= COLORS)
            *tx = -1;
        if (*tx < -1)
        if (*tx >= COLORS)
            *tx = -1;
        if (*tx < -1)
-           *tx = COLORS - 1;
+           *tx = (short) (COLORS - 1);
     } else {
        beep();
        error = TRUE;
     } else {
        beep();
        error = TRUE;
@@ -1254,11 +1259,11 @@ adjust_attr_string(int adjust)
     if (first >= ' ' && last <= '~') { /* 32..126 */
        int j, k;
        for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
     if (first >= ' ' && last <= '~') { /* 32..126 */
        int j, k;
        for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
-           attr_test_string[j] = k;
+           attr_test_string[j] = (char) k;
            if (((k + 1 - first) % 5) == 0) {
            if (((k + 1 - first) % 5) == 0) {
-               ++j;
-               if (j < MAX_ATTRSTRING)
-                   attr_test_string[j] = ' ';
+               if (++j >= MAX_ATTRSTRING)
+                   break;
+               attr_test_string[j] = ' ';
            }
        }
        while (j < MAX_ATTRSTRING)
            }
        }
        while (j < MAX_ATTRSTRING)
@@ -1448,10 +1453,10 @@ attr_test(void)
     do {
        int row = 2;
        chtype normal = A_NORMAL | BLANK;
     do {
        int row = 2;
        chtype normal = A_NORMAL | BLANK;
-       chtype extras = ac;
+       chtype extras = (chtype) ac;
 
        if (use_colors) {
 
        if (use_colors) {
-           short pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
+           short pair = (short) (fg != COLOR_BLACK || bg != COLOR_BLACK);
            if (pair != 0) {
                pair = 1;
                if (init_pair(pair, fg, bg) == ERR) {
            if (pair != 0) {
                pair = 1;
                if (init_pair(pair, fg, bg) == ERR) {
@@ -1514,9 +1519,9 @@ wide_adjust_attr_string(int adjust)
        for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
            wide_attr_test_string[j] = k;
            if (((k + 1 - first) % 5) == 0) {
        for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
            wide_attr_test_string[j] = k;
            if (((k + 1 - first) % 5) == 0) {
-               ++j;
-               if (j < MAX_ATTRSTRING)
-                   wide_attr_test_string[j] = ' ';
+               if (++j >= MAX_ATTRSTRING)
+                   break;
+               wide_attr_test_string[j] = ' ';
            }
        }
        while (j < MAX_ATTRSTRING)
            }
        }
        while (j < MAX_ATTRSTRING)
@@ -1727,7 +1732,7 @@ wide_attr_test(void)
        short extras = 0;
 
        if (use_colors) {
        short extras = 0;
 
        if (use_colors) {
-           pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
+           pair = (short) (fg != COLOR_BLACK || bg != COLOR_BLACK);
            if (pair != 0) {
                pair = 1;
                if (init_pair(pair, fg, bg) == ERR) {
            if (pair != 0) {
                pair = 1;
                if (init_pair(pair, fg, bg) == ERR) {
@@ -1916,14 +1921,14 @@ color_test(void)
            show_color_name(top + 2, (i + 1) * width, i, opt_wide);
 
        /* show a grid of colors, with color names/ numbers on the left */
            show_color_name(top + 2, (i + 1) * width, i, opt_wide);
 
        /* show a grid of colors, with color names/ numbers on the left */
-       for (i = (base_row * per_row); i < pairs_max; i++) {
+       for (i = (short) (base_row * per_row); i < pairs_max; i++) {
            int row = grid_top + (i / per_row) - base_row;
            int col = (i % per_row + 1) * width;
            short pair = i;
 
            if (row >= 0 && move(row, col) != ERR) {
            int row = grid_top + (i / per_row) - base_row;
            int col = (i % per_row + 1) * width;
            short pair = i;
 
            if (row >= 0 && move(row, col) != ERR) {
-               short fg = i % COLORS;
-               short bg = i / COLORS;
+               short fg = (short) (i % COLORS);
+               short bg = (short) (i / COLORS);
 
                init_pair(pair, fg, bg);
                attron((attr_t) COLOR_PAIR(pair));
 
                init_pair(pair, fg, bg);
                attron((attr_t) COLOR_PAIR(pair));
@@ -2100,10 +2105,10 @@ wide_color_test(void)
        for (i = (base_row * per_row); i < pairs_max; i++) {
            int row = grid_top + (i / per_row) - base_row;
            int col = (i % per_row + 1) * width;
        for (i = (base_row * per_row); i < pairs_max; i++) {
            int row = grid_top + (i / per_row) - base_row;
            int col = (i % per_row + 1) * width;
-           int pair = i;
+           short pair = (short) i;
 
            if (row >= 0 && move(row, col) != ERR) {
 
            if (row >= 0 && move(row, col) != ERR) {
-               init_pair(pair, i % COLORS, i / COLORS);
+               init_pair(pair, (short) (i % COLORS), (short) (i / COLORS));
                color_set(pair, NULL);
                if (opt_acsc)
                    attr_on((attr_t) A_ALTCHARSET, NULL);
                color_set(pair, NULL);
                if (opt_acsc)
                    attr_on((attr_t) A_ALTCHARSET, NULL);
@@ -2231,13 +2236,13 @@ change_color(short current, int field, int value, int usebase)
 
     switch (field) {
     case 0:
 
     switch (field) {
     case 0:
-       red = usebase ? red + value : value;
+       red = (short) (usebase ? (red + value) : value);
        break;
     case 1:
        break;
     case 1:
-       green = usebase ? green + value : value;
+       green = (short) (usebase ? (green + value) : value);
        break;
     case 2:
        break;
     case 2:
-       blue = usebase ? blue + value : value;
+       blue = (short) (usebase ? (blue + value) : value);
        break;
     }
 
        break;
     }
 
@@ -2263,8 +2268,8 @@ static void
 color_edit(void)
 /* display the color test pattern, without trying to edit colors */
 {
 color_edit(void)
 /* display the color test pattern, without trying to edit colors */
 {
-    short i;
-    short current = 0;
+    int i;
+    int current = 0;
     int this_c = 0, value = 0, field = 0;
     int last_c;
     int top_color = 0;
     int this_c = 0, value = 0, field = 0;
     int last_c;
     int top_color = 0;
@@ -2274,7 +2279,7 @@ color_edit(void)
     refresh();
 
     for (i = 0; i < max_colors; i++)
     refresh();
 
     for (i = 0; i < max_colors; i++)
-       init_pair(i, COLOR_WHITE, i);
+       init_pair((short) i, (short) COLOR_WHITE, (short) i);
 
     mvprintw(LINES - 2, 0, "Number: %d", value);
 
 
     mvprintw(LINES - 2, 0, "Number: %d", value);
 
@@ -2285,7 +2290,7 @@ color_edit(void)
        mvaddstr(0, 20, "Color RGB Value Editing");
        attroff(A_BOLD);
 
        mvaddstr(0, 20, "Color RGB Value Editing");
        attroff(A_BOLD);
 
-       for (i = top_color;
+       for (i = (short) top_color;
             (i - top_color < page_size)
             && (i < max_colors); i++) {
            char numeric[80];
             (i - top_color < page_size)
             && (i < max_colors); i++) {
            char numeric[80];
@@ -2299,7 +2304,7 @@ color_edit(void)
            addstr("        ");
            attrset(A_NORMAL);
 
            addstr("        ");
            attrset(A_NORMAL);
 
-           color_content(i, &red, &green, &blue);
+           color_content((short) i, &red, &green, &blue);
            addstr("   R = ");
            if (current == i && field == 0)
                attron(A_STANDOUT);
            addstr("   R = ");
            if (current == i && field == 0)
                attron(A_STANDOUT);
@@ -2386,15 +2391,15 @@ color_edit(void)
            break;
 
        case '+':
            break;
 
        case '+':
-           change_color(current, field, value, 1);
+           change_color((short) current, field, value, 1);
            break;
 
        case '-':
            break;
 
        case '-':
-           change_color(current, field, -value, 1);
+           change_color((short) current, field, -value, 1);
            break;
 
        case '=':
            break;
 
        case '=':
-           change_color(current, field, value, 0);
+           change_color((short) current, field, value, 0);
            break;
 
        case '?':
            break;
 
        case '?':
@@ -2599,13 +2604,13 @@ slk_test(void)
 #if HAVE_SLK_COLOR
        case 'F':
            if (use_colors) {
 #if HAVE_SLK_COLOR
        case 'F':
            if (use_colors) {
-               fg = (fg + 1) % COLORS;
+               fg = (short) ((fg + 1) % COLORS);
                call_slk_color(fg, bg);
            }
            break;
        case 'B':
            if (use_colors) {
                call_slk_color(fg, bg);
            }
            break;
        case 'B':
            if (use_colors) {
-               bg = (bg + 1) % COLORS;
+               bg = (short) ((bg + 1) % COLORS);
                call_slk_color(fg, bg);
            }
            break;
                call_slk_color(fg, bg);
            }
            break;
@@ -2731,13 +2736,13 @@ wide_slk_test(void)
 
        case 'F':
            if (use_colors) {
 
        case 'F':
            if (use_colors) {
-               fg = (fg + 1) % COLORS;
+               fg = (short) ((fg + 1) % COLORS);
                call_slk_color(fg, bg);
            }
            break;
        case 'B':
            if (use_colors) {
                call_slk_color(fg, bg);
            }
            break;
        case 'B':
            if (use_colors) {
-               bg = (bg + 1) % COLORS;
+               bg = (short) ((bg + 1) % COLORS);
                call_slk_color(fg, bg);
            }
            break;
                call_slk_color(fg, bg);
            }
            break;
@@ -2830,10 +2835,10 @@ cycle_colors(int ch, int *fg, int *bg, short *pair)
            break;
        }
        if (result) {
            break;
        }
        if (result) {
-           *pair = (*fg != COLOR_BLACK || *bg != COLOR_BLACK);
+           *pair = (short) (*fg != COLOR_BLACK || *bg != COLOR_BLACK);
            if (*pair != 0) {
                *pair = 1;
            if (*pair != 0) {
                *pair = 1;
-               if (init_pair(*pair, *fg, *bg) == ERR) {
+               if (init_pair(*pair, (short) *fg, (short) *bg) == ERR) {
                    result = FALSE;
                }
            }
                    result = FALSE;
                }
            }
@@ -2862,8 +2867,8 @@ show_upper_chars(unsigned first, int repeat, attr_t attr, short pair)
 
     for (code = first; code <= last; code++) {
        int count = repeat;
 
     for (code = first; code <= last; code++) {
        int count = repeat;
-       int row = 2 + ((code - first) % 16);
-       int col = ((code - first) / 16) * COLS / 2;
+       int row = 2 + ((int) (code - first) % 16);
+       int col = ((int) (code - first) / 16) * COLS / 2;
        char tmp[80];
        sprintf(tmp, "%3u (0x%x)", code, code);
        mvprintw(row, col, "%*s: ", COLS / 4, tmp);
        char tmp[80];
        sprintf(tmp, "%3u (0x%x)", code, code);
        mvprintw(row, col, "%*s: ", COLS / 4, tmp);
@@ -2902,8 +2907,8 @@ show_pc_chars(int repeat, attr_t attr, short pair)
     }
     for (code = 0; code < 256; code++) {
        int count = repeat;
     }
     for (code = 0; code < 256; code++) {
        int count = repeat;
-       int row = 3 + (code / 16) + (code >= 128);
-       int col = 8 + (code % 16) * PC_COLS;
+       int row = 3 + (int) (code / 16) + (code >= 128);
+       int col = 8 + (int) (code % 16) * PC_COLS;
        if ((code % 16) == 0)
            mvprintw(row, 0, "0x%02x:", code);
        move(row, col);
        if ((code % 16) == 0)
            mvprintw(row, 0, "0x%02x:", code);
        move(row, col);
@@ -3101,7 +3106,7 @@ acs_display(void)
        if (last_show_acs != 0)
            last_show_acs(repeat, attr, pair);
        else
        if (last_show_acs != 0)
            last_show_acs(repeat, attr, pair);
        else
-           show_upper_chars(digit * 32 + 128, repeat, attr, pair);
+           show_upper_chars((unsigned) (digit * 32 + 128), repeat, attr, pair);
 
        mvprintw(LINES - 3, 0,
                 "Note: ANSI terminals may not display C1 characters.");
 
        mvprintw(LINES - 3, 0,
                 "Note: ANSI terminals may not display C1 characters.");
@@ -3137,7 +3142,7 @@ merge_wide_attr(cchar_t *dst, const cchar_t *src, attr_t attr, short pair)
 
     *dst = *src;
     if (count > 0) {
 
     *dst = *src;
     if (count > 0) {
-       if ((wch = typeMalloc(wchar_t, count + 1)) != 0) {
+       if ((wch = typeMalloc(wchar_t, (unsigned) count + 1)) != 0) {
            if (getcchar(src, wch, &ignore_attr, &ignore_pair, 0) != ERR) {
                attr |= (ignore_attr & A_ALTCHARSET);
                setcchar(dst, wch, attr, pair, 0);
            if (getcchar(src, wch, &ignore_attr, &ignore_pair, 0) != ERR) {
                attr |= (ignore_attr & A_ALTCHARSET);
                setcchar(dst, wch, attr, pair, 0);
@@ -3574,6 +3579,12 @@ FRAME
 #define is_scrollok(win) FALSE
 #endif
 
 #define is_scrollok(win) FALSE
 #endif
 
+static WINDOW *
+frame_win(FRAME * curp)
+{
+    return (curp != 0) ? curp->wind : stdscr;
+}
+
 /* We need to know if these flags are actually set, so don't look in FRAME.
  * These names are known to work with SVr4 curses as well as ncurses.  The
  * _use_keypad name does not work with Solaris 8.
 /* We need to know if these flags are actually set, so don't look in FRAME.
  * These names are known to work with SVr4 curses as well as ncurses.  The
  * _use_keypad name does not work with Solaris 8.
@@ -3581,7 +3592,7 @@ FRAME
 static bool
 HaveKeypad(FRAME * curp)
 {
 static bool
 HaveKeypad(FRAME * curp)
 {
-    WINDOW *win = (curp ? curp->wind : stdscr);
+    WINDOW *win = frame_win(curp);
     (void) win;
     return is_keypad(win);
 }
     (void) win;
     return is_keypad(win);
 }
@@ -3589,7 +3600,7 @@ HaveKeypad(FRAME * curp)
 static bool
 HaveScroll(FRAME * curp)
 {
 static bool
 HaveScroll(FRAME * curp)
 {
-    WINDOW *win = (curp ? curp->wind : stdscr);
+    WINDOW *win = frame_win(curp);
     (void) win;
     return is_scrollok(win);
 }
     (void) win;
     return is_scrollok(win);
 }
@@ -3687,7 +3698,7 @@ static void
 newwin_report(FRAME * curp)
 /* report on the cursor's current position, then restore it */
 {
 newwin_report(FRAME * curp)
 /* report on the cursor's current position, then restore it */
 {
-    WINDOW *win = (curp != 0) ? curp->wind : stdscr;
+    WINDOW *win = frame_win(curp);
     int y, x;
 
     if (win != stdscr)
     int y, x;
 
     if (win != stdscr)
@@ -3814,7 +3825,7 @@ getwindow(void)
 static void
 newwin_move(FRAME * curp, int dy, int dx)
 {
 static void
 newwin_move(FRAME * curp, int dy, int dx)
 {
-    WINDOW *win = (curp != 0) ? curp->wind : stdscr;
+    WINDOW *win = frame_win(curp);
     int cur_y, cur_x;
     int max_y, max_x;
 
     int cur_y, cur_x;
     int max_y, max_x;
 
@@ -3834,19 +3845,21 @@ newwin_move(FRAME * curp, int dy, int dx)
 static FRAME *
 delete_framed(FRAME * fp, bool showit)
 {
 static FRAME *
 delete_framed(FRAME * fp, bool showit)
 {
-    FRAME *np;
+    FRAME *np = 0;
 
 
-    fp->last->next = fp->next;
-    fp->next->last = fp->last;
+    if (fp != 0) {
+       fp->last->next = fp->next;
+       fp->next->last = fp->last;
 
 
-    if (showit) {
-       werase(fp->wind);
-       wrefresh(fp->wind);
-    }
-    delwin(fp->wind);
+       if (showit) {
+           werase(fp->wind);
+           wrefresh(fp->wind);
+       }
+       delwin(fp->wind);
 
 
-    np = (fp == fp->next) ? 0 : fp->next;
-    free(fp);
+       np = (fp == fp->next) ? 0 : fp->next;
+       free(fp);
+    }
     return np;
 }
 
     return np;
 }
 
@@ -3872,9 +3885,13 @@ acs_and_scroll(void)
        transient((FRAME *) 0, (char *) 0);
        switch (c) {
        case CTRL('C'):
        transient((FRAME *) 0, (char *) 0);
        switch (c) {
        case CTRL('C'):
-           neww = typeCalloc(FRAME, 1);
-           if ((neww->wind = getwindow()) == (WINDOW *) 0)
+           if ((neww = typeCalloc(FRAME, 1)) == 0) {
+               goto breakout;
+           }
+           if ((neww->wind = getwindow()) == (WINDOW *) 0) {
+               free(neww);
                goto breakout;
                goto breakout;
+           }
 
            if (current == 0) { /* First element,  */
                neww->next = neww;      /*   so point it at itself */
 
            if (current == 0) { /* First element,  */
                neww->next = neww;      /*   so point it at itself */
@@ -3907,12 +3924,12 @@ acs_and_scroll(void)
 
        case CTRL('F'): /* scroll current window forward */
            if (current)
 
        case CTRL('F'): /* scroll current window forward */
            if (current)
-               wscrl(current->wind, 1);
+               wscrl(frame_win(current), 1);
            break;
 
        case CTRL('B'): /* scroll current window backwards */
            if (current)
            break;
 
        case CTRL('B'): /* scroll current window backwards */
            if (current)
-               wscrl(current->wind, -1);
+               wscrl(frame_win(current), -1);
            break;
 
        case CTRL('K'): /* toggle keypad mode for current */
            break;
 
        case CTRL('K'): /* toggle keypad mode for current */
@@ -3931,13 +3948,13 @@ acs_and_scroll(void)
 
 #if HAVE_PUTWIN && HAVE_GETWIN
        case CTRL('W'): /* save and delete window */
 
 #if HAVE_PUTWIN && HAVE_GETWIN
        case CTRL('W'): /* save and delete window */
-           if (current == current->next) {
+           if ((current != 0) && (current == current->next)) {
                transient(current, "Will not save/delete ONLY window");
                break;
            } else if ((fp = fopen(DUMPFILE, "w")) == (FILE *) 0) {
                transient(current, "Can't open screen dump file");
            } else {
                transient(current, "Will not save/delete ONLY window");
                break;
            } else if ((fp = fopen(DUMPFILE, "w")) == (FILE *) 0) {
                transient(current, "Can't open screen dump file");
            } else {
-               (void) putwin(current->wind, fp);
+               (void) putwin(frame_win(current), fp);
                (void) fclose(fp);
 
                current = delete_framed(current, TRUE);
                (void) fclose(fp);
 
                current = delete_framed(current, TRUE);
@@ -3948,17 +3965,18 @@ acs_and_scroll(void)
            if ((fp = fopen(DUMPFILE, "r")) == (FILE *) 0) {
                transient(current, "Can't open screen dump file");
            } else {
            if ((fp = fopen(DUMPFILE, "r")) == (FILE *) 0) {
                transient(current, "Can't open screen dump file");
            } else {
-               neww = typeCalloc(FRAME, 1);
+               if ((neww = typeCalloc(FRAME, 1)) != 0) {
 
 
-               neww->next = current->next;
-               neww->last = current;
-               neww->last->next = neww;
-               neww->next->last = neww;
+                   neww->next = current ? current->next : 0;
+                   neww->last = current;
+                   neww->last->next = neww;
+                   neww->next->last = neww;
 
 
-               neww->wind = getwin(fp);
-               (void) fclose(fp);
+                   neww->wind = getwin(fp);
 
 
-               wrefresh(neww->wind);
+                   wrefresh(neww->wind);
+               }
+               (void) fclose(fp);
            }
            break;
 #endif
            }
            break;
 #endif
@@ -4045,13 +4063,13 @@ acs_and_scroll(void)
        case KEY_DC:
            {
                int y, x;
        case KEY_DC:
            {
                int y, x;
-               getyx(current->wind, y, x);
+               getyx(frame_win(current), y, x);
                if (--x < 0) {
                    if (--y < 0)
                        break;
                if (--x < 0) {
                    if (--y < 0)
                        break;
-                   x = getmaxx(current->wind) - 1;
+                   x = getmaxx(frame_win(current)) - 1;
                }
                }
-               mvwdelch(current->wind, y, x);
+               mvwdelch(frame_win(current), y, x);
            }
            break;
 
            }
            break;
 
@@ -4067,7 +4085,7 @@ acs_and_scroll(void)
            break;
        }
        newwin_report(current);
            break;
        }
        newwin_report(current);
-       usescr = (current ? current->wind : stdscr);
+       usescr = frame_win(current);
        wrefresh(usescr);
     } while
        (!isQuit(c = wGetchar(usescr))
        wrefresh(usescr);
     } while
        (!isQuit(c = wGetchar(usescr))
@@ -4154,7 +4172,7 @@ mkpanel(short color, int rows, int cols, int tly, int tlx)
        if ((pan = new_panel(win)) == 0) {
            delwin(win);
        } else if (use_colors) {
        if ((pan = new_panel(win)) == 0) {
            delwin(win);
        } else if (use_colors) {
-           short fg = (color == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK;
+           short fg = (short) ((color == COLOR_BLUE) ? COLOR_WHITE : COLOR_BLACK);
            short bg = color;
 
            init_pair(color, fg, bg);
            short bg = color;
 
            init_pair(color, fg, bg);
@@ -4205,7 +4223,8 @@ static void
 fill_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
 fill_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
-    int num = ((const char *) panel_userptr(pan))[1];
+    const char *userptr = (const char *) panel_userptr(pan);
+    int num = (userptr && *userptr) ? userptr[1] : '?';
     int y, x;
 
     wmove(win, 1, 1);
     int y, x;
 
     wmove(win, 1, 1);
@@ -4241,7 +4260,8 @@ static void
 fill_wide_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
 fill_wide_panel(PANEL * pan)
 {
     WINDOW *win = panel_window(pan);
-    int num = ((const char *) panel_userptr(pan))[1];
+    const char *userptr = (const char *) panel_userptr(pan);
+    int num = (userptr && *userptr) ? userptr[1] : '?';
     int y, x;
 
     wmove(win, 1, 1);
     int y, x;
 
     wmove(win, 1, 1);
@@ -4449,7 +4469,7 @@ panner_legend(int line)
        "Use <,> (or h,l) to grow/shrink the panner horizontally.",
        "Number repeats.  Toggle legend:? filler:a timer:t scrollmark:s."
     };
        "Use <,> (or h,l) to grow/shrink the panner horizontally.",
        "Number repeats.  Toggle legend:? filler:a timer:t scrollmark:s."
     };
-    int n = (SIZEOF(legend) - (LINES - line));
+    int n = ((int) SIZEOF(legend) - (LINES - line));
     if (line < LINES && (n >= 0)) {
        move(line, 0);
        if (show_panner_legend)
     if (line < LINES && (n >= 0)) {
        move(line, 0);
        if (show_panner_legend)
@@ -4492,7 +4512,7 @@ fill_pad(WINDOW *panpad, bool pan_lines)
                    waddch(panpad, pan_lines ? ACS_LTEE : '+');
                else
                    waddch(panpad, (chtype) ((pan_lines ? 'a' : 'A') +
                    waddch(panpad, pan_lines ? ACS_LTEE : '+');
                else
                    waddch(panpad, (chtype) ((pan_lines ? 'a' : 'A') +
-                                            (gridcount++ % 26)));
+                                            (int) (gridcount++ % 26)));
            } else if (y % GRIDSIZE == 0)
                waddch(panpad, pan_lines ? ACS_HLINE : '-');
            else if (x % GRIDSIZE == 0)
            } else if (y % GRIDSIZE == 0)
                waddch(panpad, pan_lines ? ACS_HLINE : '-');
            else if (x % GRIDSIZE == 0)
@@ -4701,8 +4721,8 @@ panner(WINDOW *pad,
            int length = (portx - top_x - 1);
            float ratio = ((float) length) / ((float) pxmax);
 
            int length = (portx - top_x - 1);
            float ratio = ((float) length) / ((float) pxmax);
 
-           lowend = (int) (top_x + (basex * ratio));
-           highend = (int) (top_x + ((basex + length) * ratio));
+           lowend = (int) ((float) top_x + ((float) basex * ratio));
+           highend = (int) ((float) top_x + ((float) (basex + length) * ratio));
 
            do_h_line(porty - 1, top_x, ACS_HLINE, lowend);
            if (highend < portx) {
 
            do_h_line(porty - 1, top_x, ACS_HLINE, lowend);
            if (highend < portx) {
@@ -4718,8 +4738,8 @@ panner(WINDOW *pad,
            int length = (porty - top_y - 1);
            float ratio = ((float) length) / ((float) pymax);
 
            int length = (porty - top_y - 1);
            float ratio = ((float) length) / ((float) pymax);
 
-           lowend = (int) (top_y + (basey * ratio));
-           highend = (int) (top_y + ((basey + length) * ratio));
+           lowend = (int) ((float) top_y + ((float) basey * ratio));
+           highend = (int) ((float) top_y + ((float) (basey + length) * ratio));
 
            do_v_line(top_y, portx - 1, ACS_VLINE, lowend);
            if (highend < porty) {
 
            do_v_line(top_y, portx - 1, ACS_VLINE, lowend);
            if (highend < porty) {
@@ -5045,8 +5065,10 @@ menu_test(void)
     mvaddstr(5, 0, "  Press return to exit.");
     refresh();
 
     mvaddstr(5, 0, "  Press return to exit.");
     refresh();
 
-    for (ap = animals; *ap; ap++)
-       *ip++ = new_item(*ap, "");
+    for (ap = animals; *ap; ap++) {
+       if ((*ip = new_item(*ap, "")) != 0)
+           ++ip;
+    }
     *ip = (ITEM *) 0;
 
     m = new_menu(items);
     *ip = (ITEM *) 0;
 
     m = new_menu(items);
@@ -5201,8 +5223,11 @@ trace_set(void)
 
     refresh();
 
 
     refresh();
 
-    for (n = 0; t_tbl[n].name != 0; n++)
-       *ip++ = new_item(t_tbl[n].name, "");
+    for (n = 0; t_tbl[n].name != 0; n++) {
+       if ((*ip = new_item(t_tbl[n].name, "")) != 0) {
+           ++ip;
+       }
+    }
     *ip = (ITEM *) 0;
 
     m = new_menu(items);
     *ip = (ITEM *) 0;
 
     m = new_menu(items);
@@ -5330,7 +5355,7 @@ edit_secure(FIELD * me, int c)
        len = (long) (char *) field_userptr(me);
        if (c <= KEY_MAX) {
            if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
        len = (long) (char *) field_userptr(me);
        if (c <= KEY_MAX) {
            if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
-               temp[len++] = c;
+               temp[len++] = (char) c;
                temp[len] = 0;
                set_field_buffer(me, 1, temp);
                c = '*';
                temp[len] = 0;
                set_field_buffer(me, 1, temp);
                c = '*';
@@ -5533,7 +5558,7 @@ FIELDCHECK_CB(mi_field_check)
 
     /* force the form to display a leading capital */
     if (islower(UChar(s[0]))) {
 
     /* force the form to display a leading capital */
     if (islower(UChar(s[0]))) {
-       s[0] = toupper(UChar(s[0]));
+       s[0] = (char) toupper(UChar(s[0]));
        set_field_buffer(fld, 0, s);
     }
     return TRUE;
        set_field_buffer(fld, 0, s);
     }
     return TRUE;
@@ -5602,6 +5627,7 @@ demo_forms(void)
     refresh();
 
     /* describe the form */
     refresh();
 
     /* describe the form */
+    memset(f, 0, sizeof(f));
     f[n++] = make_label(0, 15, "Sample Form");
 
     f[n++] = make_label(2, 0, "Last Name");
     f[n++] = make_label(0, 15, "Sample Form");
 
     f[n++] = make_label(2, 0, "Last Name");
@@ -5625,32 +5651,33 @@ demo_forms(void)
     set_field_type(f[n - 1], fty_passwd);
     f[n++] = (FIELD *) 0;
 
     set_field_type(f[n - 1], fty_passwd);
     f[n++] = (FIELD *) 0;
 
-    form = new_form(f);
+    if ((form = new_form(f)) != 0) {
 
 
-    display_form(form);
+       display_form(form);
 
 
-    w = form_win(form);
-    raw();
-    nonl();                    /* lets us read ^M's */
-    while (!finished) {
-       switch (form_driver(form, c = form_virtualize(form, w))) {
-       case E_OK:
-           mvaddstr(5, 57, field_buffer(secure, 1));
-           clrtoeol();
-           refresh();
-           break;
-       case E_UNKNOWN_COMMAND:
-           finished = my_form_driver(form, c);
-           break;
-       default:
-           beep();
-           break;
+       w = form_win(form);
+       raw();
+       nonl();                 /* lets us read ^M's */
+       while (!finished) {
+           switch (form_driver(form, c = form_virtualize(form, w))) {
+           case E_OK:
+               mvaddstr(5, 57, field_buffer(secure, 1));
+               clrtoeol();
+               refresh();
+               break;
+           case E_UNKNOWN_COMMAND:
+               finished = my_form_driver(form, c);
+               break;
+           default:
+               beep();
+               break;
+           }
        }
        }
-    }
 
 
-    erase_form(form);
+       erase_form(form);
 
 
-    free_form(form);
+       free_form(form);
+    }
     for (c = 0; f[c] != 0; c++)
        free_field(f[c]);
     free_fieldtype(fty_middle);
     for (c = 0; f[c] != 0; c++)
        free_field(f[c]);
     free_fieldtype(fty_middle);
@@ -5717,7 +5744,7 @@ overlap_helpitem(int state, int item, char *message)
 static void
 overlap_test_1_attr(WINDOW *win, int flavor, int col)
 {
 static void
 overlap_test_1_attr(WINDOW *win, int flavor, int col)
 {
-    short cpair = 1 + (flavor * 2) + col;
+    short cpair = (short) (1 + (flavor * 2) + col);
 
     switch (flavor) {
     case 0:
 
     switch (flavor) {
     case 0:
@@ -5740,7 +5767,7 @@ overlap_test_1_attr(WINDOW *win, int flavor, int col)
 static void
 overlap_test_2_attr(WINDOW *win, int flavor, int col)
 {
 static void
 overlap_test_2_attr(WINDOW *win, int flavor, int col)
 {
-    short cpair = 9 + (flavor * 2) + col;
+    short cpair = (short) (9 + (flavor * 2) + col);
 
     switch (flavor) {
     case 0:
 
     switch (flavor) {
     case 0:
@@ -5771,6 +5798,7 @@ overlap_help(int state, int flavors[OVERLAP_FLAVORS])
     if (state < 0)
        state += OVERLAP_FLAVORS;
     state = state % OVERLAP_FLAVORS;
     if (state < 0)
        state += OVERLAP_FLAVORS;
     state = state % OVERLAP_FLAVORS;
+    assert(state >= 0 && state < OVERLAP_FLAVORS);
 
     for (item = 0; item < (2 * OVERLAP_FLAVORS); ++item) {
        row = item / 2;
 
     for (item = 0; item < (2 * OVERLAP_FLAVORS); ++item) {
        row = item / 2;
@@ -6282,7 +6310,7 @@ main_menu(bool top)
         */
        command = 0;
        for (;;) {
         */
        command = 0;
        for (;;) {
-           char ch;
+           char ch = '\0';
            if (read(fileno(stdin), &ch, 1) <= 0) {
                if (command == 0)
                    command = 'q';
            if (read(fileno(stdin), &ch, 1) <= 0) {
                if (command == 0)
                    command = 'q';
@@ -6393,7 +6421,7 @@ main(int argc, char *argv[])
 #endif
 #ifdef TRACE
        case 't':
 #endif
 #ifdef TRACE
        case 't':
-           save_trace = strtol(optarg, 0, 0);
+           save_trace = (unsigned) strtol(optarg, 0, 0);
            break;
 #endif
        default:
            break;
 #endif
        default:
@@ -6454,7 +6482,7 @@ main(int argc, char *argv[])
 
        if (can_change_color()) {
            short cp;
 
        if (can_change_color()) {
            short cp;
-           all_colors = typeMalloc(RGB_DATA, max_colors);
+           all_colors = typeMalloc(RGB_DATA, (unsigned) max_colors);
            for (cp = 0; cp < max_colors; ++cp) {
                color_content(cp,
                              &all_colors[cp].red,
            for (cp = 0; cp < max_colors; ++cp) {
                color_content(cp,
                              &all_colors[cp].red,
@@ -6479,9 +6507,9 @@ main(int argc, char *argv[])
                                   && okRGB(red)
                                   && okRGB(green)
                                   && okRGB(blue)) {
                                   && okRGB(red)
                                   && okRGB(green)
                                   && okRGB(blue)) {
-                           all_colors[c].red = (red * 1000) / scale;
-                           all_colors[c].green = (green * 1000) / scale;
-                           all_colors[c].blue = (blue * 1000) / scale;
+                           all_colors[c].red = (short) ((red * 1000) / scale);
+                           all_colors[c].green = (short) ((green * 1000) / scale);
+                           all_colors[c].blue = (short) ((blue * 1000) / scale);
                        }
                    }
                    fclose(fp);
                        }
                    }
                    fclose(fp);
index 84d3f82cd06b13f31d109d18c1aae69c7e2f2310..d43996b222cb812de9889eea59d77e5b351f4647 100644 (file)
@@ -2,7 +2,7 @@
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.30 2008/02/09 16:41:29 tom Exp $
+ * $Id: newdemo.c,v 1.31 2008/08/03 20:19:38 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -319,6 +319,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
        j = 0;
        /*  Draw running As across in RED */
        set_colors(win, 7, COLOR_RED, COLOR_GREEN);
        j = 0;
        /*  Draw running As across in RED */
        set_colors(win, 7, COLOR_RED, COLOR_GREEN);
+       memset(save, ' ', sizeof(save));
        for (i = 2; i < width - 4; ++i) {
            k = mvwinch(win, 4, i);
            if (k == ERR)
        for (i = 2; i < width - 4; ++i) {
            k = mvwinch(win, 4, i);
            if (k == ERR)
index 2f3368c135eaf31ec285f5d7981b6ceef19a2f70..6a2e53fff2fb4fcf31969609cc1169b1c74e6d80 100644 (file)
@@ -7,7 +7,7 @@
  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
  *                  PDCurses or under Unix System V, R4
  *
  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
  *                  PDCurses or under Unix System V, R4
  *
- * $Id: testcurs.c,v 1.38 2008/04/12 22:00:27 tom Exp $
+ * $Id: testcurs.c,v 1.39 2008/08/03 17:58:09 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -44,7 +44,7 @@ static const COMMAND command[] =
     {"Input Test", inputTest},
     {"Output Test", outputTest}
 };
     {"Input Test", inputTest},
     {"Output Test", outputTest}
 };
-#define MAX_OPTIONS SIZEOF(command)
+#define MAX_OPTIONS (int) SIZEOF(command)
 
 #if !HAVE_STRDUP
 #define strdup my_strdup
 
 #if !HAVE_STRDUP
 #define strdup my_strdup
@@ -70,7 +70,7 @@ main(
     int old_option = (-1);
     int new_option = 0;
     bool quit = FALSE;
     int old_option = (-1);
     int new_option = 0;
     bool quit = FALSE;
-    unsigned n;
+    int n;
 
     setlocale(LC_ALL, "");
 
 
     setlocale(LC_ALL, "");
 
@@ -120,12 +120,15 @@ main(
            display_menu(old_option, new_option);
            break;
        case KEY_UP:
            display_menu(old_option, new_option);
            break;
        case KEY_UP:
-           new_option = (new_option == 0) ? new_option : new_option - 1;
+           new_option = ((new_option == 0)
+                         ? new_option
+                         : new_option - 1);
            display_menu(old_option, new_option);
            break;
        case KEY_DOWN:
            display_menu(old_option, new_option);
            break;
        case KEY_DOWN:
-           new_option = (new_option == MAX_OPTIONS - 1) ? new_option :
-               new_option + 1;
+           new_option = ((new_option == (MAX_OPTIONS - 1))
+                         ? new_option
+                         : new_option + 1);
            display_menu(old_option, new_option);
            break;
        case 'Q':
            display_menu(old_option, new_option);
            break;
        case 'Q':
@@ -676,37 +679,38 @@ padTest(WINDOW *dummy GCC_UNUSED)
 {
     WINDOW *pad, *spad;
 
 {
     WINDOW *pad, *spad;
 
-    pad = newpad(50, 100);
-    wattron(pad, A_REVERSE);
-    mvwaddstr(pad, 5, 2, "This is a new pad");
-    wattrset(pad, A_NORMAL);
-    mvwaddstr(pad, 8, 0,
-             "The end of this line should be truncated here:except  now");
-    mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
-    wmove(pad, 10, 1);
-    wclrtoeol(pad);
-    mvwaddstr(pad, 10, 1, " Press any key to continue");
-    prefresh(pad, 0, 0, 0, 0, 10, 45);
-    keypad(pad, TRUE);
-    raw();
-    wgetch(pad);
+    if ((pad = newpad(50, 100)) != 0) {
+       wattron(pad, A_REVERSE);
+       mvwaddstr(pad, 5, 2, "This is a new pad");
+       wattrset(pad, A_NORMAL);
+       mvwaddstr(pad, 8, 0,
+                 "The end of this line should be truncated here:except  now");
+       mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
+       wmove(pad, 10, 1);
+       wclrtoeol(pad);
+       mvwaddstr(pad, 10, 1, " Press any key to continue");
+       prefresh(pad, 0, 0, 0, 0, 10, 45);
+       keypad(pad, TRUE);
+       raw();
+       wgetch(pad);
 
 
-    spad = subpad(pad, 12, 25, 6, 52);
-    mvwaddstr(spad, 2, 2, "This is a new subpad");
-    box(spad, 0, 0);
-    prefresh(pad, 0, 0, 0, 0, 15, 75);
-    keypad(pad, TRUE);
-    raw();
-    wgetch(pad);
+       spad = subpad(pad, 12, 25, 6, 52);
+       mvwaddstr(spad, 2, 2, "This is a new subpad");
+       box(spad, 0, 0);
+       prefresh(pad, 0, 0, 0, 0, 15, 75);
+       keypad(pad, TRUE);
+       raw();
+       wgetch(pad);
 
 
-    mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
-    mvwaddstr(pad, 40, 1, " Press any key to continue");
-    prefresh(pad, 30, 0, 0, 0, 10, 45);
-    keypad(pad, TRUE);
-    raw();
-    wgetch(pad);
+       mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
+       mvwaddstr(pad, 40, 1, " Press any key to continue");
+       prefresh(pad, 30, 0, 0, 0, 10, 45);
+       keypad(pad, TRUE);
+       raw();
+       wgetch(pad);
 
 
-    delwin(pad);
+       delwin(pad);
+    }
 }
 
 static void
 }
 
 static void
@@ -714,13 +718,17 @@ display_menu(int old_option, int new_option)
 {
     int i;
 
 {
     int i;
 
+    assert((new_option >= 0) && (new_option < MAX_OPTIONS));
+
     attrset(A_NORMAL);
     mvaddstr(3, 20, "PDCurses Test Program");
 
     for (i = 0; i < (int) MAX_OPTIONS; i++)
        mvaddstr(5 + i, 25, command[i].text);
     attrset(A_NORMAL);
     mvaddstr(3, 20, "PDCurses Test Program");
 
     for (i = 0; i < (int) MAX_OPTIONS; i++)
        mvaddstr(5 + i, 25, command[i].text);
-    if (old_option != (-1))
+
+    if ((old_option >= 0) && (old_option < MAX_OPTIONS))
        mvaddstr(5 + old_option, 25, command[old_option].text);
        mvaddstr(5 + old_option, 25, command[old_option].text);
+
     attrset(A_REVERSE);
     mvaddstr(5 + new_option, 25, command[new_option].text);
     attrset(A_NORMAL);
     attrset(A_REVERSE);
     mvaddstr(5 + new_option, 25, command[new_option].text);
     attrset(A_NORMAL);
index 9834e44415a7f496142d53133ba2176c7267ab70..3925b842c47d1fb8f2a8e37e6b8d3612e3f4252c 100644 (file)
@@ -50,7 +50,7 @@
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
- * $Id: view.c,v 1.67 2008/01/19 21:01:21 tom Exp $
+ * $Id: view.c,v 1.68 2008/08/03 11:37:07 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -238,7 +238,8 @@ main(int argc, char *argv[])
            CATCHALL(SIG_IGN);
            break;
        case 'n':
            CATCHALL(SIG_IGN);
            break;
        case 'n':
-           if ((MAXLINES = atoi(optarg)) < 1)
+           if ((MAXLINES = atoi(optarg)) < 1 ||
+               (MAXLINES + 2) <= 1)
                usage();
            break;
 #if CAN_RESIZE
                usage();
            break;
 #if CAN_RESIZE
@@ -508,9 +509,10 @@ show_all(const char *tag)
     time_t this_time;
 
 #if CAN_RESIZE
     time_t this_time;
 
 #if CAN_RESIZE
-    sprintf(temp, "%s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
+    sprintf(temp, "%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
     i = strlen(temp);
     i = strlen(temp);
-    sprintf(temp + i, "view %.*s", (int) (sizeof(temp) - 7 - i), fname);
+    if ((i + 7) < (int) sizeof(temp))
+       sprintf(temp + i, "view %.*s", (int) (sizeof(temp) - 7 - i), fname);
 #else
     (void) tag;
     sprintf(temp, "view %.*s", (int) sizeof(temp) - 7, fname);
 #else
     (void) tag;
     sprintf(temp, "view %.*s", (int) sizeof(temp) - 7, fname);
index 9b66cca7b2b462275cd667e25917fe9a1d6c35a1..b838bae2bc2de7c0c67f296e6392305ba4dd7f5f 100644 (file)
@@ -92,7 +92,7 @@
 /******************************************************************************/
 
 /*
 /******************************************************************************/
 
 /*
- * $Id: xmas.c,v 1.23 2008/04/12 22:05:04 tom Exp $
+ * $Id: xmas.c,v 1.24 2008/08/03 11:08:59 tom Exp $
  */
 #include <test.priv.h>
 
  */
 #include <test.priv.h>
 
@@ -206,44 +206,48 @@ main(int argc GCC_UNUSED, char **argv GCC_UNUSED)
     }
     curs_set(0);
 
     }
     curs_set(0);
 
-    treescrn = newwin(16, 27, 3, 53);
-    treescrn2 = newwin(16, 27, 3, 53);
-    treescrn3 = newwin(16, 27, 3, 53);
-    treescrn4 = newwin(16, 27, 3, 53);
-    treescrn5 = newwin(16, 27, 3, 53);
-    treescrn6 = newwin(16, 27, 3, 53);
-    treescrn7 = newwin(16, 27, 3, 53);
-    treescrn8 = newwin(16, 27, 3, 53);
-
-    dotdeer0 = newwin(3, 71, 0, 8);
-
-    stardeer0 = newwin(4, 56, 0, 8);
-
-    lildeer0 = newwin(7, 53, 0, 8);
-    lildeer1 = newwin(2, 4, 0, 0);
-    lildeer2 = newwin(2, 4, 0, 0);
-    lildeer3 = newwin(2, 4, 0, 0);
-
-    middeer0 = newwin(15, 42, 0, 8);
-    middeer1 = newwin(3, 7, 0, 0);
-    middeer2 = newwin(3, 7, 0, 0);
-    middeer3 = newwin(3, 7, 0, 0);
-
-    bigdeer0 = newwin(10, 23, 0, 0);
-    bigdeer1 = newwin(10, 23, 0, 0);
-    bigdeer2 = newwin(10, 23, 0, 0);
-    bigdeer3 = newwin(10, 23, 0, 0);
-    bigdeer4 = newwin(10, 23, 0, 0);
-
-    lookdeer0 = newwin(10, 25, 0, 0);
-    lookdeer1 = newwin(10, 25, 0, 0);
-    lookdeer2 = newwin(10, 25, 0, 0);
-    lookdeer3 = newwin(10, 25, 0, 0);
-    lookdeer4 = newwin(10, 25, 0, 0);
-
-    w_holiday = newwin(1, 26, 3, 27);
-
-    w_del_msg = newwin(1, 19, 23, 60);
+    if ((treescrn = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn2 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn3 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn4 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn5 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn6 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn7 = newwin(16, 27, 3, 53)) == 0 ||
+       (treescrn8 = newwin(16, 27, 3, 53)) == 0 ||
+
+       (dotdeer0 = newwin(3, 71, 0, 8)) == 0 ||
+
+       (stardeer0 = newwin(4, 56, 0, 8)) == 0 ||
+
+       (lildeer0 = newwin(7, 53, 0, 8)) == 0 ||
+       (lildeer1 = newwin(2, 4, 0, 0)) == 0 ||
+       (lildeer2 = newwin(2, 4, 0, 0)) == 0 ||
+       (lildeer3 = newwin(2, 4, 0, 0)) == 0 ||
+
+       (middeer0 = newwin(15, 42, 0, 8)) == 0 ||
+       (middeer1 = newwin(3, 7, 0, 0)) == 0 ||
+       (middeer2 = newwin(3, 7, 0, 0)) == 0 ||
+       (middeer3 = newwin(3, 7, 0, 0)) == 0 ||
+
+       (bigdeer0 = newwin(10, 23, 0, 0)) == 0 ||
+       (bigdeer1 = newwin(10, 23, 0, 0)) == 0 ||
+       (bigdeer2 = newwin(10, 23, 0, 0)) == 0 ||
+       (bigdeer3 = newwin(10, 23, 0, 0)) == 0 ||
+       (bigdeer4 = newwin(10, 23, 0, 0)) == 0 ||
+
+       (lookdeer0 = newwin(10, 25, 0, 0)) == 0 ||
+       (lookdeer1 = newwin(10, 25, 0, 0)) == 0 ||
+       (lookdeer2 = newwin(10, 25, 0, 0)) == 0 ||
+       (lookdeer3 = newwin(10, 25, 0, 0)) == 0 ||
+       (lookdeer4 = newwin(10, 25, 0, 0)) == 0 ||
+
+       (w_holiday = newwin(1, 26, 3, 27)) == 0 ||
+
+       (w_del_msg = newwin(1, 19, 23, 60)) == 0) {
+       endwin();
+       fprintf(stderr, "Cannot create windows - screen too small\n");
+       ExitProgram(EXIT_FAILURE);
+    }
 
     mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit");
 
 
     mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit");