+ 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).
-- 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
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).
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
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.
[
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
[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,
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
// * 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 *
#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(),
{
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 = ⊂
// * 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 *
* 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"
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
NCursesApplication::getApplication()->push(*S);
F();
NCursesApplication::getApplication()->pop();
+ delete S;
return FALSE;
}
};
{
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
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
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
# 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
# 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)
/****************************************************************************
- * 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 *
#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 =
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);
}
/****************************************************************************
- * 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 *
/****************************************************************************
* 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
*/
{
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)
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;
/****************************************************************************
- * 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 *
****************************************************************************/
/****************************************************************************
- * 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
*
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 */
#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 */
else
{
my_top_row += rdiff;
- while (rdiff-- > 0 && item != (ITEM *) 0)
+ while (rdiff-- > 0 && item != 0 && item->down != 0)
item = item->down;
}
break;
else
{
my_top_row -= rdiff;
- while (rdiff-- && item != (ITEM *) 0)
+ while (rdiff-- > 0 && item != 0 && item->up != 0)
item = item->up;
}
break;
#!/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 *
#* 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
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(,' \
# ${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(,' \
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
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) {
#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>
SCREEN *sp = _nc_screen_of(win);
int rc;
+ if (sp != 0) {
#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
- {
- 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;
}
#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
_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
#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)
* 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 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) {
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.
/****************************************************************************
- * 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 *
#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.
}
} 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);
/*
- * $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
*
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) { }
/****************************************************************************
- * 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 *
#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 */
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;
} /* 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;
/****************************************************************************
- * 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 *
#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.
result = typeRealloc(char, allocated, result);
if (result == 0)
return (EOF);
+ bufstart = result;
}
if (used == 0)
_nc_curr_file_pos = ftell(yyin);
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()
_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 *ptr;
+ char *tok_ptr;
char *s;
char numbuf[80];
int ch;
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;
- FreeAndNull(buffer);
+ FreeAndNull(tok_buf);
}
return (EOF);
}
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
- ptr = buffer;
- *(ptr++) = ch;
+ tok_ptr = tok_buf;
+ AddCh(ch);
if (first_column) {
_nc_comment_start = token_start;
if (ch == EOF) {
_nc_err_abort(MSG_NO_INPUTS);
} else if (ch == '|') {
- after_list = ptr;
+ after_list = tok_ptr;
if (after_name == 0)
- after_name = ptr;
+ after_name = tok_ptr;
} else if (ch == ':' && last_char() != ',') {
_nc_syntax = SYN_TERMCAP;
separator = ':';
} 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
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;
- ptr[1] = '\0';
+ tok_ptr[1] = '\0';
}
/*
if (after_name != 0) {
ch = *after_name;
*after_name = '\0';
- _nc_set_type(buffer);
+ _nc_set_type(tok_buf);
*after_name = ch;
}
_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"));
}
* 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");
}
}
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
type = NAMES;
} else {
if (had_newline && _nc_syntax == SYN_TERMCAP) {
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");
- _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",
- 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;
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");
}
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
_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");
- _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;
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;
+ }
if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
break;
if (ch == '^' && last_ch != '%') {
/****************************************************************************
- * 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 *
#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 */
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);
/****************************************************************************
- * 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 *
#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
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) {
#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 $")
/****************************************************************************
*
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;
+ }
+ }
}
}
}
/****************************************************************************
- * 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 *
#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 *
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)) {
#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)
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);
}
}
}
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);
}
/****************************************************************************
- * 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 *
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
#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>
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 scanned;
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;
/****************************************************************************
- * 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 *
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
#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)
if (sp == 0) {
if (FirstName != 0)
FreeAndNull(FirstName);
- return 0;
- }
+ } else
#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);
}
/****************************************************************************
- * 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 *
#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[] =
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));
/*
* type, this will do the job.
*/
- /* tell max_attributes from arrow_key_map */
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));
+ assert(entry_ptr != 0);
- /* map terminfo's string MT to MT */
} 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));
+ assert(entry_ptr != 0);
- /* treat strings without following "=" as empty strings */
} else if (token_type == BOOLEAN
&& entry_ptr->nte_type == STRING) {
+ /* treat strings without following "=" as empty strings */
token_type = STRING;
- /* we couldn't recover; skip this token */
} else {
+ /* we couldn't recover; skip this token */
if (!silent) {
const char *type_name;
switch (entry_ptr->nte_type) {
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 (!ap->to) {
+ }
+ if (!(ap->from && ap->to)) {
_nc_warning("unknown capability `%.*s' in ko string",
(int) len, base);
continue;
#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))
}
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,
#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;
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));
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);
}
while (*other_names != '\0') {
ptr = other_names++;
+ assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
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));
- 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;
#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 */
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);
}
+ TracePath[size] = '\0';
+ assert(strlen(TracePath) <= size);
strcat(TracePath, "/trace");
if (_nc_is_dir_path(TracePath)) {
strcat(TracePath, ".log");
#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))
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;
#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
- /* 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);
- }
+#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
- 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 *)
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;
- /* *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) {
_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 *)
-_tracechtype (chtype ch)
+_tracechtype(chtype ch)
{
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;
#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;
- 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 *)
-_tracecchar_t (const cchar_t *ch)
+_tracecchar_t(const cchar_t *ch)
{
return _tracecchar_t2(0, ch);
}
#endif
#else
-empty_module(_nc_lib_traceatr)
+EMPTY_MODULE(_nc_lib_traceatr)
#endif /* TRACE */
/****************************************************************************
- * 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 *
#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
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)
- {
- 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
- {
- "CS6 ", CS6
- },
+ CS_DATA(CS6),
#endif
#ifdef CS7
- {
- "CS7 ", CS7
- },
+ CS_DATA(CS7),
#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
- 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
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);
return _nc_trace_ttymode(&(cur_term->Nttyb));
}
#else
-empty_module(_nc_tracebits)
+EMPTY_MODULE(_nc_tracebits)
#endif /* TRACE */
#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
return _nc_tracechar(SP, ch);
}
#else
-empty_module(_nc_lib_tracechr)
+EMPTY_MODULE(_nc_lib_tracechr)
#endif
/****************************************************************************
- * 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 *
#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
}
#else
-empty_module(_nc_lib_tracedmp)
+EMPTY_MODULE(_nc_lib_tracedmp)
#endif /* TRACE */
#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
}
#else /* !TRACE */
-empty_module(_nc_lib_tracemouse)
+EMPTY_MODULE(_nc_lib_tracemouse)
#endif
/****************************************************************************
- * 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 *
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
* trace_buf.c - Tracing/Debugging buffers (attributes)
#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
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) {
- 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
_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;
}
/****************************************************************************
- * 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 *
#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
}
#else
-empty_module(_nc_trace_tries)
+EMPTY_MODULE(_nc_trace_tries)
#endif
/****************************************************************************
- * 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 *
#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
return (MyBuffer);
}
#else
-empty_module(_nc_varargs)
+EMPTY_MODULE(_nc_varargs)
#endif
#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);
{
if (c == '"' || c == '\\') {
*tp++ = '\\';
- *tp++ = c;
+ *tp++ = (char) c;
} else if (is7bits(c) && (isgraph(c) || c == ' ')) {
- *tp++ = c;
+ *tp++ = (char) c;
} else if (c == '\n') {
*tp++ = '\\';
*tp++ = 'n';
} 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);
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
- char *vbuf;
+ const char *vbuf;
char *tp;
int c;
return ("(cancelled)");
if (len < 0)
- len = strlen(buf);
+ len = (int) strlen(buf);
#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]);
- tp = vbuf = mybuf[bufnum];
+ vbuf = tp = mybuf[bufnum];
}
#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);
}
static const char *
_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
- char *vbuf;
+ const char *vbuf;
char *tp;
wchar_t c;
return ("(null)");
if (len < 0)
- len = wcslen(buf);
+ len = (int) wcslen(buf);
#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]);
- tp = vbuf = mybuf[bufnum];
+ vbuf = tp = mybuf[bufnum];
}
#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);
}
int first;
const char *found;
+ if (result != 0) {
#if USE_WIDEC_SUPPORT
- if (len < 0)
- len = _nc_wchstrlen(buf);
+ if (len < 0)
+ len = _nc_wchstrlen(buf);
#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 (!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
- {
- 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 */
+ }
+ 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;
}
/****************************************************************************
- * 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 *
/****************************************************************************
* 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 *
****************************************************************************/
/******************************************************************************
#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)
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) */
/****************************************************************************
- * 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 *
/****************************************************************************
* 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
*/
#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;
{
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)
{
/****************************************************************************
* 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
#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 OkIndex(index,array) ((int)(index) >= 0 && (int)(index) < (int) SIZEOF(array))
+
typedef struct {
char *text;
size_t used;
}
#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 */
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:
- if (num_from_termcap[np->nte_index])
- return (numcodes[np->nte_index]);
+ NameTrans(num_from_termcap, numcodes);
break;
case STRING:
- if (str_from_termcap[np->nte_index])
- return (strcodes[np->nte_index]);
+ NameTrans(str_from_termcap, strcodes);
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 */
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
- && column + want > width) {
+ && column + (int) want > width) {
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)) \
- 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 ":".
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;
}
#define SAME_CAP(n,cap) (&tterm->Strings[n] == &cap)
+#define EXTRA_CAP 20
int
fmt_entry(TERMTYPE *tterm,
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;
} 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);
+ assert(strlen(name) < sizeof(buffer) - EXTRA_CAP);
if (!version_filter(BOOLEAN, i))
continue;
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 (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++;
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))
} 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,
} else {
strcpy_DYN(&tmpbuf, src);
}
- len += strlen(capability) + 1;
+ len += (int) strlen(capability) + 1;
wrap_concat(tmpbuf.text);
outcount = TRUE;
}
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
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;
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;
trim_trailing();
(void) fputs(outbuf.text, stdout);
putchar('\n');
- return outbuf.used;
+ return (int) outbuf.used;
}
void
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 {
- extra = source;
+ extra = (char) source;
}
}
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];
}
}
#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 "}"
static char *
lookup_params(const assoc * table, char *dst, char *src)
{
+ char *result = 0;
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)
{
- char buf[MAX_TERMINFO_LENGTH];
char buf2[MAX_TERMINFO_LENGTH];
const char *sp;
const assoc *ap;
return;
(void) printf("%s: ", name);
- buf[0] = '\0';
for (sp = cap; *sp; sp++) {
int i;
int csi;
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)
&& strncmp(ap->from + adj, sp + csi, len - adj) == 0) {
expansion = ap->to;
len -= adj;
- len += csi;
+ len += (size_t) csi;
break;
}
}
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';
- len += csi + 1;
+ len += (size_t) csi + 1;
expansion = lookup_params(std_modes, buf2, buf3);
}
&& (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';
- len += csi + 2;
+ len += (size_t) csi + 2;
expansion = lookup_params(private_modes, buf2, buf3);
}
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';
- len += csi + 1;
+ len += (size_t) csi + 1;
expansion = lookup_params(ecma_highlights, buf2, buf3);
}
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;
if (strncmp(buf2, sp + csi, len) == 0)
expansion = "RSR";
}
- len += csi;
+ len += (size_t) csi;
}
/* now check for home-down */
expansion = "LL";
}
}
- len += csi;
+ len += (size_t) csi;
}
/* now look at the expansion we got, if any */
if (expansion) {
- (void) sprintf(buf + strlen(buf), "{%s}", expansion);
+ printf("{%s}", expansion);
sp += len - 1;
- continue;
} 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');
}
/***************************************************************************
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_initializers(TERMTYPE *term)
{
unsigned n;
- int size;
const char *str = 0;
printf("\nstatic char %s[] = \"%s\";\n\n",
}
(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) {
_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,
/****************************************************************************
- * 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 *
* 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
*
# endif
#endif
+#include <assert.h>
#include <errno.h>
#if DECL_ERRNO
/****************************************************************************
- * 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 *
/****************************************************************************
* 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 *
****************************************************************************/
/*
#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";
] \
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
-cleanup(void)
+cleanup(char **namelst)
{
+#if NO_LEAKS
+ free_namelist(namelst);
+#endif
if (tmp_fp != 0)
fclose(tmp_fp);
if (to_remove != 0) {
failed(const char *msg)
{
perror(msg);
- cleanup();
+ cleanup((char **) 0);
ExitProgram(EXIT_FAILURE);
}
d = result;
t = s;
while ((ch = *t++) != 0) {
- *d++ = ch;
+ *d++ = (char) ch;
if (ch == '\\') {
*d++ = *t++;
} else if ((ch == '%')
&& value < 127
&& isprint((int) value)) {
*d++ = S_QUOTE;
- *d++ = (int) value;
+ *d++ = (char) value;
*d++ = S_QUOTE;
t = (v + 1);
}
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;
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)
break;
case 'V':
puts(curses_version());
- return EXIT_SUCCESS;
+ cleanup(namelst);
+ ExitProgram(EXIT_SUCCESS);
case 'c':
check_only = TRUE;
break;
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 */
_nc_progname,
_nc_progname,
usage_string);
- cleanup();
+ cleanup(namelst);
ExitProgram(EXIT_FAILURE);
}
}
/* do use resolution */
if (check_only || (!infodump && !capdump) || forceresolve) {
if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
- cleanup();
+ cleanup(namelst);
ExitProgram(EXIT_FAILURE);
}
}
else
fprintf(log_fp, "No entries written\n");
}
-#if NO_LEAKS
- free_namelist(namelst);
-#endif
- cleanup();
+ cleanup(namelst);
ExitProgram(EXIT_SUCCESS);
}
}
mapped[UChar(p[0])] = p[1];
}
+
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];
}
- *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);
}
}
}
-static int
+static char
keypad_final(const char *string)
{
- int result = '\0';
+ char result = '\0';
if (VALID_STRING(string)
&& *string++ == '\033'
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.
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;
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;
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 */
- for (j = 1; j < 5; ++j) {
+ for (j = 1; j < MAX_KP; ++j) {
if (list[j] > list[j - 1]) {
++increase;
}
}
- if (increase != 4) {
+ if (increase != (MAX_KP - 1)) {
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) {
}
}
last = test;
+ assert(strlen(show) < (MAX_KP * 4));
switch (kk) {
case 0:
strcat(show, " ka1");
#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, ".."))
for (i = 0; i < eargc; i++) {
#if USE_DATABASE
if (_nc_is_dir_path(eargv[i])) {
+ char *cwd_buf = 0;
DIR *termdir;
DIRENT *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;
+ 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;
- (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(".");
+ if (entrydir == 0) {
+ perror(cwd_buf);
+ continue;
+ }
while ((entry = readdir(entrydir)) != 0) {
char name_2[PATH_MAX];
TERMTYPE lterm;
closedir(entrydir);
}
closedir(termdir);
+ if (cwd_buf != 0)
+ free(cwd_buf);
}
#if USE_HASHED_DB
else {
/****************************************************************************
- * 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 *
#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;
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 {
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;
}
+ free(copy);
#ifdef MAPDEBUG
(void) printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
(void) printf("type: %s\n", mapp->type);
#ifdef NLDLY
| NLDLY
#endif
-#ifdef CRDLY
+#ifdef CRDLY
| CRDLY
#endif
-#ifdef TABDLY
+#ifdef TABDLY
| TABDLY
#endif
-#ifdef BSDLY
+#ifdef BSDLY
| BSDLY
#endif
-#ifdef VTDLY
+#ifdef VTDLY
| VTDLY
#endif
#ifdef FFDLY
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
can_restore = TRUE;
original = oldmode = mode;
#ifdef TERMIOS
- ospeed = cfgetospeed(&mode);
+ ospeed = (NCURSES_OSPEED) cfgetospeed(&mode);
#else
- ospeed = mode.sg_ospeed;
+ ospeed = (NCURSES_OSPEED) mode.sg_ospeed;
#endif
if (!strcmp(_nc_progname, PROG_RESET)) {
* 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
/****************************************************************************
- * 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 *
* 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>
{
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 */
* 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>
(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);
}
error((char *) NULL);
} else if (strchr("hjkl8462", c)) {
+ assert(ss != 0);
ss->x = curx;
ss->y = cury;
/*
* 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.
*/
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 {
+ offset = 0;
if (card->content != 0)
free(card->content);
card->content = typeMalloc(char, total + 1);
* 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
static char temp[10];
ch = UChar(ch);
+ assert(ch >= 0 && ch < 256);
if (ch == '\\') {
strcpy(temp, "\\\\");
} else if (ch == '\033') {
/****************************************************************************
- * 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 *
* 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
{
WINDOW *w;
FORM *form;
- FIELD *f[100];
+ FIELD *f[100]; // FIXME memset to zero
int finished = 0, c;
unsigned n = 0;
int pg;
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);
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();
* 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
static void
menu_destroy(MENU * m)
{
- ITEM **ip;
int count;
+ Trace(("menu_destroy %p", m));
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);
+ Trace(("menu_destroy %p count %d", m, count));
+ if ((count > 0) && (m == mpSelect)) {
+ blob = item_name(*items);
+ }
+ unpost_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
}
ITEM **ip;
CONST_MENUS char **ap = 0;
+ CONST_MENUS char **myList = 0;
unsigned count = 0;
if (filename != 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);
+ Trace(("build_select_menu blob=%p, items=%p", blob, items));
if (blob != 0 && list != 0) {
FILE *fp = fopen(filename, "r");
if (fp != 0) {
}
list[k] = 0;
count = k;
- ap = list;
+ ap = myList = list;
}
fclose(fp);
}
*ip = 0;
mpSelect = menu_create(items, (int) count, 1, number);
+ if (myList != 0)
+ free(myList);
}
static int
* 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.
*/
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);
{
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;
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);
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++) {
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);
} 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);
- buffer[length++] = c0 = ch;
+ buffer[length++] = (char) (c0 = 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);
- buffer[length++] = c0 = ch;
+ buffer[length++] = (char) (c0 = ch);
} else {
beep();
}
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);
}
/*
* 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.
int amaster;
int aslave;
char slave_name[1024];
- char s_option[1024];
+ char s_option[sizeof(slave_name) + 80];
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;
_exit(0);
}
fp = fdopen(amaster, "r+");
+ if (fp == 0)
+ failed(path);
#else
struct stat sb;
failed(path);
printf("opened %s\n", path);
#endif
+ assert(fp != 0);
return fp;
}
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);
while ((ch = peek_fifo(fifo, peek)) > 0) {
changed = TRUE;
- waddch(win, ch);
+ waddch(win, (chtype) ch);
wnoutrefresh(win);
}
}
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++) {
/****************************************************************************
- * 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 *
* 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>
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);
}
if (optind < argc) {
count = atoi(argv[optind++]);
+ assert(count >= 0);
}
if (optind < argc)
usage();
/****************************************************************************
- * 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 *
*
* 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>
COLOR_RED, /* Length 19 */
};
static int NMoves = 0;
+static bool AutoFlag = FALSE;
static void InitTiles(int NTiles);
static void DisplayTiles(void);
main(int argc, char **argv)
{
int NTiles, FromCol, ToCol;
- bool AutoFlag = 0;
setlocale(LC_ALL, "");
/* 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);
return TRUE;
*To -= ('0' + 1);
refresh();
- napms(500);
+ if (!AutoFlag)
+ napms(500);
move(STATUSLINE, 0);
clrtoeol();
/****************************************************************************
- * 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 *
* 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>
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;
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 $
***************************************************************************/
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);
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[x++] = ch;
+ buffer[x++] = (char) ch;
} else {
flash();
}
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);
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[x++] = ch;
+ buffer[x++] = (wchar_t) ch;
} else {
beep();
}
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));
{
unsigned need = (level + 1) * 2;
+ assert(level < COLS);
+
if (winstack == 0) {
len_winstack = 20;
winstack = typeMalloc(WINSTACK, len_winstack);
#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
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;
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 (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);
}
if (use_colors) {
switch (ch) {
case 'f':
- *fg = (*fg + 1);
+ *fg = (short) (*fg + 1);
break;
case 'F':
- *fg = (*fg - 1);
+ *fg = (short) (*fg - 1);
break;
case 'b':
- *bg = (*bg + 1);
+ *bg = (short) (*bg + 1);
break;
case 'B':
- *bg = (*bg - 1);
+ *bg = (short) (*bg - 1);
break;
case 't':
- *tx = (*tx + 1);
+ *tx = (short) (*tx + 1);
break;
case 'T':
- *tx = (*tx - 1);
+ *tx = (short) (*tx - 1);
break;
default:
beep();
break;
}
if (*fg >= COLORS)
- *fg = min_colors;
+ *fg = (short) min_colors;
if (*fg < min_colors)
- *fg = COLORS - 1;
+ *fg = (short) (COLORS - 1);
if (*bg >= COLORS)
- *bg = min_colors;
+ *bg = (short) min_colors;
if (*bg < min_colors)
- *bg = COLORS - 1;
+ *bg = (short) (COLORS - 1);
if (*tx >= COLORS)
*tx = -1;
if (*tx < -1)
- *tx = COLORS - 1;
+ *tx = (short) (COLORS - 1);
} else {
beep();
error = TRUE;
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) {
- ++j;
- if (j < MAX_ATTRSTRING)
- attr_test_string[j] = ' ';
+ if (++j >= MAX_ATTRSTRING)
+ break;
+ attr_test_string[j] = ' ';
}
}
while (j < MAX_ATTRSTRING)
do {
int row = 2;
chtype normal = A_NORMAL | BLANK;
- chtype extras = ac;
+ chtype extras = (chtype) ac;
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) {
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)
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) {
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) {
- 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));
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) {
- 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);
switch (field) {
case 0:
- red = usebase ? red + value : value;
+ red = (short) (usebase ? (red + value) : value);
break;
case 1:
- green = usebase ? green + value : value;
+ green = (short) (usebase ? (green + value) : value);
break;
case 2:
- blue = usebase ? blue + value : value;
+ blue = (short) (usebase ? (blue + value) : value);
break;
}
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;
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);
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];
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);
break;
case '+':
- change_color(current, field, value, 1);
+ change_color((short) current, field, value, 1);
break;
case '-':
- change_color(current, field, -value, 1);
+ change_color((short) current, field, -value, 1);
break;
case '=':
- change_color(current, field, value, 0);
+ change_color((short) current, field, value, 0);
break;
case '?':
#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) {
- bg = (bg + 1) % COLORS;
+ bg = (short) ((bg + 1) % COLORS);
call_slk_color(fg, bg);
}
break;
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) {
- bg = (bg + 1) % COLORS;
+ bg = (short) ((bg + 1) % COLORS);
call_slk_color(fg, bg);
}
break;
break;
}
if (result) {
- *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 (init_pair(*pair, (short) *fg, (short) *bg) == ERR) {
result = FALSE;
}
}
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);
}
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 (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.");
*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);
#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.
static bool
HaveKeypad(FRAME * curp)
{
- WINDOW *win = (curp ? curp->wind : stdscr);
+ WINDOW *win = frame_win(curp);
(void) win;
return is_keypad(win);
}
static bool
HaveScroll(FRAME * curp)
{
- WINDOW *win = (curp ? curp->wind : stdscr);
+ WINDOW *win = frame_win(curp);
(void) win;
return is_scrollok(win);
}
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)
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;
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;
}
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;
+ }
if (current == 0) { /* First element, */
neww->next = neww; /* so point it at itself */
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)
- wscrl(current->wind, -1);
+ wscrl(frame_win(current), -1);
break;
case CTRL('K'): /* toggle keypad mode for current */
#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 {
- (void) putwin(current->wind, fp);
+ (void) putwin(frame_win(current), fp);
(void) fclose(fp);
current = delete_framed(current, TRUE);
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
case KEY_DC:
{
int y, x;
- getyx(current->wind, y, x);
+ getyx(frame_win(current), y, x);
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;
}
newwin_report(current);
- usescr = (current ? current->wind : stdscr);
+ usescr = frame_win(current);
wrefresh(usescr);
} while
(!isQuit(c = wGetchar(usescr))
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);
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);
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);
"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)
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)
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) {
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) {
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);
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);
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 = '*';
/* 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;
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");
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);
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:
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:
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;
*/
command = 0;
for (;;) {
- char ch;
+ char ch = '\0';
if (read(fileno(stdin), &ch, 1) <= 0) {
if (command == 0)
command = 'q';
#endif
#ifdef TRACE
case 't':
- save_trace = strtol(optarg, 0, 0);
+ save_trace = (unsigned) strtol(optarg, 0, 0);
break;
#endif
default:
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,
&& 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);
* 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>
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)
* 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>
{"Input Test", inputTest},
{"Output Test", outputTest}
};
-#define MAX_OPTIONS SIZEOF(command)
+#define MAX_OPTIONS (int) SIZEOF(command)
#if !HAVE_STRDUP
#define strdup my_strdup
int old_option = (-1);
int new_option = 0;
bool quit = FALSE;
- unsigned n;
+ int n;
setlocale(LC_ALL, "");
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:
- 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':
{
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
{
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);
- if (old_option != (-1))
+
+ if ((old_option >= 0) && (old_option < MAX_OPTIONS))
mvaddstr(5 + old_option, 25, command[old_option].text);
+
attrset(A_REVERSE);
mvaddstr(5 + new_option, 25, command[new_option].text);
attrset(A_NORMAL);
* 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>
CATCHALL(SIG_IGN);
break;
case 'n':
- if ((MAXLINES = atoi(optarg)) < 1)
+ if ((MAXLINES = atoi(optarg)) < 1 ||
+ (MAXLINES + 2) <= 1)
usage();
break;
#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);
- 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);
/******************************************************************************/
/*
- * $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>
}
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");