summaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo')
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKcaptab.awk134
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKcaptab.sh149
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKcodes.awk161
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKnames.awk226
-rw-r--r--contrib/ncurses/ncurses/tinfo/access.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/add_tries.c39
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_error.c34
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_hash.c111
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_parse.c96
-rw-r--r--contrib/ncurses/ncurses/tinfo/db_iterator.c52
-rw-r--r--contrib/ncurses/ncurses/tinfo/entries.c144
-rw-r--r--contrib/ncurses/ncurses/tinfo/home_terminfo.c21
-rw-r--r--contrib/ncurses/ncurses/tinfo/init_keytry.c16
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_acs.c28
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_baudrate.c27
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_data.c148
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_options.c4
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c8
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_setup.c112
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c60
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tparm.c153
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tputs.c17
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ttyflags.c80
-rw-r--r--contrib/ncurses/ncurses/tinfo/make_keys.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/name_match.c24
-rw-r--r--contrib/ncurses/ncurses/tinfo/parse_entry.c20
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/setbuf.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/strings.c6
-rw-r--r--contrib/ncurses/ncurses/tinfo/trim_sgr0.c10
-rw-r--r--contrib/ncurses/ncurses/tinfo/use_screen.c60
-rw-r--r--contrib/ncurses/ncurses/tinfo/write_entry.c22
32 files changed, 1352 insertions, 638 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/MKcaptab.awk b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
index 57087b820e3b..56d3d17754d1 100644
--- a/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
+++ b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
@@ -1,6 +1,5 @@
-#!/bin/sh
##############################################################################
-# Copyright (c) 1998-2000,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 "Software"), #
@@ -26,73 +25,70 @@
# 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
+# $Id: MKcaptab.awk,v 1.20 2007/08/12 00:26:15 tom Exp $
+function add_string(text) {
+ if (text != "IGNORE") {
+ offsets[num_strings] = offset;
+ offset = offset + length(text) + 1;
+ printf "%s\\0", text;
+ } else {
+ offsets[num_strings] = -1;
+ }
+ num_strings = num_strings + 1;
+ if ((num_strings % 3) == 0) {
+ printf "\\\n";
+ }
+ return offsets[num_strings - 1];
+}
+BEGIN {
+ first = 1;
+ num_aliases = 0;
+ num_strings = 0;
+ offset = 0;
+}
-$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
+/^[^#]/ {
+ if (first) {
+ printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings;
+ print ""
+ if (bigstrings) {
+ printf "static struct alias *_nc_%s_table = 0;\n", tablename;
+ print "";
+ printf "static const char %s_text[] = \"\\\n", tablename;
+ } else {
+ printf "static const struct alias _nc_%s_table[] =\n", tablename;
+ printf "{\n";
}
-'
-
-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
+ first = 0;
+ }
+ if ($1 == tablename) {
+ if ($3 == "IGNORE") {
+ to = "(char *)NULL";
+ } else {
+ to = "\"" $3 "\"";
}
-'
-
-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 ;
-}
-
-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 (bigstrings) {
+ c1 = add_string($2);
+ c2 = add_string($3);
+ c3 = add_string($4);
+ aliases[num_aliases] = sprintf("\t{%5d, %5d, %5d},\t /* %s */", c1, c2, c3, $5);
+ num_aliases = num_aliases + 1;
+ } else {
+ printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n", $2, to, $4, $5;
+ }
+ }
+ }
+END {
+ if (bigstrings) {
+ printf "\";\n\n";
+ printf "static const alias_table_data %s_data[] = {\n", tablename;
+ for (n = 0; n < num_aliases; ++n) {
+ printf "%s\n", aliases[n];
+ }
+ printf "};\n\n";
+ } else {
+ printf "\t{(char *)NULL, (char *)NULL, (char *)NULL}\n";
+ printf "};\n\n";
+ }
+ }
+# vile:sw=4:
diff --git a/contrib/ncurses/ncurses/tinfo/MKcaptab.sh b/contrib/ncurses/ncurses/tinfo/MKcaptab.sh
new file mode 100644
index 000000000000..98c04e884309
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/MKcaptab.sh
@@ -0,0 +1,149 @@
+#!/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.8 2007/08/12 13:13:51 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 <curses.priv.h>
+#include <tic.h>
+#include <hashsize.h>
+
+EOF
+
+./make_hash 1 info $OPT1 <$DATA
+./make_hash 3 cap $OPT1 <$DATA
+
+$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias <$DATA
+
+$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias <$DATA
+
+cat <<EOF
+
+#if $OPT1
+static void
+next_string(const char *strings, unsigned *offset)
+{
+ *offset += strlen(strings + *offset) + 1;
+}
+
+static const struct name_table_entry *
+_nc_build_names(struct name_table_entry **actual,
+ const name_table_data *source,
+ const char *strings)
+{
+ if (*actual == 0) {
+ *actual = typeCalloc(struct name_table_entry, CAPTABSIZE);
+ if (*actual != 0) {
+ unsigned n;
+ unsigned len = 0;
+ for (n = 0; n < CAPTABSIZE; ++n) {
+ (*actual)[n].nte_name = strings + len;
+ (*actual)[n].nte_type = source[n].nte_type;
+ (*actual)[n].nte_index = source[n].nte_index;
+ (*actual)[n].nte_link = source[n].nte_link;
+ next_string(strings, &len);
+ }
+ }
+ }
+ return *actual;
+}
+
+#define add_alias(field) \\
+ if (source[n].field >= 0) { \\
+ (*actual)[n].field = strings + source[n].field; \\
+ }
+
+static const struct alias *
+_nc_build_alias(struct alias **actual,
+ const alias_table_data *source,
+ const char *strings,
+ unsigned tablesize)
+{
+ if (*actual == 0) {
+ *actual = typeCalloc(struct alias, tablesize + 1);
+ if (*actual != 0) {
+ unsigned n;
+ for (n = 0; n < tablesize; ++n) {
+ add_alias(from);
+ add_alias(to);
+ add_alias(source);
+ }
+ }
+ }
+ return *actual;
+}
+
+#define build_names(root) _nc_build_names(&_nc_##root##_table, \\
+ root##_names_data, \\
+ root##_names_text)
+#define build_alias(root) _nc_build_alias(&_nc_##root##alias_table, \\
+ root##alias_data, \\
+ root##alias_text, \\
+ SIZEOF(root##alias_data))
+#else
+#define build_names(root) _nc_ ## root ## _table
+#define build_alias(root) _nc_ ## root ## alias_table
+#endif
+
+NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
+{
+ return termcap ? build_names(cap) : build_names(info) ;
+}
+
+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 ? build_alias(cap) : build_alias(info) ;
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void) _nc_comp_captab_leaks(void)
+{
+#if $OPT1
+ FreeIfNeeded(_nc_cap_table);
+ FreeIfNeeded(_nc_info_table);
+ FreeIfNeeded(_nc_capalias_table);
+ FreeIfNeeded(_nc_infoalias_table);
+#endif
+}
+#endif /* NO_LEAKS */
+EOF
diff --git a/contrib/ncurses/ncurses/tinfo/MKcodes.awk b/contrib/ncurses/ncurses/tinfo/MKcodes.awk
new file mode 100644
index 000000000000..db8ad5541841
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/MKcodes.awk
@@ -0,0 +1,161 @@
+##############################################################################
+# 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 "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: MKcodes.awk,v 1.4 2007/11/03 20:24:15 tom Exp $
+function large_item(value) {
+ result = sprintf("%d,", offset);
+ offset = offset + length(value) + 1;
+ offcol = offcol + length(result) + 2;
+ if (offcol > 70) {
+ result = result "\n";
+ offcol = 0;
+ } else {
+ result = result " ";
+ }
+ bigstr = bigstr sprintf("\"%s\\0\" ", value);
+ bigcol = bigcol + length(value) + 5;
+ if (bigcol > 70) {
+ bigstr = bigstr "\\\n";
+ bigcol = 0;
+ }
+ return result;
+}
+
+function small_item(value) {
+ return sprintf("\t\t\"%s\",\n", value);
+}
+
+function print_strings(name,value) {
+ printf "DCL(%s) = {\n", name
+ print value
+ print "\t\t(NCURSES_CONST char *)0,"
+ print "};"
+ print ""
+}
+
+function print_offsets(name,value) {
+ printf "static const short _nc_offset_%s[] = {\n", name
+ printf "%s", value
+ print "};"
+ print ""
+ printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ print ""
+}
+
+BEGIN {
+ print "/* This file was generated by MKcodes.awk */"
+ print ""
+ print "#include <curses.priv.h>"
+ print ""
+ print "#define IT NCURSES_CONST char * const"
+ print ""
+ offset = 0;
+ offcol = 0;
+ bigcol = 0;
+ }
+
+$1 ~ /^#/ {next;}
+
+$1 == "SKIPWARN" {next;}
+
+$3 == "bool" {
+ small_boolcodes = small_boolcodes small_item($4);
+ large_boolcodes = large_boolcodes large_item($4);
+ }
+
+$3 == "num" {
+ small_numcodes = small_numcodes small_item($4);
+ large_numcodes = large_numcodes large_item($4);
+ }
+
+$3 == "str" {
+ small_strcodes = small_strcodes small_item($4);
+ large_strcodes = large_strcodes large_item($4);
+ }
+
+END {
+ print ""
+ print "#if BROKEN_LINKER || USE_REENTRANT"
+ print ""
+ print "#include <term.h>"
+ print ""
+ if (bigstrings) {
+ printf "static const char _nc_code_blob[] = \n"
+ printf "%s;\n", bigstr;
+ print_offsets("boolcodes", large_boolcodes);
+ print_offsets("numcodes", large_numcodes);
+ print_offsets("strcodes", large_strcodes);
+ print ""
+ print "static IT *"
+ print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
+ print "{"
+ print " if (*value == 0) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " unsigned n;"
+ print " for (n = 0; n < size; ++n) {"
+ print " (*value)[n] = _nc_code_blob + offsets[n];"
+ print " }"
+ print " }"
+ print " }"
+ print " return *value;"
+ print "}"
+ print ""
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ } else {
+ print "#define DCL(it) static IT data##it[]"
+ print ""
+ print_strings("boolcodes", small_boolcodes);
+ print_strings("numcodes", small_numcodes);
+ print_strings("strcodes", small_strcodes);
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
+ }
+ print ""
+ print "FIX(boolcodes)"
+ print "FIX(numcodes)"
+ print "FIX(strcodes)"
+ print ""
+ print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
+ print ""
+ print "NCURSES_EXPORT(void)"
+ print "_nc_codes_leaks(void)"
+ print "{"
+ if (bigstrings) {
+ print "FREE_FIX(boolcodes)"
+ print "FREE_FIX(numcodes)"
+ print "FREE_FIX(strcodes)"
+ }
+ print "}"
+ print "#else"
+ print ""
+ print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
+ print ""
+ print_strings("boolcodes", small_boolcodes);
+ print_strings("numcodes", small_numcodes);
+ print_strings("strcodes", small_strcodes);
+ print ""
+ print "#endif /* BROKEN_LINKER */"
+ }
diff --git a/contrib/ncurses/ncurses/tinfo/MKnames.awk b/contrib/ncurses/ncurses/tinfo/MKnames.awk
index 6be00ad4488d..93e682c2d28d 100644
--- a/contrib/ncurses/ncurses/tinfo/MKnames.awk
+++ b/contrib/ncurses/ncurses/tinfo/MKnames.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. #
+# 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"), #
@@ -25,101 +25,159 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKnames.awk,v 1.12 2006/04/22 21:46:17 tom Exp $
-BEGIN {
- print "/* This file was generated by MKnames.awk */" > "namehdr"
- print "" > "namehdr"
- print "#include <curses.priv.h>" > "namehdr"
- print "" > "namehdr"
- print "#define IT NCURSES_CONST char * const" > "namehdr"
- print "" > "namehdr"
- print "#if BROKEN_LINKER" > "namehdr"
- print "#include <term.h>" > "namehdr"
- print "#define DCL(it) static IT data##it[]" > "namehdr"
- print "#else" > "namehdr"
- print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]" > "namehdr"
- print "#endif" > "namehdr"
- print "" > "namehdr"
- print "/*" > "boolnames"
- print " * names.c - Arrays of capability names and codes" > "boolnames"
- print " *" > "boolnames"
- print " */" > "boolnames"
- print "" > "boolnames"
- print "DCL(boolnames) = {" > "boolnames"
- print "DCL(boolfnames) = {" > "boolfnames"
- print "DCL(boolcodes) = {" > "boolcodes"
- print "DCL(numnames) = {" > "numnames"
- print "DCL(numfnames) = {" > "numfnames"
- print "DCL(numcodes) = {" > "numcodes"
- print "DCL(strnames) = {" > "strnames"
- print "DCL(strfnames) = {" > "strfnames"
- print "DCL(strcodes) = {" > "strcodes"
- }
+# $Id: MKnames.awk,v 1.18 2007/11/03 20:24:15 tom Exp $
+function large_item(value) {
+ result = sprintf("%d,", offset);
+ offset = offset + length(value) + 1;
+ offcol = offcol + length(result) + 2;
+ if (offcol > 70) {
+ result = result "\n";
+ offcol = 0;
+ } else {
+ result = result " ";
+ }
+ bigstr = bigstr sprintf("\"%s\\0\" ", value);
+ bigcol = bigcol + length(value) + 5;
+ if (bigcol > 70) {
+ bigstr = bigstr "\\\n";
+ bigcol = 0;
+ }
+ return result;
+}
+
+function small_item(value) {
+ return sprintf("\t\t\"%s\",\n", value);
+}
+
+function print_strings(name,value) {
+ printf "DCL(%s) = {\n", name
+ print value
+ print "\t\t(NCURSES_CONST char *)0,"
+ print "};"
+ print ""
+}
+
+function print_offsets(name,value) {
+ printf "static const short _nc_offset_%s[] = {\n", name
+ printf "%s", value
+ print "};"
+ print ""
+ printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ print ""
+}
+
+BEGIN {
+ print "/* This file was generated by MKnames.awk */"
+ print ""
+ print "#include <curses.priv.h>"
+ print ""
+ print "#define IT NCURSES_CONST char * const"
+ print ""
+ offset = 0;
+ offcol = 0;
+ bigcol = 0;
+ }
$1 ~ /^#/ {next;}
$1 == "SKIPWARN" {next;}
$3 == "bool" {
- printf "\t\t\"%s\",\n", $2 > "boolnames"
- printf "\t\t\"%s\",\n", $1 > "boolfnames"
- printf "\t\t\"%s\",\n", $4 > "boolcodes"
+ small_boolnames = small_boolnames small_item($2);
+ large_boolnames = large_boolnames large_item($2);
+ small_boolfnames = small_boolfnames small_item($1);
+ large_boolfnames = large_boolfnames large_item($1);
}
$3 == "num" {
- printf "\t\t\"%s\",\n", $2 > "numnames"
- printf "\t\t\"%s\",\n", $1 > "numfnames"
- printf "\t\t\"%s\",\n", $4 > "numcodes"
+ small_numnames = small_numnames small_item($2);
+ large_numnames = large_numnames large_item($2);
+ small_numfnames = small_numfnames small_item($1);
+ large_numfnames = large_numfnames large_item($1);
}
$3 == "str" {
- printf "\t\t\"%s\",\n", $2 > "strnames"
- printf "\t\t\"%s\",\n", $1 > "strfnames"
- printf "\t\t\"%s\",\n", $4 > "strcodes"
+ small_strnames = small_strnames small_item($2);
+ large_strnames = large_strnames large_item($2);
+ small_strfnames = small_strfnames small_item($1);
+ large_strfnames = large_strfnames large_item($1);
}
-END {
- print "\t\t(NCURSES_CONST char *)0," > "boolnames"
- print "};" > "boolnames"
- print "" > "boolnames"
- print "\t\t(NCURSES_CONST char *)0," > "boolfnames"
- print "};" > "boolfnames"
- print "" > "boolfnames"
- print "\t\t(NCURSES_CONST char *)0," > "boolcodes"
- print "};" > "boolcodes"
- print "" > "boolcodes"
- print "\t\t(NCURSES_CONST char *)0," > "numnames"
- print "};" > "numnames"
- print "" > "numnames"
- print "\t\t(NCURSES_CONST char *)0," > "numfnames"
- print "};" > "numfnames"
- print "" > "numfnames"
- print "\t\t(NCURSES_CONST char *)0," > "numcodes"
- print "};" > "numcodes"
- print "" > "numcodes"
- print "\t\t(NCURSES_CONST char *)0," > "strnames"
- print "};" > "strnames"
- print "" > "strnames"
- print "\t\t(NCURSES_CONST char *)0," > "strfnames"
- print "};" > "strfnames"
- print "" > "strfnames"
- print "\t\t(NCURSES_CONST char *)0," > "strcodes"
- print "};" > "strcodes"
- print "" > "strcodes"
- print "#if BROKEN_LINKER" > "nameftr"
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "nameftr"
- print "FIX(boolnames)" > "nameftr"
- print "FIX(boolfnames)" > "nameftr"
- print "FIX(numnames)" > "nameftr"
- print "FIX(numfnames)" > "nameftr"
- print "FIX(strnames)" > "nameftr"
- print "FIX(strfnames)" > "nameftr"
- print "#endif /* BROKEN_LINKER */" > "nameftr"
- print "" > "codeftr"
- print "#if BROKEN_LINKER" > "codeftr"
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "codeftr"
- print "FIX(boolcodes)" > "codeftr"
- print "FIX(numcodes)" > "codeftr"
- print "FIX(strcodes)" > "codeftr"
- print "#endif /* BROKEN_LINKER */" > "codeftr"
+END {
+ print ""
+ print "#if BROKEN_LINKER || USE_REENTRANT"
+ print ""
+ print "#include <term.h>"
+ print ""
+ if (bigstrings) {
+ printf "static const char _nc_name_blob[] = \n"
+ printf "%s;\n", bigstr;
+ print_offsets("boolfnames", large_boolfnames);
+ print_offsets("boolnames", large_boolnames);
+ print_offsets("numfnames", large_numfnames);
+ print_offsets("numnames", large_numnames);
+ print_offsets("strfnames", large_strfnames);
+ print_offsets("strnames", large_strnames);
+ print ""
+ print "static IT *"
+ print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
+ print "{"
+ print " if (*value == 0) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " unsigned n;"
+ print " for (n = 0; n < size; ++n) {"
+ print " (*value)[n] = _nc_name_blob + offsets[n];"
+ print " }"
+ print " }"
+ print " }"
+ print " return *value;"
+ print "}"
+ print ""
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ } else {
+ print "#define DCL(it) static IT data##it[]"
+ print ""
+ print_strings("boolnames", small_boolnames);
+ print_strings("boolfnames", small_boolfnames);
+ print_strings("numnames", small_numnames);
+ print_strings("numfnames", small_numfnames);
+ print_strings("strnames", small_strnames);
+ print_strings("strfnames", small_strfnames);
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
+ }
+ print ""
+ print "FIX(boolnames)"
+ print "FIX(boolfnames)"
+ print "FIX(numnames)"
+ print "FIX(numfnames)"
+ print "FIX(strnames)"
+ print "FIX(strfnames)"
+ print ""
+ print ""
+ print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
+ print ""
+ print "NCURSES_EXPORT(void)"
+ print "_nc_names_leaks(void)"
+ print "{"
+ if (bigstrings) {
+ print "FREE_FIX(boolnames)"
+ print "FREE_FIX(boolfnames)"
+ print "FREE_FIX(numnames)"
+ print "FREE_FIX(numfnames)"
+ print "FREE_FIX(strnames)"
+ print "FREE_FIX(strfnames)"
}
+ print "}"
+ print "#else"
+ print ""
+ print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
+ print ""
+ print_strings("boolnames", small_boolnames);
+ print_strings("boolfnames", small_boolfnames);
+ print_strings("numnames", small_numnames);
+ print_strings("numfnames", small_numfnames);
+ print_strings("strnames", small_strnames);
+ print_strings("strfnames", small_strfnames);
+ print ""
+ print "#endif /* BROKEN_LINKER */"
+ }
diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c
index c10b7e0af556..ce8ccdac53f6 100644
--- a/contrib/ncurses/ncurses/tinfo/access.c
+++ b/contrib/ncurses/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,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 *
@@ -32,12 +32,13 @@
#include <curses.priv.h>
+#include <ctype.h>
#include <sys/stat.h>
#include <tic.h>
#include <nc_alloc.h>
-MODULE_ID("$Id: access.c,v 1.12 2006/08/05 17:18:14 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.14 2007/11/18 00:57:53 tom Exp $")
#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
@@ -45,14 +46,13 @@ NCURSES_EXPORT(char *)
_nc_rootname(char *path)
{
char *result = _nc_basename(path);
-#if !defined(MIXEDCASE_FILENAMES) || defined(PROG_EXT)
+#if !MIXEDCASE_FILENAMES || defined(PROG_EXT)
static char *temp;
char *s;
temp = strdup(result);
result = temp;
-#if !defined(MIXEDCASE_FILENAMES)
- int n;
+#if !MIXEDCASE_FILENAMES
for (s = result; *s != '\0'; ++s) {
*s = LOWERCASE(*s);
}
diff --git a/contrib/ncurses/ncurses/tinfo/add_tries.c b/contrib/ncurses/ncurses/tinfo/add_tries.c
index 46c93b8fecc7..455d142edc8e 100644
--- a/contrib/ncurses/ncurses/tinfo/add_tries.c
+++ b/contrib/ncurses/ncurses/tinfo/add_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey 1998-on *
****************************************************************************/
/*
@@ -39,20 +39,20 @@
#include <curses.priv.h>
-MODULE_ID("$Id: add_tries.c,v 1.5 2005/11/20 01:32:48 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.8 2006/12/30 23:15:26 tom Exp $")
#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
-NCURSES_EXPORT(void)
-_nc_add_to_try(struct tries **tree, const char *str, unsigned code)
+NCURSES_EXPORT(int)
+_nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
{
- static bool out_of_memory = FALSE;
- struct tries *ptr, *savedptr;
+ TRIES *ptr, *savedptr;
unsigned const char *txt = (unsigned const char *) str;
- if (txt == 0 || *txt == '\0' || out_of_memory || code == 0)
- return;
+ T((T_CALLED("_nc_add_to_try(%p, %s, %u)"), *tree, _nc_visbuf(str), code));
+ if (txt == 0 || *txt == '\0' || code == 0)
+ returnCode(ERR);
if ((*tree) != 0) {
ptr = savedptr = (*tree);
@@ -67,16 +67,15 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned code)
if (CMP_TRY(ptr->ch, cmp)) {
if (*(++txt) == '\0') {
ptr->value = code;
- return;
+ returnCode(OK);
}
if (ptr->child != 0)
ptr = ptr->child;
else
break;
} else {
- if ((ptr->sibling = typeCalloc(struct tries, 1)) == 0) {
- out_of_memory = TRUE;
- return;
+ if ((ptr->sibling = typeCalloc(TRIES, 1)) == 0) {
+ returnCode(ERR);
}
savedptr = ptr = ptr->sibling;
@@ -87,11 +86,10 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned code)
}
} /* end for (;;) */
} else { /* (*tree) == 0 :: First sequence to be added */
- savedptr = ptr = (*tree) = typeCalloc(struct tries, 1);
+ savedptr = ptr = (*tree) = typeCalloc(TRIES, 1);
if (ptr == 0) {
- out_of_memory = TRUE;
- return;
+ returnCode(ERR);
}
SET_TRY(ptr, txt);
@@ -101,19 +99,16 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned code)
/* at this point, we are adding to the try. ptr->child == 0 */
while (*txt) {
- ptr->child = typeCalloc(struct tries, 1);
+ ptr->child = typeCalloc(TRIES, 1);
ptr = ptr->child;
if (ptr == 0) {
- out_of_memory = TRUE;
-
while ((ptr = savedptr) != 0) {
savedptr = ptr->child;
free(ptr);
}
-
- return;
+ returnCode(ERR);
}
SET_TRY(ptr, txt);
@@ -121,5 +116,5 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned code)
}
ptr->value = code;
- return;
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c
index 015f34886eb1..56c362a4f7dd 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_error.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_error.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,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 *
@@ -41,36 +41,36 @@
#include <tic.h>
-MODULE_ID("$Id: comp_error.c,v 1.30 2005/11/26 15:28:47 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.31 2007/04/21 23:38:32 tom Exp $")
NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
NCURSES_EXPORT_VAR(int) _nc_curr_col = 0; /* current column # in input */
-static const char *sourcename;
-static char *termtype;
+#define SourceName _nc_globals.comp_sourcename
+#define TermType _nc_globals.comp_termtype
NCURSES_EXPORT(const char *)
_nc_get_source(void)
{
- return sourcename;
+ return SourceName;
}
NCURSES_EXPORT(void)
_nc_set_source(const char *const name)
{
- sourcename = name;
+ SourceName = name;
}
NCURSES_EXPORT(void)
_nc_set_type(const char *const name)
{
- if (termtype == 0)
- termtype = typeMalloc(char, MAX_NAME_SIZE + 1);
- if (termtype != 0) {
- termtype[0] = '\0';
+ if (TermType == 0)
+ TermType = typeMalloc(char, MAX_NAME_SIZE + 1);
+ if (TermType != 0) {
+ TermType[0] = '\0';
if (name)
- strncat(termtype, name, MAX_NAME_SIZE);
+ strncat(TermType, name, MAX_NAME_SIZE);
}
}
@@ -78,25 +78,25 @@ NCURSES_EXPORT(void)
_nc_get_type(char *name)
{
#if NO_LEAKS
- if (name == 0 && termtype != 0) {
- FreeAndNull(termtype);
+ if (name == 0 && TermType != 0) {
+ FreeAndNull(TermType);
return;
}
#endif
if (name != 0)
- strcpy(name, termtype != 0 ? termtype : "");
+ strcpy(name, TermType != 0 ? TermType : "");
}
static NCURSES_INLINE void
where_is_problem(void)
{
- fprintf(stderr, "\"%s\"", sourcename);
+ fprintf(stderr, "\"%s\"", SourceName ? SourceName : "?");
if (_nc_curr_line >= 0)
fprintf(stderr, ", line %d", _nc_curr_line);
if (_nc_curr_col >= 0)
fprintf(stderr, ", col %d", _nc_curr_col);
- if (termtype != 0 && termtype[0] != '\0')
- fprintf(stderr, ", terminal '%s'", termtype);
+ if (TermType != 0 && TermType[0] != '\0')
+ fprintf(stderr, ", terminal '%s'", TermType);
fputc(':', stderr);
fputc(' ', stderr);
}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_hash.c b/contrib/ncurses/ncurses/tinfo/comp_hash.c
index d4d9eaa62e13..8b85eee6ced8 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_hash.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,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 *
@@ -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.33 2007/08/18 21:42:25 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,10 +237,10 @@ 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 bigstring = 0;
int n;
char buffer[BUFSIZ];
@@ -248,11 +254,12 @@ main(int argc, char **argv)
/* The first argument is the column-number (starting with 0).
* The second is the root name of the tables to generate.
*/
- if (argc <= 2
+ if (argc <= 3
|| (column = atoi(argv[1])) <= 0
|| (column >= MAX_COLUMNS)
- || *(root_name = argv[2]) == 0) {
- fprintf(stderr, "usage: make_hash column root_name\n");
+ || *(root_name = argv[2]) == 0
+ || (bigstring = atoi(argv[3])) < 0) {
+ fprintf(stderr, "usage: make_hash column root_name bigstring\n");
exit(EXIT_FAILURE);
}
@@ -288,36 +295,64 @@ main(int argc, char **argv)
/*
* Write the compiled tables to standard output
*/
- printf("static struct name_table_entry const _nc_%s_table[] =\n",
- root_name);
- printf("{\n");
- for (n = 0; n < CAPTABSIZE; n++) {
- sprintf(buffer, "\"%s\"",
- name_table[n].nte_name);
- printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n",
- buffer,
- typenames[name_table[n].nte_type],
- name_table[n].nte_index,
- name_table[n].nte_link,
- n < CAPTABSIZE - 1 ? ',' : ' ');
+ if (bigstring) {
+ int len = 0;
+ int nxt;
+
+ printf("static const char %s_names_text[] = \\\n", root_name);
+ for (n = 0; n < CAPTABSIZE; n++) {
+ nxt = strlen(name_table[n].nte_name) + 5;
+ if (nxt + len > 72) {
+ printf("\\\n");
+ len = 0;
+ }
+ printf("\"%s\\0\" ", name_table[n].nte_name);
+ len += nxt;
+ }
+ printf(";\n\n");
+
+ len = 0;
+ printf("static name_table_data const %s_names_data[] =\n",
+ root_name);
+ printf("{\n");
+ for (n = 0; n < CAPTABSIZE; n++) {
+ printf("\t{ %15d,\t%10s,\t%3d, %3d }%c\n",
+ len,
+ typenames[name_table[n].nte_type],
+ name_table[n].nte_index,
+ name_table[n].nte_link,
+ n < CAPTABSIZE - 1 ? ',' : ' ');
+ len += strlen(name_table[n].nte_name) + 1;
+ }
+ printf("};\n\n");
+ printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name);
+ } else {
+
+ printf("static struct name_table_entry %s _nc_%s_table[] =\n",
+ bigstring ? "" : "const",
+ root_name);
+ printf("{\n");
+ for (n = 0; n < CAPTABSIZE; n++) {
+ sprintf(buffer, "\"%s\"",
+ name_table[n].nte_name);
+ printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n",
+ buffer,
+ typenames[name_table[n].nte_type],
+ name_table[n].nte_index,
+ name_table[n].nte_link,
+ n < CAPTABSIZE - 1 ? ',' : ' ');
+ }
+ printf("};\n\n");
}
- printf("};\n\n");
- printf("const struct name_table_entry * const _nc_%s_hash_table[%d] =\n",
+ printf("static 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",
diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c
index 667b3257f25a..aa60047b0aad 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_parse.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c
@@ -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 *
@@ -53,7 +53,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.63 2006/07/08 18:55:14 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.68 2007/11/03 20:41:46 tom Exp $")
static void sanity_check2(TERMTYPE *, bool);
NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
@@ -62,30 +62,6 @@ NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanit
static void sanity_check(TERMTYPE *);
NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
-/****************************************************************************
- *
- * Entry queue handling
- *
- ****************************************************************************/
-/*
- * The entry list is a doubly linked list with NULLs terminating the lists:
- *
- * --------- --------- ---------
- * | | | | | | offset
- * |-------| |-------| |-------|
- * | ----+-->| ----+-->| NULL | next
- * |-------| |-------| |-------|
- * | NULL |<--+---- |<--+---- | last
- * --------- --------- ---------
- * ^ ^
- * | |
- * | |
- * _nc_head _nc_tail
- */
-
-NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
-NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
-
static void
enqueue(ENTRY * ep)
/* add an entry to the in-core list */
@@ -103,51 +79,6 @@ enqueue(ENTRY * ep)
newp->last->next = newp;
}
-NCURSES_EXPORT(void)
-_nc_free_entries(ENTRY * headp)
-/* free the allocated storage consumed by list entries */
-{
- (void) headp; /* unused - _nc_head is altered here! */
-
- while (_nc_head != 0) {
- _nc_free_termtype(&(_nc_head->tterm));
- }
-}
-
-NCURSES_EXPORT(ENTRY *)
-_nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
-/* delink the allocated storage for the given list entry */
-{
- ENTRY *ep, *last;
-
- for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
- if (&(ep->tterm) == tterm) {
- if (last != 0) {
- last->next = ep->next;
- }
- if (ep == _nc_head) {
- _nc_head = ep->next;
- }
- if (ep == _nc_tail) {
- _nc_tail = last;
- }
- break;
- }
- }
- return ep;
-}
-
-NCURSES_EXPORT(void)
-_nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
-/* free the allocated storage consumed by the given list entry */
-{
- ENTRY *ep;
-
- if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
- free(ep);
- }
-}
-
static char *
force_bar(char *dst, char *src)
{
@@ -534,3 +465,26 @@ sanity_check(TERMTYPE *tp)
{
sanity_check2(tp, FALSE);
}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_leaks_tic(void)
+{
+ _nc_alloc_entry_leaks();
+ _nc_captoinfo_leaks();
+ _nc_comp_captab_leaks();
+ _nc_comp_scan_leaks();
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_names_leaks();
+ _nc_codes_leaks();
+#endif
+ _nc_tic_expand(0, FALSE, 0);
+}
+
+NCURSES_EXPORT(void)
+_nc_free_tic(int code)
+{
+ _nc_leaks_tic();
+ _nc_free_tinfo(code);
+}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/db_iterator.c b/contrib/ncurses/ncurses/tinfo/db_iterator.c
index e69aa5e18834..fdc2bb09eadc 100644
--- a/contrib/ncurses/ncurses/tinfo/db_iterator.c
+++ b/contrib/ncurses/ncurses/tinfo/db_iterator.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * Copyright (c) 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 2006 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
@@ -38,10 +38,11 @@
#include <tic.h>
-MODULE_ID("$Id: db_iterator.c,v 1.5 2006/12/16 19:06:42 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.6 2007/04/22 00:00:26 tom Exp $")
-static bool have_tic_directory = FALSE;
-static bool keep_tic_directory = FALSE;
+#define HaveTicDirectory _nc_globals.have_tic_directory
+#define KeepTicDirectory _nc_globals.keep_tic_directory
+#define TicDirectory _nc_globals.tic_directory
/*
* Record the "official" location of the terminfo directory, according to
@@ -50,19 +51,17 @@ static bool keep_tic_directory = FALSE;
NCURSES_EXPORT(const char *)
_nc_tic_dir(const char *path)
{
- static const char *result = TERMINFO;
-
- if (!keep_tic_directory) {
+ if (!KeepTicDirectory) {
if (path != 0) {
- result = path;
- have_tic_directory = TRUE;
- } else if (!have_tic_directory && use_terminfo_vars()) {
+ TicDirectory = path;
+ HaveTicDirectory = TRUE;
+ } else if (!HaveTicDirectory && use_terminfo_vars()) {
char *envp;
if ((envp = getenv("TERMINFO")) != 0)
return _nc_tic_dir(envp);
}
}
- return result;
+ return TicDirectory;
}
/*
@@ -74,16 +73,15 @@ NCURSES_EXPORT(void)
_nc_keep_tic_dir(const char *path)
{
_nc_tic_dir(path);
- keep_tic_directory = TRUE;
+ KeepTicDirectory = TRUE;
}
/*
* Process the list of :-separated directories, looking for the terminal type.
* We don't use strtok because it does not show us empty tokens.
*/
-
-static char *this_db_list = 0;
-static int size_db_list;
+#define ThisDbList _nc_globals.dbi_list
+#define ThisDbSize _nc_globals.dbi_size
/*
* Cleanup.
@@ -91,10 +89,10 @@ static int size_db_list;
NCURSES_EXPORT(void)
_nc_last_db(void)
{
- if (this_db_list != 0) {
- FreeAndNull(this_db_list);
+ if (ThisDbList != 0) {
+ FreeAndNull(ThisDbList);
}
- size_db_list = 0;
+ ThisDbSize = 0;
}
/* The TERMINFO_DIRS value, if defined by the configure script, begins with a
@@ -104,14 +102,14 @@ static const char *
next_list_item(const char *source, int *offset)
{
if (source != 0) {
- FreeIfNeeded(this_db_list);
- this_db_list = strdup(source);
- size_db_list = strlen(source);
+ FreeIfNeeded(ThisDbList);
+ ThisDbList = strdup(source);
+ ThisDbSize = strlen(source);
}
- if (this_db_list != 0 && size_db_list && *offset < size_db_list) {
+ if (ThisDbList != 0 && ThisDbSize && *offset < ThisDbSize) {
static char system_db[] = TERMINFO;
- char *result = this_db_list + *offset;
+ char *result = ThisDbList + *offset;
char *marker = strchr(result, NCURSES_PATHSEP);
/*
@@ -124,9 +122,9 @@ next_list_item(const char *source, int *offset)
marker = result + *offset;
} else {
*marker++ = 0;
- *offset = marker - this_db_list;
+ *offset = marker - ThisDbList;
}
- if (*result == 0 && result != (this_db_list + size_db_list))
+ if (*result == 0 && result != (ThisDbList + ThisDbSize))
result = system_db;
return result;
}
@@ -153,7 +151,7 @@ _nc_next_db(DBDIRS * state, int *offset)
switch (*state) {
case dbdTIC:
- if (have_tic_directory)
+ if (HaveTicDirectory)
result = _nc_tic_dir(0);
break;
#if USE_DATABASE
diff --git a/contrib/ncurses/ncurses/tinfo/entries.c b/contrib/ncurses/ncurses/tinfo/entries.c
new file mode 100644
index 000000000000..8b63f0d8965c
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/entries.c
@@ -0,0 +1,144 @@
+/****************************************************************************
+ * Copyright (c) 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 *
+ * "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. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+
+#include <tic.h>
+#include <term_entry.h>
+
+MODULE_ID("$Id: entries.c,v 1.4 2007/11/03 21:00:27 tom Exp $")
+
+/****************************************************************************
+ *
+ * Entry queue handling
+ *
+ ****************************************************************************/
+/*
+ * The entry list is a doubly linked list with NULLs terminating the lists:
+ *
+ * --------- --------- ---------
+ * | | | | | | offset
+ * |-------| |-------| |-------|
+ * | ----+-->| ----+-->| NULL | next
+ * |-------| |-------| |-------|
+ * | NULL |<--+---- |<--+---- | last
+ * --------- --------- ---------
+ * ^ ^
+ * | |
+ * | |
+ * _nc_head _nc_tail
+ */
+
+NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
+NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
+
+NCURSES_EXPORT(void)
+_nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
+/* free the allocated storage consumed by the given list entry */
+{
+ ENTRY *ep;
+
+ if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
+ free(ep);
+ }
+}
+
+NCURSES_EXPORT(void)
+_nc_free_entries(ENTRY * headp)
+/* free the allocated storage consumed by list entries */
+{
+ (void) headp; /* unused - _nc_head is altered here! */
+
+ while (_nc_head != 0) {
+ _nc_free_termtype(&(_nc_head->tterm));
+ }
+}
+
+NCURSES_EXPORT(ENTRY *)
+_nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
+/* delink the allocated storage for the given list entry */
+{
+ ENTRY *ep, *last;
+
+ for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
+ if (&(ep->tterm) == tterm) {
+ if (last != 0) {
+ last->next = ep->next;
+ }
+ if (ep == _nc_head) {
+ _nc_head = ep->next;
+ }
+ if (ep == _nc_tail) {
+ _nc_tail = last;
+ }
+ break;
+ }
+ }
+ return ep;
+}
+
+NCURSES_EXPORT(void)
+_nc_leaks_tinfo(void)
+{
+ char *s;
+
+ T((T_CALLED("_nc_free_tinfo()")));
+#if NO_LEAKS
+ _nc_free_tparm();
+ _nc_tgetent_leaks();
+#endif
+ _nc_free_entries(_nc_head);
+ _nc_get_type(0);
+ _nc_first_name(0);
+#if NO_LEAKS
+ _nc_keyname_leaks();
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_names_leaks();
+ _nc_codes_leaks();
+#endif
+
+ if ((s = _nc_home_terminfo()) != 0)
+ free(s);
+ returnVoid;
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_free_tinfo(int code)
+{
+ _nc_leaks_tinfo();
+ exit(code);
+}
+#endif
diff --git a/contrib/ncurses/ncurses/tinfo/home_terminfo.c b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
index ce6576a82f82..92c26705a016 100644
--- a/contrib/ncurses/ncurses/tinfo/home_terminfo.c
+++ b/contrib/ncurses/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1998,2000,2004,2005 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
@@ -37,31 +37,32 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.9 2005/07/02 19:43:38 tom Exp $")
+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))
/* ncurses extension...fall back on user's private directory */
+#define MyBuffer _nc_globals.home_terminfo
+
NCURSES_EXPORT(char *)
_nc_home_terminfo(void)
{
char *result = 0;
-#ifdef USE_HOME_TERMINFO
+#if USE_HOME_TERMINFO
char *home;
- static char *temp = 0;
if (use_terminfo_vars()) {
- if (temp == 0) {
+ if (MyBuffer == 0) {
if ((home = getenv("HOME")) != 0
&& my_length <= PATH_MAX) {
- temp = typeMalloc(char, my_length);
- if (temp == 0)
+ MyBuffer = typeMalloc(char, my_length);
+ if (MyBuffer == 0)
_nc_err_abort(MSG_NO_MEMORY);
- (void) sprintf(temp, PRIVATE_INFO, home);
+ (void) sprintf(MyBuffer, PRIVATE_INFO, home);
}
}
- result = temp;
+ result = MyBuffer;
}
#endif
return result;
diff --git a/contrib/ncurses/ncurses/tinfo/init_keytry.c b/contrib/ncurses/ncurses/tinfo/init_keytry.c
index 3461dd4d5e51..d20321061554 100644
--- a/contrib/ncurses/ncurses/tinfo/init_keytry.c
+++ b/contrib/ncurses/ncurses/tinfo/init_keytry.c
@@ -36,7 +36,7 @@
#include <term_entry.h>
-MODULE_ID("$Id: init_keytry.c,v 1.8 2006/01/21 23:43:28 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.10 2007/04/29 22:57:50 tom Exp $")
/*
** _nc_init_keytry()
@@ -56,7 +56,7 @@ MODULE_ID("$Id: init_keytry.c,v 1.8 2006/01/21 23:43:28 tom Exp $")
#endif*/
#if BROKEN_LINKER
-struct tinfo_fkeys *
+const struct tinfo_fkeys *
_nc_tinfo_fkeysf(void)
{
return _nc_tinfo_fkeys;
@@ -76,9 +76,9 @@ _nc_init_keytry(void)
if (SP != 0) {
for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
- _nc_add_to_try(&(SP->_keytry),
- CUR Strings[_nc_tinfo_fkeys[n].offset],
- _nc_tinfo_fkeys[n].code);
+ (void) _nc_add_to_try(&(SP->_keytry),
+ CUR Strings[_nc_tinfo_fkeys[n].offset],
+ _nc_tinfo_fkeys[n].code);
}
}
#if NCURSES_XNAMES
@@ -96,9 +96,9 @@ _nc_init_keytry(void)
&& *name == 'k'
&& value != 0
&& key_defined(value) == 0) {
- _nc_add_to_try(&(SP->_keytry),
- value,
- n - STRCOUNT + KEY_MAX);
+ (void) _nc_add_to_try(&(SP->_keytry),
+ value,
+ n - STRCOUNT + KEY_MAX);
}
}
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_acs.c b/contrib/ncurses/ncurses/tinfo/lib_acs.c
index 2719795d9d4f..6a24285460b3 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_acs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_acs.c
@@ -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 *
@@ -35,17 +35,18 @@
#include <curses.priv.h>
#include <term.h> /* ena_acs, acs_chars */
-MODULE_ID("$Id: lib_acs.c,v 1.30 2006/01/07 21:27:15 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.34 2007/09/29 20:37:13 tom Exp $")
-#if BROKEN_LINKER
+#if BROKEN_LINKER || USE_REENTRANT
+#define MyBuffer _nc_prescreen.real_acs_map
NCURSES_EXPORT_VAR(chtype *)
_nc_acs_map(void)
{
- static chtype *the_map = 0;
- if (the_map == 0)
- the_map = typeCalloc(chtype, ACS_LEN);
- return the_map;
+ if (MyBuffer == 0)
+ MyBuffer = typeCalloc(chtype, ACS_LEN);
+ return MyBuffer;
}
+#undef MyBuffer
#else
NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] =
{
@@ -117,16 +118,6 @@ _nc_init_acs(void)
real_map['|'] = '!'; /* should be not-equal */
real_map['}'] = 'f'; /* should be pound-sterling symbol */
-#if !USE_WIDEC_SUPPORT
- if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
- acs_chars = NULL;
- ena_acs = NULL;
- enter_alt_charset_mode = NULL;
- exit_alt_charset_mode = NULL;
- set_attributes = NULL;
- }
-#endif
-
if (ena_acs != NULL) {
TPUTS_TRACE("ena_acs");
putp(ena_acs);
@@ -175,7 +166,7 @@ _nc_init_acs(void)
/* Show the equivalent mapping, noting if it does not match the
* given attribute, whether by re-ordering or duplication.
*/
- if (_nc_tracing & TRACE_CALLS) {
+ if (USE_TRACEF(TRACE_CALLS)) {
size_t n, m;
char show[ACS_LEN * 2 + 1];
for (n = 1, m = 0; n < ACS_LEN; n++) {
@@ -196,6 +187,7 @@ _nc_init_acs(void)
? "DIFF"
: "SAME"),
_nc_visbuf(show));
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
index 523892414367..4070160da393 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2002 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -39,6 +40,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term, pad_char */
#include <termcap.h> /* ospeed */
+#if defined(__FreeBSD__)
+#include <sys/param.h>
+#endif
/*
* These systems use similar header files, which define B1200 as 1200, etc.,
@@ -46,7 +50,7 @@
* of the indices up to B115200 fit nicely in a 'short', allowing us to retain
* ospeed's type for compatibility.
*/
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || defined(__NetBSD__) || defined(__OpenBSD__)
#undef B0
#undef B50
#undef B75
@@ -76,7 +80,7 @@
#undef USE_OLD_TTY
#endif /* USE_OLD_TTY */
-MODULE_ID("$Id: lib_baudrate.c,v 1.22 2002/01/19 23:07:53 Andrey.A.Chernov Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.25 2007/10/20 15:00:41 Rong-En.Fan Exp $")
/*
* int
@@ -141,16 +145,20 @@ static struct speed const speeds[] =
NCURSES_EXPORT(int)
_nc_baudrate(int OSpeed)
{
+#if !USE_REENTRANT
static int last_OSpeed;
static int last_baudrate;
+#endif
- int result;
+ int result = ERR;
unsigned i;
+#if !USE_REENTRANT
if (OSpeed == last_OSpeed) {
result = last_baudrate;
- } else {
- result = ERR;
+ }
+#endif
+ if (result == ERR) {
if (OSpeed >= 0) {
for (i = 0; i < SIZEOF(speeds); i++) {
if (speeds[i].s == OSpeed) {
@@ -159,7 +167,12 @@ _nc_baudrate(int OSpeed)
}
}
}
- last_baudrate = result;
+#if !USE_REENTRANT
+ if (OSpeed == last_OSpeed) {
+ last_OSpeed = OSpeed;
+ last_baudrate = result;
+ }
+#endif
}
return (result);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_data.c b/contrib/ncurses/ncurses/tinfo/lib_data.c
index 34f033a79021..225935ea79f0 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_data.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_data.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,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 *
@@ -41,15 +41,33 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_data.c,v 1.17 2005/01/22 17:39:22 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.34 2007/10/20 21:49:10 tom Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
* constructing a dll (reported by J.J.G.Ripoll).
*/
+#if USE_REENTRANT
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(stdscr) (void)
+{
+ return SP ? SP->_stdscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(curscr) (void)
+{
+ return SP ? SP->_curscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(newscr) (void)
+{
+ return SP ? SP->_newscr : 0;
+}
+#else
NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
+#endif
NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
@@ -87,3 +105,129 @@ _nc_set_screen(SCREEN *sp)
#else
NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
#endif
+/* *INDENT-OFF* */
+#define CHARS_0s { '\0' }
+
+#define TGETENT_0 { 0L, FALSE, NULL, NULL, NULL }
+#define TGETENT_0s { TGETENT_0, TGETENT_0, TGETENT_0, TGETENT_0 }
+
+NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
+ 0, /* have_sigwinch */
+ 0, /* cleanup_nested */
+
+ FALSE, /* init_signals */
+ FALSE, /* init_screen */
+
+ NULL, /* comp_sourcename */
+ NULL, /* comp_termtype */
+
+ FALSE, /* have_tic_directory */
+ FALSE, /* keep_tic_directory */
+ TERMINFO, /* tic_directory */
+
+ NULL, /* dbi_list */
+ 0, /* dbi_size */
+
+ NULL, /* first_name */
+ NULL, /* keyname_table */
+
+ NULL, /* safeprint_buf */
+ 0, /* safeprint_used */
+
+ TGETENT_0s, /* tgetent_cache */
+ 0, /* tgetent_index */
+ 0, /* tgetent_sequence */
+
+#if USE_HOME_TERMINFO
+ NULL, /* home_terminfo */
+#endif
+
+#if !USE_SAFE_SPRINTF
+ 0, /* safeprint_cols */
+ 0, /* safeprint_rows */
+#endif
+
+#ifdef TRACE
+ FALSE, /* init_trace */
+ CHARS_0s, /* trace_fname */
+ 0, /* trace_level */
+ NULL, /* trace_fp */
+
+ NULL, /* tracearg_buf */
+ 0, /* tracearg_used */
+
+ NULL, /* tracebuf_ptr */
+ 0, /* tracebuf_used */
+
+ CHARS_0s, /* tracechr_buf */
+
+ NULL, /* tracedmp_buf */
+ 0, /* tracedmp_used */
+
+ CHARS_0s, /* tracemse_buf */
+
+ NULL, /* tracetry_buf */
+ 0, /* tracetry_used */
+
+#ifndef USE_TERMLIB
+ { CHARS_0s, CHARS_0s }, /* traceatr_color_buf */
+ 0, /* traceatr_color_sel */
+ -1, /* traceatr_color_last */
+#endif /* USE_TERMLIB */
+
+#endif /* TRACE */
+#ifdef USE_PTHREADS
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_set_SP */
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_screen */
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_window */
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_windowlist */
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
+ 0, /* nested_tracef */
+#endif
+};
+
+#define STACK_FRAME_0 { { 0 }, 0 }
+#define STACK_FRAME_0s { STACK_FRAME_0 }
+#define NUM_VARS_0s { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+
+#define RIPOFF_0 { 0,0 }
+#define RIPOFF_0s { RIPOFF_0 }
+
+NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
+ TRUE, /* use_env */
+ FALSE, /* filter_mode */
+ A_NORMAL, /* previous_attr */
+ RIPOFF_0s, /* ripoff */
+ NULL, /* rsp */
+ { /* tparm_state */
+#ifdef TRACE
+ NULL, /* tname */
+#endif
+ NULL, /* tparam_base */
+
+ STACK_FRAME_0s, /* stack */
+ 0, /* stack_ptr */
+
+ NULL, /* out_buff */
+ 0, /* out_size */
+ 0, /* out_used */
+
+ NULL, /* fmt_buff */
+ 0, /* fmt_size */
+
+ NUM_VARS_0s, /* dynamic_var */
+ NUM_VARS_0s, /* static_vars */
+ },
+ NULL, /* saved_tty */
+#if BROKEN_LINKER || USE_REENTRANT
+ NULL, /* real_acs_map */
+ 0, /* LINES */
+ 0, /* COLS */
+#ifdef TRACE
+ 0L, /* _outchars */
+ NULL, /* _tputs_trace */
+#endif
+#endif
+};
+/* *INDENT-ON* */
diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c
index bdb0b7024d7c..5cdd1d468077 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_options.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_options.c
@@ -43,7 +43,7 @@
#include <term.h>
-MODULE_ID("$Id: lib_options.c,v 1.49 2006/03/04 19:28:25 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.50 2006/12/30 16:03:27 tom Exp $")
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
@@ -220,7 +220,7 @@ typeahead(int fd)
#if NCURSES_EXT_FUNCS
static int
-has_key_internal(int keycode, struct tries *tp)
+has_key_internal(int keycode, TRIES *tp)
{
if (tp == 0)
return (FALSE);
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index aa09f52c8c8d..58e71889af12 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,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 *
@@ -49,7 +49,7 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -69,8 +69,8 @@ MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
#ifdef TRACE
-#define BEFORE(N) if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _nc_tracebits())
-#define AFTER(N) if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _nc_tracebits())
+#define BEFORE(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s before bits: %s", N, _nc_tracebits())
+#define AFTER(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s after bits: %s", N, _nc_tracebits())
#else
#define BEFORE(s)
#define AFTER(s)
diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c
index 350824208830..1a061e083f28 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_setup.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c
@@ -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 *
@@ -29,7 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-2003 *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -53,7 +53,7 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_setup.c,v 1.95 2006/07/28 22:58:13 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.100 2007/09/01 20:58:26 tom Exp $")
/****************************************************************************
*
@@ -99,55 +99,57 @@ MODULE_ID("$Id: lib_setup.c,v 1.95 2006/07/28 22:58:13 tom Exp $")
# endif
#endif
+#if USE_REENTRANT
+NCURSES_EXPORT(char *)
+NCURSES_PUBLIC_VAR(ttytype) (void)
+{
+ static char empty[] = "";
+ return cur_term ? cur_term->type.term_names : empty;
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(LINES) (void)
+{
+ return (SP ? SP->_LINES : _nc_prescreen._LINES);
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLS) (void)
+{
+ return SP ? SP->_COLS : _nc_prescreen._COLS;
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(TABSIZE) (void)
+{
+ return SP ? SP->_TABSIZE : 8;
+}
+#else
NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = "";
NCURSES_EXPORT_VAR(int) LINES = 0;
NCURSES_EXPORT_VAR(int) COLS = 0;
NCURSES_EXPORT_VAR(int) TABSIZE = 0;
-
-static int _use_env = TRUE;
+#endif
#if USE_SIGWINCH
-int
-_nc_handle_sigwinch(int enable)
+/*
+ * If we have a pending SIGWINCH, set the flag in each screen.
+ */
+NCURSES_EXPORT(int)
+_nc_handle_sigwinch(int update)
{
- static int have_sigwinch = 0; /* initially no SIGWINCH's */
- static int can_resizeall = 1; /* initially enabled */
SCREEN *scan;
- int result;
-
- switch (enable) {
- default:
- /* record a SIGWINCH */
- have_sigwinch = 1;
- break;
- case 0:
- /* temporarily disable the next block */
- --can_resizeall;
- break;
- case 1:
- /* temporarily enable the next block */
- ++can_resizeall;
- break;
- }
- /*
- * If we have a pending SIGWINCH, set the flag in each screen.
- * But do this only if the block is enabled.
- */
- if (can_resizeall-- >= 0) { /* test and disable */
- if (have_sigwinch) {
- scan = _nc_screen_chain;
- while (scan) {
- scan->_sig_winch = TRUE;
- scan = scan->_next_screen;
- }
- have_sigwinch = 0;
+ (void) update; /* no longer used */
+
+ if (_nc_globals.have_sigwinch) {
+ _nc_globals.have_sigwinch = 0;
+
+ scan = _nc_screen_chain;
+ while (scan) {
+ scan->_sig_winch = TRUE;
+ scan = scan->_next_screen;
}
}
- result = can_resizeall + 1; /* reenable (unless disables are nested) */
- can_resizeall = result;
- return result;
+ return (SP ? SP->_sig_winch : 0);
}
#endif
@@ -156,19 +158,20 @@ NCURSES_EXPORT(void)
use_env(bool f)
{
T((T_CALLED("use_env()")));
- _use_env = f;
+ _nc_prescreen.use_env = f;
returnVoid;
}
-static void
+NCURSES_EXPORT(void)
_nc_get_screensize(int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
+ int my_tabsize;
+
/* figure out the size of the screen */
T(("screen size: terminfo lines = %d columns = %d", lines, columns));
- _nc_handle_sigwinch(0);
- if (!_use_env) {
+ if (!_nc_prescreen.use_env) {
*linep = (int) lines;
*colp = (int) columns;
} else { /* usually want to query LINES and COLUMNS from environment */
@@ -246,14 +249,20 @@ _nc_get_screensize(int *linep, int *colp)
lines = (short) (*linep);
columns = (short) (*colp);
}
- _nc_handle_sigwinch(1);
T(("screen size is %dx%d", *linep, *colp));
if (VALID_NUMERIC(init_tabs))
- TABSIZE = (int) init_tabs;
+ my_tabsize = (int) init_tabs;
else
- TABSIZE = 8;
+ my_tabsize = 8;
+
+#if USE_REENTRANT
+ if (SP != 0)
+ SP->_TABSIZE = my_tabsize;
+#else
+ TABSIZE = my_tabsize;
+#endif
T(("TABSIZE = %d", TABSIZE));
}
@@ -536,8 +545,10 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
if (command_character && getenv("CC"))
do_prototype();
+#if !USE_REENTRANT
strncpy(ttytype, cur_term->type.term_names, NAMESIZE - 1);
ttytype[NAMESIZE - 1] = '\0';
+#endif
cur_term->Filedes = Filedes;
cur_term->_termname = strdup(tname);
@@ -557,13 +568,16 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
/*
* We should always check the screensize, just in case.
*/
+#if USE_REENTRANT
+ _nc_get_screensize(SP ? &(SP->_LINES) : &(_nc_prescreen._LINES),
+ SP ? &(SP->_COLS) : &(_nc_prescreen._COLS));
+#else
_nc_get_screensize(&LINES, &COLS);
+#endif
if (errret)
*errret = TGETENT_YES;
- T((T_CREATE("screen %s %dx%d"), tname, LINES, COLS));
-
if (generic_type) {
ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
index 33e15c55c179..ff97eea920f8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
@@ -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 *
@@ -45,26 +45,20 @@
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.58 2006/09/02 19:39:46 Miroslav.Lichvar Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.61 2007/06/02 19:36:03 tom Exp $")
NCURSES_EXPORT_VAR(char *) UP = 0;
NCURSES_EXPORT_VAR(char *) BC = 0;
-typedef struct {
- long sequence;
- char *fix_sgr0; /* this holds the filtered sgr0 string */
- char *last_bufp; /* help with fix_sgr0 leak */
- TERMINAL *last_term;
-} CACHE;
+#define MyCache _nc_globals.tgetent_cache
+#define CacheInx _nc_globals.tgetent_index
+#define CacheSeq _nc_globals.tgetent_sequence
-#define MAX_CACHE 4
-static CACHE cache[MAX_CACHE];
-static int in_cache = 0;
-
-#define FIX_SGR0 cache[in_cache].fix_sgr0
-#define LAST_TRM cache[in_cache].last_term
-#define LAST_BUF cache[in_cache].last_bufp
-#define LAST_SEQ cache[in_cache].sequence
+#define FIX_SGR0 MyCache[CacheInx].fix_sgr0
+#define LAST_TRM MyCache[CacheInx].last_term
+#define LAST_BUF MyCache[CacheInx].last_bufp
+#define LAST_USE MyCache[CacheInx].last_used
+#define LAST_SEQ MyCache[CacheInx].sequence
/***************************************************************************
*
@@ -84,8 +78,6 @@ static int in_cache = 0;
NCURSES_EXPORT(int)
tgetent(char *bufp, const char *name)
{
- static long sequence;
-
int errcode;
int n;
bool found_cache = FALSE;
@@ -100,11 +92,17 @@ tgetent(char *bufp, const char *name)
* caller, but if tgetent() is called with the same buffer, that is
* good enough, since the previous data would be invalidated by the
* current call.
+ *
+ * bufp may be a null pointer, e.g., GNU termcap. That allocates data,
+ * which is good until the next tgetent() call. The conventional termcap
+ * is inconvenient because of the fixed buffer size, but because it uses
+ * caller-supplied buffers, can have multiple terminal descriptions in
+ * use at a given time.
*/
- for (n = 0; n < MAX_CACHE; ++n) {
- bool same_result = (bufp != 0 && cache[n].last_bufp == bufp);
+ for (n = 0; n < TGETENT_MAX; ++n) {
+ bool same_result = (MyCache[n].last_used && MyCache[n].last_bufp == bufp);
if (same_result) {
- in_cache = n;
+ CacheInx = n;
if (FIX_SGR0 != 0) {
FreeAndNull(FIX_SGR0);
}
@@ -114,10 +112,10 @@ tgetent(char *bufp, const char *name)
if (LAST_TRM != 0 && LAST_TRM != cur_term) {
TERMINAL *trm = LAST_TRM;
del_curterm(LAST_TRM);
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache)
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx)
if (LAST_TRM == trm)
LAST_TRM = 0;
- in_cache = n;
+ CacheInx = n;
}
found_cache = TRUE;
break;
@@ -126,15 +124,15 @@ tgetent(char *bufp, const char *name)
if (!found_cache) {
int best = 0;
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache) {
- if (LAST_SEQ < cache[best].sequence) {
- best = in_cache;
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
+ if (LAST_SEQ < MyCache[best].sequence) {
+ best = CacheInx;
}
}
- in_cache = best;
+ CacheInx = best;
}
LAST_TRM = cur_term;
- LAST_SEQ = ++sequence;
+ LAST_SEQ = ++CacheSeq;
PC = 0;
UP = 0;
@@ -164,6 +162,7 @@ tgetent(char *bufp, const char *name)
}
}
LAST_BUF = bufp;
+ LAST_USE = TRUE;
(void) baudrate(); /* sets ospeed as a side-effect */
@@ -282,9 +281,10 @@ tgetstr(NCURSES_CONST char *id, char **area)
NCURSES_EXPORT(void)
_nc_tgetent_leaks(void)
{
- for (in_cache = 0; in_cache < MAX_CACHE; ++in_cache) {
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
FreeIfNeeded(FIX_SGR0);
- del_curterm(LAST_TRM);
+ if (LAST_TRM != 0)
+ del_curterm(LAST_TRM);
}
}
#endif
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tparm.c b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
index cba31d9fd36b..d11fcf80cfbf 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tparm.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
@@ -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 *
@@ -43,7 +43,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.71 2006/11/26 01:12:56 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.74 2007/09/29 20:37:13 tom Exp $")
/*
* char *
@@ -105,43 +105,20 @@ MODULE_ID("$Id: lib_tparm.c,v 1.71 2006/11/26 01:12:56 tom Exp $")
* resulting in x mod y, not the reverse.
*/
-#define STACKSIZE 20
-
-typedef struct {
- union {
- int num;
- char *str;
- } data;
- bool num_type;
-} stack_frame;
-
NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
-static stack_frame stack[STACKSIZE];
-static int stack_ptr;
-static const char *tparam_base = "";
-
-#ifdef TRACE
-static const char *tname;
-#endif /* TRACE */
-
-static char *out_buff;
-static size_t out_size;
-static size_t out_used;
-
-static char *fmt_buff;
-static size_t fmt_size;
+#define TPS(var) _nc_prescreen.tparm_state.var
#if NO_LEAKS
NCURSES_EXPORT(void)
_nc_free_tparm(void)
{
- if (out_buff != 0) {
- FreeAndNull(out_buff);
- out_size = 0;
- out_used = 0;
- FreeAndNull(fmt_buff);
- fmt_size = 0;
+ if (TPS(out_buff) != 0) {
+ FreeAndNull(TPS(out_buff));
+ TPS(out_size) = 0;
+ TPS(out_used) = 0;
+ FreeAndNull(TPS(fmt_buff));
+ TPS(fmt_size) = 0;
}
}
#endif
@@ -149,11 +126,11 @@ _nc_free_tparm(void)
static NCURSES_INLINE void
get_space(size_t need)
{
- need += out_used;
- if (need > out_size) {
- out_size = need * 2;
- out_buff = typeRealloc(char, out_size, out_buff);
- if (out_buff == 0)
+ need += TPS(out_used);
+ if (need > TPS(out_size)) {
+ TPS(out_size) = need * 2;
+ TPS(out_buff) = typeRealloc(char, TPS(out_size), TPS(out_buff));
+ if (TPS(out_buff) == 0)
_nc_err_abort(MSG_NO_MEMORY);
}
}
@@ -167,8 +144,8 @@ save_text(const char *fmt, const char *s, int len)
get_space(s_len + 1);
- (void) sprintf(out_buff + out_used, fmt, s);
- out_used += strlen(out_buff + out_used);
+ (void) sprintf(TPS(out_buff) + TPS(out_used), fmt, s);
+ TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
static NCURSES_INLINE void
@@ -179,8 +156,8 @@ save_number(const char *fmt, int number, int len)
get_space((unsigned) len + 1);
- (void) sprintf(out_buff + out_used, fmt, number);
- out_used += strlen(out_buff + out_used);
+ (void) sprintf(TPS(out_buff) + TPS(out_used), fmt, number);
+ TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
static NCURSES_INLINE void
@@ -189,18 +166,18 @@ save_char(int c)
if (c == 0)
c = 0200;
get_space(1);
- out_buff[out_used++] = c;
+ TPS(out_buff)[TPS(out_used)++] = c;
}
static NCURSES_INLINE void
npush(int x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num_type = TRUE;
- stack[stack_ptr].data.num = x;
- stack_ptr++;
+ if (TPS(stack_ptr) < STACKSIZE) {
+ TPS(stack)[TPS(stack_ptr)].num_type = TRUE;
+ TPS(stack)[TPS(stack_ptr)].data.num = x;
+ TPS(stack_ptr)++;
} else {
- DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(tparam_base)));
+ DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
_nc_tparm_err++;
}
}
@@ -209,12 +186,12 @@ static NCURSES_INLINE int
npop(void)
{
int result = 0;
- if (stack_ptr > 0) {
- stack_ptr--;
- if (stack[stack_ptr].num_type)
- result = stack[stack_ptr].data.num;
+ if (TPS(stack_ptr) > 0) {
+ TPS(stack_ptr)--;
+ if (TPS(stack)[TPS(stack_ptr)].num_type)
+ result = TPS(stack)[TPS(stack_ptr)].data.num;
} else {
- DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(tparam_base)));
+ DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
_nc_tparm_err++;
}
return result;
@@ -223,12 +200,12 @@ npop(void)
static NCURSES_INLINE void
spush(char *x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num_type = FALSE;
- stack[stack_ptr].data.str = x;
- stack_ptr++;
+ if (TPS(stack_ptr) < STACKSIZE) {
+ TPS(stack)[TPS(stack_ptr)].num_type = FALSE;
+ TPS(stack)[TPS(stack_ptr)].data.str = x;
+ TPS(stack_ptr)++;
} else {
- DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(tparam_base)));
+ DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
_nc_tparm_err++;
}
}
@@ -238,12 +215,13 @@ spop(void)
{
static char dummy[] = ""; /* avoid const-cast */
char *result = dummy;
- if (stack_ptr > 0) {
- stack_ptr--;
- if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
- result = stack[stack_ptr].data.str;
+ if (TPS(stack_ptr) > 0) {
+ TPS(stack_ptr)--;
+ if (!TPS(stack)[TPS(stack_ptr)].num_type
+ && TPS(stack)[TPS(stack_ptr)].data.str != 0)
+ result = TPS(stack)[TPS(stack_ptr)].data.str;
} else {
- DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(tparam_base)));
+ DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
_nc_tparm_err++;
}
return result;
@@ -369,10 +347,11 @@ _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
if (cp == 0)
return 0;
- if ((len2 = strlen(cp)) > fmt_size) {
- fmt_size = len2 + fmt_size + 2;
- if ((fmt_buff = typeRealloc(char, fmt_size, fmt_buff)) == 0)
- return 0;
+ if ((len2 = strlen(cp)) > TPS(fmt_size)) {
+ TPS(fmt_size) = len2 + TPS(fmt_size) + 2;
+ TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
+ if (TPS(fmt_buff) == 0)
+ return 0;
}
memset(p_is_s, 0, sizeof(p_is_s[0]) * NUM_PARM);
@@ -381,7 +360,7 @@ _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
while ((cp - string) < (int) len2) {
if (*cp == '%') {
cp++;
- cp = parse_format(cp, fmt_buff, &len);
+ cp = parse_format(cp, TPS(fmt_buff), &len);
switch (*cp) {
default:
break;
@@ -474,7 +453,6 @@ _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
static NCURSES_INLINE char *
tparam_internal(const char *string, va_list ap)
{
-#define NUM_VARS 26
char *p_is_s[NUM_PARM];
TPARM_ARG param[NUM_PARM];
int popcount;
@@ -485,13 +463,11 @@ tparam_internal(const char *string, va_list ap)
int i;
const char *cp = string;
size_t len2;
- static int dynamic_var[NUM_VARS];
- static int static_vars[NUM_VARS];
if (cp == NULL)
return NULL;
- out_used = 0;
+ TPS(out_used) = 0;
len2 = strlen(cp);
/*
@@ -500,7 +476,7 @@ tparam_internal(const char *string, va_list ap)
* variable-length argument list.
*/
number = _nc_tparm_analyze(cp, p_is_s, &popcount);
- if (fmt_buff == 0)
+ if (TPS(fmt_buff) == 0)
return NULL;
for (i = 0; i < max(popcount, number); i++) {
@@ -525,22 +501,23 @@ tparam_internal(const char *string, va_list ap)
* the expansion of (for example) \E[%d;%dH work correctly in termcap
* style, which means tparam() will expand termcap strings OK.
*/
- stack_ptr = 0;
+ TPS(stack_ptr) = 0;
if (popcount == 0) {
popcount = number;
for (i = number - 1; i >= 0; i--)
npush(param[i]);
}
#ifdef TRACE
- if (_nc_tracing & TRACE_CALLS) {
+ if (USE_TRACEF(TRACE_CALLS)) {
for (i = 0; i < popcount; i++) {
if (p_is_s[i] != 0)
save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
else
save_number(", %d", param[i], 0);
}
- _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(cp), out_buff);
- out_used = 0;
+ _tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
+ TPS(out_used) = 0;
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -548,8 +525,8 @@ tparam_internal(const char *string, va_list ap)
if (*cp != '%') {
save_char(UChar(*cp));
} else {
- tparam_base = cp++;
- cp = parse_format(cp, fmt_buff, &len);
+ TPS(tparam_base) = cp++;
+ cp = parse_format(cp, TPS(fmt_buff), &len);
switch (*cp) {
default:
break;
@@ -561,7 +538,7 @@ tparam_internal(const char *string, va_list ap)
case 'o': /* FALLTHRU */
case 'x': /* FALLTHRU */
case 'X': /* FALLTHRU */
- save_number(fmt_buff, npop(), len);
+ save_number(TPS(fmt_buff), npop(), len);
break;
case 'c': /* FALLTHRU */
@@ -573,7 +550,7 @@ tparam_internal(const char *string, va_list ap)
break;
case 's':
- save_text(fmt_buff, spop(), len);
+ save_text(TPS(fmt_buff), spop(), len);
break;
case 'p':
@@ -591,10 +568,10 @@ tparam_internal(const char *string, va_list ap)
cp++;
if (isUPPER(*cp)) {
i = (UChar(*cp) - 'A');
- static_vars[i] = npop();
+ TPS(static_vars)[i] = npop();
} else if (isLOWER(*cp)) {
i = (UChar(*cp) - 'a');
- dynamic_var[i] = npop();
+ TPS(dynamic_var)[i] = npop();
}
break;
@@ -602,10 +579,10 @@ tparam_internal(const char *string, va_list ap)
cp++;
if (isUPPER(*cp)) {
i = (UChar(*cp) - 'A');
- npush(static_vars[i]);
+ npush(TPS(static_vars)[i]);
} else if (isLOWER(*cp)) {
i = (UChar(*cp) - 'a');
- npush(dynamic_var[i]);
+ npush(TPS(dynamic_var)[i]);
}
break;
@@ -768,10 +745,10 @@ tparam_internal(const char *string, va_list ap)
} /* endwhile (*cp) */
get_space(1);
- out_buff[out_used] = '\0';
+ TPS(out_buff)[TPS(out_used)] = '\0';
- T((T_RETURN("%s"), _nc_visbuf(out_buff)));
- return (out_buff);
+ T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));
+ return (TPS(out_buff));
}
#if NCURSES_TPARM_VARARGS
@@ -789,7 +766,7 @@ tparm_varargs(NCURSES_CONST char *string,...)
_nc_tparm_err = 0;
va_start(ap, string);
#ifdef TRACE
- tname = "tparm";
+ TPS(tname) = "tparm";
#endif /* TRACE */
result = tparam_internal(string, ap);
va_end(ap);
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
index 3a18ffd7404f..aab3351905ce 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,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 *
@@ -45,12 +45,12 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.62 2003/08/23 21:39:20 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.64 2007/09/29 20:37:13 tom Exp $")
-NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0; /* used by 'tack' program */
+NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0; /* used by 'tack' program */
static int (*my_outch) (int c) = _nc_outch;
@@ -84,7 +84,7 @@ _nc_flush(void)
NCURSES_EXPORT(int)
_nc_outch(int ch)
{
- TRACE_OUTCHARS(1);
+ COUNT_OUTCHARS(1);
if (SP != 0
&& SP->_cleanup) {
@@ -119,7 +119,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
#ifdef TRACE
char addrbuf[32];
- if (_nc_tracing & TRACE_TPUTS) {
+ if (USE_TRACEF(TRACE_TPUTS)) {
if (outc == _nc_outch)
(void) strcpy(addrbuf, "_nc_outch");
else
@@ -130,7 +130,8 @@ tputs(const char *string, int affcnt, int (*outc) (int))
} else {
_tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
- _nc_tputs_trace = (char *) NULL;
+ TPUTS_TRACE(NULL);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
diff --git a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
index 77c35fa58426..4cbbf504a0c7 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c
@@ -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 *
@@ -38,31 +38,35 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_ttyflags.c,v 1.13 2006/12/10 01:31:54 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.15 2007/05/26 18:54:25 tom Exp $")
NCURSES_EXPORT(int)
_nc_get_tty_mode(TTY * buf)
{
int result = OK;
- if (cur_term == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- for (;;) {
- if (GET_TTY(cur_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- result = ERR;
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (GET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ result = ERR;
+ }
+ break;
}
- break;
}
- }
- if (result == ERR)
- memset(buf, 0, sizeof(*buf));
+ if (result == ERR)
+ memset(buf, 0, sizeof(*buf));
- TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
+ TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
+ cur_term->Filedes, _nc_trace_ttymode(buf)));
+ }
return (result);
}
@@ -71,22 +75,26 @@ _nc_set_tty_mode(TTY * buf)
{
int result = OK;
- if (cur_term == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- for (;;) {
- if (SET_TTY(cur_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- if ((errno == ENOTTY) && (SP != 0))
- SP->_notty = TRUE;
- result = ERR;
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (SET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOTTY) && (SP != 0))
+ SP->_notty = TRUE;
+ result = ERR;
+ }
+ break;
}
- break;
}
+ TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
+ cur_term->Filedes, _nc_trace_ttymode(buf)));
}
- TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
return (result);
}
@@ -164,19 +172,33 @@ reset_shell_mode(void)
returnCode(ERR);
}
+static TTY *
+saved_tty(void)
+{
+ TTY *result = 0;
+
+ if (SP != 0) {
+ result = &(SP->_saved_tty);
+ } else {
+ if (_nc_prescreen.saved_tty == 0) {
+ _nc_prescreen.saved_tty = typeCalloc(TTY, 1);
+ }
+ result = _nc_prescreen.saved_tty;
+ }
+ return result;
+}
+
/*
** savetty() and resetty()
**
*/
-static TTY buf;
-
NCURSES_EXPORT(int)
savetty(void)
{
T((T_CALLED("savetty()")));
- returnCode(_nc_get_tty_mode(&buf));
+ returnCode(_nc_get_tty_mode(saved_tty()));
}
NCURSES_EXPORT(int)
@@ -184,5 +206,5 @@ resetty(void)
{
T((T_CALLED("resetty()")));
- returnCode(_nc_set_tty_mode(&buf));
+ returnCode(_nc_set_tty_mode(saved_tty()));
}
diff --git a/contrib/ncurses/ncurses/tinfo/make_keys.c b/contrib/ncurses/ncurses/tinfo/make_keys.c
index 8f6243c93c75..00367185a45c 100644
--- a/contrib/ncurses/ncurses/tinfo/make_keys.c
+++ b/contrib/ncurses/ncurses/tinfo/make_keys.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,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 *
@@ -39,7 +39,7 @@
#define USE_TERMLIB 1
#include <curses.priv.h>
-MODULE_ID("$Id: make_keys.c,v 1.12 2005/08/20 19:58:18 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.13 2007/01/07 00:00:14 tom Exp $")
#include <names.c>
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
"#if BROKEN_LINKER",
"static",
"#endif",
- "struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
+ "const struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
0
};
static const char *suffix[] =
diff --git a/contrib/ncurses/ncurses/tinfo/name_match.c b/contrib/ncurses/ncurses/tinfo/name_match.c
index fee3ba3bc711..c8d728faa7c4 100644
--- a/contrib/ncurses/ncurses/tinfo/name_match.c
+++ b/contrib/ncurses/ncurses/tinfo/name_match.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,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 *
@@ -34,38 +34,38 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: name_match.c,v 1.15 2005/01/22 21:47:25 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.16 2007/04/21 21:28:13 tom Exp $")
/*
* _nc_first_name(char *names)
*
* Extract the primary name from a compiled entry.
*/
+#define FirstName _nc_globals.first_name
NCURSES_EXPORT(char *)
_nc_first_name(const char *const sp)
/* get the first name from the given name list */
{
- static char *buf;
- register unsigned n;
+ unsigned n;
#if NO_LEAKS
if (sp == 0) {
- if (buf != 0)
- FreeAndNull(buf); /* for leak-testing */
+ if (FirstName != 0)
+ FreeAndNull(FirstName);
return 0;
}
#endif
- if (buf == 0)
- buf = 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 ((buf[n] = sp[n]) == '\0'
- || (buf[n] == '|'))
+ if ((FirstName[n] = sp[n]) == '\0'
+ || (FirstName[n] == '|'))
break;
}
- buf[n] = '\0';
- return (buf);
+ FirstName[n] = '\0';
+ return (FirstName);
}
/*
diff --git a/contrib/ncurses/ncurses/tinfo/parse_entry.c b/contrib/ncurses/ncurses/tinfo/parse_entry.c
index 510b232c8b5c..375ce8ff9957 100644
--- a/contrib/ncurses/ncurses/tinfo/parse_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/parse_entry.c
@@ -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.65 2007/08/11 16:19:02 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -283,7 +283,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
+ _nc_get_hash_table(_nc_syntax));
/*
* Our kluge to handle aliasing. The reason it's done
@@ -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",
@@ -308,14 +308,15 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
goto nexttok;
}
- entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
+ entry_ptr = _nc_find_entry(ap->to,
+ _nc_get_hash_table(TRUE));
if (entry_ptr && !silent)
_nc_warning("%s (%s termcap extension) aliased to %s",
ap->from, ap->source, ap->to);
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",
@@ -323,7 +324,8 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
goto nexttok;
}
- entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ entry_ptr = _nc_find_entry(ap->to,
+ _nc_get_hash_table(FALSE));
if (entry_ptr && !silent)
_nc_warning("%s (%s terminfo extension) aliased to %s",
ap->from, ap->source, ap->to);
@@ -796,8 +798,8 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
/* now we know we found a match in ko_table, so... */
- from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
- to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ from_ptr = _nc_find_entry(ap->from, _nc_get_hash_table(TRUE));
+ to_ptr = _nc_find_entry(ap->to, _nc_get_hash_table(FALSE));
if (!from_ptr || !to_ptr) /* should never happen! */
_nc_err_abort("ko translation table is invalid, I give up");
diff --git a/contrib/ncurses/ncurses/tinfo/read_entry.c b/contrib/ncurses/ncurses/tinfo/read_entry.c
index c6c327514d57..6a050ee78e66 100644
--- a/contrib/ncurses/ncurses/tinfo/read_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/read_entry.c
@@ -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 *
@@ -42,7 +42,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.99 2006/08/19 15:58:50 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.100 2007/11/17 23:56:50 tom Exp $")
#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
@@ -409,7 +409,7 @@ _nc_read_tic_entry(char *filename,
unsigned need = 4 + strlen(path) + strlen(name);
if (need <= limit) {
- (void) sprintf(filename, "%s/%c/%s", path, *name, name);
+ (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name);
result = _nc_read_file_entry(filename, tp);
}
}
diff --git a/contrib/ncurses/ncurses/tinfo/setbuf.c b/contrib/ncurses/ncurses/tinfo/setbuf.c
index 94bb6d3463c5..ba910e8983a4 100644
--- a/contrib/ncurses/ncurses/tinfo/setbuf.c
+++ b/contrib/ncurses/ncurses/tinfo/setbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,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 *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: setbuf.c,v 1.12 2003/11/15 23:55:34 tom Exp $")
+MODULE_ID("$Id: setbuf.c,v 1.13 2007/05/12 19:04:02 tom Exp $")
/*
* If the output file descriptor is connected to a tty (the typical case) it
@@ -102,7 +102,7 @@ _nc_set_buffer(FILE *ofp, bool buffered)
{
/* optional optimization hack -- do before any output to ofp */
#if HAVE_SETVBUF || HAVE_SETBUFFER
- if (SP->_buffered != (int)buffered) {
+ if (SP->_buffered != buffered) {
unsigned buf_len;
char *buf_ptr;
diff --git a/contrib/ncurses/ncurses/tinfo/strings.c b/contrib/ncurses/ncurses/tinfo/strings.c
index d5377fe07a51..78cd2ef4f5f5 100644
--- a/contrib/ncurses/ncurses/tinfo/strings.c
+++ b/contrib/ncurses/ncurses/tinfo/strings.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2000,2003 Free Software Foundation, Inc. *
+ * Copyright (c) 2000-2003,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 *
@@ -36,7 +36,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: strings.c,v 1.5 2003/08/16 23:46:00 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.6 2007/08/11 17:12:17 tom Exp $")
/****************************************************************************
* Useful string functions (especially for mvcur)
@@ -52,7 +52,7 @@ _nc_strstr(const char *haystack, const char *needle)
while ((len1 != 0) && (len1-- >= len2)) {
if (!strncmp(haystack, needle, len2)) {
- result = haystack;
+ result = (char *) haystack;
break;
}
haystack++;
diff --git a/contrib/ncurses/ncurses/tinfo/trim_sgr0.c b/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
index 3ce18e070b06..80c8f77fbebe 100644
--- a/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
+++ b/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2005 Free Software Foundation, Inc. *
+ * Copyright (c) 2005-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 *
@@ -37,7 +37,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: trim_sgr0.c,v 1.7 2006/12/02 19:37:57 tom Exp $")
+MODULE_ID("$Id: trim_sgr0.c,v 1.8 2007/04/07 17:14:11 tom Exp $")
#undef CUR
#define CUR tp->
@@ -247,9 +247,7 @@ _nc_trim_sgr0(TERMTYPE *tp)
if (!rewrite_sgr(on, enter_alt_charset_mode)
|| !rewrite_sgr(off, exit_alt_charset_mode)
|| !rewrite_sgr(end, exit_alt_charset_mode)) {
- FreeIfNeeded(on);
FreeIfNeeded(off);
- FreeIfNeeded(end);
} else if (similar_sgr(off, end)
&& !similar_sgr(off, on)) {
TR(TRACE_DATABASE, ("adjusting sgr(9:off) : %s", _nc_visbuf(off)));
@@ -315,8 +313,8 @@ _nc_trim_sgr0(TERMTYPE *tp)
*/
free(off);
}
- free(end);
- free(on);
+ FreeIfNeeded(end);
+ FreeIfNeeded(on);
} else {
/*
* Possibly some applications are confused if sgr0 contains rmacs,
diff --git a/contrib/ncurses/ncurses/tinfo/use_screen.c b/contrib/ncurses/ncurses/tinfo/use_screen.c
new file mode 100644
index 000000000000..27730b055c12
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/use_screen.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * 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. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2007 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: use_screen.c,v 1.2 2007/09/08 21:46:48 tom Exp $")
+
+NCURSES_EXPORT(int)
+use_screen(SCREEN *screen, NCURSES_CALLBACK func, void *data)
+{
+ SCREEN *save_SP;
+ int code = OK;
+
+ T((T_CALLED("use_screen(%p,%p,%p)"), screen, func, data));
+
+ /*
+ * FIXME - add a flag so a given thread can check if _it_ has already
+ * recurred through this point, return an error if so.
+ */
+ _nc_lock_global(use_screen);
+ save_SP = SP;
+ set_term(screen);
+
+ code = func(screen->_stdscr, data);
+
+ set_term(save_SP);
+ _nc_unlock_global(use_screen);
+ returnCode(code);
+
+ return 0;
+}
diff --git a/contrib/ncurses/ncurses/tinfo/write_entry.c b/contrib/ncurses/ncurses/tinfo/write_entry.c
index 5426f1fc40d0..05027e0021a2 100644
--- a/contrib/ncurses/ncurses/tinfo/write_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/write_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,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 *
@@ -54,7 +54,7 @@
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$Id: write_entry.c,v 1.68 2006/10/14 20:45:16 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.70 2007/11/17 23:38:28 tom Exp $")
static int total_written;
@@ -97,17 +97,16 @@ check_writeable(int code)
static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
static bool verified[sizeof(dirnames)];
- char dir[2];
+ char dir[sizeof(LEAF_FMT)];
char *s = 0;
if (code == 0 || (s = strchr(dirnames, code)) == 0)
- _nc_err_abort("Illegal terminfo subdirectory \"%c\"", code);
+ _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code);
if (verified[s - dirnames])
return;
- dir[0] = code;
- dir[1] = '\0';
+ sprintf(dir, LEAF_FMT, code);
if (make_db_root(dir) < 0) {
_nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
}
@@ -358,7 +357,7 @@ _nc_write_entry(TERMTYPE *const tp)
if (strlen(first_name) > sizeof(filename) - 3)
_nc_warning("terminal name too long.");
- sprintf(filename, "%c/%s", first_name[0], first_name);
+ sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
/*
* Has this primary name been written since the first call to
@@ -399,7 +398,7 @@ _nc_write_entry(TERMTYPE *const tp)
}
check_writeable(ptr[0]);
- sprintf(linkname, "%c/%s", ptr[0], ptr);
+ sprintf(linkname, LEAF_FMT "/%s", ptr[0], ptr);
if (strcmp(filename, linkname) == 0) {
_nc_warning("self-synonym ignored");
@@ -502,7 +501,8 @@ compute_offsets(char **Strings, unsigned strmax, short *offsets)
} else {
offsets[i] = nextfree;
nextfree += strlen(Strings[i]) + 1;
- TRACE_OUT(("put Strings[%d]=%s(%d)", i, _nc_visbuf(Strings[i]), nextfree));
+ TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i,
+ _nc_visbuf(Strings[i]), nextfree));
}
}
return nextfree;
@@ -740,7 +740,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
*/
for (i = 0; i < tp->ext_Strings; i++) {
if (VALID_STRING(tp->Strings[i + STRCOUNT])) {
- TRACE_OUT(("WRITE ext_Strings[%d]=%s", i,
+ TRACE_OUT(("WRITE ext_Strings[%d]=%s", (int) i,
_nc_visbuf(tp->Strings[i + STRCOUNT])));
if (!WRITE_STRING(tp->Strings[i + STRCOUNT]))
return (ERR);
@@ -751,7 +751,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
* Write the extended names
*/
for (i = 0; i < extcnt; i++) {
- TRACE_OUT(("WRITE ext_Names[%d]=%s", i, tp->ext_Names[i]));
+ TRACE_OUT(("WRITE ext_Names[%d]=%s", (int) i, tp->ext_Names[i]));
if (!WRITE_STRING(tp->ext_Names[i]))
return (ERR);
}