-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1918 2012/06/16 19:19:48 tom Exp $
+-- $Id: NEWS,v 1.1919 2012/06/22 23:10:32 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.
+20120622
+ + add -d, -e and -q options to test/demo_terminfo and test/demo_termcap
+ + fix caching of environment variables in database-iterator (patch by
+ Philippe Troin, Redhat #831366).
+
20120616
+ add configure check to distinguish clang from gcc to eliminate
warnings about unused command-line parameters when compiler warnings
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: dist.mk,v 1.878 2012/06/16 14:25:35 tom Exp $
+# $Id: dist.mk,v 1.879 2012/06/22 17:51:21 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 = 9
-NCURSES_PATCH = 20120616
+NCURSES_PATCH = 20120622
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
#include <hashed_db.h>
#endif
-MODULE_ID("$Id: db_iterator.c,v 1.31 2012/02/22 22:40:24 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.33 2012/06/23 00:16:58 tom Exp $")
#define HaveTicDirectory _nc_globals.have_tic_directory
#define KeepTicDirectory _nc_globals.keep_tic_directory
update_getenv(const char *name, DBDIRS which)
{
bool result = FALSE;
- char *value = getenv(name);
if (which < dbdLAST) {
- if (my_vars[which].name == 0 || strcmp(my_vars[which].name, name)) {
+ char *value = getenv(name);
+
+ if ((value = getenv(name)) == 0 || (value = strdup(value)) == 0) {
+ ;
+ } else if (my_vars[which].name == 0 || strcmp(my_vars[which].name, name)) {
FreeIfNeeded(my_vars[which].value);
my_vars[which].name = name;
my_vars[which].value = value;
FreeIfNeeded(my_vars[which].value);
my_vars[which].value = value;
result = TRUE;
+ } else {
+ free(value);
}
}
return result;
NCURSES_EXPORT(void)
_nc_first_db(DBDIRS * state, int *offset)
{
+ bool cache_has_expired = FALSE;
*state = dbdTIC;
*offset = 0;
/* build a blob containing all of the strings we will use for a lookup
* table.
*/
- if (my_blob == 0) {
+ if (my_blob == 0 || (cache_has_expired = cache_expired())) {
size_t blobsize = 0;
const char *values[dbdLAST];
struct stat *my_stat;
int j, k;
+ if (cache_has_expired)
+ free_cache();
+
for (j = 0; j < dbdLAST; ++j)
values[j] = 0;
void
_nc_db_iterator_leaks(void)
{
+ DBDIRS which;
+
if (my_blob != 0)
FreeAndNull(my_blob);
if (my_list != 0)
FreeAndNull(my_list);
+ for (which = 0; which < dbdLAST; ++which) {
+ my_vars[which].name = 0;
+ FreeIfNeeded(my_vars[which].value);
+ my_vars[which].value = 0;
+ }
}
#endif
-ncurses6 (5.9-20120616) unstable; urgency=low
+ncurses6 (5.9-20120622) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 16 Jun 2012 18:00:23 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Fri, 22 Jun 2012 13:52:38 -0400
ncurses6 (5.9-20120608) unstable; urgency=low
Summary: shared libraries for terminal handling
Name: ncurses6
Release: 5.9
-Version: 20120616
+Version: 20120622
License: X11
Group: Development/Libraries
Source: ncurses-%{release}-%{version}.tgz
/*
* Author: Thomas E. Dickey
*
- * $Id: demo_termcap.c,v 1.17 2012/03/01 01:09:30 tom Exp $
+ * $Id: demo_termcap.c,v 1.20 2012/06/22 22:37:05 tom Exp $
*
* A simple demo of the termcap interface.
*/
#if USE_CODE_LISTS
static bool b_opt = FALSE;
static bool n_opt = FALSE;
+static bool q_opt = FALSE;
static bool s_opt = FALSE;
#endif
+static char *d_opt;
+static char *e_opt;
+static char **db_list;
+static int db_item;
+
+static long total_values;
+
#define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0)
#if NO_LEAKS && USE_CODE_LISTS
#define save_screen() /* nothing */
#endif
+static char *
+make_dbitem(char *p, char *q)
+{
+ char *result = malloc(strlen(e_opt) + 2 + p - q);
+ sprintf(result, "%s=%.*s", e_opt, p - q, q);
+ return result;
+}
+
+static void
+make_dblist(void)
+{
+ if (d_opt && e_opt) {
+ int pass;
+
+ for (pass = 0; pass < 2; ++pass) {
+ char *p, *q;
+ size_t count = 0;
+
+ for (p = q = d_opt; *p != '\0'; ++p) {
+ if (*p == ':') {
+ if (p != q + 1) {
+ if (pass) {
+ db_list[count] = make_dbitem(p, q);
+ }
+ count++;
+ }
+ q = p + 1;
+ }
+ }
+ if (p != q + 1) {
+ if (pass) {
+ db_list[count] = make_dbitem(p, q);
+ }
+ count++;
+ }
+ if (!pass) {
+ db_list = typeCalloc(char *, count + 1);
+ }
+ }
+ }
+}
+
+static char *
+next_dbitem(void)
+{
+ char *result = 0;
+
+ if (db_list) {
+ if ((result = db_list[db_item]) == 0) {
+ db_item = 0;
+ result = db_list[0];
+ } else {
+ db_item++;
+ }
+ }
+ printf("** %s\n", result);
+ return result;
+}
+
+static void
+free_dblist(void)
+{
+ if (db_list) {
+ int n;
+ for (n = 0; db_list[n]; ++n)
+ free(db_list[n]);
+ free(db_list);
+ db_list = 0;
+ }
+}
+
static void
dumpit(NCURSES_CONST char *cap)
{
int num;
if ((str = tgetstr(cap, &ap)) != 0) {
- /*
- * Note that the strings returned are mostly terminfo format, since
- * ncurses does not convert except for a handful of special cases.
- */
- printf(FNAME(str), cap);
- while (*str != 0) {
- int ch = UChar(*str++);
- switch (ch) {
- case '\177':
- fputs("^?", stdout);
- break;
- case '\033':
- fputs("\\E", stdout);
- break;
- case '\b':
- fputs("\\b", stdout);
- break;
- case '\f':
- fputs("\\f", stdout);
- break;
- case '\n':
- fputs("\\n", stdout);
- break;
- case '\r':
- fputs("\\r", stdout);
- break;
- case ' ':
- fputs("\\s", stdout);
- break;
- case '\t':
- fputs("\\t", stdout);
- break;
- case '^':
- fputs("\\^", stdout);
- break;
- case ':':
- fputs("\\072", stdout);
- break;
- case '\\':
- fputs("\\\\", stdout);
- break;
- default:
- if (isgraph(ch))
- fputc(ch, stdout);
- else if (ch < 32)
- printf("^%c", ch + '@');
- else
- printf("\\%03o", ch);
- break;
+ total_values++;
+ if (!q_opt) {
+ /*
+ * Note that the strings returned are mostly terminfo format, since
+ * ncurses does not convert except for a handful of special cases.
+ */
+ printf(FNAME(str), cap);
+ while (*str != 0) {
+ int ch = UChar(*str++);
+ switch (ch) {
+ case '\177':
+ fputs("^?", stdout);
+ break;
+ case '\033':
+ fputs("\\E", stdout);
+ break;
+ case '\b':
+ fputs("\\b", stdout);
+ break;
+ case '\f':
+ fputs("\\f", stdout);
+ break;
+ case '\n':
+ fputs("\\n", stdout);
+ break;
+ case '\r':
+ fputs("\\r", stdout);
+ break;
+ case ' ':
+ fputs("\\s", stdout);
+ break;
+ case '\t':
+ fputs("\\t", stdout);
+ break;
+ case '^':
+ fputs("\\^", stdout);
+ break;
+ case ':':
+ fputs("\\072", stdout);
+ break;
+ case '\\':
+ fputs("\\\\", stdout);
+ break;
+ default:
+ if (isgraph(ch))
+ fputc(ch, stdout);
+ else if (ch < 32)
+ printf("^%c", ch + '@');
+ else
+ printf("\\%03o", ch);
+ break;
+ }
}
+ printf("\n");
}
- printf("\n");
} else if ((num = tgetnum(cap)) >= 0) {
- printf(FNAME(num), cap);
- printf(" %d\n", num);
+ total_values++;
+ if (!q_opt) {
+ printf(FNAME(num), cap);
+ printf(" %d\n", num);
+ }
} else if (tgetflag(cap) > 0) {
- printf(FNAME(flg), cap);
- printf("%s\n", "true");
+ ++total_values;
+ if (!q_opt) {
+ printf(FNAME(flg), cap);
+ printf("%s\n", "true");
+ }
}
- fflush(stdout);
+
+ if (!q_opt)
+ fflush(stdout);
}
static void
{
char buffer[1024];
+ if (db_list) {
+ putenv(next_dbitem());
+ }
printf("Terminal type %s\n", name);
if (tgetent(buffer, name) >= 0) {
char cap[3];
unsigned n;
NCURSES_CONST char *cap;
+ if (db_list) {
+ putenv(next_dbitem());
+ }
printf("Terminal type \"%s\"\n", name);
#if HAVE_SETUPTERM
setupterm(name, 1, (int *) 0);
"Options:",
" -a try all names, print capabilities found",
" -b print boolean-capabilities",
+ " -d LIST colon-separated list of databases to use",
+ " -e NAME environment variable to set with -d option",
" -n print numeric-capabilities",
+ " -q quiet (prints only counts)",
" -r COUNT repeat for given count",
" -s print string-capabilities",
};
int repeat;
int r_opt = 1;
- while ((n = getopt(argc, argv, "abnr:s")) != -1) {
+ while ((n = getopt(argc, argv, "abd:e:nqr:s")) != -1) {
switch (n) {
case 'a':
a_opt = TRUE;
case 'b':
b_opt = TRUE;
break;
+ case 'd':
+ d_opt = optarg;
+ break;
+ case 'e':
+ e_opt = optarg;
+ break;
case 'n':
n_opt = TRUE;
break;
+ case 'q':
+ q_opt = TRUE;
+ break;
case 'r':
if ((r_opt = atoi(optarg)) <= 0)
usage();
a_opt = TRUE;
#endif
+ make_dblist();
+
if (a_opt) {
if (optind < argc) {
for (n = optind; n < argc; ++n) {
}
#endif /* USE_CODE_LISTS */
+ printf("%ld values\n", total_values);
+
+ free_dblist();
+
ExitProgram(EXIT_SUCCESS);
}
char *argv[]GCC_UNUSED)
{
printf("This program requires termcap\n");
- exit(EXIT_FAILURE);
+ ExitProgram(EXIT_FAILURE);
}
#endif
/****************************************************************************
- * Copyright (c) 2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2009-2010,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 *
/*
* Author: Thomas E. Dickey
*
- * $Id: demo_terminfo.c,v 1.9 2010/11/28 00:15:27 tom Exp $
+ * $Id: demo_terminfo.c,v 1.11 2012/06/22 23:04:03 tom Exp $
*
* A simple demo of the terminfo interface.
*/
static bool b_opt = FALSE;
static bool f_opt = FALSE;
static bool n_opt = FALSE;
+static bool q_opt = FALSE;
static bool s_opt = FALSE;
static bool x_opt = FALSE;
+static char *d_opt;
+static char *e_opt;
+static char **db_list;
+static int db_item;
+
+static long total_values;
+
#define FCOLS 8
#define FNAME(type) "%s %-*s = ", #type, FCOLS
+static char *
+make_dbitem(char *p, char *q)
+{
+ char *result = malloc(strlen(e_opt) + 2 + p - q);
+ sprintf(result, "%s=%.*s", e_opt, p - q, q);
+ return result;
+}
+
+static void
+make_dblist(void)
+{
+ if (d_opt && e_opt) {
+ int pass;
+
+ for (pass = 0; pass < 2; ++pass) {
+ char *p, *q;
+ size_t count = 0;
+
+ for (p = q = d_opt; *p != '\0'; ++p) {
+ if (*p == ':') {
+ if (p != q + 1) {
+ if (pass) {
+ db_list[count] = make_dbitem(p, q);
+ }
+ count++;
+ }
+ q = p + 1;
+ }
+ }
+ if (p != q + 1) {
+ if (pass) {
+ db_list[count] = make_dbitem(p, q);
+ }
+ count++;
+ }
+ if (!pass) {
+ db_list = typeCalloc(char *, count + 1);
+ }
+ }
+ }
+}
+
+static char *
+next_dbitem(void)
+{
+ char *result = 0;
+
+ if (db_list) {
+ if ((result = db_list[db_item]) == 0) {
+ db_item = 0;
+ result = db_list[0];
+ } else {
+ db_item++;
+ }
+ }
+ printf("** %s\n", result);
+ return result;
+}
+
+static void
+free_dblist(void)
+{
+ if (db_list) {
+ int n;
+ for (n = 0; db_list[n]; ++n)
+ free(db_list[n]);
+ free(db_list);
+ db_list = 0;
+ }
+}
static void
dumpit(NCURSES_CONST char *cap)
{
int num;
if ((str = tigetstr(cap)) != 0 && (str != (char *) -1)) {
- /*
- * Note that the strings returned are mostly terminfo format, since
- * ncurses does not convert except for a handful of special cases.
- */
- printf(FNAME(str), cap);
- while (*str != 0) {
- int ch = UChar(*str++);
- switch (ch) {
- case '\177':
- fputs("^?", stdout);
- break;
- case '\033':
- fputs("\\E", stdout);
- break;
- case '\b':
- fputs("\\b", stdout);
- break;
- case '\f':
- fputs("\\f", stdout);
- break;
- case '\n':
- fputs("\\n", stdout);
- break;
- case '\r':
- fputs("\\r", stdout);
- break;
- case ' ':
- fputs("\\s", stdout);
- break;
- case '\t':
- fputs("\\t", stdout);
- break;
- case '^':
- fputs("\\^", stdout);
- break;
- case ':':
- fputs("\\072", stdout);
- break;
- case '\\':
- fputs("\\\\", stdout);
- break;
- default:
- if (isgraph(ch))
- fputc(ch, stdout);
- else if (ch < 32)
- printf("^%c", ch + '@');
- else
- printf("\\%03o", ch);
- break;
+ total_values++;
+ if (!q_opt) {
+ /*
+ * Note that the strings returned are mostly terminfo format, since
+ * ncurses does not convert except for a handful of special cases.
+ */
+ printf(FNAME(str), cap);
+ while (*str != 0) {
+ int ch = UChar(*str++);
+ switch (ch) {
+ case '\177':
+ fputs("^?", stdout);
+ break;
+ case '\033':
+ fputs("\\E", stdout);
+ break;
+ case '\b':
+ fputs("\\b", stdout);
+ break;
+ case '\f':
+ fputs("\\f", stdout);
+ break;
+ case '\n':
+ fputs("\\n", stdout);
+ break;
+ case '\r':
+ fputs("\\r", stdout);
+ break;
+ case ' ':
+ fputs("\\s", stdout);
+ break;
+ case '\t':
+ fputs("\\t", stdout);
+ break;
+ case '^':
+ fputs("\\^", stdout);
+ break;
+ case ':':
+ fputs("\\072", stdout);
+ break;
+ case '\\':
+ fputs("\\\\", stdout);
+ break;
+ default:
+ if (isgraph(ch))
+ fputc(ch, stdout);
+ else if (ch < 32)
+ printf("^%c", ch + '@');
+ else
+ printf("\\%03o", ch);
+ break;
+ }
}
+ printf("\n");
}
- printf("\n");
} else if ((num = tigetnum(cap)) >= 0) {
- printf(FNAME(num), cap);
- printf(" %d\n", num);
+ total_values++;
+ if (!q_opt) {
+ printf(FNAME(num), cap);
+ printf(" %d\n", num);
+ }
} else if ((num = tigetflag(cap)) >= 0) {
- printf(FNAME(flg), cap);
- printf("%s\n", num ? "true" : "false");
+ total_values++;
+ if (!q_opt) {
+ printf(FNAME(flg), cap);
+ printf("%s\n", num ? "true" : "false");
+ }
}
- fflush(stdout);
+
+ if (!q_opt)
+ fflush(stdout);
}
static void
unsigned n;
NCURSES_CONST char *cap;
+ if (db_list) {
+ putenv(next_dbitem());
+ }
printf("Terminal type \"%s\"\n", name);
setupterm(name, 1, (int *) 0);
"",
"Options:",
" -b print boolean-capabilities",
+ " -d LIST colon-separated list of databases to use",
+ " -e NAME environment variable to set with -d option",
" -f print full names",
" -n print numeric-capabilities",
+ " -q quiet (prints only counts)",
" -r COUNT repeat for given count",
" -s print string-capabilities",
#ifdef NCURSES_VERSION
char *name;
int r_opt = 1;
- while ((n = getopt(argc, argv, "bfnr:sx")) != -1) {
+ while ((n = getopt(argc, argv, "bd:e:fnqr:sx")) != -1) {
switch (n) {
case 'b':
b_opt = TRUE;
break;
+ case 'd':
+ d_opt = optarg;
+ break;
+ case 'e':
+ e_opt = optarg;
+ break;
case 'f':
f_opt = TRUE;
break;
case 'n':
n_opt = TRUE;
break;
+ case 'q':
+ q_opt = TRUE;
+ break;
case 'r':
if ((r_opt = atoi(optarg)) <= 0)
usage();
s_opt = TRUE;
}
+ make_dblist();
+
for (repeat = 0; repeat < r_opt; ++repeat) {
if (optind < argc) {
for (n = optind; n < argc; ++n) {
}
}
+ printf("%ld values\n", total_values);
+
+ free_dblist();
+
ExitProgram(EXIT_SUCCESS);
}