ncurses 5.6 - patch 20070728

+ make _nc_capalias_table and _nc_infoalias_table private, accessed via
  _nc_get_alias_table() since they are used only by parse_entry.c
+ make _nc_key_names private since it is used only by lib_keyname.c
+ add --disable-big-strings configure option to control whether
  unctrl.c is generated using the big-string optimization - which may
  use strings longer than supported by a given compiler.
+ reduce relocation tables for tic, infocmp by changing type of
  internal hash tables to short, and make those private symbols.
+ eliminate large fixed arrays from progs/infocmp.c
This commit is contained in:
Thomas E. Dickey 2007-07-29 00:27:12 +00:00
parent 772f879d17
commit 03a795bde5
17 changed files with 1825 additions and 1682 deletions

View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: INSTALL,v 1.118 2007/03/11 00:06:53 tom Exp $
-- $Id: INSTALL,v 1.119 2007/07/28 19:56:35 tom Exp $
---------------------------------------------------------------------
How to install Ncurses/Terminfo on your system
---------------------------------------------------------------------
@ -304,6 +304,11 @@ SUMMARY OF CONFIGURE OPTIONS:
return deceptive results, so you may have to override the configure
script. Or you may be building tic for a smaller machine.
--disable-big-strings
Disable compile-time optimization of predefined tables which puts
all of their strings into a very long string, to reduce relocation
overhead.
--disable-database
Use only built-in data. The ncurses libraries normally read terminfo
and termcap data from disk. You can configure ncurses to have a

View File

@ -812,6 +812,7 @@
./ncurses/llib-lncursesw
./ncurses/modules
./ncurses/tinfo/MKcaptab.awk
./ncurses/tinfo/MKcaptab.sh
./ncurses/tinfo/MKfallback.sh
./ncurses/tinfo/MKkeys_list.sh
./ncurses/tinfo/MKnames.awk
@ -1002,8 +1003,6 @@
./test/test.priv.h
./test/test_get_wstr.c
./test/test_getstr.c
./test/test_getstr.c
./test/test_instr.c
./test/test_instr.c
./test/test_inwstr.c
./test/testaddch.c

13
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: NEWS,v 1.1147 2007/07/21 22:28:54 tom Exp $
-- $Id: NEWS,v 1.1148 2007/07/28 22:19:17 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,17 @@ 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.
20070728
+ make _nc_capalias_table and _nc_infoalias_table private, accessed via
_nc_get_alias_table() since they are used only by parse_entry.c
+ make _nc_key_names private since it is used only by lib_keyname.c
+ add --disable-big-strings configure option to control whether
unctrl.c is generated using the big-string optimization - which may
use strings longer than supported by a given compiler.
+ reduce relocation tables for tic, infocmp by changing type of
internal hash tables to short, and make those private symbols.
+ eliminate large fixed arrays from progs/infocmp.c
20070721
+ change winnstr() to stop at the end of the line (cf: 970315).
+ add test/test_get_wstr.c

2938
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -28,14 +28,14 @@ dnl***************************************************************************
dnl
dnl Author: Thomas E. Dickey 1995-on
dnl
dnl $Id: configure.in,v 1.421 2007/07/14 15:45:08 tom Exp $
dnl $Id: configure.in,v 1.422 2007/07/28 18:23:55 tom Exp $
dnl Process this file with autoconf to produce a configure script.
dnl
dnl See http://invisible-island.net/autoconf/ for additional information.
dnl
dnl ---------------------------------------------------------------------------
AC_PREREQ(2.13.20020210)
AC_REVISION($Revision: 1.421 $)
AC_REVISION($Revision: 1.422 $)
AC_INIT(ncurses/base/lib_initscr.c)
AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
@ -488,6 +488,19 @@ int main() {
AC_MSG_RESULT($with_big_core)
test "$with_big_core" = "yes" && AC_DEFINE(HAVE_BIG_CORE)
### ISO C only guarantees 512-char strings, we have tables which load faster
### when constructed using "big" strings.
AC_MSG_CHECKING(if big-strings option selected)
AC_ARG_ENABLE(big-strings,
[ --disable-big-strings assume compiler has only standard-size strings],
[with_big_strings=no],
[with_big_strings=yes])
AC_MSG_RESULT($with_big_strings)
USE_BIG_STRINGS=0
test "$with_big_strings" = "yes" && USE_BIG_STRINGS=1
AC_SUBST(USE_BIG_STRINGS)
### use option --enable-termcap to compile in the termcap fallback support
AC_MSG_CHECKING(if you want termcap-fallback support)
AC_ARG_ENABLE(termcap,

View File

@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: dist.mk,v 1.603 2007/07/21 17:15:56 tom Exp $
# $Id: dist.mk,v 1.604 2007/07/28 17:07:07 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 = 6
NCURSES_PATCH = 20070721
NCURSES_PATCH = 20070728
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -33,7 +33,7 @@
****************************************************************************/
/*
* $Id: tic.h,v 1.58 2007/04/29 22:56:15 tom Exp $
* $Id: tic.h,v 1.61 2007/07/28 22:20:07 tom Exp $
* tic.h - Global variables and structures for the terminfo
* compiler.
*/
@ -163,16 +163,6 @@ struct token
extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token;
/*
* List of keynames with their corresponding code.
*/
struct kn {
int offset;
int code;
};
extern NCURSES_EXPORT_VAR(const struct kn) _nc_key_names[];
/*
* Offsets to string capabilities, with the corresponding functionkey
* codes.
@ -214,14 +204,12 @@ struct alias
const char *source;
};
extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_info_hash_table[];
extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_cap_hash_table[];
extern NCURSES_EXPORT_VAR(const struct alias) _nc_capalias_table[];
extern NCURSES_EXPORT_VAR(const struct alias) _nc_infoalias_table[];
extern NCURSES_EXPORT_VAR(const short) _nc_info_hash_table[];
extern NCURSES_EXPORT_VAR(const short) _nc_cap_hash_table[];
extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
extern NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool);
extern NCURSES_EXPORT(const short *) _nc_get_hash_table (bool);
extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
#define NOTFOUND ((struct name_table_entry *) 0)
@ -259,7 +247,7 @@ extern NCURSES_EXPORT(char *) _nc_rootname (char *);
/* comp_hash.c: name lookup */
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
(const char *, const struct name_table_entry *const *);
(const char *, const short *);
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
(const char *, int, const struct name_table_entry *);

View File

@ -1,4 +1,4 @@
# $Id: Makefile.in,v 1.108 2007/07/14 15:00:07 tom Exp $
# $Id: Makefile.in,v 1.110 2007/07/28 20:24:39 tom Exp $
##############################################################################
# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# #
@ -137,6 +137,7 @@ LINT_LIBS = -lncurses @LIBS@
FALLBACK_LIST = @FALLBACK_LIST@
USE_BIG_STRINGS = @USE_BIG_STRINGS@
TERMINFO_CAPS = $(top_srcdir)/include/@TERMINFO_CAPS@
AUTO_SRC = \
@ -210,14 +211,15 @@ make_hash$(BUILD_EXEEXT) : \
./comp_captab.c: \
make_hash$(BUILD_EXEEXT) \
../include/hashsize.h \
$(tinfo)/MKcaptab.sh \
$(tinfo)/MKcaptab.awk
sh $(tinfo)/MKcaptab.awk $(AWK) $(srcdir)/../include/@TERMINFO_CAPS@ > $@
sh $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@
./lib_keyname.c: keys.list $(base)/MKkeyname.awk
$(AWK) -f $(base)/MKkeyname.awk keys.list > $@
$(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@
names-stamp: $(tinfo)/MKnames.awk
$(AWK) -f $(tinfo)/MKnames.awk $(srcdir)/../include/@TERMINFO_CAPS@
$(AWK) -f $(tinfo)/MKnames.awk bigstrings=$(USE_BIG_STRINGS) $(srcdir)/../include/@TERMINFO_CAPS@
cat namehdr boolnames boolfnames numnames numfnames strnames strfnames nameftr >names.c
cat namehdr boolcodes numcodes strcodes codeftr >codes.c
-rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames numfnames numcodes strnames strfnames strcodes
@ -230,7 +232,7 @@ names-stamp: $(tinfo)/MKnames.awk
@echo made $@
./unctrl.c: $(base)/MKunctrl.awk
echo | $(AWK) -f $(base)/MKunctrl.awk >$@
echo | $(AWK) -f $(base)/MKunctrl.awk bigstrings=$(USE_BIG_STRINGS) >$@
tags:
ctags *.[ch] */*.[ch]

View File

@ -1,4 +1,4 @@
# $Id: MKkeyname.awk,v 1.36 2007/06/12 20:28:18 tom Exp $
# $Id: MKkeyname.awk,v 1.37 2007/07/28 21:47:21 tom Exp $
##############################################################################
# Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. #
# #
@ -33,19 +33,36 @@ BEGIN {
print "#include <tic.h>"
print "#include <term_entry.h>"
print ""
print "const struct kn _nc_key_names[] = {"
first = 1;
}
/^[^#]/ {
printf "\t{ %d, %s },\n", offset, $1
offset += length($1) + 1
names = names"\n\t\""$1"\\0\""
if (bigstrings) {
if (first) {
print "struct kn { int offset; int code; };"
print "static const struct kn _nc_key_names[] = {"
}
printf "\t{ %d, %s },\n", offset, $1
offset += length($1) + 1
names = names"\n\t\""$1"\\0\""
} else {
if (first) {
print "struct kn { const char *name; int code; };"
print "static const struct kn _nc_key_names[] = {"
}
printf "\t{ \"%s\", %s },\n", $1, $1;
}
first = 0;
}
END {
printf "\t{ -1, 0 }};\n"
print ""
print "static const char key_names[] = "names";"
if (bigstrings) {
printf "\t{ -1, 0 }};\n"
print ""
print "static const char key_names[] = "names";"
} else {
printf "\t{ 0, 0 }};\n"
}
print ""
print "#define SIZEOF_TABLE 256"
print "#define MyTable _nc_globals.keyname_table"
@ -60,12 +77,21 @@ END {
print " if (c == -1) {"
print " result = \"-1\";"
print " } else {"
print " for (i = 0; _nc_key_names[i].offset != -1; i++) {"
print " if (_nc_key_names[i].code == c) {"
print " result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;"
print " break;"
print " }"
print " }"
if (bigstrings) {
print " for (i = 0; _nc_key_names[i].offset != -1; i++) {"
print " if (_nc_key_names[i].code == c) {"
print " result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;"
print " break;"
print " }"
print " }"
} else {
print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
print " if (_nc_key_names[i].code == c) {"
print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
print " break;"
print " }"
print " }"
}
print ""
print " if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
print " if (MyTable == 0)"

View File

@ -1,4 +1,4 @@
# $Id: MKunctrl.awk,v 1.13 2007/01/06 22:52:02 tom Exp $
# $Id: MKunctrl.awk,v 1.14 2007/07/28 21:13:21 tom Exp $
##############################################################################
# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# #
@ -44,7 +44,11 @@ END {
blob=""
offset=0
printf "static const short unctrl_table[] = {"
if (bigstrings) {
printf "static const short unctrl_table[] = {"
} else {
printf "static const char* const unctrl_table[] = {"
}
for ( ch = 0; ch < 256; ch++ ) {
gap = ","
part=""
@ -54,34 +58,43 @@ END {
blob = blob "\""
blob = blob "\n \""
}
printf "%4d%s", offset, gap;
if (bigstrings)
printf "%4d%s", offset, gap;
if (ch < 32) {
part = sprintf ("^\\%03o\\0", ch + 64);
part = sprintf ("^\\%03o", ch + 64);
offset = offset + 3;
} else if (ch == 127) {
part = "^?\\0";
part = "^?";
offset = offset + 3;
} else if (ch >= 128 && ch < 160) {
part = sprintf("~\\%03o\\0", ch - 64);
part = sprintf("~\\%03o", ch - 64);
offset = offset + 3;
} else {
gap = gap " "
part = sprintf("\\%03o\\0", ch);
part = sprintf("\\%03o", ch);
offset = offset + 2;
}
blob = blob part
if (ch == 255)
gap = "\n"
else if (((ch + 1) % 8) != 0)
gap = gap " "
if (bigstrings) {
blob = blob part "\\0";
} else {
printf "\"%s\"%s", part, gap
}
}
print "};"
blob = blob "\"";
print ""
print "#if NCURSES_EXT_FUNCS"
blob = blob "\n#if NCURSES_EXT_FUNCS"
printf "static const short unctrl_c1[] = {"
if (bigstrings) {
blob = blob "\n#if NCURSES_EXT_FUNCS"
printf "static const short unctrl_c1[] = {"
} else {
printf "static const char* const unctrl_c1[] = {"
}
for ( ch = 128; ch < 160; ch++ ) {
gap = ","
if ((ch % 8) == 0) {
@ -90,20 +103,37 @@ END {
printf "\n "
blob = blob "\n \""
}
printf "%4d%s", offset, gap;
part = sprintf("\\%03o\\0", ch);
blob = blob part
offset = offset + 2;
if (((ch + 1) % 8) != 0)
gap = gap " "
if (bigstrings) {
printf "%4d%s", offset, gap;
part = sprintf("\\%03o\\0", ch);
blob = blob part
offset = offset + 2;
if (((ch + 1) % 8) != 0)
gap = gap " "
} else {
if (ch >= 128 && ch < 160) {
printf "\"\\%03o\"", ch
gap = gap " "
}
if (ch == 255)
gap = "\n"
else if (((ch + 1) % 8) != 0)
gap = gap " "
printf "%s", gap
}
}
print "};"
print "#endif /* NCURSES_EXT_FUNCS */"
blob = blob "\"\n#endif /* NCURSES_EXT_FUNCS */\n"
print ""
print "static const char unctrl_blob[] = "blob";"
print ""
if (bigstrings) {
print "static const char unctrl_blob[] = "blob";"
print ""
stringname = "unctrl_blob + unctrl"
} else {
stringname = "unctrl"
}
print "\tint check = ChCharOf(ch);"
print "\tconst char *result;"
print ""
@ -113,10 +143,10 @@ END {
print "\t\t && (SP->_legacy_coding > 1)"
print "\t\t && (check >= 128)"
print "\t\t && (check < 160))"
print "\t\t\tresult = unctrl_blob + unctrl_c1[check - 128];"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
print "#endif /* NCURSES_EXT_FUNCS */"
print "\t\t\tresult = unctrl_blob + unctrl_table[check];"
printf "\t\t\tresult = %s_table[check];\n", stringname;
print "\t} else {"
print "\t\tresult = 0;"
print "\t}"

View File

@ -1,4 +1,3 @@
#!/bin/sh
##############################################################################
# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. #
# #
@ -26,73 +25,27 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: MKcaptab.awk,v 1.13 2006/04/22 21:46:17 tom Exp $
AWK=${1-awk}
DATA=${2-../include/Caps}
cat <<'EOF'
/*
* comp_captab.c -- The names of the capabilities indexed via a hash
* table for the compiler.
*
*/
#include <ncurses_cfg.h>
#include <curses.priv.h>
#include <tic.h>
#include <term.h>
EOF
./make_hash 1 info <$DATA
./make_hash 3 cap <$DATA
cat <<'EOF'
const struct alias _nc_capalias_table[] =
{
EOF
$AWK <$DATA '
$1 == "capalias" {
if ($3 == "IGNORE")
to = "(char *)NULL";
else
to = "\"" $3 "\"";
printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
$2, to, $4, $5
}
'
cat <<'EOF'
{(char *)NULL, (char *)NULL, (char *)NULL}
};
const struct alias _nc_infoalias_table[] =
{
EOF
$AWK <$DATA '
$1 == "infoalias" {
if ($3 == "IGNORE")
to = "(char *)NULL";
else
to = "\"" $3 "\"";
printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
$2, to, $4, $5
}
'
cat <<'EOF'
{(char *)NULL, (char *)NULL, (char *)NULL}
};
NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
{
return termcap ? _nc_cap_table: _nc_info_table ;
# $Id: MKcaptab.awk,v 1.17 2007/07/28 20:43:37 tom Exp $
BEGIN {
first = 1;
}
NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool termcap)
{
return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
}
EOF
/^[^#]/ {
if (first) {
printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings;
printf "const struct alias _nc_%s_table[] =\n", tablename;
printf "{\n";
first = 0;
}
if ($1 == tablename) {
if ($3 == "IGNORE")
to = "(char *)NULL";
else
to = "\"" $3 "\"";
printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n", $2, to, $4, $5;
}
}
END {
printf "\t{(char *)NULL, (char *)NULL, (char *)NULL}\n";
printf "};\n\n";
}

72
ncurses/tinfo/MKcaptab.sh Normal file
View File

@ -0,0 +1,72 @@
#!/bin/sh
##############################################################################
# Copyright (c) 2007 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 "Software"), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, distribute #
# with modifications, sublicense, and/or sell copies of the Software, and to #
# permit persons to whom the Software is furnished to do so, subject to the #
# following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
# #
# Except as contained in this notice, the name(s) of the above copyright #
# holders shall not be used in advertising or otherwise to promote the sale, #
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: MKcaptab.sh,v 1.3 2007/07/28 22:14:57 tom Exp $
AWK=${1-awk}
OPT1=${2-0}
OPT2=${3-tinfo/MKcaptab.awk}
DATA=${4-../include/Caps}
cat <<'EOF'
/*
* comp_captab.c -- The names of the capabilities indexed via a hash
* table for the compiler.
*
*/
#include <ncurses_cfg.h>
#include <curses.priv.h>
#include <tic.h>
#include <term.h>
EOF
./make_hash 1 info <$DATA
./make_hash 3 cap <$DATA
$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias <$DATA
$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias <$DATA
cat <<'EOF'
NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
{
return termcap ? _nc_cap_table: _nc_info_table ;
}
NCURSES_EXPORT(const short *) _nc_get_hash_table (bool termcap)
{
return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
}
NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool termcap)
{
return termcap ? _nc_capalias_table: _nc_infoalias_table ;
}
EOF

View File

@ -50,7 +50,7 @@
#define DEBUG(level, params) /*nothing */
#endif
MODULE_ID("$Id: comp_hash.c,v 1.28 2005/08/20 19:58:18 tom Exp $")
MODULE_ID("$Id: comp_hash.c,v 1.29 2007/07/28 19:44:40 tom Exp $")
static int hash_function(const char *);
@ -71,21 +71,24 @@ static int hash_function(const char *);
static void
_nc_make_hash_table(struct name_table_entry *table,
struct name_table_entry **hash_table)
short *hash_table)
{
int i;
int hashvalue;
int collisions = 0;
for (i = 0; i < HASHTABSIZE; i++) {
hash_table[i] = -1;
}
for (i = 0; i < CAPTABSIZE; i++) {
hashvalue = hash_function(table[i].nte_name);
if (hash_table[hashvalue] != (struct name_table_entry *) 0)
if (hash_table[hashvalue] >= 0)
collisions++;
if (hash_table[hashvalue] != 0)
table[i].nte_link = (short) (hash_table[hashvalue] - table);
hash_table[hashvalue] = &table[i];
table[i].nte_link = hash_table[hashvalue];
hash_table[hashvalue] = i;
}
DEBUG(4, ("Hash table complete: %d collisions out of %d entries",
@ -130,18 +133,21 @@ hash_function(const char *string)
#ifndef MAIN_PROGRAM
NCURSES_EXPORT(struct name_table_entry const *)
_nc_find_entry(const char *string,
const struct name_table_entry *const *hash_table)
const short *hash_table)
{
int hashvalue;
struct name_table_entry const *ptr;
struct name_table_entry const *ptr = 0;
struct name_table_entry const *real_table;
hashvalue = hash_function(string);
if ((ptr = hash_table[hashvalue]) != 0) {
if (hash_table[hashvalue] >= 0) {
real_table = _nc_get_table(hash_table != _nc_get_hash_table(FALSE));
ptr = real_table + hash_table[hashvalue];
while (strcmp(ptr->nte_name, string) != 0) {
if (ptr->nte_link < 0)
return 0;
ptr = ptr->nte_link + hash_table[HASHTABSIZE];
ptr = real_table + (ptr->nte_link + hash_table[HASHTABSIZE]);
}
}
@ -231,8 +237,7 @@ main(int argc, char **argv)
{
struct name_table_entry *name_table = typeCalloc(struct
name_table_entry, CAPTABSIZE);
struct name_table_entry **hash_table = typeCalloc(struct name_table_entry
*, HASHTABSIZE);
short *hash_table = typeCalloc(short, HASHTABSIZE);
const char *root_name = "";
int column = 0;
int n;
@ -303,21 +308,14 @@ main(int argc, char **argv)
}
printf("};\n\n");
printf("const struct name_table_entry * const _nc_%s_hash_table[%d] =\n",
printf("const short _nc_%s_hash_table[%d] =\n",
root_name,
HASHTABSIZE + 1);
printf("{\n");
for (n = 0; n < HASHTABSIZE; n++) {
if (hash_table[n] != 0) {
sprintf(buffer, "_nc_%s_table + %3ld",
root_name,
(long) (hash_table[n] - name_table));
} else {
strcpy(buffer, "0");
}
printf("\t%s,\n", buffer);
printf("\t%3d,\n", hash_table[n]);
}
printf("\t_nc_%s_table\t/* base-of-table */\n", root_name);
printf("\t0\t/* base-of-table */\n");
printf("};\n\n");
printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* Copyright (c) 1998-2006,2007 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 *
@ -48,7 +48,7 @@
#include <tic.h>
#include <term_entry.h>
MODULE_ID("$Id: parse_entry.c,v 1.63 2006/06/17 17:57:50 tom Exp $")
MODULE_ID("$Id: parse_entry.c,v 1.64 2007/07/28 22:21:22 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@ -300,7 +300,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entryp->nuses != 0) {
BAD_TC_USAGE
}
for (ap = _nc_capalias_table; ap->from; ap++)
for (ap = _nc_get_alias_table(TRUE); ap->from; ap++)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s termcap extension) ignored",
@ -315,7 +315,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
break;
}
} else { /* if (_nc_syntax == SYN_TERMINFO) */
for (ap = _nc_infoalias_table; ap->from; ap++)
for (ap = _nc_get_alias_table(FALSE); ap->from; ap++)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s terminfo extension) ignored",

View File

@ -35,18 +35,18 @@
/*
* infocmp.c -- decompile an entry, or compare two entries
* written by Eric S. Raymond
* and Thomas E Dickey
*/
#include <progs.priv.h>
#include <dump_entry.h>
MODULE_ID("$Id: infocmp.c,v 1.89 2007/07/21 17:45:59 tom Exp $")
MODULE_ID("$Id: infocmp.c,v 1.91 2007/07/28 23:00:19 tom Exp $")
#define L_CURL "{"
#define R_CURL "}"
#define MAXTERMS 32 /* max # terminal arguments we can handle */
#define MAX_STRING 1024 /* maximum formatted string */
const char *_nc_progname = "infocmp";
@ -60,8 +60,7 @@ typedef char path[PATH_MAX];
*
***************************************************************************/
static char *tname[MAXTERMS]; /* terminal type names */
static ENTRY entries[MAXTERMS]; /* terminfo entries */
static ENTRY *entries; /* terminfo entries */
static int termcount; /* count of terminal entries */
static bool limited = TRUE; /* "-r" option is not set */
@ -96,6 +95,7 @@ ExitProgram(int code)
while (termcount-- > 0)
_nc_free_termtype(&entries[termcount].tterm);
_nc_leaks_dump_entry();
free(entries);
_nc_free_tic(code);
}
#endif
@ -932,7 +932,8 @@ file_comparison(int argc, char *argv[])
case C_DIFFERENCE:
if (itrace)
(void) fprintf(stderr,
"infocmp: dumping differences\n");
"%s: dumping differences\n",
_nc_progname);
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@ -940,7 +941,8 @@ file_comparison(int argc, char *argv[])
case C_COMMON:
if (itrace)
(void) fprintf(stderr,
"infocmp: dumping common capabilities\n");
"%s: dumping common capabilities\n",
_nc_progname);
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@ -948,7 +950,8 @@ file_comparison(int argc, char *argv[])
case C_NAND:
if (itrace)
(void) fprintf(stderr,
"infocmp: dumping differences\n");
"%s: dumping differences\n",
_nc_progname);
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@ -1236,7 +1239,8 @@ terminal_env(void)
if ((terminal = getenv("TERM")) == 0) {
(void) fprintf(stderr,
"infocmp: environment variable TERM not set\n");
"%s: environment variable TERM not set\n",
_nc_progname);
exit(EXIT_FAILURE);
}
return terminal;
@ -1251,10 +1255,13 @@ terminal_env(void)
int
main(int argc, char *argv[])
{
char *firstdir, *restdir;
/* Avoid "local data >32k" error with mwcc */
/* Also avoid overflowing smaller stacks on systems like AmigaOS */
path *tfile = (path *) malloc(sizeof(path) * MAXTERMS);
path *tfile = 0;
char **tname = 0;
int maxterms;
char *firstdir, *restdir;
int c, i, len;
bool formatted = FALSE;
bool filecompare = FALSE;
@ -1269,6 +1276,8 @@ main(int argc, char *argv[])
use_extended_names(FALSE);
#endif
_nc_progname = _nc_rootname(argv[0]);
while ((c = getopt(argc,
argv,
"1A:aB:CcdEeFfGgIiLlnpqR:rs:TtUuVv:w:x")) != -1) {
@ -1386,7 +1395,8 @@ main(int argc, char *argv[])
sortmode = S_TERMCAP;
else {
(void) fprintf(stderr,
"infocmp: unknown sort mode\n");
"%s: unknown sort mode\n",
_nc_progname);
ExitProgram(EXIT_FAILURE);
}
break;
@ -1434,6 +1444,18 @@ main(int argc, char *argv[])
}
}
maxterms = (argc + 1 - optind);
tfile = typeMalloc(path, maxterms);
tname = typeCalloc(char *, maxterms);
entries = typeCalloc(ENTRY, maxterms);
if (tfile == 0
|| tname == 0
|| entries == 0) {
fprintf(stderr, "%s: not enough memory\n", _nc_progname);
ExitProgram(EXIT_FAILURE);
}
/* by default, sort by terminfo name */
if (sortmode == S_DEFAULT)
sortmode = S_TERMINFO;
@ -1457,53 +1479,51 @@ main(int argc, char *argv[])
/* grab the entries */
termcount = 0;
for (; optind < argc; optind++) {
if (termcount >= MAXTERMS) {
(void) fprintf(stderr,
"infocmp: too many terminal type arguments\n");
ExitProgram(EXIT_FAILURE);
} else {
const char *directory = termcount ? restdir : firstdir;
int status;
const char *directory = termcount ? restdir : firstdir;
int status;
tname[termcount] = argv[optind];
tname[termcount] = argv[optind];
if (directory) {
if (directory) {
#if USE_DATABASE
(void) sprintf(tfile[termcount], "%s/%c/%s",
directory,
*argv[optind], argv[optind]);
if (itrace)
(void) fprintf(stderr,
"infocmp: reading entry %s from file %s\n",
argv[optind], tfile[termcount]);
status = _nc_read_file_entry(tfile[termcount],
&entries[termcount].tterm);
#else
(void) fprintf(stderr, "terminfo files not supported\n");
ExitProgram(EXIT_FAILURE);
#endif
} else {
if (itrace)
(void) fprintf(stderr,
"infocmp: reading entry %s from database\n",
tname[termcount]);
status = _nc_read_entry(tname[termcount],
tfile[termcount],
&entries[termcount].tterm);
directory = TERMINFO; /* for error message */
}
if (status <= 0) {
(void) sprintf(tfile[termcount], "%s/%c/%s",
directory,
*argv[optind], argv[optind]);
if (itrace)
(void) fprintf(stderr,
"infocmp: couldn't open terminfo file %s.\n",
tfile[termcount]);
ExitProgram(EXIT_FAILURE);
}
repair_acsc(&entries[termcount].tterm);
termcount++;
"%s: reading entry %s from file %s\n",
_nc_progname,
argv[optind], tfile[termcount]);
status = _nc_read_file_entry(tfile[termcount],
&entries[termcount].tterm);
#else
(void) fprintf(stderr, "%s: terminfo files not supported\n",
_nc_progname);
ExitProgram(EXIT_FAILURE);
#endif
} else {
if (itrace)
(void) fprintf(stderr,
"%s: reading entry %s from database\n",
_nc_progname,
tname[termcount]);
status = _nc_read_entry(tname[termcount],
tfile[termcount],
&entries[termcount].tterm);
directory = TERMINFO; /* for error message */
}
if (status <= 0) {
(void) fprintf(stderr,
"%s: couldn't open terminfo file %s.\n",
_nc_progname,
tfile[termcount]);
ExitProgram(EXIT_FAILURE);
}
repair_acsc(&entries[termcount].tterm);
termcount++;
}
#if NCURSES_XNAMES
@ -1541,7 +1561,8 @@ main(int argc, char *argv[])
case C_DEFAULT:
if (itrace)
(void) fprintf(stderr,
"infocmp: about to dump %s\n",
"%s: about to dump %s\n",
_nc_progname,
tname[0]);
(void) printf("#\tReconstructed via infocmp from file: %s\n",
tfile[0]);
@ -1552,12 +1573,12 @@ main(int argc, char *argv[])
NULL);
len = show_entry();
if (itrace)
(void) fprintf(stderr, "infocmp: length %d\n", len);
(void) fprintf(stderr, "%s: length %d\n", _nc_progname, len);
break;
case C_DIFFERENCE:
if (itrace)
(void) fprintf(stderr, "infocmp: dumping differences\n");
(void) fprintf(stderr, "%s: dumping differences\n", _nc_progname);
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@ -1565,7 +1586,8 @@ main(int argc, char *argv[])
case C_COMMON:
if (itrace)
(void) fprintf(stderr,
"infocmp: dumping common capabilities\n");
"%s: dumping common capabilities\n",
_nc_progname);
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
@ -1573,14 +1595,15 @@ main(int argc, char *argv[])
case C_NAND:
if (itrace)
(void) fprintf(stderr,
"infocmp: dumping differences\n");
"%s: dumping differences\n",
_nc_progname);
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
compare_entry(compare_predicate, &entries->tterm, quiet);
break;
case C_USEALL:
if (itrace)
(void) fprintf(stderr, "infocmp: dumping use entry\n");
(void) fprintf(stderr, "%s: dumping use entry\n", _nc_progname);
dump_entry(&entries[0].tterm,
suppress_untranslatable,
limited,
@ -1591,7 +1614,7 @@ main(int argc, char *argv[])
|| outform == F_TCONVERR));
len = show_entry();
if (itrace)
(void) fprintf(stderr, "infocmp: length %d\n", len);
(void) fprintf(stderr, "%s: length %d\n", _nc_progname, len);
break;
}
}
@ -1605,7 +1628,10 @@ main(int argc, char *argv[])
else
file_comparison(argc - optind, argv + optind);
#if NO_LEAKS
free(tfile);
free(tname);
#endif
ExitProgram(EXIT_SUCCESS);
}

View File

@ -26,7 +26,7 @@
* authorization. *
****************************************************************************/
/*
* $Id: test_get_wstr.c,v 1.3 2007/07/21 22:47:21 tom Exp $
* $Id: test_get_wstr.c,v 1.4 2007/07/28 19:46:34 tom Exp $
*
* Author: Thomas E Dickey
*
@ -91,7 +91,7 @@ MovePrompt(WINDOW *txtwin, int limit, int y, int x)
static int
ShowFlavor(WINDOW *strwin, WINDOW *txtwin, Flavors flavor, int limit)
{
char *name = "?";
const char *name = "?";
bool limited = FALSE;
bool wins = (txtwin != stdscr);
int result;

View File

@ -26,7 +26,7 @@
* authorization. *
****************************************************************************/
/*
* $Id: test_getstr.c,v 1.5 2007/07/21 22:22:55 tom Exp $
* $Id: test_getstr.c,v 1.6 2007/07/28 19:46:43 tom Exp $
*
* Author: Thomas E Dickey
*
@ -89,7 +89,7 @@ MovePrompt(WINDOW *txtwin, int limit, int y, int x)
static int
ShowFlavor(WINDOW *strwin, WINDOW *txtwin, Flavors flavor, int limit)
{
char *name = "?";
const char *name = "?";
bool limited = FALSE;
bool wins = (txtwin != stdscr);
int result;