snapshot of project "ncurses", label v5_9_20120721

This commit is contained in:
Thomas E. Dickey 2012-07-22 00:45:34 -04:00
parent cfb617718c
commit 0de22f63ea
13 changed files with 180 additions and 97 deletions

10
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: NEWS,v 1.1927 2012/07/14 23:02:40 tom Exp $
-- $Id: NEWS,v 1.1931 2012/07/21 23:24:40 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,14 @@ See the AUTHORS file for the corresponding full names.
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
20120721
+ improved form_request_by_name() and menu_request_by_name().
+ eliminate two fixed-size buffers in toe.c
+ extend use_tioctl() to have expected behavior when use_env(FALSE) and
use_tioctl(TRUE) are called.
+ modify ncurses test-program, adding -E and -T options to demonstrate
use_env() versus use_tioctl().
20120714
+ add use_tioctl() function (adapted from patch by Werner Fink,
Novell #769788):

View File

@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: dist.mk,v 1.882 2012/07/14 17:09:16 tom Exp $
# $Id: dist.mk,v 1.883 2012/07/21 16:14:00 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
@ -37,7 +37,7 @@ SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5
NCURSES_MINOR = 9
NCURSES_PATCH = 20120714
NCURSES_PATCH = 20120721
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -32,7 +32,7 @@
#include "form.priv.h"
MODULE_ID("$Id: frm_driver.c,v 1.101 2012/06/10 00:28:04 tom Exp $")
MODULE_ID("$Id: frm_driver.c,v 1.102 2012/07/21 23:23:08 tom Exp $")
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
@ -4229,7 +4229,10 @@ form_driver(FORM *form, int c)
if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
BI = &(bindings[c - MIN_FORM_COMMAND]);
{
TR(TRACE_CALLS, ("form_request %s", form_request_name(c)));
BI = &(bindings[c - MIN_FORM_COMMAND]);
}
if (BI)
{
@ -4256,9 +4259,13 @@ form_driver(FORM *form, int c)
Generic_Method fct = Generic_Methods[method];
if (fct)
res = fct(BI->cmd, form);
{
res = fct(BI->cmd, form);
}
else
res = (BI->cmd) (form);
{
res = (BI->cmd) (form);
}
}
}
#ifdef NCURSES_MOUSE_VERSION

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
* Copyright (c) 1998-2009,2012 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 *
@ -37,7 +37,7 @@
#include "form.priv.h"
MODULE_ID("$Id: frm_req_name.c,v 1.17 2009/10/10 16:17:01 tom Exp $")
MODULE_ID("$Id: frm_req_name.c,v 1.18 2012/07/21 23:17:23 tom Exp $")
static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{
@ -144,23 +144,26 @@ form_request_by_name(const char *str)
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
*/
unsigned int i = 0;
char buf[16];
size_t i = 0;
char buf[16]; /* longest name is 10 chars */
T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
if (str)
if (str != 0 && (i = strlen(str)) != 0)
{
strncpy(buf, str, sizeof(buf));
while ((i < sizeof(buf)) && (buf[i] != '\0'))
if (i > sizeof(buf) - 2)
i = sizeof(buf) - 2;
memcpy(buf, str, i);
buf[i] = '\0';
for (i = 0; buf[i] != '\0'; ++i)
{
buf[i] = (char)toupper(UChar(buf[i]));
i++;
}
for (i = 0; i < A_SIZE; i++)
{
if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
if (strcmp(request_names[i], buf) == 0)
returnCode(MIN_FORM_COMMAND + (int)i);
}
}

View File

@ -1,3 +1,4 @@
'\" t
.\"***************************************************************************
.\" Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
.\" *
@ -26,7 +27,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
.\" $Id: curs_util.3x,v 1.35 2012/07/15 00:23:52 tom Exp $
.\" $Id: curs_util.3x,v 1.36 2012/07/21 18:51:10 tom Exp $
.TH curs_util 3X ""
.de bP
.IP \(bu 4
@ -136,14 +137,15 @@ when determining the screen size.
Normally ncurses looks first at the terminal database for the screen size.
.IP
If \fBuse_env\fP was called with \fBFALSE\fP for parameter,
it stops here.
it stops here unless
If \fBuse_tioctl\fP was also called with \fBTRUE\fP for parameter.
.bP
Then it asks for the screen size via operating system calls.
If successful,
it overrides the values from the terminal database.
.bP
Finally, ncurses examines the
\fBLINES\fR or \fBCOLUMNS\fR environment variables,
Finally (unless \fBuse_env\fP was called with \fBFALSE\fP parameter),
ncurses examines the \fBLINES\fR or \fBCOLUMNS\fR environment variables,
using a value in those to override the results
from the operating system or terminal database.
.IP
@ -166,6 +168,30 @@ or from the terminal database.
ncurses re-fetches the value of the environment variables so that
it is still the environment variables which set the screen size.
.PP
The \fBuse_env\fP and \fBuse_tioctl\fP routines combine as
summarized here:
.TS
center tab(/);
l l l
_ _ _
lw7 lw7 lw40.
\fIuse_env\fR/\fIuse_tioctl\fR/\fISummary\fR
TRUE/FALSE/T{
This is the default behavior.
ncurses uses operating system calls
unless overridden by $LINES or $COLUMNS environment variables.
T}
TRUE/TRUE/T{
ncurses updates $LINES and $COLUMNS based on operating system calls.
T}
FALSE/TRUE/T{
ncurses ignores $LINES and $COLUMNS, uses operating system calls to obtain size.
T}
FALSE/FALSE/T{
ncurses relies on the terminal database to determine size.
T}
.TE
.PP
The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
the file to which \fIfilep\fR points. This information can be later retrieved
using the \fBgetwin\fR function.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
* Copyright (c) 1998-2009,2012 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 *
@ -37,7 +37,7 @@
#include "menu.priv.h"
MODULE_ID("$Id: m_req_name.c,v 1.21 2009/10/10 16:17:23 tom Exp $")
MODULE_ID("$Id: m_req_name.c,v 1.22 2012/07/21 23:27:32 tom Exp $")
static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
{
@ -99,23 +99,26 @@ menu_request_by_name(const char *str)
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
*/
unsigned int i = 0;
size_t i = 0;
char buf[16];
T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
if (str)
if (str != 0 && (i = strlen(str)) != 0)
{
strncpy(buf, str, sizeof(buf));
while ((i < sizeof(buf)) && (buf[i] != '\0'))
if (i > sizeof(buf) - 2)
i = sizeof(buf) - 2;
memcpy(buf, str, i);
buf[i] = '\0';
for (i = 0; buf[i] != '\0'; ++i)
{
buf[i] = (char)toupper(UChar(buf[i]));
i++;
}
for (i = 0; i < A_SIZE; i++)
{
if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
if (strcmp(request_names[i], buf) == 0)
returnCode(MIN_MENU_COMMAND + (int)i);
}
}

View File

@ -84,7 +84,7 @@
#define CUR SP_TERMTYPE
#endif
MODULE_ID("$Id: lib_mouse.c,v 1.138 2012/02/29 10:38:46 tom Exp $")
MODULE_ID("$Id: lib_mouse.c,v 1.139 2012/07/21 23:30:50 tom Exp $")
#include <tic.h>
@ -225,7 +225,7 @@ write_event(SCREEN *sp, int down, int button, int x, int y)
char buf[6];
unsigned long ignore;
strncpy(buf, key_mouse, 3); /* should be "\033[M" */
strcpy(buf, "\033[M"); /* should be the same as key_mouse */
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;

View File

@ -48,7 +48,7 @@
#include <locale.h>
#endif
MODULE_ID("$Id: lib_setup.c,v 1.147 2012/07/14 23:59:26 tom Exp $")
MODULE_ID("$Id: lib_setup.c,v 1.148 2012/07/21 18:05:41 tom Exp $")
/****************************************************************************
*
@ -304,7 +304,7 @@ _nc_get_screensize(SCREEN *sp,
*linep = (int) lines;
*colp = (int) columns;
if (_nc_prescreen.use_env) {
if (_nc_prescreen.use_env || _nc_prescreen.use_tioctl) {
int value;
#ifdef __EMX__
@ -340,31 +340,33 @@ _nc_get_screensize(SCREEN *sp,
}
#endif /* HAVE_SIZECHANGE */
if (_nc_prescreen.use_tioctl) {
/*
* If environment variables are used, update them.
*/
if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
if (_nc_prescreen.use_env) {
if (_nc_prescreen.use_tioctl) {
/*
* If environment variables are used, update them.
*/
if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
}
if (_nc_getenv_num("COLUMNS") > 0) {
_nc_setenv_num("COLUMNS", *colp);
}
}
if (_nc_getenv_num("COLUMNS") > 0) {
_nc_setenv_num("COLUMNS", *colp);
}
}
/*
* Finally, look for environment variables.
*
* Solaris lets users override either dimension with an environment
* variable.
*/
if ((value = _nc_getenv_num("LINES")) > 0) {
*linep = value;
T(("screen size: environment LINES = %d", *linep));
}
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
*colp = value;
T(("screen size: environment COLUMNS = %d", *colp));
/*
* Finally, look for environment variables.
*
* Solaris lets users override either dimension with an environment
* variable.
*/
if ((value = _nc_getenv_num("LINES")) > 0) {
*linep = value;
T(("screen size: environment LINES = %d", *linep));
}
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
*colp = value;
T(("screen size: environment COLUMNS = %d", *colp));
}
}
/* if we can't get dynamic info about the size, use static */

View File

@ -50,7 +50,7 @@
# endif
#endif
MODULE_ID("$Id: tinfo_driver.c,v 1.21 2012/07/15 00:20:43 tom Exp $")
MODULE_ID("$Id: tinfo_driver.c,v 1.23 2012/07/22 00:45:34 tom Exp $")
/*
* SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
@ -361,7 +361,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
*linep = (int) lines;
*colp = (int) columns;
if (useEnv) {
if (useEnv || useTioctl) {
int value;
#ifdef __EMX__
@ -400,35 +400,35 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
}
#endif /* HAVE_SIZECHANGE */
if (useTioctl) {
char buf[128];
if (useEnv) {
if (useTioctl) {
/*
* If environment variables are used, update them.
*/
if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
}
if (_nc_getenv_num("COLUMNS") > 0) {
_nc_setenv_num("COLUMNS", *colp);
}
}
/*
* If environment variables are used, update them.
* Finally, look for environment variables.
*
* Solaris lets users override either dimension with an environment
* variable.
*/
if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
if ((value = _nc_getenv_num("LINES")) > 0) {
*linep = value;
T(("screen size: environment LINES = %d", *linep));
}
if (_nc_getenv_num("COLUMNS") > 0) {
_nc_setenv_num("COLUMNS", *colp);
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
*colp = value;
T(("screen size: environment COLUMNS = %d", *colp));
}
}
/*
* Finally, look for environment variables.
*
* Solaris lets users override either dimension with an environment
* variable.
*/
if ((value = _nc_getenv_num("LINES")) > 0) {
*linep = value;
T(("screen size: environment LINES = %d", *linep));
}
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
*colp = value;
T(("screen size: environment COLUMNS = %d", *colp));
}
/* if we can't get dynamic info about the size, use static */
if (*linep <= 0) {
*linep = (int) lines;

View File

@ -1,8 +1,8 @@
ncurses6 (5.9-20120714) unstable; urgency=low
ncurses6 (5.9-20120721) unstable; urgency=low
* latest weekly patch
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 14 Jul 2012 19:07:27 -0400
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 21 Jul 2012 19:33:07 -0400
ncurses6 (5.9-20120608) unstable; urgency=low

View File

@ -1,7 +1,7 @@
Summary: shared libraries for terminal handling
Name: ncurses6
Release: 5.9
Version: 20120714
Version: 20120721
License: X11
Group: Development/Libraries
Source: ncurses-%{release}-%{version}.tgz

View File

@ -44,7 +44,7 @@
#include <hashed_db.h>
#endif
MODULE_ID("$Id: toe.c,v 1.67 2012/03/10 23:22:21 tom Exp $")
MODULE_ID("$Id: toe.c,v 1.68 2012/07/21 22:55:59 tom Exp $")
#define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
@ -345,6 +345,21 @@ show_termcap(int db_index, int db_limit, char *buffer, DescHook hook)
}
#endif
#if USE_DATABASE
static char *
copy_entryname(DIRENT * src)
{
size_t len = NAMLEN(src);
char *result = malloc(len + 1);
if (result == 0)
failed("copy entryname");
memcpy(result, src->d_name, len);
result[len] = '\0';
return result;
}
#endif
static int
typelist(int eargc, char *eargv[],
bool verbosity,
@ -372,24 +387,28 @@ typelist(int eargc, char *eargv[],
(void) printf("#\n#%s:\n#\n", eargv[i]);
while ((subdir = readdir(termdir)) != 0) {
size_t len = NAMLEN(subdir);
size_t cwd_len = len + strlen(eargv[i]) + 3;
char name_1[PATH_MAX];
size_t cwd_len;
char *name_1;
DIR *entrydir;
DIRENT *entry;
name_1 = copy_entryname(subdir);
if (isDotname(name_1)) {
free(name_1);
continue;
}
cwd_len = NAMLEN(subdir) + strlen(eargv[i]) + 3;
cwd_buf = typeRealloc(char, cwd_len, cwd_buf);
if (cwd_buf == 0)
failed("realloc cwd_buf");
assert(cwd_buf != 0);
strncpy(name_1, subdir->d_name, len)[len] = '\0';
if (isDotname(name_1))
continue;
_nc_SPRINTF(cwd_buf, _nc_SLIMIT(cwd_len)
"%s/%.*s/", eargv[i], (int) len, name_1);
"%s/%s/", eargv[i], name_1);
free(name_1);
if (chdir(cwd_buf) != 0)
continue;
@ -399,15 +418,16 @@ typelist(int eargc, char *eargv[],
continue;
}
while ((entry = readdir(entrydir)) != 0) {
char name_2[PATH_MAX];
char *name_2;
TERMTYPE lterm;
char *cn;
int status;
len = NAMLEN(entry);
strncpy(name_2, entry->d_name, len)[len] = '\0';
if (isDotname(name_2) || !_nc_is_file_path(name_2))
name_2 = copy_entryname(entry);
if (isDotname(name_2) || !_nc_is_file_path(name_2)) {
free(name_2);
continue;
}
status = _nc_read_file_entry(name_2, &lterm);
if (status <= 0) {
@ -415,6 +435,7 @@ typelist(int eargc, char *eargv[],
(void) fprintf(stderr,
"%s: couldn't open terminfo file %s.\n",
_nc_progname, name_2);
free(name_2);
return (EXIT_FAILURE);
}
@ -425,6 +446,7 @@ typelist(int eargc, char *eargv[],
hook(i, eargc, cn, &lterm);
}
_nc_free_termtype(&lterm);
free(name_2);
}
closedir(entrydir);
}

View File

@ -40,7 +40,7 @@ AUTHOR
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
Thomas E. Dickey (beginning revision 1.27 in 1996).
$Id: ncurses.c,v 1.372 2012/07/07 18:09:38 tom Exp $
$Id: ncurses.c,v 1.373 2012/07/21 17:40:21 tom Exp $
***************************************************************************/
@ -6497,6 +6497,7 @@ usage(void)
," -a f,b set default-colors (assumed white-on-black)"
," -d use default-colors if terminal supports them"
#endif
," -E call use_env(FALSE) to ignore $LINES and $COLUMNS"
#if USE_SOFTKEYS
," -e fmt specify format for soft-keys test (e)"
#endif
@ -6509,6 +6510,9 @@ usage(void)
#if USE_LIBPANEL
," -s msec specify nominal time for panel-demo (default: 1, to hold)"
#endif
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714)
," -T call use_tioctl(TRUE) to allow SIGWINCH to override environment"
#endif
#ifdef TRACE
," -t mask specify default trace-level (may toggle with ^T)"
#endif
@ -6695,7 +6699,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
while ((c = getopt(argc, argv, "a:de:fhmp:s:t:")) != -1) {
while ((c = getopt(argc, argv, "a:dEe:fhmp:s:Tt:")) != -1) {
switch (c) {
#ifdef NCURSES_VERSION
case 'a':
@ -6706,6 +6710,9 @@ main(int argc, char *argv[])
default_colors = TRUE;
break;
#endif
case 'E':
use_env(FALSE);
break;
case 'e':
my_e_param = atoi(optarg);
#ifdef NCURSES_VERSION
@ -6735,6 +6742,11 @@ main(int argc, char *argv[])
nap_msec = (int) atol(optarg);
break;
#endif
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714)
case 'T':
use_tioctl(TRUE);
break;
#endif
#ifdef TRACE
case 't':
save_trace = (unsigned) strtol(optarg, 0, 0);