aboutsummaryrefslogtreecommitdiff
path: root/ncurses/tinfo
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-02-28 19:12:44 +0000
committerXin LI <delphij@FreeBSD.org>2014-02-28 19:12:44 +0000
commit4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a (patch)
treeb8f6e12b479a78216f3bffb8e1258d54087268de /ncurses/tinfo
parente07762606a5bf651a501cb095c98cba90e4a8fe2 (diff)
downloadsrc-4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a.tar.gz
src-4b819fa20a8d007a10f2d3e8d6a5dedf7f18fc9a.zip
Undo two previous imports which was never done in preparation of doing a
new import.
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=262616
Diffstat (limited to 'ncurses/tinfo')
-rw-r--r--ncurses/tinfo/MKcaptab.sh136
-rw-r--r--ncurses/tinfo/MKcodes.awk23
-rwxr-xr-xncurses/tinfo/MKfallback.sh18
-rw-r--r--ncurses/tinfo/MKnames.awk26
-rw-r--r--ncurses/tinfo/access.c7
-rw-r--r--ncurses/tinfo/add_tries.c11
-rw-r--r--ncurses/tinfo/alloc_entry.c19
-rw-r--r--ncurses/tinfo/alloc_ttype.c90
-rw-r--r--ncurses/tinfo/captoinfo.c49
-rw-r--r--ncurses/tinfo/comp_expand.c6
-rw-r--r--ncurses/tinfo/comp_hash.c334
-rw-r--r--ncurses/tinfo/comp_parse.c18
-rw-r--r--ncurses/tinfo/comp_scan.c94
-rw-r--r--ncurses/tinfo/db_iterator.c11
-rw-r--r--ncurses/tinfo/entries.c18
-rw-r--r--ncurses/tinfo/free_ttype.c6
-rw-r--r--ncurses/tinfo/hashed_db.c58
-rw-r--r--ncurses/tinfo/home_terminfo.c6
-rw-r--r--ncurses/tinfo/init_keytry.c20
-rw-r--r--ncurses/tinfo/lib_acs.c82
-rw-r--r--ncurses/tinfo/lib_baudrate.c32
-rw-r--r--ncurses/tinfo/lib_cur_term.c112
-rw-r--r--ncurses/tinfo/lib_data.c50
-rw-r--r--ncurses/tinfo/lib_has_cap.c53
-rw-r--r--ncurses/tinfo/lib_kernel.c82
-rw-r--r--ncurses/tinfo/lib_longname.c42
-rw-r--r--ncurses/tinfo/lib_napms.c21
-rw-r--r--ncurses/tinfo/lib_options.c277
-rw-r--r--ncurses/tinfo/lib_print.c39
-rw-r--r--ncurses/tinfo/lib_raw.c202
-rw-r--r--ncurses/tinfo/lib_setup.c401
-rw-r--r--ncurses/tinfo/lib_termcap.c227
-rw-r--r--ncurses/tinfo/lib_termname.c22
-rw-r--r--ncurses/tinfo/lib_ti.c162
-rw-r--r--ncurses/tinfo/lib_tparm.c49
-rw-r--r--ncurses/tinfo/lib_tputs.c168
-rw-r--r--ncurses/tinfo/lib_ttyflags.c207
-rw-r--r--ncurses/tinfo/make_hash.c294
-rw-r--r--ncurses/tinfo/make_keys.c24
-rw-r--r--ncurses/tinfo/name_match.c3
-rw-r--r--ncurses/tinfo/parse_entry.c55
-rw-r--r--ncurses/tinfo/read_entry.c71
-rw-r--r--ncurses/tinfo/read_termcap.c20
-rw-r--r--ncurses/tinfo/setbuf.c35
-rw-r--r--ncurses/tinfo/tinfo_driver.c1337
-rw-r--r--ncurses/tinfo/trim_sgr0.c38
-rw-r--r--ncurses/tinfo/use_screen.c8
-rw-r--r--ncurses/tinfo/write_entry.c82
48 files changed, 1288 insertions, 3857 deletions
diff --git a/ncurses/tinfo/MKcaptab.sh b/ncurses/tinfo/MKcaptab.sh
index 4d1b53a5bd9a..98c04e884309 100644
--- a/ncurses/tinfo/MKcaptab.sh
+++ b/ncurses/tinfo/MKcaptab.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##############################################################################
-# Copyright (c) 2007-2009,2010 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"), #
@@ -26,19 +26,12 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKcaptab.sh,v 1.13 2010/12/25 23:43:58 tom Exp $
+# $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
-/*
- * generated by $0
- */
-
-EOF
-
cat <<'EOF'
/*
* comp_captab.c -- The names of the capabilities indexed via a hash
@@ -55,7 +48,7 @@ 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=capalias <$DATA
$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias <$DATA
@@ -65,7 +58,7 @@ cat <<EOF
static void
next_string(const char *strings, unsigned *offset)
{
- *offset += (unsigned) strlen(strings + *offset) + 1;
+ *offset += strlen(strings + *offset) + 1;
}
static const struct name_table_entry *
@@ -73,21 +66,21 @@ _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);
- }
+ 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;
+ return *actual;
}
#define add_alias(field) \\
@@ -101,18 +94,18 @@ _nc_build_alias(struct alias **actual,
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);
- }
+ 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;
+ return *actual;
}
#define build_names(root) _nc_build_names(&_nc_##root##_table, \\
@@ -129,82 +122,27 @@ _nc_build_alias(struct alias **actual,
NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
{
- return termcap ? build_names(cap) : build_names(info) ;
+ return termcap ? build_names(cap) : build_names(info) ;
}
-/* entrypoint used by tack (do not alter) */
-NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool termcap)
+NCURSES_EXPORT(const short *) _nc_get_hash_table (bool termcap)
{
- return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
+ 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) ;
-}
-
-static HashValue
-info_hash(const char *string)
-{
- long sum = 0;
-
- DEBUG(9, ("hashing %s", string));
- while (*string) {
- sum += (long) (*string + (*(string + 1) << 8));
- string++;
- }
-
- DEBUG(9, ("sum is %ld", sum));
- return (HashValue) (sum % HASHTABSIZE);
-}
-
-#define TCAP_LEN 2 /* only 1- or 2-character names are used */
-
-static HashValue
-tcap_hash(const char *string)
-{
- char temp[TCAP_LEN + 1];
- int limit = 0;
-
- while (*string) {
- temp[limit++] = *string++;
- if (limit >= TCAP_LEN)
- break;
- }
- temp[limit] = '\0';
- return info_hash(temp);
-}
-
-static int
-compare_tcap_names(const char *a, const char *b)
-{
- return !strncmp(a, b, TCAP_LEN);
-}
-
-static int
-compare_info_names(const char *a, const char *b)
-{
- return !strcmp(a, b);
-}
-
-static const HashData hash_data[2] = {
- { HASHTABSIZE, _nc_info_hash_table, info_hash, compare_info_names },
- { HASHTABSIZE, _nc_cap_hash_table, tcap_hash, compare_tcap_names }
-};
-
-NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool termcap)
-{
- return &hash_data[(termcap != FALSE)];
+ 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);
+ FreeIfNeeded(_nc_cap_table);
+ FreeIfNeeded(_nc_info_table);
+ FreeIfNeeded(_nc_capalias_table);
+ FreeIfNeeded(_nc_infoalias_table);
#endif
}
#endif /* NO_LEAKS */
diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk
index 97e5131ba07c..b9ba636e0ccd 100644
--- a/ncurses/tinfo/MKcodes.awk
+++ b/ncurses/tinfo/MKcodes.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKcodes.awk,v 1.9 2010/01/23 17:57:43 tom Exp $
+# $Id: MKcodes.awk,v 1.5 2008/06/28 23:13:25 tom Exp $
function large_item(value) {
result = sprintf("%d,", offset);
offset = offset + length(value) + 1;
@@ -101,6 +101,8 @@ 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;
@@ -115,39 +117,28 @@ END {
print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
print " unsigned n;"
print " for (n = 0; n < size; ++n) {"
- print " (*value)[n] = (NCURSES_CONST char *) _nc_code_blob + offsets[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 NCURSES_PUBLIC_VAR(it)(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ 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 NCURSES_PUBLIC_VAR(it)(void) { return data##it; }"
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
}
print ""
- print "/* remove public definition which conflicts with FIX() */"
- print "#undef boolcodes"
- print "#undef numcodes"
- print "#undef strcodes"
- print ""
- print "/* add local definition */"
print "FIX(boolcodes)"
print "FIX(numcodes)"
print "FIX(strcodes)"
print ""
- print "/* restore the public definition */"
- print ""
print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
- print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())"
- print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())"
- print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())"
print ""
print "#if NO_LEAKS"
print "NCURSES_EXPORT(void)"
diff --git a/ncurses/tinfo/MKfallback.sh b/ncurses/tinfo/MKfallback.sh
index 11f1d2ead138..9feab3507cc0 100755
--- a/ncurses/tinfo/MKfallback.sh
+++ b/ncurses/tinfo/MKfallback.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2001,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 "Software"), #
@@ -26,7 +26,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKfallback.sh,v 1.15 2010/08/07 20:32:34 tom Exp $
+# $Id: MKfallback.sh,v 1.13 2006/07/15 16:54:20 tom Exp $
#
# MKfallback.sh -- create fallback table for entry reads
#
@@ -42,17 +42,6 @@ shift
terminfo_src=$1
shift
-tic_path=$1
-shift
-
-case $tic_path in #(vi
-/*)
- tic_head=`echo "$tic_path" | sed -e 's,/[^/]*$,,'`
- PATH=$tic_head:$PATH
- export PATH
- ;;
-esac
-
if test $# != 0 ; then
tmp_info=tmp_info
echo creating temporary terminfo directory... >&2
@@ -63,7 +52,7 @@ if test $# != 0 ; then
TERMINFO_DIRS=$TERMINFO:$terminfo_dir
export TERMINFO_DIRS
- $tic_path -x $terminfo_src >&2
+ tic -x $terminfo_src >&2
else
tmp_info=
fi
@@ -74,6 +63,7 @@ cat <<EOF
*/
#include <curses.priv.h>
+#include <term.h>
EOF
diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk
index 7685d1831ef0..7e5074480864 100644
--- a/ncurses/tinfo/MKnames.awk
+++ b/ncurses/tinfo/MKnames.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 2007-2008,2009 Free Software Foundation, Inc. #
+# Copyright (c) 2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKnames.awk,v 1.22 2009/03/21 21:03:39 tom Exp $
+# $Id: MKnames.awk,v 1.20 2008/10/11 21:07:56 tom Exp $
function large_item(value) {
result = sprintf("%d,", offset);
offset = offset + length(value) + 1;
@@ -107,6 +107,8 @@ 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;
@@ -131,7 +133,7 @@ END {
print " return *value;"
print "}"
print ""
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API NCURSES_PUBLIC_VAR(it)(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ 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 ""
@@ -141,18 +143,9 @@ END {
print_strings("numfnames", small_numfnames);
print_strings("strnames", small_strnames);
print_strings("strfnames", small_strfnames);
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API NCURSES_PUBLIC_VAR(it)(void) { return data##it; }"
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
}
print ""
- print "/* remove public definition which conflicts with FIX() */"
- print "#undef boolnames"
- print "#undef boolfnames"
- print "#undef numnames"
- print "#undef numfnames"
- print "#undef strnames"
- print "#undef strfnames"
- print ""
- print "/* add local definition */"
print "FIX(boolnames)"
print "FIX(boolfnames)"
print "FIX(numnames)"
@@ -160,13 +153,6 @@ END {
print "FIX(strnames)"
print "FIX(strfnames)"
print ""
- print "/* restore the public definition */"
- print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())"
- print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
- print "#define numnames NCURSES_PUBLIC_VAR(numnames())"
- print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())"
- print "#define strnames NCURSES_PUBLIC_VAR(strnames())"
- print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())"
print ""
print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
print ""
diff --git a/ncurses/tinfo/access.c b/ncurses/tinfo/access.c
index 87c4f462fd4f..ce8ccdac53f6 100644
--- a/ncurses/tinfo/access.c
+++ b/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 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 *
@@ -36,8 +36,9 @@
#include <sys/stat.h>
#include <tic.h>
+#include <nc_alloc.h>
-MODULE_ID("$Id: access.c,v 1.16 2010/01/23 17:57:43 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))
@@ -96,7 +97,7 @@ _nc_pathlast(const char *path)
test = path;
else
test++;
- return (unsigned) (test - path);
+ return (test - path);
}
NCURSES_EXPORT(char *)
diff --git a/ncurses/tinfo/add_tries.c b/ncurses/tinfo/add_tries.c
index 29a1a60045b5..455d142edc8e 100644
--- a/ncurses/tinfo/add_tries.c
+++ b/ncurses/tinfo/add_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: add_tries.c,v 1.10 2010/12/19 01:31:14 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))
@@ -50,8 +50,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
TRIES *ptr, *savedptr;
unsigned const char *txt = (unsigned const char *) str;
- T((T_CALLED("_nc_add_to_try(%p, %s, %u)"),
- (void *) *tree, _nc_visbuf(str), code));
+ T((T_CALLED("_nc_add_to_try(%p, %s, %u)"), *tree, _nc_visbuf(str), code));
if (txt == 0 || *txt == '\0' || code == 0)
returnCode(ERR);
@@ -67,7 +66,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
if (CMP_TRY(ptr->ch, cmp)) {
if (*(++txt) == '\0') {
- ptr->value = (unsigned short) code;
+ ptr->value = code;
returnCode(OK);
}
if (ptr->child != 0)
@@ -116,6 +115,6 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
ptr->value = 0;
}
- ptr->value = (unsigned short) code;
+ ptr->value = code;
returnCode(OK);
}
diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c
index 506fb386d208..4638e99c4d58 100644
--- a/ncurses/tinfo/alloc_entry.c
+++ b/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -46,8 +46,9 @@
#include <curses.priv.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: alloc_entry.c,v 1.51 2010/12/25 23:06:01 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.48 2008/08/16 16:25:31 tom Exp $")
#define ABSENT_OFFSET -1
#define CANCELLED_OFFSET -2
@@ -64,10 +65,8 @@ _nc_init_entry(TERMTYPE *const tp)
unsigned i;
#if NO_LEAKS
- if (tp == 0) {
- if (stringbuf != 0) {
- FreeAndNull(stringbuf);
- }
+ if (tp == 0 && stringbuf != 0) {
+ FreeAndNull(stringbuf);
return;
}
#endif
@@ -182,7 +181,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
} else if (tp->Strings[i] == CANCELLED_STRING) {
offsets[i] = CANCELLED_OFFSET;
} else {
- offsets[i] = (int) (tp->Strings[i] - stringbuf);
+ offsets[i] = tp->Strings[i] - stringbuf;
}
}
}
@@ -191,7 +190,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
if (ep->uses[i].name == 0)
useoffsets[i] = ABSENT_OFFSET;
else
- useoffsets[i] = (int) (ep->uses[i].name - stringbuf);
+ useoffsets[i] = ep->uses[i].name - stringbuf;
}
if ((tp->str_table = typeMalloc(char, next_free)) == (char *) 0)
@@ -215,10 +214,10 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
if (!copy_strings) {
if ((n = (unsigned) NUM_EXT_NAMES(tp)) != 0) {
if (n < SIZEOF(offsets)) {
- size_t length = 0;
+ unsigned length = 0;
for (i = 0; i < n; i++) {
length += strlen(tp->ext_Names[i]) + 1;
- offsets[i] = (int) (tp->ext_Names[i] - stringbuf);
+ offsets[i] = tp->ext_Names[i] - stringbuf;
}
if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
_nc_err_abort(MSG_NO_MEMORY);
diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c
index b02cb9c6010e..b2b06d1b79ce 100644
--- a/ncurses/tinfo/alloc_ttype.c
+++ b/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,8 +41,9 @@
#include <curses.priv.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.22 2010/12/19 00:24:09 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.17 2008/10/12 16:12:00 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -90,9 +91,6 @@ find_name(char **table, int length, char *name)
return FALSE;
}
-#define EXTEND_NUM(num, ext) \
- to->num = (unsigned short) (to->num + (ext - to->ext))
-
static void
realign_data(TERMTYPE *to, char **ext_Names,
int ext_Booleans,
@@ -103,7 +101,7 @@ realign_data(TERMTYPE *to, char **ext_Names,
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
if (to->ext_Booleans != ext_Booleans) {
- EXTEND_NUM(num_Booleans, ext_Booleans);
+ to->num_Booleans += (ext_Booleans - to->ext_Booleans);
to->Booleans = typeRealloc(NCURSES_SBOOL, to->num_Booleans, to->Booleans);
for (n = to->ext_Booleans - 1,
m = ext_Booleans - 1,
@@ -114,10 +112,10 @@ realign_data(TERMTYPE *to, char **ext_Names,
to->Booleans[base + m] = FALSE;
}
}
- to->ext_Booleans = UShort(ext_Booleans);
+ to->ext_Booleans = ext_Booleans;
}
if (to->ext_Numbers != ext_Numbers) {
- EXTEND_NUM(num_Numbers, ext_Numbers);
+ to->num_Numbers += (ext_Numbers - to->ext_Numbers);
to->Numbers = typeRealloc(short, to->num_Numbers, to->Numbers);
for (n = to->ext_Numbers - 1,
m = ext_Numbers - 1,
@@ -128,10 +126,10 @@ realign_data(TERMTYPE *to, char **ext_Names,
to->Numbers[base + m] = ABSENT_NUMERIC;
}
}
- to->ext_Numbers = UShort(ext_Numbers);
+ to->ext_Numbers = ext_Numbers;
}
if (to->ext_Strings != ext_Strings) {
- EXTEND_NUM(num_Strings, ext_Strings);
+ to->num_Strings += (ext_Strings - to->ext_Strings);
to->Strings = typeRealloc(char *, to->num_Strings, to->Strings);
for (n = to->ext_Strings - 1,
m = ext_Strings - 1,
@@ -142,17 +140,17 @@ realign_data(TERMTYPE *to, char **ext_Names,
to->Strings[base + m] = ABSENT_STRING;
}
}
- to->ext_Strings = UShort(ext_Strings);
+ to->ext_Strings = ext_Strings;
}
}
/*
* Returns the first index in ext_Names[] for the given token-type
*/
-static unsigned
+static int
_nc_first_ext_name(TERMTYPE *tp, int token_type)
{
- unsigned first;
+ int first;
switch (token_type) {
case BOOLEAN:
@@ -162,7 +160,7 @@ _nc_first_ext_name(TERMTYPE *tp, int token_type)
first = tp->ext_Booleans;
break;
case STRING:
- first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
+ first = tp->ext_Booleans + tp->ext_Numbers;
break;
default:
first = 0;
@@ -174,17 +172,17 @@ _nc_first_ext_name(TERMTYPE *tp, int token_type)
/*
* Returns the last index in ext_Names[] for the given token-type
*/
-static unsigned
+static int
_nc_last_ext_name(TERMTYPE *tp, int token_type)
{
- unsigned last;
+ int last;
switch (token_type) {
case BOOLEAN:
last = tp->ext_Booleans;
break;
case NUMBER:
- last = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
+ last = tp->ext_Booleans + tp->ext_Numbers;
break;
default:
case STRING:
@@ -206,7 +204,7 @@ _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
for (j = first; j < last; j++) {
if (!strcmp(name, tp->ext_Names[j])) {
- return (int) j;
+ return j;
}
}
return -1;
@@ -246,7 +244,7 @@ _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
int first, last;
if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) {
- last = (int) NUM_EXT_NAMES(tp) - 1;
+ last = NUM_EXT_NAMES(tp) - 1;
for (j = first; j < last; j++) {
tp->ext_Names[j] = tp->ext_Names[j + 1];
}
@@ -256,22 +254,22 @@ _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
last = tp->num_Booleans - 1;
for (j = first; j < last; j++)
tp->Booleans[j] = tp->Booleans[j + 1];
- tp->ext_Booleans--;
- tp->num_Booleans--;
+ tp->ext_Booleans -= 1;
+ tp->num_Booleans -= 1;
break;
case NUMBER:
last = tp->num_Numbers - 1;
for (j = first; j < last; j++)
tp->Numbers[j] = tp->Numbers[j + 1];
- tp->ext_Numbers--;
- tp->num_Numbers--;
+ tp->ext_Numbers -= 1;
+ tp->num_Numbers -= 1;
break;
case STRING:
last = tp->num_Strings - 1;
for (j = first; j < last; j++)
tp->Strings[j] = tp->Strings[j + 1];
- tp->ext_Strings--;
- tp->num_Strings--;
+ tp->ext_Strings -= 1;
+ tp->num_Strings -= 1;
break;
}
return TRUE;
@@ -305,32 +303,32 @@ _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
for (k = total - 1; k > j; k--)
tp->ext_Names[k] = tp->ext_Names[k - 1];
tp->ext_Names[j] = name;
- j = (unsigned) _nc_ext_data_index(tp, (int) j, token_type);
+ j = _nc_ext_data_index(tp, (int) j, token_type);
switch (token_type) {
case BOOLEAN:
- tp->ext_Booleans++;
- tp->num_Booleans++;
+ tp->ext_Booleans += 1;
+ tp->num_Booleans += 1;
tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
- for (k = (unsigned) (tp->num_Booleans - 1); k > j; k--)
+ for (k = tp->num_Booleans - 1; k > j; k--)
tp->Booleans[k] = tp->Booleans[k - 1];
break;
case NUMBER:
- tp->ext_Numbers++;
- tp->num_Numbers++;
+ tp->ext_Numbers += 1;
+ tp->num_Numbers += 1;
tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
- for (k = (unsigned) (tp->num_Numbers - 1); k > j; k--)
+ for (k = tp->num_Numbers - 1; k > j; k--)
tp->Numbers[k] = tp->Numbers[k - 1];
break;
case STRING:
- tp->ext_Strings++;
- tp->num_Strings++;
+ tp->ext_Strings += 1;
+ tp->num_Strings += 1;
tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
- for (k = (unsigned) (tp->num_Strings - 1); k > j; k--)
+ for (k = tp->num_Strings - 1; k > j; k--)
tp->Strings[k] = tp->Strings[k - 1];
break;
}
- return (int) j;
+ return j;
}
/*
@@ -347,10 +345,10 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
for (j = first; j < last;) {
char *name = to->ext_Names[j];
- int j_str = to->num_Strings - first - to->ext_Strings;
+ unsigned j_str = to->num_Strings - first - to->ext_Strings;
if (to->Strings[j + j_str] == CANCELLED_STRING) {
- if (_nc_find_ext_name(from, to->ext_Names[j], BOOLEAN) >= 0) {
+ if ((k = _nc_find_ext_name(from, to->ext_Names[j], BOOLEAN)) >= 0) {
if (_nc_del_ext_name(to, name, STRING)
|| _nc_del_ext_name(to, name, NUMBER)) {
k = _nc_ins_ext_name(to, name, BOOLEAN);
@@ -358,7 +356,8 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
} else {
j++;
}
- } else if (_nc_find_ext_name(from, to->ext_Names[j], NUMBER) >= 0) {
+ } else if ((k = _nc_find_ext_name(from, to->ext_Names[j],
+ NUMBER)) >= 0) {
if (_nc_del_ext_name(to, name, STRING)
|| _nc_del_ext_name(to, name, BOOLEAN)) {
k = _nc_ins_ext_name(to, name, NUMBER);
@@ -366,7 +365,8 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
} else {
j++;
}
- } else if (_nc_find_ext_name(from, to->ext_Names[j], STRING) >= 0) {
+ } else if ((k = _nc_find_ext_name(from, to->ext_Names[j],
+ STRING)) >= 0) {
if (_nc_del_ext_name(to, name, NUMBER)
|| _nc_del_ext_name(to, name, BOOLEAN)) {
k = _nc_ins_ext_name(to, name, STRING);
@@ -386,8 +386,8 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
NCURSES_EXPORT(void)
_nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
{
- int na = (int) NUM_EXT_NAMES(to);
- int nb = (int) NUM_EXT_NAMES(from);
+ int na = NUM_EXT_NAMES(to);
+ int nb = NUM_EXT_NAMES(from);
int n;
bool same;
char **ext_Names;
@@ -417,7 +417,7 @@ _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
* into it, updating to's counts for booleans, etc. Fortunately we do
* this only for the terminfo compiler (tic) and comparer (infocmp).
*/
- ext_Names = typeMalloc(char *, (size_t)(na + nb));
+ ext_Names = typeMalloc(char *, na + nb);
if (to->ext_Strings && (from->ext_Booleans + from->ext_Numbers))
adjust_cancels(to, from);
@@ -461,8 +461,8 @@ _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
realign_data(from, ext_Names, ext_Booleans, ext_Numbers, ext_Strings);
- from->ext_Names = typeRealloc(char *, (size_t) nb, from->ext_Names);
- memcpy(from->ext_Names, ext_Names, sizeof(char *) * (size_t) nb);
+ from->ext_Names = typeRealloc(char *, nb, from->ext_Names);
+ memcpy(from->ext_Names, ext_Names, sizeof(char *) * nb);
DEBUG(2, ("realigned %d extended names for '%s' (from)",
NUM_EXT_NAMES(from), from->term_names));
}
diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c
index a0da44dea989..93300c1be3e4 100644
--- a/ncurses/tinfo/captoinfo.c
+++ b/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -93,7 +93,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: captoinfo.c,v 1.58 2010/12/04 20:08:19 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.52 2008/08/16 19:24:51 tom Exp $")
#define MAX_PUSHED 16 /* max # args we can push onto the stack */
@@ -125,10 +125,10 @@ init_string(void)
static char *
save_string(char *d, const char *const s)
{
- size_t have = (size_t) (d - my_string);
+ size_t have = (d - my_string);
size_t need = have + strlen(s) + 2;
if (need > my_length) {
- my_string = (char *) _nc_doalloc(my_string, my_length = (need + need));
+ my_string = (char *) realloc(my_string, my_length = (need + need));
if (my_string == 0)
_nc_err_abort(MSG_NO_MEMORY);
d = my_string + have;
@@ -196,7 +196,7 @@ cvtchar(register const char *sp)
case '3':
len = 1;
while (isdigit(UChar(*sp))) {
- c = (unsigned char) (8 * c + (*sp++ - '0'));
+ c = 8 * c + (*sp++ - '0');
len++;
}
break;
@@ -207,7 +207,7 @@ cvtchar(register const char *sp)
}
break;
case '^':
- c = (unsigned char) (*++sp & 0x1f);
+ c = (*++sp & 0x1f);
len = 2;
break;
default:
@@ -643,7 +643,6 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
const char *padding;
const char *trimmed = 0;
- int in0, in1, in2;
char ch1 = 0, ch2 = 0;
char *bufptr = init_string();
int len;
@@ -667,27 +666,8 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
int c1, c2;
char *cp = 0;
- if (str[0] == '^') {
- if (str[1] == '\0' || (str + 1) == trimmed) {
- bufptr = save_string(bufptr, "\\136");
- ++str;
- } else {
- bufptr = save_char(bufptr, *str++);
- bufptr = save_char(bufptr, *str);
- }
- } else if (str[0] == '\\') {
- if (str[1] == '\0' || (str + 1) == trimmed) {
- bufptr = save_string(bufptr, "\\134");
- ++str;
- } else if (str[1] == '^') {
- bufptr = save_string(bufptr, "\\136");
- ++str;
- } else if (str[1] == ',') {
- bufptr = save_char(bufptr, *++str);
- } else {
- bufptr = save_char(bufptr, *str++);
- bufptr = save_char(bufptr, *str);
- }
+ if (str[0] == '\\' && (str[1] == '^' || str[1] == ',')) {
+ bufptr = save_char(bufptr, *++str);
} else if (str[0] == '$' && str[1] == '<') { /* discard padding */
str += 2;
while (isdigit(UChar(*str))
@@ -697,19 +677,6 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
|| *str == '>')
str++;
--str;
- } else if (sscanf(str,
- "[%%?%%p1%%{8}%%<%%t%d%%p1%%d%%e%%p1%%{16}%%<%%t%d%%p1%%{8}%%-%%d%%e%d;5;%%p1%%d%%;m",
- &in0, &in1, &in2) == 3
- && ((in0 == 4 && in1 == 10 && in2 == 48)
- || (in0 == 3 && in1 == 9 && in2 == 38))) {
- /* dumb-down an optimized case from xterm-256color for termcap */
- str = strstr(str, ";m");
- ++str;
- if (in2 == 48) {
- bufptr = save_string(bufptr, "[48;5;%dm");
- } else {
- bufptr = save_string(bufptr, "[38;5;%dm");
- }
} else if (str[0] == '%' && str[1] == '%') { /* escaped '%' */
bufptr = save_string(bufptr, "%%");
++str;
diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c
index 71012b6355e3..6e79a926b5ac 100644
--- a/ncurses/tinfo/comp_expand.c
+++ b/ncurses/tinfo/comp_expand.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -35,7 +35,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: comp_expand.c,v 1.21 2010/01/16 17:11:23 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.20 2008/08/16 19:29:42 tom Exp $")
static int
trailing_spaces(const char *src)
@@ -91,7 +91,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
&& REALPRINT(str + 1)
&& str[2] == S_QUOTE) {
sprintf(buffer + bufp, "{%d}", str[1]);
- bufp += (int) strlen(buffer + bufp);
+ bufp += strlen(buffer + bufp);
str += 2;
} else {
buffer[bufp++] = *str;
diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c
index 959c6e156431..b7fbd0616345 100644
--- a/ncurses/tinfo/comp_hash.c
+++ b/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -44,36 +44,110 @@
#include <tic.h>
#include <hashsize.h>
-MODULE_ID("$Id: comp_hash.c,v 1.48 2009/08/08 17:36:21 tom Exp $")
+#ifdef MAIN_PROGRAM
+#include <ctype.h>
+#undef DEBUG
+#define DEBUG(level, params) /*nothing */
+#endif
+
+MODULE_ID("$Id: comp_hash.c,v 1.36 2008/08/16 17:06:53 tom Exp $")
+
+static int hash_function(const char *);
/*
- * Finds the entry for the given string in the hash table if present.
- * Returns a pointer to the entry in the table or 0 if not found.
+ * _nc_make_hash_table()
+ *
+ * Takes the entries in table[] and hashes them into hash_table[]
+ * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE
+ * slots in hash_table[].
+ *
*/
-/* entrypoint used by tack (do not alter) */
+
+#ifdef MAIN_PROGRAM
+
+#undef MODULE_ID
+#define MODULE_ID(id) /*nothing */
+#include <tinfo/doalloc.c>
+
+static void
+_nc_make_hash_table(struct name_table_entry *table,
+ short *hash_table)
+{
+ short 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] >= 0)
+ collisions++;
+
+ if (hash_table[hashvalue] != 0)
+ table[i].nte_link = hash_table[hashvalue];
+ hash_table[hashvalue] = i;
+ }
+
+ DEBUG(4, ("Hash table complete: %d collisions out of %d entries",
+ collisions, CAPTABSIZE));
+}
+#endif
+
+/*
+ * int hash_function(string)
+ *
+ * Computes the hashing function on the given string.
+ *
+ * The current hash function is the sum of each consectutive pair
+ * of characters, taken as two-byte integers, mod HASHTABSIZE.
+ *
+ */
+
+static int
+hash_function(const char *string)
+{
+ long sum = 0;
+
+ DEBUG(9, ("hashing %s", string));
+ while (*string) {
+ sum += (long) (*string + (*(string + 1) << 8));
+ string++;
+ }
+
+ DEBUG(9, ("sum is %ld", sum));
+ return (int) (sum % HASHTABSIZE);
+}
+
+/*
+ * struct name_table_entry *
+ * find_entry(string)
+ *
+ * Finds the entry for the given string in the hash table if present.
+ * Returns a pointer to the entry in the table or 0 if not found.
+ *
+ */
+
+#ifndef MAIN_PROGRAM
NCURSES_EXPORT(struct name_table_entry const *)
_nc_find_entry(const char *string,
- const HashValue * hash_table)
+ const short *hash_table)
{
- bool termcap = (hash_table != _nc_get_hash_table(FALSE));
- const HashData *data = _nc_get_hash_info(termcap);
int hashvalue;
struct name_table_entry const *ptr = 0;
struct name_table_entry const *real_table;
- hashvalue = data->hash_of(string);
-
- if (data->table_data[hashvalue] >= 0) {
+ hashvalue = hash_function(string);
- real_table = _nc_get_table(termcap);
- ptr = real_table + data->table_data[hashvalue];
- while (!data->compare_names(ptr->nte_name, string)) {
- if (ptr->nte_link < 0) {
- ptr = 0;
- break;
- }
- ptr = real_table + (ptr->nte_link
- + data->table_data[data->table_size]);
+ 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 = real_table + (ptr->nte_link + hash_table[HASHTABSIZE]);
}
}
@@ -81,34 +155,216 @@ _nc_find_entry(const char *string,
}
/*
- * Finds the entry for the given name with the given type in the given table if
- * present (as distinct from _nc_find_entry, which finds the last entry
- * regardless of type).
+ * struct name_table_entry *
+ * find_type_entry(string, type, table)
*
- * Returns a pointer to the entry in the table or 0 if not found.
+ * Finds the first entry for the given name with the given type in the
+ * given table if present (as distinct from find_entry, which finds the
+ * the last entry regardless of type). You can use this if you detect
+ * a name clash. It's slower, though. Returns a pointer to the entry
+ * in the table or 0 if not found.
*/
+
NCURSES_EXPORT(struct name_table_entry const *)
_nc_find_type_entry(const char *string,
int type,
- bool termcap)
+ const struct name_table_entry *table)
+{
+ struct name_table_entry const *ptr;
+
+ for (ptr = table; ptr < table + CAPTABSIZE; ptr++) {
+ if (ptr->nte_type == type && strcmp(string, ptr->nte_name) == 0)
+ return (ptr);
+ }
+
+ return ((struct name_table_entry *) NULL);
+}
+#endif
+
+#ifdef MAIN_PROGRAM
+/*
+ * This filter reads from standard input a list of tab-delimited columns,
+ * (e.g., from Caps.filtered) computes the hash-value of a specified column and
+ * writes the hashed tables to standard output.
+ *
+ * By compiling the hash table at build time, we're able to make the entire
+ * set of terminfo and termcap tables readonly (and also provide some runtime
+ * performance enhancement).
+ */
+
+#define MAX_COLUMNS BUFSIZ /* this _has_ to be worst-case */
+
+static char **
+parse_columns(char *buffer)
{
- struct name_table_entry const *ptr = NULL;
- const HashData *data = _nc_get_hash_info(termcap);
- int hashvalue = data->hash_of(string);
-
- if (data->table_data[hashvalue] >= 0) {
- const struct name_table_entry *const table = _nc_get_table(termcap);
-
- ptr = table + data->table_data[hashvalue];
- while (ptr->nte_type != type
- || !data->compare_names(ptr->nte_name, string)) {
- if (ptr->nte_link < 0) {
- ptr = 0;
+ static char **list;
+
+ int col = 0;
+
+ if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
+ return (0);
+
+ if (*buffer != '#') {
+ while (*buffer != '\0') {
+ char *s;
+ for (s = buffer; (*s != '\0') && !isspace(UChar(*s)); s++)
+ /*EMPTY */ ;
+ if (s != buffer) {
+ char mark = *s;
+ *s = '\0';
+ if ((s - buffer) > 1
+ && (*buffer == '"')
+ && (s[-1] == '"')) { /* strip the quotes */
+ assert(s > buffer + 1);
+ s[-1] = '\0';
+ buffer++;
+ }
+ list[col] = buffer;
+ col++;
+ if (mark == '\0')
+ break;
+ while (*++s && isspace(UChar(*s)))
+ /*EMPTY */ ;
+ buffer = s;
+ } else
break;
+ }
+ }
+ return col ? list : 0;
+}
+
+int
+main(int argc, char **argv)
+{
+ struct name_table_entry *name_table = typeCalloc(struct
+ name_table_entry, CAPTABSIZE);
+ short *hash_table = typeCalloc(short, HASHTABSIZE);
+ const char *root_name = "";
+ int column = 0;
+ int bigstring = 0;
+ int n;
+ char buffer[BUFSIZ];
+
+ static const char *typenames[] =
+ {"BOOLEAN", "NUMBER", "STRING"};
+
+ short BoolCount = 0;
+ short NumCount = 0;
+ short StrCount = 0;
+
+ /* The first argument is the column-number (starting with 0).
+ * The second is the root name of the tables to generate.
+ */
+ if (argc <= 3
+ || (column = atoi(argv[1])) <= 0
+ || (column >= MAX_COLUMNS)
+ || *(root_name = argv[2]) == 0
+ || (bigstring = atoi(argv[3])) < 0
+ || name_table == 0
+ || hash_table == 0) {
+ fprintf(stderr, "usage: make_hash column root_name bigstring\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Read the table into our arrays.
+ */
+ for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin);) {
+ char **list, *nlp = strchr(buffer, '\n');
+ if (nlp)
+ *nlp = '\0';
+ list = parse_columns(buffer);
+ if (list == 0) /* blank or comment */
+ continue;
+ name_table[n].nte_link = -1; /* end-of-hash */
+ name_table[n].nte_name = strdup(list[column]);
+ if (!strcmp(list[2], "bool")) {
+ name_table[n].nte_type = BOOLEAN;
+ name_table[n].nte_index = BoolCount++;
+ } else if (!strcmp(list[2], "num")) {
+ name_table[n].nte_type = NUMBER;
+ name_table[n].nte_index = NumCount++;
+ } else if (!strcmp(list[2], "str")) {
+ name_table[n].nte_type = STRING;
+ name_table[n].nte_index = StrCount++;
+ } else {
+ fprintf(stderr, "Unknown type: %s\n", list[2]);
+ exit(EXIT_FAILURE);
+ }
+ n++;
+ }
+ _nc_make_hash_table(name_table, hash_table);
+
+ /*
+ * Write the compiled tables to standard output
+ */
+ if (bigstring) {
+ int len = 0;
+ int nxt;
+
+ printf("static const char %s_names_text[] = \\\n", root_name);
+ for (n = 0; n < CAPTABSIZE; n++) {
+ nxt = (int) strlen(name_table[n].nte_name) + 5;
+ if (nxt + len > 72) {
+ printf("\\\n");
+ len = 0;
}
- ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
+ 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 += (int) 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("static const short _nc_%s_hash_table[%d] =\n",
+ root_name,
+ HASHTABSIZE + 1);
+ printf("{\n");
+ for (n = 0; n < HASHTABSIZE; n++) {
+ printf("\t%3d,\n", hash_table[n]);
}
+ printf("\t0\t/* base-of-table */\n");
+ printf("};\n\n");
+
+ printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
+ BoolCount, NumCount, StrCount);
+ printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
+ printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
+ printf("#endif\n\n");
- return ptr;
+ free(hash_table);
+ return EXIT_SUCCESS;
}
+#endif
diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c
index 8204d75a8193..3325a0ddae6c 100644
--- a/ncurses/tinfo/comp_parse.c
+++ b/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -51,8 +51,9 @@
#include <ctype.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.73 2010/12/25 23:06:37 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.69 2008/08/16 21:58:16 tom Exp $")
static void sanity_check2(TERMTYPE *, bool);
NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
@@ -91,18 +92,16 @@ force_bar(char *dst, char *src)
}
return src;
}
-#define ForceBar(dst, src) ((strchr(src, '|') == 0) ? force_bar(dst, src) : src)
NCURSES_EXPORT(bool)
_nc_entry_match(char *n1, char *n2)
/* do any of the aliases in a pair of terminal names match? */
{
char *pstart, *qstart, *pend, *qend;
- char nc1[MAX_NAME_SIZE + 2];
- char nc2[MAX_NAME_SIZE + 2];
+ char nc1[MAX_NAME_SIZE + 2], nc2[MAX_NAME_SIZE + 2];
- n1 = ForceBar(nc1, n1);
- n2 = ForceBar(nc2, n2);
+ n1 = force_bar(nc1, n1);
+ n2 = force_bar(nc2, n2);
for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1)
for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1)
@@ -274,7 +273,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
unresolved++;
total_unresolved++;
- _nc_curr_line = (int) lookline;
+ _nc_curr_line = lookline;
_nc_warning("resolution of use=%s failed", lookfor);
qp->uses[i].link = 0;
}
@@ -376,7 +375,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
if (_nc_check_termtype != 0) {
_nc_curr_col = -1;
for_entry_list(qp) {
- _nc_curr_line = (int) qp->startline;
+ _nc_curr_line = qp->startline;
_nc_set_type(_nc_first_name(qp->tterm.term_names));
_nc_check_termtype2(&qp->tterm, literal);
}
@@ -474,6 +473,7 @@ _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();
diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c
index 8725b2edb7eb..5ad750f930dd 100644
--- a/ncurses/tinfo/comp_scan.c
+++ b/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -48,9 +48,10 @@
#include <curses.priv.h>
#include <ctype.h>
+#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.89 2010/12/25 23:06:37 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.83 2008/08/16 19:22:55 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -60,13 +61,19 @@ MODULE_ID("$Id: comp_scan.c,v 1.89 2010/12/25 23:06:37 tom Exp $")
#define iswhite(ch) (ch == ' ' || ch == '\t')
-NCURSES_EXPORT_VAR (int) _nc_syntax = 0; /* termcap or terminfo? */
-NCURSES_EXPORT_VAR (long) _nc_curr_file_pos = 0; /* file offset of current line */
-NCURSES_EXPORT_VAR (long) _nc_comment_start = 0; /* start of comment range before name */
-NCURSES_EXPORT_VAR (long) _nc_comment_end = 0; /* end of comment range before name */
-NCURSES_EXPORT_VAR (long) _nc_start_line = 0; /* start line of current entry */
-
-NCURSES_EXPORT_VAR (struct token) _nc_curr_token =
+NCURSES_EXPORT_VAR(int)
+_nc_syntax = 0; /* termcap or terminfo? */
+NCURSES_EXPORT_VAR(long)
+_nc_curr_file_pos = 0; /* file offset of current line */
+NCURSES_EXPORT_VAR(long)
+_nc_comment_start = 0; /* start of comment range before name */
+NCURSES_EXPORT_VAR(long)
+_nc_comment_end = 0; /* end of comment range before name */
+NCURSES_EXPORT_VAR(long)
+_nc_start_line = 0; /* start line of current entry */
+
+NCURSES_EXPORT_VAR(struct token)
+_nc_curr_token =
{
0, 0, 0
};
@@ -84,7 +91,8 @@ static int pushtype; /* type of pushback token */
static char *pushname;
#if NCURSES_EXT_FUNCS
-NCURSES_EXPORT_VAR (bool) _nc_disable_period = FALSE; /* used by tic -a option */
+NCURSES_EXPORT_VAR(bool)
+_nc_disable_period = FALSE; /* used by tic -a option */
#endif
/*****************************************************************************
@@ -203,10 +211,6 @@ next_char(void)
if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
bufstart = result;
if (used == 0) {
- if (_nc_curr_line == 0
- && IS_TIC_MAGIC(result)) {
- _nc_err_abort("This is a compiled terminal description, not a source");
- }
_nc_curr_line++;
_nc_curr_col = 0;
}
@@ -427,7 +431,7 @@ _nc_get_token(bool silent)
&& !strchr(terminfo_punct, (char) ch)) {
if (!silent)
_nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
- terminfo_punct, unctrl(UChar(ch)));
+ terminfo_punct, unctrl((chtype) ch));
_nc_panic_mode(separator);
goto start_token;
}
@@ -483,6 +487,7 @@ _nc_get_token(bool silent)
if (OkToAdd()) {
AddCh(ch);
} else {
+ ch = EOF;
break;
}
}
@@ -591,7 +596,7 @@ _nc_get_token(bool silent)
case '@':
if ((ch = next_char()) != separator && !silent)
_nc_warning("Missing separator after `%s', have %s",
- tok_buf, unctrl(UChar(ch)));
+ tok_buf, unctrl((chtype) ch));
_nc_curr_token.tk_name = tok_buf;
type = CANCEL;
break;
@@ -612,7 +617,7 @@ _nc_get_token(bool silent)
_nc_warning("Missing separator");
}
_nc_curr_token.tk_name = tok_buf;
- _nc_curr_token.tk_valnumber = (int) number;
+ _nc_curr_token.tk_valnumber = number;
type = NUMBER;
break;
@@ -632,7 +637,7 @@ _nc_get_token(bool silent)
/* just to get rid of the compiler warning */
type = UNDEF;
if (!silent)
- _nc_warning("Illegal character - '%s'", unctrl(UChar(ch)));
+ _nc_warning("Illegal character - '%s'", unctrl((chtype) ch));
}
} /* end else (first_column == FALSE) */
} /* end else (ch != EOF) */
@@ -725,47 +730,48 @@ _nc_trans_string(char *ptr, char *last)
int count = 0;
int number = 0;
int i, c;
- int last_ch = '\0';
+ chtype ch, last_ch = '\0';
bool ignored = FALSE;
bool long_warning = FALSE;
- while ((c = next_char()) != separator && c != EOF) {
+ while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
if (ptr >= (last - 1)) {
if (c != EOF) {
while ((c = next_char()) != separator && c != EOF) {
;
}
+ ch = c;
}
break;
}
if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
break;
- if (c == '^' && last_ch != '%') {
- c = next_char();
+ if (ch == '^' && last_ch != '%') {
+ ch = c = next_char();
if (c == EOF)
_nc_err_abort(MSG_NO_INPUTS);
- if (!(is7bits(c) && isprint(c))) {
- _nc_warning("Illegal ^ character - '%s'", unctrl(UChar(c)));
+ if (!(is7bits(ch) && isprint(ch))) {
+ _nc_warning("Illegal ^ character - '%s'", unctrl(ch));
}
- if (c == '?') {
+ if (ch == '?') {
*(ptr++) = '\177';
if (_nc_tracing)
_nc_warning("Allow ^? as synonym for \\177");
} else {
- if ((c &= 037) == 0)
- c = 128;
- *(ptr++) = (char) (c);
+ if ((ch &= 037) == 0)
+ ch = 128;
+ *(ptr++) = (char) (ch);
}
- } else if (c == '\\') {
- c = next_char();
+ } else if (ch == '\\') {
+ ch = c = next_char();
if (c == EOF)
_nc_err_abort(MSG_NO_INPUTS);
- if (c >= '0' && c <= '7') {
- number = c - '0';
+ if (ch >= '0' && ch <= '7') {
+ number = ch - '0';
for (i = 0; i < 2; i++) {
- c = next_char();
+ ch = c = next_char();
if (c == EOF)
_nc_err_abort(MSG_NO_INPUTS);
@@ -842,31 +848,31 @@ _nc_trans_string(char *ptr, char *last)
default:
_nc_warning("Illegal character '%s' in \\ sequence",
- unctrl(UChar(c)));
+ unctrl(ch));
/* FALLTHRU */
case '|':
- *(ptr++) = (char) c;
- } /* endswitch (c) */
- } /* endelse (c < '0' || c > '7') */
+ *(ptr++) = (char) ch;
+ } /* endswitch (ch) */
+ } /* endelse (ch < '0' || ch > '7') */
}
- /* end else if (c == '\\') */
- else if (c == '\n' && (_nc_syntax == SYN_TERMINFO)) {
+ /* end else if (ch == '\\') */
+ else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
/*
* Newlines embedded in a terminfo string are ignored, provided
* that the next line begins with whitespace.
*/
ignored = TRUE;
} else {
- *(ptr++) = (char) c;
+ *(ptr++) = (char) ch;
}
if (!ignored) {
if (_nc_curr_col <= 1) {
- push_back((char) c);
- c = '\n';
+ push_back((char) ch);
+ ch = '\n';
break;
}
- last_ch = c;
+ last_ch = ch;
count++;
}
ignored = FALSE;
@@ -879,7 +885,7 @@ _nc_trans_string(char *ptr, char *last)
*ptr = '\0';
- return (c);
+ return (ch);
}
/*
diff --git a/ncurses/tinfo/db_iterator.c b/ncurses/tinfo/db_iterator.c
index 82665cb54be6..fdc2bb09eadc 100644
--- a/ncurses/tinfo/db_iterator.c
+++ b/ncurses/tinfo/db_iterator.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2006-2007,2010 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 *
@@ -38,7 +38,7 @@
#include <tic.h>
-MODULE_ID("$Id: db_iterator.c,v 1.9 2010/12/25 23:00:25 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.6 2007/04/22 00:00:26 tom Exp $")
#define HaveTicDirectory _nc_globals.have_tic_directory
#define KeepTicDirectory _nc_globals.keep_tic_directory
@@ -104,7 +104,7 @@ next_list_item(const char *source, int *offset)
if (source != 0) {
FreeIfNeeded(ThisDbList);
ThisDbList = strdup(source);
- ThisDbSize = (int) strlen(source);
+ ThisDbSize = strlen(source);
}
if (ThisDbList != 0 && ThisDbSize && *offset < ThisDbSize) {
@@ -118,10 +118,11 @@ next_list_item(const char *source, int *offset)
* again, using the data at the offset.
*/
if (marker == 0) {
- *offset += (int) strlen(result);
+ *offset += strlen(result) + 1;
+ marker = result + *offset;
} else {
*marker++ = 0;
- *offset = (int) (marker - ThisDbList);
+ *offset = marker - ThisDbList;
}
if (*result == 0 && result != (ThisDbList + ThisDbSize))
result = system_db;
diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c
index b1e14a803f31..cf2a8337b870 100644
--- a/ncurses/tinfo/entries.c
+++ b/ncurses/tinfo/entries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2006-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2006-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -28,7 +28,6 @@
/****************************************************************************
* Author: Thomas E. Dickey *
- * and: Juergen Pfeifer *
****************************************************************************/
#include <curses.priv.h>
@@ -36,8 +35,9 @@
#include <ctype.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: entries.c,v 1.17 2010/01/23 17:57:43 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.8 2008/09/27 13:11:10 tom Exp $")
/****************************************************************************
*
@@ -119,12 +119,6 @@ _nc_leaks_tinfo(void)
#if NO_LEAKS
_nc_free_tparm();
_nc_tgetent_leaks();
-
- if (TerminalOf(CURRENT_SCREEN) != 0) {
- del_curterm(TerminalOf(CURRENT_SCREEN));
- }
-
- _nc_comp_captab_leaks();
_nc_free_entries(_nc_head);
_nc_get_type(0);
_nc_first_name(0);
@@ -137,12 +131,6 @@ _nc_leaks_tinfo(void)
if ((s = _nc_home_terminfo()) != 0)
free(s);
-
-#ifdef TRACE
- trace(0);
- _nc_trace_buf(-1, 0);
-#endif
-
#endif /* NO_LEAKS */
returnVoid;
}
diff --git a/ncurses/tinfo/free_ttype.c b/ncurses/tinfo/free_ttype.c
index ad056ba4545b..fa0fff1b83fb 100644
--- a/ncurses/tinfo/free_ttype.c
+++ b/ncurses/tinfo/free_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-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 *
@@ -41,8 +41,9 @@
#include <curses.priv.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: free_ttype.c,v 1.15 2011/02/06 01:08:31 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.13 2006/06/25 10:46:02 tom Exp $")
NCURSES_EXPORT(void)
_nc_free_termtype(TERMTYPE *ptr)
@@ -69,7 +70,6 @@ use_extended_names(bool flag)
{
int oldflag = _nc_user_definable;
- START_TRACE();
T((T_CALLED("use_extended_names(%d)"), flag));
_nc_user_definable = flag;
returnBool(oldflag);
diff --git a/ncurses/tinfo/hashed_db.c b/ncurses/tinfo/hashed_db.c
index bf7a968ee96d..3fc04eae3cca 100644
--- a/ncurses/tinfo/hashed_db.c
+++ b/ncurses/tinfo/hashed_db.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2006,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 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 2006-on *
+ * Author: Thomas E. Dickey 2006 *
****************************************************************************/
#include <curses.priv.h>
@@ -36,7 +36,7 @@
#if USE_HASHED_DB
-MODULE_ID("$Id: hashed_db.c,v 1.14 2008/12/13 20:59:02 tom Exp $")
+MODULE_ID("$Id: hashed_db.c,v 1.13 2006/08/19 19:48:38 tom Exp $")
#if HASHED_DB_API >= 2
static DBC *cursor;
@@ -49,30 +49,27 @@ NCURSES_EXPORT(DB *)
_nc_db_open(const char *path, bool modify)
{
DB *result = 0;
- int code;
#if HASHED_DB_API >= 4
db_create(&result, NULL, 0);
- if ((code = result->open(result,
- NULL,
- path,
- NULL,
- DB_HASH,
- modify ? DB_CREATE : DB_RDONLY,
- 0644)) != 0) {
- result = 0;
- }
+ result->open(result,
+ NULL,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
#elif HASHED_DB_API >= 3
db_create(&result, NULL, 0);
- if ((code = result->open(result,
- path,
- NULL,
- DB_HASH,
- modify ? DB_CREATE : DB_RDONLY,
- 0644)) != 0) {
- result = 0;
- }
+ result->open(result,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
#elif HASHED_DB_API >= 2
+ int code;
+
if ((code = db_open(path,
DB_HASH,
modify ? DB_CREATE : DB_RDONLY,
@@ -80,22 +77,21 @@ _nc_db_open(const char *path, bool modify)
(DB_ENV *) 0,
(DB_INFO *) 0,
&result)) != 0) {
+ T(("cannot open %s: %s", path, strerror(code)));
result = 0;
+ } else {
+ T(("opened %s", path));
}
#else
- if ((result = dbopen(path,
- modify ? (O_CREAT | O_RDWR) : O_RDONLY,
- 0644,
- DB_HASH,
- NULL)) == 0) {
- code = errno;
- }
-#endif
+ result = dbopen(path,
+ modify ? (O_CREAT | O_RDWR) : O_RDONLY,
+ 0644,
+ DB_HASH,
+ NULL);
if (result != 0) {
T(("opened %s", path));
- } else {
- T(("cannot open %s: %s", path, strerror(code)));
}
+#endif
return result;
}
diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c
index 69d69f95bf7c..4521c4a8da68 100644
--- a/ncurses/tinfo/home_terminfo.c
+++ b/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.12 2010/12/25 23:43:58 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.11 2008/08/03 23:43:11 tom Exp $")
/* ncurses extension...fall back on user's private directory */
@@ -53,7 +53,7 @@ _nc_home_terminfo(void)
if (use_terminfo_vars()) {
if (MyBuffer == 0) {
if ((home = getenv("HOME")) != 0) {
- size_t want = (strlen(home) + sizeof(PRIVATE_INFO));
+ unsigned want = (strlen(home) + sizeof(PRIVATE_INFO));
MyBuffer = typeMalloc(char, want);
if (MyBuffer == 0)
_nc_err_abort(MSG_NO_MEMORY);
diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c
index ea47b382b493..2f6fe4f6fad7 100644
--- a/ncurses/tinfo/init_keytry.c
+++ b/ncurses/tinfo/init_keytry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -27,9 +27,16 @@
****************************************************************************/
#include <curses.priv.h>
+
+#include <term.h>
+/* keypad_xmit, keypad_local, meta_on, meta_off */
+/* cursor_visible,cursor_normal,cursor_invisible */
+
#include <tic.h> /* struct tinfo_fkeys */
-MODULE_ID("$Id: init_keytry.c,v 1.17 2010/04/24 22:29:56 tom Exp $")
+#include <term_entry.h>
+
+MODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $")
/*
** _nc_init_keytry()
@@ -43,7 +50,7 @@ MODULE_ID("$Id: init_keytry.c,v 1.17 2010/04/24 22:29:56 tom Exp $")
* than cur_term.
*/
#undef CUR
-#define CUR SP_TERMTYPE
+#define CUR (sp->_term)->type.
#if BROKEN_LINKER
#undef _nc_tinfo_fkeys
@@ -66,7 +73,7 @@ _nc_tinfo_fkeysf(void)
NCURSES_EXPORT(void)
_nc_init_keytry(SCREEN *sp)
{
- unsigned n;
+ size_t n;
/* The sp->_keytry value is initialized in newterm(), where the sp
* structure is created, because we can not tell where keypad() or
@@ -90,13 +97,12 @@ _nc_init_keytry(SCREEN *sp)
{
TERMTYPE *tp = &(sp->_term->type);
for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
- const char *name = ExtStrname(tp, (int) n, strnames);
+ const char *name = ExtStrname(tp, n, strnames);
char *value = tp->Strings[n];
if (name != 0
&& *name == 'k'
&& value != 0
- && NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx
- value) == 0) {
+ && key_defined(value) == 0) {
(void) _nc_add_to_try(&(sp->_keytry),
value,
n - STRCOUNT + KEY_MAX);
diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c
index d8fdedca843f..919e47287a7b 100644
--- a/ncurses/tinfo/lib_acs.c
+++ b/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,21 +30,17 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2008 *
****************************************************************************/
#include <curses.priv.h>
+#include <term.h> /* ena_acs, acs_chars */
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
-
-MODULE_ID("$Id: lib_acs.c,v 1.43 2010/12/25 23:00:45 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.36 2008/08/16 19:22:55 tom Exp $")
#if BROKEN_LINKER || USE_REENTRANT
#define MyBuffer _nc_prescreen.real_acs_map
-NCURSES_EXPORT(chtype *)
-NCURSES_PUBLIC_VAR(acs_map) (void)
+NCURSES_EXPORT_VAR(chtype *)
+_nc_acs_map(void)
{
if (MyBuffer == 0)
MyBuffer = typeCalloc(chtype, ACS_LEN);
@@ -52,35 +48,17 @@ NCURSES_PUBLIC_VAR(acs_map) (void)
}
#undef MyBuffer
#else
-NCURSES_EXPORT_VAR (chtype) acs_map[ACS_LEN] =
+NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] =
{
0
};
#endif
-#ifdef USE_TERM_DRIVER
-NCURSES_EXPORT(chtype)
-NCURSES_SP_NAME(_nc_acs_char) (NCURSES_SP_DCLx int c)
-{
- chtype *map;
- if (c < 0 || c >= ACS_LEN)
- return (chtype) 0;
- map = (SP_PARM != 0) ? SP_PARM->_acs_map :
-#if BROKEN_LINKER || USE_REENTRANT
- _nc_prescreen.real_acs_map
-#else
- acs_map
-#endif
- ;
- return map[c];
-}
-#endif /* USE_TERM_DRIVER */
-
NCURSES_EXPORT(void)
-NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
+_nc_init_acs(void)
{
chtype *fake_map = acs_map;
- chtype *real_map = SP_PARM != 0 ? SP_PARM->_acs_map : fake_map;
+ chtype *real_map = SP != 0 ? SP->_acs_map : fake_map;
int j;
T(("initializing ACS map"));
@@ -93,9 +71,9 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
if (real_map != fake_map) {
for (j = 1; j < ACS_LEN; ++j) {
real_map[j] = 0;
- fake_map[j] = A_ALTCHARSET | (chtype) j;
- if (SP_PARM)
- SP_PARM->_screen_acs_map[j] = FALSE;
+ fake_map[j] = A_ALTCHARSET | j;
+ if (SP)
+ SP->_screen_acs_map[j] = FALSE;
}
} else {
for (j = 1; j < ACS_LEN; ++j) {
@@ -140,34 +118,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
real_map['{'] = '*'; /* should be greek pi */
real_map['|'] = '!'; /* should be not-equal */
real_map['}'] = 'f'; /* should be pound-sterling symbol */
- /* thick-line-drawing */
- real_map['L'] = '+'; /* upper left corner */
- real_map['M'] = '+'; /* lower left corner */
- real_map['K'] = '+'; /* upper right corner */
- real_map['J'] = '+'; /* lower right corner */
- real_map['T'] = '+'; /* tee pointing left */
- real_map['U'] = '+'; /* tee pointing right */
- real_map['V'] = '+'; /* tee pointing up */
- real_map['W'] = '+'; /* tee pointing down */
- real_map['Q'] = '-'; /* horizontal line */
- real_map['X'] = '|'; /* vertical line */
- real_map['N'] = '+'; /* large plus or crossover */
- /* double-line-drawing */
- real_map['C'] = '+'; /* upper left corner */
- real_map['D'] = '+'; /* lower left corner */
- real_map['B'] = '+'; /* upper right corner */
- real_map['A'] = '+'; /* lower right corner */
- real_map['G'] = '+'; /* tee pointing left */
- real_map['F'] = '+'; /* tee pointing right */
- real_map['H'] = '+'; /* tee pointing up */
- real_map['I'] = '+'; /* tee pointing down */
- real_map['R'] = '-'; /* horizontal line */
- real_map['Y'] = '|'; /* vertical line */
- real_map['E'] = '+'; /* large plus or crossover */
-#ifdef USE_TERM_DRIVER
- CallDriver_2(SP_PARM, initacs, real_map, fake_map);
-#else
if (ena_acs != NULL) {
TPUTS_TRACE("ena_acs");
putp(ena_acs);
@@ -189,7 +140,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
size_t i;
for (i = 1; i < ACS_LEN; ++i) {
if (real_map[i] == 0) {
- real_map[i] = (chtype) i;
+ real_map[i] = i;
if (real_map != fake_map) {
if (SP != 0)
SP->_screen_acs_map[i] = TRUE;
@@ -240,13 +191,4 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
_nc_unlock_global(tracef);
}
#endif /* TRACE */
-#endif
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(void)
-_nc_init_acs(void)
-{
- NCURSES_SP_NAME(_nc_init_acs) (CURRENT_SCREEN);
}
-#endif
diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c
index 9302f022b89c..b9cdfda9acce 100644
--- a/ncurses/tinfo/lib_baudrate.c
+++ b/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,6 +38,7 @@
*/
#include <curses.priv.h>
+#include <term.h> /* cur_term, pad_char */
#include <termcap.h> /* ospeed */
#if defined(__FreeBSD__)
#include <sys/param.h>
@@ -79,7 +80,7 @@
#undef USE_OLD_TTY
#endif /* USE_OLD_TTY */
-MODULE_ID("$Id: lib_baudrate.c,v 1.31 2010/12/19 01:50:50 tom Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.27 2008/06/28 15:19:24 tom Exp $")
/*
* int
@@ -194,11 +195,11 @@ _nc_ospeed(int BaudRate)
}
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0)
+baudrate(void)
{
int result;
- T((T_CALLED("baudrate(%p)"), (void *) SP_PARM));
+ T((T_CALLED("baudrate()")));
/*
* In debugging, allow the environment symbol to override when we're
@@ -206,41 +207,32 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0)
* that take into account costs that depend on baudrate.
*/
#ifdef TRACE
- if (IsValidTIScreen(SP_PARM)
- && !isatty(fileno(SP_PARM ? SP_PARM->_ofp : stdout))
+ if (!isatty(fileno(SP ? SP->_ofp : stdout))
&& getenv("BAUDRATE") != 0) {
int ret;
if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
ret = 9600;
- ospeed = (NCURSES_OSPEED) _nc_ospeed(ret);
+ ospeed = _nc_ospeed(ret);
returnCode(ret);
}
#endif
- if (IsValidTIScreen(SP_PARM)) {
+ if (cur_term != 0) {
#ifdef USE_OLD_TTY
- result = cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb));
+ result = cfgetospeed(&cur_term->Nttyb);
ospeed = _nc_ospeed(result);
#else /* !USE_OLD_TTY */
#ifdef TERMIOS
- ospeed = (NCURSES_OSPEED) cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb));
+ ospeed = cfgetospeed(&cur_term->Nttyb);
#else
- ospeed = (NCURSES_OSPEED) TerminalOf(SP_PARM)->Nttyb.sg_ospeed;
+ ospeed = cur_term->Nttyb.sg_ospeed;
#endif
result = _nc_baudrate(ospeed);
#endif
- TerminalOf(SP_PARM)->_baudrate = result;
+ cur_term->_baudrate = result;
} else {
result = ERR;
}
returnCode(result);
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-baudrate(void)
-{
- return NCURSES_SP_NAME(baudrate) (CURRENT_SCREEN);
-}
-#endif
diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c
index 86e130e78527..626578d5c08b 100644
--- a/ncurses/tinfo/lib_cur_term.c
+++ b/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,141 +37,69 @@
*/
#include <curses.priv.h>
+#include <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
-MODULE_ID("$Id: lib_cur_term.c,v 1.30 2010/12/19 01:38:45 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.18 2008/08/16 19:22:55 tom Exp $")
#undef CUR
#define CUR termp->type.
-#if BROKEN_LINKER && !USE_REENTRANT
-NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
-#elif BROKEN_LINKER || USE_REENTRANT
-
-NCURSES_EXPORT(TERMINAL *)
-NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_DCL0)
-{
- return ((0 != TerminalOf(SP_PARM)) ? TerminalOf(SP_PARM) : CurTerm);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(TERMINAL *)
-_nc_get_cur_term(void)
-{
- return NCURSES_SP_NAME(_nc_get_cur_term) (CURRENT_SCREEN);
-}
-#endif
-
+#if BROKEN_LINKER || USE_REENTRANT
NCURSES_EXPORT(TERMINAL *)
NCURSES_PUBLIC_VAR(cur_term) (void)
{
-#if NCURSES_SP_FUNCS
- return NCURSES_SP_NAME(_nc_get_cur_term) (CURRENT_SCREEN);
-#else
- return NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG);
-#endif
+ return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term;
}
-
#else
NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
#endif
NCURSES_EXPORT(TERMINAL *)
-NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
+set_curterm(TERMINAL * termp)
{
TERMINAL *oldterm;
- T((T_CALLED("set_curterm(%p)"), (void *) termp));
+ T((T_CALLED("set_curterm(%p)"), termp));
_nc_lock_global(curses);
oldterm = cur_term;
- if (SP_PARM)
- SP_PARM->_term = termp;
-#if BROKEN_LINKER && !USE_REENTRANT
- cur_term = termp;
+ if (SP)
+ SP->_term = termp;
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_prescreen._cur_term = termp;
#else
- CurTerm = termp;
+ cur_term = termp;
#endif
if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp;
- ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate);
- if (TCB->drv->isTerminfo && termp->type.Strings) {
- PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
- }
- TCB->csp = SP_PARM;
-#else
- ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate);
+ ospeed = _nc_ospeed(termp->_baudrate);
if (termp->type.Strings) {
PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
}
-#endif
}
_nc_unlock_global(curses);
- T((T_RETURN("%p"), (void *) oldterm));
+ T((T_RETURN("%p"), oldterm));
return (oldterm);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(TERMINAL *)
-set_curterm(TERMINAL * termp)
-{
- return NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN, termp);
-}
-#endif
-
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL * termp)
+del_curterm(TERMINAL * termp)
{
int rc = ERR;
- T((T_CALLED("del_curterm(%p, %p)"), (void *) SP_PARM, (void *) termp));
+ T((T_CALLED("del_curterm(%p)"), termp));
+ _nc_lock_global(curses);
if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp;
-#endif
- TERMINAL *cur = (
-#if BROKEN_LINKER && !USE_REENTRANT
- cur_term
-#elif BROKEN_LINKER || USE_REENTRANT
- NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG)
-#else
- cur_term
-#endif
- );
-
_nc_free_termtype(&(termp->type));
- if (termp == cur)
- NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx 0);
-
FreeIfNeeded(termp->_termname);
-#if USE_HOME_TERMINFO
- if (_nc_globals.home_terminfo != 0)
- FreeAndNull(_nc_globals.home_terminfo);
-#endif
-#ifdef USE_TERM_DRIVER
- if (TCB->drv)
- TCB->drv->release(TCB);
-#endif
free(termp);
-
+ if (termp == cur_term)
+ set_curterm(0);
rc = OK;
}
- returnCode(rc);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-del_curterm(TERMINAL * termp)
-{
- int rc = ERR;
-
- _nc_lock_global(curses);
- rc = NCURSES_SP_NAME(del_curterm) (CURRENT_SCREEN, termp);
_nc_unlock_global(curses);
- return (rc);
+ returnCode(rc);
}
-#endif
diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c
index 195ddf978ab6..e84209d4022c 100644
--- a/ncurses/tinfo/lib_data.c
+++ b/ncurses/tinfo/lib_data.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,7 +30,6 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer *
****************************************************************************/
/*
@@ -42,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_data.c,v 1.61 2010/05/15 22:06:56 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.52 2008/08/23 22:16:15 tom Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
@@ -52,17 +51,17 @@ MODULE_ID("$Id: lib_data.c,v 1.61 2010/05/15 22:06:56 tom Exp $")
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(stdscr) (void)
{
- return CURRENT_SCREEN ? StdScreen(CURRENT_SCREEN) : 0;
+ return SP ? SP->_stdscr : 0;
}
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(curscr) (void)
{
- return CURRENT_SCREEN ? CurScreen(CURRENT_SCREEN) : 0;
+ return SP ? SP->_curscr : 0;
}
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(newscr) (void)
{
- return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : 0;
+ return SP ? SP->_newscr : 0;
}
#else
NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
@@ -94,7 +93,7 @@ _nc_screen(void)
NCURSES_EXPORT(int)
_nc_alloc_screen(void)
{
- return ((my_screen = _nc_alloc_screen_sp()) != 0);
+ return ((my_screen = typeCalloc(SCREEN, 1)) != 0);
}
NCURSES_EXPORT(void)
@@ -104,7 +103,6 @@ _nc_set_screen(SCREEN *sp)
}
#else
-
NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
#endif
/* *INDENT-OFF* */
@@ -142,9 +140,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
0, /* tgetent_index */
0, /* tgetent_sequence */
-#ifndef USE_SP_WINDOWLIST
0, /* _nc_windowlist */
-#endif
#if USE_HOME_TERMINFO
NULL, /* home_terminfo */
@@ -155,10 +151,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
0, /* safeprint_rows */
#endif
-#ifdef USE_TERM_DRIVER
- 0, /* term_driver */
-#endif
-
#ifdef TRACE
FALSE, /* init_trace */
CHARS_0s, /* trace_fname */
@@ -182,9 +174,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
{ CHARS_0s, CHARS_0s }, /* traceatr_color_buf */
0, /* traceatr_color_sel */
-1, /* traceatr_color_last */
-#if !defined(USE_PTHREADS) && USE_REENTRANT
- 0, /* nested_tracef */
-#endif
+
#endif /* TRACE */
#ifdef USE_PTHREADS
PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */
@@ -193,9 +183,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
0, /* nested_tracef */
0, /* use_pthreads */
#endif
-#if USE_PTHREADS_EINTR
- 0, /* read_thread */
-#endif
};
#define STACK_FRAME_0 { { 0 }, 0 }
@@ -209,10 +196,8 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
TRUE, /* use_env */
FALSE, /* filter_mode */
A_NORMAL, /* previous_attr */
-#ifndef USE_SP_RIPOFF
RIPOFF_0s, /* ripoff */
NULL, /* rsp */
-#endif
{ /* tparm_state */
#ifdef TRACE
NULL, /* tname */
@@ -236,13 +221,10 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
#if NCURSES_NO_PADDING
FALSE, /* flag to set if padding disabled */
#endif
- 0, /* _outch */
#if BROKEN_LINKER || USE_REENTRANT
NULL, /* real_acs_map */
0, /* LINES */
0, /* COLS */
- 8, /* TABSIZE */
- 1000, /* ESCDELAY */
0, /* cur_term */
#ifdef TRACE
0L, /* _outchars */
@@ -252,22 +234,6 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
};
/* *INDENT-ON* */
-/*
- * wgetch() and other functions with a WINDOW* parameter may use a SCREEN*
- * internally, and it is useful to allow those to be invoked without switching
- * SCREEN's, e.g., for multi-threaded applications.
- */
-NCURSES_EXPORT(SCREEN *)
-_nc_screen_of(WINDOW *win)
-{
- SCREEN *sp = 0;
-
- if (win != 0) {
- sp = WINDOW_EXT(win, screen);
- }
- return (sp);
-}
-
/******************************************************************************/
#ifdef USE_PTHREADS
static void
@@ -348,9 +314,7 @@ _nc_mutex_unlock(pthread_mutex_t * obj)
return 0;
return pthread_mutex_unlock(obj);
}
-#endif /* USE_PTHREADS */
-#if defined(USE_PTHREADS) || USE_PTHREADS_EINTR
#if USE_WEAK_SYMBOLS
/*
* NB: sigprocmask(2) is global but pthread_sigmask(3p)
diff --git a/ncurses/tinfo/lib_has_cap.c b/ncurses/tinfo/lib_has_cap.c
index d1b9b8d966da..0dc66bd9b918 100644
--- a/ncurses/tinfo/lib_has_cap.c
+++ b/ncurses/tinfo/lib_has_cap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 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 *
@@ -30,7 +30,6 @@
* 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: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -42,53 +41,25 @@
#include <curses.priv.h>
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
+#include <term.h>
-MODULE_ID("$Id: lib_has_cap.c,v 1.9 2009/10/24 22:15:47 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.4 2003/10/25 19:43:55 tom Exp $")
NCURSES_EXPORT(bool)
-NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0)
-{
- bool code = FALSE;
-
- T((T_CALLED("has_ic(%p)"), (void *) SP_PARM));
-
- if (IsValidTIScreen(SP_PARM) && IsTermInfo(SP_PARM)) {
- code = ((insert_character || parm_ich
- || (enter_insert_mode && exit_insert_mode))
- && (delete_character || parm_dch)) ? TRUE : FALSE;
- }
-
- returnCode(code);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(bool)
has_ic(void)
{
- return NCURSES_SP_NAME(has_ic) (CURRENT_SCREEN);
-}
-#endif
-
-NCURSES_EXPORT(bool)
-NCURSES_SP_NAME(has_il) (NCURSES_SP_DCL0)
-{
- bool code = FALSE;
- T((T_CALLED("has_il(%p)"), (void *) SP_PARM));
- if (IsValidTIScreen(SP_PARM) && IsTermInfo(SP_PARM)) {
- code = ((insert_line || parm_insert_line)
- && (delete_line || parm_delete_line)) ? TRUE : FALSE;
- }
-
- returnCode(code);
+ T((T_CALLED("has_ic()")));
+ returnCode(cur_term &&
+ (insert_character || parm_ich
+ || (enter_insert_mode && exit_insert_mode))
+ && (delete_character || parm_dch));
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(bool)
has_il(void)
{
- return NCURSES_SP_NAME(has_il) (CURRENT_SCREEN);
+ T((T_CALLED("has_il()")));
+ returnCode(cur_term
+ && (insert_line || parm_insert_line)
+ && (delete_line || parm_delete_line));
}
-#endif
diff --git a/ncurses/tinfo/lib_kernel.c b/ncurses/tinfo/lib_kernel.c
index 37f70842907d..89dc1e80ea8e 100644
--- a/ncurses/tinfo/lib_kernel.c
+++ b/ncurses/tinfo/lib_kernel.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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,8 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 2002 *
- * and: Juergen Pfeifer 2009 *
+ * and: Thomas E. Dickey 2002 *
****************************************************************************/
/*
@@ -47,8 +46,9 @@
*/
#include <curses.priv.h>
+#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_kernel.c,v 1.31 2010/12/19 01:21:19 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.24 2004/05/08 17:11:21 tom Exp $")
static int
_nc_vdisable(void)
@@ -59,7 +59,7 @@ _nc_vdisable(void)
#endif
#if defined(_PC_VDISABLE)
if (value == -1) {
- value = (int) fpathconf(0, _PC_VDISABLE);
+ value = fpathconf(0, _PC_VDISABLE);
if (value == -1) {
value = 0377;
}
@@ -79,32 +79,22 @@ _nc_vdisable(void)
*/
NCURSES_EXPORT(char)
-NCURSES_SP_NAME(erasechar) (NCURSES_SP_DCL0)
+erasechar(void)
{
int result = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
-
- T((T_CALLED("erasechar(%p)"), (void *) SP_PARM));
+ T((T_CALLED("erasechar()")));
- if (termp != 0) {
+ if (cur_term != 0) {
#ifdef TERMIOS
- result = termp->Ottyb.c_cc[VERASE];
+ result = cur_term->Ottyb.c_cc[VERASE];
if (result == _nc_vdisable())
result = ERR;
#else
- result = termp->Ottyb.sg_erase;
+ result = cur_term->Ottyb.sg_erase;
#endif
}
- returnChar((char) result);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char)
-erasechar(void)
-{
- return NCURSES_SP_NAME(erasechar) (CURRENT_SCREEN);
+ returnCode(result);
}
-#endif
/*
* killchar()
@@ -114,32 +104,22 @@ erasechar(void)
*/
NCURSES_EXPORT(char)
-NCURSES_SP_NAME(killchar) (NCURSES_SP_DCL0)
+killchar(void)
{
int result = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
+ T((T_CALLED("killchar()")));
- T((T_CALLED("killchar(%p)"), (void *) SP_PARM));
-
- if (termp != 0) {
+ if (cur_term != 0) {
#ifdef TERMIOS
- result = termp->Ottyb.c_cc[VKILL];
+ result = cur_term->Ottyb.c_cc[VKILL];
if (result == _nc_vdisable())
result = ERR;
#else
- result = termp->Ottyb.sg_kill;
+ result = cur_term->Ottyb.sg_kill;
#endif
}
- returnChar((char) result);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char)
-killchar(void)
-{
- return NCURSES_SP_NAME(killchar) (CURRENT_SCREEN);
+ returnCode(result);
}
-#endif
/*
* flushinp()
@@ -149,36 +129,26 @@ killchar(void)
*/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0)
+flushinp(void)
{
- TERMINAL *termp = TerminalOf(SP_PARM);
-
- T((T_CALLED("flushinp(%p)"), (void *) SP_PARM));
+ T((T_CALLED("flushinp()")));
- if (termp != 0) {
+ if (cur_term != 0) {
#ifdef TERMIOS
- tcflush(termp->Filedes, TCIFLUSH);
+ tcflush(cur_term->Filedes, TCIFLUSH);
#else
errno = 0;
do {
- ioctl(termp->Filedes, TIOCFLUSH, 0);
+ ioctl(cur_term->Filedes, TIOCFLUSH, 0);
} while
(errno == EINTR);
#endif
- if (SP_PARM) {
- SP_PARM->_fifohead = -1;
- SP_PARM->_fifotail = 0;
- SP_PARM->_fifopeek = 0;
+ if (SP) {
+ SP->_fifohead = -1;
+ SP->_fifotail = 0;
+ SP->_fifopeek = 0;
}
returnCode(OK);
}
returnCode(ERR);
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-flushinp(void)
-{
- return NCURSES_SP_NAME(flushinp) (CURRENT_SCREEN);
-}
-#endif
diff --git a/ncurses/tinfo/lib_longname.c b/ncurses/tinfo/lib_longname.c
index 14903175b322..1301ee516944 100644
--- a/ncurses/tinfo/lib_longname.c
+++ b/ncurses/tinfo/lib_longname.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 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,8 +29,6 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -42,38 +40,8 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_longname.c,v 1.12 2010/12/20 00:31:26 tom Exp $")
+MODULE_ID("$Id: lib_longname.c,v 1.9 2000/12/10 02:55:07 tom Exp $")
-#if USE_REENTRANT
-NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0)
-{
- static char empty[] =
- {'\0'};
- char *ptr;
-
- T((T_CALLED("longname(%p)"), (void *) SP_PARM));
-
- if (SP_PARM) {
- for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype);
- ptr > SP_PARM->_ttytype;
- ptr--)
- if (*ptr == '|')
- returnPtr(ptr + 1);
- returnPtr(SP_PARM->_ttytype);
- }
- return empty;
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char *)
-longname(void)
-{
- return NCURSES_SP_NAME(longname) (CURRENT_SCREEN);
-}
-#endif
-
-#else
NCURSES_EXPORT(char *)
longname(void)
{
@@ -81,11 +49,9 @@ longname(void)
T((T_CALLED("longname()")));
- for (ptr = ttytype + strlen(ttytype);
- ptr > ttytype;
- ptr--)
+ for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
if (*ptr == '|')
returnPtr(ptr + 1);
+
returnPtr(ttytype);
}
-#endif
diff --git a/ncurses/tinfo/lib_napms.c b/ncurses/tinfo/lib_napms.c
index 1e6abda10d09..417b3b4b4dbc 100644
--- a/ncurses/tinfo/lib_napms.c
+++ b/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,6 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -51,17 +49,13 @@
#endif
#endif
-MODULE_ID("$Id: lib_napms.c,v 1.20 2009/11/07 20:37:30 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.17 2008/05/03 21:34:13 tom Exp $")
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
+napms(int ms)
{
- (void) SP_PARM;
T((T_CALLED("napms(%d)"), ms));
-#ifdef USE_TERM_DRIVER
- CallDriver_1(SP_PARM, nap, ms);
-#else /* !USE_TERM_DRIVER */
#if HAVE_NANOSLEEP
{
struct timespec request, remaining;
@@ -75,15 +69,6 @@ NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
#else
_nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
#endif
-#endif /* !USE_TERM_DRIVER */
returnCode(OK);
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-napms(int ms)
-{
- return NCURSES_SP_NAME(napms) (CURRENT_SCREEN, ms);
-}
-#endif
diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c
index 654bf940aa1f..f3b1485bf111 100644
--- a/ncurses/tinfo/lib_options.c
+++ b/ncurses/tinfo/lib_options.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,7 +30,6 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -42,67 +41,53 @@
#include <curses.priv.h>
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
+#include <term.h>
+
+MODULE_ID("$Id: lib_options.c,v 1.58 2008/08/16 21:20:48 Werner.Fink Exp $")
-MODULE_ID("$Id: lib_options.c,v 1.71 2009/10/24 21:56:15 tom Exp $")
+static int _nc_curs_set(SCREEN *, int);
+static int _nc_meta(SCREEN *, bool);
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
{
- int res = ERR;
- T((T_CALLED("idlok(%p,%d)"), (void *) win, flag));
+ T((T_CALLED("idlok(%p,%d)"), win, flag));
if (win) {
- SCREEN *sp = _nc_screen_of(win);
- if (sp && IsTermInfo(sp)) {
- sp->_nc_sp_idlok =
- win->_idlok = (flag && (NCURSES_SP_NAME(has_il) (NCURSES_SP_ARG)
- || change_scroll_region));
- res = OK;
- }
- }
- returnCode(res);
+ _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
NCURSES_EXPORT(void)
idcok(WINDOW *win, bool flag)
{
- T((T_CALLED("idcok(%p,%d)"), (void *) win, flag));
+ T((T_CALLED("idcok(%p,%d)"), win, flag));
+
+ if (win)
+ _nc_idcok = win->_idcok = (flag && has_ic());
- if (win) {
- SCREEN *sp = _nc_screen_of(win);
- sp->_nc_sp_idcok = win->_idcok = (flag && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG));
- }
returnVoid;
}
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t)
+halfdelay(int t)
{
- T((T_CALLED("halfdelay(%p,%d)"), (void *) SP_PARM, t));
+ T((T_CALLED("halfdelay(%d)"), t));
- if (t < 1 || t > 255 || !IsValidTIScreen(SP_PARM))
+ if (t < 1 || t > 255 || SP == 0)
returnCode(ERR);
- NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
- SP_PARM->_cbreak = t + 1;
+ cbreak();
+ SP->_cbreak = t + 1;
returnCode(OK);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-halfdelay(int t)
-{
- return NCURSES_SP_NAME(halfdelay) (CURRENT_SCREEN, t);
-}
-#endif
-
NCURSES_EXPORT(int)
nodelay(WINDOW *win, bool flag)
{
- T((T_CALLED("nodelay(%p,%d)"), (void *) win, flag));
+ T((T_CALLED("nodelay(%p,%d)"), win, flag));
if (win) {
if (flag == TRUE)
@@ -117,7 +102,7 @@ nodelay(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
notimeout(WINDOW *win, bool f)
{
- T((T_CALLED("notimeout(%p,%d)"), (void *) win, f));
+ T((T_CALLED("notimeout(%p,%d)"), win, f));
if (win) {
win->_notimeout = f;
@@ -129,7 +114,7 @@ notimeout(WINDOW *win, bool f)
NCURSES_EXPORT(void)
wtimeout(WINDOW *win, int delay)
{
- T((T_CALLED("wtimeout(%p,%d)"), (void *) win, delay));
+ T((T_CALLED("wtimeout(%p,%d)"), win, delay));
if (win) {
win->_delay = delay;
@@ -140,11 +125,11 @@ wtimeout(WINDOW *win, int delay)
NCURSES_EXPORT(int)
keypad(WINDOW *win, bool flag)
{
- T((T_CALLED("keypad(%p,%d)"), (void *) win, flag));
+ T((T_CALLED("keypad(%p,%d)"), win, flag));
if (win) {
win->_use_keypad = flag;
- returnCode(_nc_keypad(_nc_screen_of(win), flag));
+ returnCode(_nc_keypad(SP, flag));
} else
returnCode(ERR);
}
@@ -152,106 +137,38 @@ keypad(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
meta(WINDOW *win GCC_UNUSED, bool flag)
{
- int result = ERR;
- SCREEN *sp = (win == 0) ? CURRENT_SCREEN : _nc_screen_of(win);
-
- /* Ok, we stay relaxed and don't signal an error if win is NULL */
- T((T_CALLED("meta(%p,%d)"), (void *) win, flag));
+ int result;
/* Ok, we stay relaxed and don't signal an error if win is NULL */
-
- if (sp != 0) {
- sp->_use_meta = flag;
-#ifdef USE_TERM_DRIVER
- if (IsTermInfo(sp)) {
- if (flag) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_on", meta_on);
- } else {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_off", meta_off);
- }
- }
-#else
- if (flag) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_on", meta_on);
- } else {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "meta_off", meta_off);
- }
-#endif
- result = OK;
- }
+ T((T_CALLED("meta(%p,%d)"), win, flag));
+ result = _nc_meta(SP, flag);
returnCode(result);
}
/* curs_set() moved here to narrow the kernel interface */
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis)
-{
- int code = ERR;
- T((T_CALLED("curs_set(%p,%d)"), (void *) SP_PARM, vis));
-
- if (SP_PARM != 0 && vis >= 0 && vis <= 2) {
- int cursor = SP_PARM->_cursor;
- bool bBuiltIn = !IsTermInfo(SP_PARM);
- if (vis == cursor) {
- code = cursor;
- } else {
- if (!bBuiltIn) {
- switch (vis) {
- case 2:
- code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx
- "cursor_visible",
- cursor_visible);
- break;
- case 1:
- code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx
- "cursor_normal",
- cursor_normal);
- break;
- case 0:
- code = NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx
- "cursor_invisible",
- cursor_invisible);
- break;
- }
- } else
- code = ERR;
- if (code != ERR)
- code = (cursor == -1 ? 1 : cursor);
- SP_PARM->_cursor = vis;
- }
- }
- returnCode(code);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
curs_set(int vis)
{
- return (NCURSES_SP_NAME(curs_set) (CURRENT_SCREEN, vis));
+ int result;
+
+ T((T_CALLED("curs_set(%d)"), vis));
+ result = _nc_curs_set(SP, vis);
+ returnCode(result);
}
-#endif
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd)
+typeahead(int fd)
{
- T((T_CALLED("typeahead(%p, %d)"), (void *) SP_PARM, fd));
- if (IsValidTIScreen(SP_PARM)) {
- SP_PARM->_checkfd = fd;
+ T((T_CALLED("typeahead(%d)"), fd));
+ if (SP != 0) {
+ SP->_checkfd = fd;
returnCode(OK);
} else {
returnCode(ERR);
}
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-typeahead(int fd)
-{
- return NCURSES_SP_NAME(typeahead) (CURRENT_SCREEN, fd);
-}
-#endif
-
/*
** has_key()
**
@@ -272,49 +189,42 @@ has_key_internal(int keycode, TRIES * tp)
|| has_key_internal(keycode, tp->sibling));
}
-#ifdef USE_TERM_DRIVER
-NCURSES_EXPORT(int)
-TINFO_HAS_KEY(SCREEN *sp, int keycode)
-{
- return IsValidTIScreen(sp) ?
- has_key_internal(keycode, sp->_keytry) : 0;
-}
-#else
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode)
-{
- T((T_CALLED("has_key(%p,%d)"), (void *) SP_PARM, keycode));
- returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE);
-}
-
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
has_key(int keycode)
{
- return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode);
+ T((T_CALLED("has_key(%d)"), keycode));
+ returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE);
}
-#endif
-#endif
#endif /* NCURSES_EXT_FUNCS */
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx
- const char *name, const char *value)
+/*
+ * Internal entrypoints use SCREEN* parameter to obtain capabilities rather
+ * than cur_term.
+ */
+#undef CUR
+#define CUR (sp->_term)->type.
+
+static int
+_nc_putp(const char *name GCC_UNUSED, const char *value)
{
- int rc = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx name, value);
- if (rc != ERR) {
- _nc_flush();
+ int rc = ERR;
+
+ if (value) {
+ TPUTS_TRACE(name);
+ rc = putp(value);
}
return rc;
}
-#if 0 && NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
+static int
_nc_putp_flush(const char *name, const char *value)
{
- return NCURSES_SP_NAME(_nc_putp_flush) (CURRENT_SCREEN, name, value);
+ int rc = _nc_putp(name, value);
+ if (rc != ERR) {
+ _nc_flush();
+ }
+ return rc;
}
-#endif
/* Turn the keypad on/off
*
@@ -335,12 +245,12 @@ _nc_keypad(SCREEN *sp, bool flag)
* has wgetch() reading in more than one thread. putp() and below
* may use SP explicitly.
*/
- if (_nc_use_pthreads && sp != CURRENT_SCREEN) {
+ if (_nc_use_pthreads && sp != SP) {
SCREEN *save_sp;
/* cannot use use_screen(), since that is not in tinfo library */
_nc_lock_global(curses);
- save_sp = CURRENT_SCREEN;
+ save_sp = SP;
_nc_set_screen(sp);
rc = _nc_keypad(sp, flag);
_nc_set_screen(save_sp);
@@ -348,19 +258,10 @@ _nc_keypad(SCREEN *sp, bool flag)
} else
#endif
{
-#ifdef USE_TERM_DRIVER
- rc = CallDriver_1(sp, kpad, flag);
- if (rc == OK)
- sp->_keypad_on = flag;
-#else
if (flag) {
- (void) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx
- "keypad_xmit",
- keypad_xmit);
+ (void) _nc_putp_flush("keypad_xmit", keypad_xmit);
} else if (!flag && keypad_local) {
- (void) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_ARGx
- "keypad_local",
- keypad_local);
+ (void) _nc_putp_flush("keypad_local", keypad_local);
}
if (flag && !sp->_tried) {
@@ -369,8 +270,58 @@ _nc_keypad(SCREEN *sp, bool flag)
}
sp->_keypad_on = flag;
rc = OK;
-#endif
}
}
return (rc);
}
+
+static int
+_nc_curs_set(SCREEN *sp, int vis)
+{
+ int result = ERR;
+
+ T((T_CALLED("curs_set(%d)"), vis));
+ if (sp != 0 && vis >= 0 && vis <= 2) {
+ int cursor = sp->_cursor;
+
+ if (vis == cursor) {
+ result = cursor;
+ } else {
+ switch (vis) {
+ case 2:
+ result = _nc_putp_flush("cursor_visible", cursor_visible);
+ break;
+ case 1:
+ result = _nc_putp_flush("cursor_normal", cursor_normal);
+ break;
+ case 0:
+ result = _nc_putp_flush("cursor_invisible", cursor_invisible);
+ break;
+ }
+ if (result != ERR)
+ result = (cursor == -1 ? 1 : cursor);
+ sp->_cursor = vis;
+ }
+ }
+ returnCode(result);
+}
+
+static int
+_nc_meta(SCREEN *sp, bool flag)
+{
+ int result = ERR;
+
+ /* Ok, we stay relaxed and don't signal an error if win is NULL */
+
+ if (SP != 0) {
+ SP->_use_meta = flag;
+
+ if (flag) {
+ _nc_putp("meta_on", meta_on);
+ } else {
+ _nc_putp("meta_off", meta_off);
+ }
+ result = OK;
+ }
+ return result;
+}
diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c
index c7bd3a62fa87..975b46d85773 100644
--- a/ncurses/tinfo/lib_print.c
+++ b/ncurses/tinfo/lib_print.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,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 *
@@ -29,31 +29,23 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer *
****************************************************************************/
#include <curses.priv.h>
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
+#include <term.h>
-MODULE_ID("$Id: lib_print.c,v 1.20 2010/06/05 22:18:35 tom Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.16 2006/11/26 00:26:34 tom Exp $")
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
+mcprint(char *data, int len)
/* ship binary character data to the printer via mc4/mc5/mc5p */
{
- int result;
char *mybuf, *switchon;
- size_t onsize, offsize;
- size_t need;
+ size_t onsize, offsize, res;
errno = 0;
- if (!HasTInfoTerminal(SP_PARM)
- || len <= 0
- || (!prtr_non && (!prtr_on || !prtr_off))) {
+ if (!cur_term || (!prtr_non && (!prtr_on || !prtr_off))) {
errno = ENODEV;
return (ERR);
}
@@ -68,10 +60,8 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
offsize = strlen(prtr_off);
}
- need = onsize + (size_t) len + offsize;
-
if (switchon == 0
- || (mybuf = typeMalloc(char, need + 1)) == 0) {
+ || (mybuf = typeMalloc(char, onsize + len + offsize + 1)) == 0) {
errno = ENOMEM;
return (ERR);
}
@@ -88,24 +78,15 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
* data has actually been shipped to the terminal. If the write(2)
* operation is truly atomic we're protected from this.
*/
- result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need);
+ res = write(cur_term->Filedes, mybuf, onsize + len + offsize);
/*
* By giving up our scheduler slot here we increase the odds that the
* kernel will ship the contiguous clist items from the last write
* immediately.
*/
-#ifndef __MINGW32__
(void) sleep(0);
-#endif
- free(mybuf);
- return (result);
-}
-#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
-NCURSES_EXPORT(int)
-mcprint(char *data, int len)
-{
- return NCURSES_SP_NAME(mcprint) (CURRENT_SCREEN, data, len);
+ free(mybuf);
+ return (res);
}
-#endif
diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c
index b524a1bb55be..58e71889af12 100644
--- a/ncurses/tinfo/lib_raw.c
+++ b/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 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 *
@@ -29,8 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1998-on *
- * and: Juergen Pfeifer 2009 *
+ * and: Thomas E. Dickey 1998 on *
****************************************************************************/
/*
@@ -48,8 +47,9 @@
*/
#include <curses.priv.h>
+#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_raw.c,v 1.19 2010/04/24 23:49:12 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
@@ -61,7 +61,7 @@ MODULE_ID("$Id: lib_raw.c,v 1.19 2010/04/24 23:49:12 tom Exp $")
#ifdef __EMX__
#include <io.h>
-#define _nc_setmode(mode) setmode(SP_PARM->_ifd, mode)
+#define _nc_setmode(mode) setmode(SP->_ifd, mode)
#else
#define _nc_setmode(mode) /* nothing */
#endif
@@ -77,235 +77,188 @@ MODULE_ID("$Id: lib_raw.c,v 1.19 2010/04/24 23:49:12 tom Exp $")
#endif /* TRACE */
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
+raw(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("raw(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("raw()")));
+
+ if (SP != 0 && cur_term != 0) {
TTY buf;
BEFORE("raw");
_nc_setmode(O_BINARY);
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= (unsigned) ~(ICANON | ISIG | IEXTEN);
- buf.c_iflag &= (unsigned) ~(COOKED_INPUT);
+ buf.c_lflag &= ~(ICANON | ISIG | IEXTEN);
+ buf.c_iflag &= ~(COOKED_INPUT);
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
#else
buf.sg_flags |= RAW;
#endif
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
- if (result == OK) {
- SP_PARM->_raw = TRUE;
- SP_PARM->_cbreak = 1;
- termp->Nttyb = buf;
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = TRUE;
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
}
AFTER("raw");
}
returnCode(result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-raw(void)
-{
- return NCURSES_SP_NAME(raw) (CURRENT_SCREEN);
-}
-#endif
-
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
+cbreak(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("cbreak(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("cbreak()")));
+
+ if (SP != 0 && cur_term != 0) {
TTY buf;
BEFORE("cbreak");
_nc_setmode(O_BINARY);
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= (unsigned) ~ICANON;
- buf.c_iflag &= (unsigned) ~ICRNL;
+ buf.c_lflag &= ~ICANON;
+ buf.c_iflag &= ~ICRNL;
buf.c_lflag |= ISIG;
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
#else
buf.sg_flags |= CBREAK;
#endif
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
- if (result == OK) {
- SP_PARM->_cbreak = 1;
- termp->Nttyb = buf;
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
}
AFTER("cbreak");
}
returnCode(result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-cbreak(void)
-{
- return NCURSES_SP_NAME(cbreak) (CURRENT_SCREEN);
-}
-#endif
-
/*
* Note:
* this implementation may be wrong. See the comment under intrflush().
*/
NCURSES_EXPORT(void)
-NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0)
+qiflush(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("qiflush(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("qiflush()")));
+
+ if (cur_term != 0) {
TTY buf;
BEFORE("qiflush");
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- buf.c_lflag &= (unsigned) ~(NOFLSH);
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ buf.c_lflag &= ~(NOFLSH);
+ result = _nc_set_tty_mode(&buf);
#else
/* FIXME */
#endif
if (result == OK)
- termp->Nttyb = buf;
+ cur_term->Nttyb = buf;
AFTER("qiflush");
}
returnVoid;
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(void)
-qiflush(void)
-{
- NCURSES_SP_NAME(qiflush) (CURRENT_SCREEN);
-}
-#endif
-
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
+noraw(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("noraw(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("noraw()")));
+
+ if (SP != 0 && cur_term != 0) {
TTY buf;
BEFORE("noraw");
_nc_setmode(O_TEXT);
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
buf.c_lflag |= ISIG | ICANON |
- (termp->Ottyb.c_lflag & IEXTEN);
+ (cur_term->Ottyb.c_lflag & IEXTEN);
buf.c_iflag |= COOKED_INPUT;
#else
buf.sg_flags &= ~(RAW | CBREAK);
#endif
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
- if (result == OK) {
- SP_PARM->_raw = FALSE;
- SP_PARM->_cbreak = 0;
- termp->Nttyb = buf;
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
}
AFTER("noraw");
}
returnCode(result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-noraw(void)
-{
- return NCURSES_SP_NAME(noraw) (CURRENT_SCREEN);
-}
-#endif
-
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
+nocbreak(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("nocbreak(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("nocbreak()")));
+
+ if (SP != 0 && cur_term != 0) {
TTY buf;
BEFORE("nocbreak");
_nc_setmode(O_TEXT);
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
buf.c_lflag |= ICANON;
buf.c_iflag |= ICRNL;
#else
buf.sg_flags &= ~CBREAK;
#endif
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
- if (result == OK) {
- SP_PARM->_cbreak = 0;
- termp->Nttyb = buf;
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
}
AFTER("nocbreak");
}
returnCode(result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-nocbreak(void)
-{
- return NCURSES_SP_NAME(nocbreak) (CURRENT_SCREEN);
-}
-#endif
-
+/*
+ * Note:
+ * this implementation may be wrong. See the comment under intrflush().
+ */
NCURSES_EXPORT(void)
-NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0)
+noqiflush(void)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ T((T_CALLED("noqiflush()")));
+
+ if (cur_term != 0) {
TTY buf;
BEFORE("noqiflush");
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
buf.c_lflag |= NOFLSH;
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ result = _nc_set_tty_mode(&buf);
#else
/* FIXME */
#endif
- if (result == OK)
- termp->Nttyb = buf;
+ if (result == OK) {
+ cur_term->Nttyb = buf;
+ }
AFTER("noqiflush");
}
returnVoid;
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(void)
-noqiflush(void)
-{
- NCURSES_SP_NAME(noqiflush) (CURRENT_SCREEN);
-}
-#endif
-
/*
* This call does the same thing as the qiflush()/noqiflush() pair. We know
* for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the other hand,
@@ -314,41 +267,30 @@ noqiflush(void)
* curs_inopts(3x) is too exact to be coincidence.
*/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag)
+intrflush(WINDOW *win GCC_UNUSED, bool flag)
{
int result = ERR;
- TERMINAL *termp;
- T((T_CALLED("intrflush(%p,%d)"), (void *) SP_PARM, flag));
- if (SP_PARM == 0)
- returnCode(ERR);
+ T((T_CALLED("intrflush(%d)"), flag));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if (cur_term != 0) {
TTY buf;
BEFORE("intrflush");
- buf = termp->Nttyb;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
if (flag)
- buf.c_lflag &= (unsigned) ~(NOFLSH);
+ buf.c_lflag &= ~(NOFLSH);
else
buf.c_lflag |= (NOFLSH);
- result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
+ result = _nc_set_tty_mode(&buf);
#else
/* FIXME */
#endif
if (result == OK) {
- termp->Nttyb = buf;
+ cur_term->Nttyb = buf;
}
AFTER("intrflush");
}
returnCode(result);
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-intrflush(WINDOW *win GCC_UNUSED, bool flag)
-{
- return NCURSES_SP_NAME(intrflush) (CURRENT_SCREEN, win, flag);
-}
-#endif
diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c
index 5fcf2ae3fc32..8cfaf12c5348 100644
--- a/ncurses/tinfo/lib_setup.c
+++ b/ncurses/tinfo/lib_setup.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,7 +30,6 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -42,6 +41,7 @@
#include <curses.priv.h>
#include <tic.h> /* for MAX_NAME_SIZE */
+#include <term_entry.h>
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -51,7 +51,9 @@
#include <locale.h>
#endif
-MODULE_ID("$Id: lib_setup.c,v 1.135 2011/02/06 01:04:21 tom Exp $")
+#include <term.h> /* lines, columns, cur_term */
+
+MODULE_ID("$Id: lib_setup.c,v 1.111 2008/08/03 22:42:33 tom Exp $")
/****************************************************************************
*
@@ -107,96 +109,61 @@ MODULE_ID("$Id: lib_setup.c,v 1.135 2011/02/06 01:04:21 tom Exp $")
* Wrap global variables in this module.
*/
#if USE_REENTRANT
-
NCURSES_EXPORT(char *)
NCURSES_PUBLIC_VAR(ttytype) (void)
{
static char empty[] = "";
- char *result = empty;
-
-#if NCURSES_SP_FUNCS
- if (CURRENT_SCREEN) {
- TERMINAL *termp = TerminalOf(CURRENT_SCREEN);
- if (termp != 0) {
- result = termp->type.term_names;
- }
- }
-#else
- if (cur_term != 0) {
- result = cur_term->type.term_names;
- }
-#endif
- return result;
+ return cur_term ? cur_term->type.term_names : empty;
}
-
NCURSES_EXPORT(int *)
-_nc_ptr_Lines(SCREEN *sp)
+_nc_ptr_Lines(void)
{
- return ptrLines(sp);
+ return ptrLines();
}
-
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(LINES) (void)
{
- return *_nc_ptr_Lines(CURRENT_SCREEN);
+ return *_nc_ptr_Lines();
}
-
NCURSES_EXPORT(int *)
-_nc_ptr_Cols(SCREEN *sp)
+_nc_ptr_Cols(void)
{
- return ptrCols(sp);
+ return ptrCols();
}
-
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(COLS) (void)
{
- return *_nc_ptr_Cols(CURRENT_SCREEN);
-}
-
-NCURSES_EXPORT(int *)
-_nc_ptr_Tabsize(SCREEN *sp)
-{
- return ptrTabsize(sp);
+ return *_nc_ptr_Cols();
}
-
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(TABSIZE) (void)
{
- return *_nc_ptr_Tabsize(CURRENT_SCREEN);
+ 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 = 8;
+NCURSES_EXPORT_VAR(int) TABSIZE = 0;
#endif
#if NCURSES_EXT_FUNCS
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(set_tabsize) (NCURSES_SP_DCLx int value)
+set_tabsize(int value)
{
int code = OK;
#if USE_REENTRANT
- if (SP_PARM) {
- SP_PARM->_TABSIZE = value;
+ if (SP) {
+ SP->_TABSIZE = value;
} else {
code = ERR;
}
#else
- (void) SP_PARM;
TABSIZE = value;
#endif
return code;
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-set_tabsize(int value)
-{
- return NCURSES_SP_NAME(set_tabsize) (CURRENT_SCREEN, value);
-}
#endif
-#endif /* NCURSES_EXT_FUNCS */
#if USE_SIGWINCH
/*
@@ -221,71 +188,42 @@ _nc_handle_sigwinch(SCREEN *sp)
#endif
NCURSES_EXPORT(void)
-NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f)
-{
- T((T_CALLED("use_env(%p,%d)"), (void *) SP_PARM, (int) f));
-#if NCURSES_SP_FUNCS
- if (IsPreScreen(SP_PARM)) {
- SP_PARM->_use_env = f;
- }
-#else
- _nc_prescreen.use_env = f;
-#endif
- returnVoid;
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(void)
use_env(bool f)
{
- T((T_CALLED("use_env(%d)"), (int) f));
+ T((T_CALLED("use_env()")));
_nc_prescreen.use_env = f;
returnVoid;
}
-#endif
NCURSES_EXPORT(void)
-_nc_get_screensize(SCREEN *sp,
-#ifdef USE_TERM_DRIVER
- TERMINAL * termp,
-#endif
- int *linep, int *colp)
+_nc_get_screensize(SCREEN *sp, int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
-#ifdef USE_TERM_DRIVER
- TERMINAL_CONTROL_BLOCK *TCB;
- int my_tabsize;
-
- assert(termp != 0 && linep != 0 && colp != 0);
- TCB = (TERMINAL_CONTROL_BLOCK *) termp;
-
- my_tabsize = TCB->info.tabsize;
- TCB->drv->size(TCB, linep, colp);
-
-#if USE_REENTRANT
- if (sp != 0) {
- sp->_TABSIZE = my_tabsize;
- }
-#else
- (void) sp;
- TABSIZE = my_tabsize;
-#endif
- T(("TABSIZE = %d", my_tabsize));
-#else /* !USE_TERM_DRIVER */
TERMINAL *termp = cur_term;
int my_tabsize;
/* figure out the size of the screen */
T(("screen size: terminfo lines = %d columns = %d", lines, columns));
- *linep = (int) lines;
- *colp = (int) columns;
-
- if (_nc_prescreen.use_env) {
+ if (!_nc_prescreen.use_env) {
+ *linep = (int) lines;
+ *colp = (int) columns;
+ } else { /* usually want to query LINES and COLUMNS from environment */
int value;
+ *linep = *colp = 0;
+
+ /* first, look for environment variables */
+ if ((value = _nc_getenv_num("LINES")) > 0) {
+ *linep = value;
+ }
+ if ((value = _nc_getenv_num("COLUMNS")) > 0) {
+ *colp = value;
+ }
+ T(("screen size: environment LINES = %d COLUMNS = %d", *linep, *colp));
+
#ifdef __EMX__
- {
+ if (*linep <= 0 || *colp <= 0) {
int screendata[2];
_scrsize(screendata);
*colp = screendata[0];
@@ -295,41 +233,33 @@ _nc_get_screensize(SCREEN *sp,
}
#endif
#if HAVE_SIZECHANGE
- /* try asking the OS */
- if (isatty(cur_term->Filedes)) {
- STRUCT_WINSIZE size;
-
- errno = 0;
- do {
- if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) >= 0) {
- *linep = ((sp != 0 && sp->_filtered)
- ? 1
- : WINSIZE_ROWS(size));
+ /* if that didn't work, maybe we can try asking the OS */
+ if (*linep <= 0 || *colp <= 0) {
+ if (isatty(cur_term->Filedes)) {
+ STRUCT_WINSIZE size;
+
+ errno = 0;
+ do {
+ if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) < 0
+ && errno != EINTR)
+ goto failure;
+ } while
+ (errno == EINTR);
+
+ /*
+ * Solaris lets users override either dimension with an
+ * environment variable.
+ */
+ if (*linep <= 0)
+ *linep = (sp != 0 && sp->_filtered) ? 1 : WINSIZE_ROWS(size);
+ if (*colp <= 0)
*colp = WINSIZE_COLS(size);
- T(("SYS screen size: environment LINES = %d COLUMNS = %d",
- *linep, *colp));
- break;
- }
- } while
- (errno == EINTR);
+ }
+ /* FALLTHRU */
+ failure:;
}
#endif /* HAVE_SIZECHANGE */
- /*
- * Finally, look for environment variables.
- *
- * Solaris lets users override either dimension with an environment
- * variable.
- */
- if ((value = _nc_getenv_num("LINES")) > 0) {
- *linep = value;
- T(("screen size: environment LINES = %d", *linep));
- }
- if ((value = _nc_getenv_num("COLUMNS")) > 0) {
- *colp = value;
- T(("screen size: environment COLUMNS = %d", *colp));
- }
-
/* if we can't get dynamic info about the size, use static */
if (*linep <= 0) {
*linep = (int) lines;
@@ -368,31 +298,19 @@ _nc_get_screensize(SCREEN *sp,
TABSIZE = my_tabsize;
#endif
T(("TABSIZE = %d", TABSIZE));
-#endif /* USE_TERM_DRIVER */
}
#if USE_SIZECHANGE
NCURSES_EXPORT(void)
_nc_update_screensize(SCREEN *sp)
{
- int new_lines;
- int new_cols;
-
-#ifdef USE_TERM_DRIVER
- int old_lines;
- int old_cols;
-
- assert(sp != 0);
-
- CallDriver_2(sp, getsize, &old_lines, &old_cols);
-
-#else
TERMINAL *termp = cur_term;
int old_lines = lines;
+ int new_lines;
int old_cols = columns;
-#endif
+ int new_cols;
- TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
+ _nc_get_screensize(sp, &new_lines, &new_cols);
/*
* See is_term_resized() and resizeterm().
@@ -402,7 +320,7 @@ _nc_update_screensize(SCREEN *sp)
if (sp != 0
&& sp->_resize != 0) {
if ((new_lines != old_lines) || (new_cols != old_cols))
- sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
+ sp->_resize(new_lines, new_cols);
sp->_sig_winch = FALSE;
}
}
@@ -435,8 +353,8 @@ _nc_update_screensize(SCREEN *sp)
* Return 1 if entry found, 0 if not found, -1 if database not accessible,
* just like tgetent().
*/
-int
-_nc_setup_tinfo(const char *const tn, TERMTYPE *const tp)
+static int
+grab_entry(const char *const tn, TERMTYPE *const tp)
{
char filename[PATH_MAX];
int status = _nc_read_entry(tn, filename, tp);
@@ -463,27 +381,28 @@ _nc_setup_tinfo(const char *const tn, TERMTYPE *const tp)
#endif
/*
+** do_prototype()
+**
** Take the real command character out of the CC environment variable
** and substitute it in for the prototype given in 'command_character'.
*/
-void
-_nc_tinfo_cmdch(TERMINAL * termp, char proto)
+static void
+do_prototype(TERMINAL * termp)
{
unsigned i;
char CC;
+ char proto;
char *tmp;
- /*
- * Only use the character if the string is a single character,
- * since it is fairly common for developers to set the C compiler
- * name as an environment variable - using the same symbol.
- */
- if ((tmp = getenv("CC")) != 0 && strlen(tmp) == 1) {
- CC = *tmp;
- for_each_string(i, &(termp->type)) {
- for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
- if (*tmp == proto)
- *tmp = CC;
+ if ((tmp = getenv("CC")) != 0) {
+ if ((CC = *tmp) != 0) {
+ proto = *command_character;
+
+ for_each_string(i, &(termp->type)) {
+ for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
+ if (*tmp == proto)
+ *tmp = CC;
+ }
}
}
}
@@ -546,64 +465,39 @@ _nc_unicode_locale(void)
NCURSES_EXPORT(int)
_nc_locale_breaks_acs(TERMINAL * termp)
{
- const char *env_name = "NCURSES_NO_UTF8_ACS";
char *env;
- int value;
- int result = 0;
- if ((env = getenv(env_name)) != 0) {
- result = _nc_getenv_num(env_name);
- } else if ((value = tigetnum("U8")) >= 0) {
- result = value; /* use extension feature */
+ if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) {
+ return atoi(env);
} else if ((env = getenv("TERM")) != 0) {
- if (strstr(env, "linux")) {
- result = 1; /* always broken */
- } else if (strstr(env, "screen") != 0
- && ((env = getenv("TERMCAP")) != 0
- && strstr(env, "screen") != 0)
- && strstr(env, "hhII00") != 0) {
+ if (strstr(env, "linux"))
+ return 1; /* always broken */
+ if (strstr(env, "screen") != 0
+ && ((env = getenv("TERMCAP")) != 0
+ && strstr(env, "screen") != 0)
+ && strstr(env, "hhII00") != 0) {
if (CONTROL_N(enter_alt_charset_mode) ||
CONTROL_O(enter_alt_charset_mode) ||
CONTROL_N(set_attributes) ||
- CONTROL_O(set_attributes)) {
- result = 1;
- }
+ CONTROL_O(set_attributes))
+ return 1;
}
}
- return result;
+ return 0;
}
+/*
+ * This entrypoint is called from tgetent() to allow a special case of reusing
+ * the same TERMINAL data (see comment).
+ */
NCURSES_EXPORT(int)
-TINFO_SETUP_TERM(TERMINAL ** tp,
- NCURSES_CONST char *tname,
- int Filedes,
- int *errret,
- bool reuse)
+_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
{
-#ifdef USE_TERM_DRIVER
- TERMINAL_CONTROL_BLOCK *TCB = 0;
-#else
- int status;
-#endif
TERMINAL *termp;
- SCREEN *sp = 0;
- int code = ERR;
+ int status;
START_TRACE();
-
-#ifdef USE_TERM_DRIVER
- T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"),
- (void *) tp, _nc_visbuf(tname), Filedes, (void *) errret));
-
- if (tp == 0) {
- ret_error0(TGETENT_ERR,
- "Invalid parameter, internal error.\n");
- } else
- termp = *tp;
-#else
- termp = cur_term;
- T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, (void *) errret));
-#endif
+ T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, errret));
if (tname == 0) {
tname = getenv("TERM");
@@ -644,37 +538,22 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
* properly with this feature).
*/
if (reuse
- && (termp != 0)
+ && (termp = cur_term) != 0
&& termp->Filedes == Filedes
&& termp->_termname != 0
&& !strcmp(termp->_termname, tname)
&& _nc_name_match(termp->type.term_names, tname, "|")) {
T(("reusing existing terminal information and mode-settings"));
- code = OK;
} else {
-#ifdef USE_TERM_DRIVER
- termp = (TERMINAL *) typeCalloc(TERMINAL_CONTROL_BLOCK, 1);
-#else
+
termp = typeCalloc(TERMINAL, 1);
-#endif
+
if (termp == 0) {
ret_error0(TGETENT_ERR,
"Not enough memory to create terminal structure.\n");
}
-#ifdef USE_TERM_DRIVER
- INIT_TERM_DRIVER();
- TCB = (TERMINAL_CONTROL_BLOCK *) termp;
- code = _nc_globals.term_driver(TCB, tname, errret);
- if (code == OK) {
- termp->Filedes = (short) Filedes;
- termp->_termname = strdup(tname);
- } else {
- ret_error0(TGETENT_ERR,
- "Could not find any driver to handle this terminal.\n");
- }
-#else
#if USE_DATABASE || USE_TERMCAP
- status = _nc_setup_tinfo(tname, &termp->type);
+ status = grab_entry(tname, &termp->type);
#else
status = TGETENT_NO;
#endif
@@ -702,13 +581,13 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
ttytype[NAMESIZE - 1] = '\0';
#endif
- termp->Filedes = (short) Filedes;
+ termp->Filedes = Filedes;
termp->_termname = strdup(tname);
set_curterm(termp);
- if (command_character)
- _nc_tinfo_cmdch(termp, *command_character);
+ if (command_character && getenv("CC"))
+ do_prototype(termp);
/*
* If an application calls setupterm() rather than initscr() or
@@ -720,94 +599,24 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
def_prog_mode();
baudrate();
}
- code = OK;
-#endif
}
-#ifdef USE_TERM_DRIVER
- *tp = termp;
- NCURSES_SP_NAME(set_curterm) (sp, termp);
- TCB->drv->init(TCB);
-#else
- sp = SP;
-#endif
-
/*
* We should always check the screensize, just in case.
*/
- TINFO_GET_SIZE(sp, termp, ptrLines(sp), ptrCols(sp));
+ _nc_get_screensize(SP, ptrLines(), ptrCols());
if (errret)
*errret = TGETENT_YES;
-#ifndef USE_TERM_DRIVER
if (generic_type) {
ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
}
if (hard_copy) {
ret_error(TGETENT_YES, "'%s': I can't handle hardcopy terminals.\n", tname);
}
-#endif
- returnCode(code);
-}
-
-#if NCURSES_SP_FUNCS
-/*
- * In case of handling multiple screens, we need to have a screen before
- * initialization in setupscreen takes place. This is to extend the substitute
- * for some of the stuff in _nc_prescreen, especially for slk and ripoff
- * handling which should be done per screen.
- */
-NCURSES_EXPORT(SCREEN *)
-new_prescr(void)
-{
- static SCREEN *sp;
-
- START_TRACE();
- T((T_CALLED("new_prescr()")));
-
- if (sp == 0) {
- sp = _nc_alloc_screen_sp();
- if (sp != 0) {
- sp->rsp = sp->rippedoff;
- sp->_filtered = _nc_prescreen.filter_mode;
- sp->_use_env = _nc_prescreen.use_env;
-#if NCURSES_NO_PADDING
- sp->_no_padding = _nc_prescreen._no_padding;
-#endif
- sp->slk_format = 0;
- sp->_slk = 0;
- sp->_prescreen = TRUE;
- SP_PRE_INIT(sp);
-#if USE_REENTRANT
- sp->_TABSIZE = _nc_prescreen._TABSIZE;
- sp->_ESCDELAY = _nc_prescreen._ESCDELAY;
-#endif
- }
- }
- returnSP(sp);
-}
-#endif
-
-#ifdef USE_TERM_DRIVER
-/*
- * This entrypoint is called from tgetent() to allow a special case of reusing
- * the same TERMINAL data (see comment).
- */
-NCURSES_EXPORT(int)
-_nc_setupterm(NCURSES_CONST char *tname,
- int Filedes,
- int *errret,
- bool reuse)
-{
- int res;
- TERMINAL *termp;
- res = TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse);
- if (ERR != res)
- NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp);
- return res;
+ returnCode(OK);
}
-#endif
/*
* setupterm(termname, Filedes, errret)
diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c
index e9dae85bdd97..2d245ffbb61f 100644
--- a/ncurses/tinfo/lib_termcap.c
+++ b/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,7 +30,6 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer *
* *
* some of the code in here was contributed by: *
* Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93) *
@@ -44,11 +43,9 @@
#include <tic.h>
#include <ctype.h>
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
+#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.73 2010/12/25 19:27:12 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.63 2008/08/16 19:22:55 tom Exp $")
NCURSES_EXPORT_VAR(char *) UP = 0;
NCURSES_EXPORT_VAR(char *) BC = 0;
@@ -79,26 +76,16 @@ NCURSES_EXPORT_VAR(char *) BC = 0;
***************************************************************************/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
+tgetent(char *bufp, const char *name)
{
- int rc = ERR;
+ int errcode;
int n;
bool found_cache = FALSE;
-#ifdef USE_TERM_DRIVER
- TERMINAL *termp = 0;
-#endif
START_TRACE();
T((T_CALLED("tgetent()")));
- TINFO_SETUP_TERM(&termp, (NCURSES_CONST char *) name,
- STDOUT_FILENO, &rc, TRUE);
-
-#ifdef USE_TERM_DRIVER
- if (termp == 0 ||
- !((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo)
- return (rc);
-#endif
+ _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE);
/*
* In general we cannot tell if the fixed sgr0 is still used by the
@@ -122,9 +109,9 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
/*
* Also free the terminfo data that we loaded (much bigger leak).
*/
- if (LAST_TRM != 0 && LAST_TRM != TerminalOf(SP_PARM)) {
+ if (LAST_TRM != 0 && LAST_TRM != cur_term) {
TERMINAL *trm = LAST_TRM;
- NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM);
+ del_curterm(LAST_TRM);
for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx)
if (LAST_TRM == trm)
LAST_TRM = 0;
@@ -144,7 +131,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
}
CacheInx = best;
}
- LAST_TRM = TerminalOf(SP_PARM);
+ LAST_TRM = cur_term;
LAST_SEQ = ++CacheSeq;
PC = 0;
@@ -152,7 +139,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
BC = 0;
FIX_SGR0 = 0; /* don't free it - application may still use */
- if (rc == 1) {
+ if (errcode == 1) {
if (cursor_left)
if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0)
@@ -166,7 +153,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
if (backspace_if_not_bs != NULL)
BC = backspace_if_not_bs;
- if ((FIX_SGR0 = _nc_trim_sgr0(&(TerminalOf(SP_PARM)->type))) != 0) {
+ if ((FIX_SGR0 = _nc_trim_sgr0(&(cur_term->type))) != 0) {
if (!strcmp(FIX_SGR0, exit_attribute_mode)) {
if (FIX_SGR0 != exit_attribute_mode) {
free(FIX_SGR0);
@@ -177,8 +164,8 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
LAST_BUF = bufp;
LAST_USE = TRUE;
- SetNoPadding(SP_PARM);
- (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side-effect */
+ SetNoPadding(SP);
+ (void) baudrate(); /* sets ospeed as a side-effect */
/* LINT_PREPRO
#if 0*/
@@ -187,27 +174,8 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
#endif*/
}
- returnCode(rc);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-tgetent(char *bufp, const char *name)
-{
- return NCURSES_SP_NAME(tgetent) (CURRENT_SCREEN, bufp, name);
-}
-#endif
-
-#if 0
-static bool
-same_tcname(const char *a, const char *b)
-{
- fprintf(stderr, "compare(%s,%s)\n", a, b);
- return !strncmp(a, b, 2);
+ returnCode(errcode);
}
-#else
-#define same_tcname(a,b) !strncmp(a,b,2)
-#endif
/***************************************************************************
*
@@ -219,48 +187,24 @@ same_tcname(const char *a, const char *b)
***************************************************************************/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx NCURSES_CONST char *id)
+tgetflag(NCURSES_CONST char *id)
{
- int result = 0; /* Solaris returns zero for missing flag */
- int i, j;
-
- T((T_CALLED("tgetflag(%p, %s)"), (void *) SP_PARM, id));
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(id, BOOLEAN, TRUE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_boolean(i, tp) {
- const char *capname = ExtBoolname(tp, i, boolcodes);
- if (same_tcname(id, capname)) {
- j = i;
- break;
- }
+ unsigned i;
+
+ T((T_CALLED("tgetflag(%s)"), id));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_boolean(i, tp) {
+ const char *capname = ExtBoolname(tp, i, boolcodes);
+ if (!strncmp(id, capname, 2)) {
+ /* setupterm forces invalid booleans to false */
+ returnCode(tp->Booleans[i]);
}
}
-#endif
- if (j >= 0) {
- /* note: setupterm forces invalid booleans to false */
- result = tp->Booleans[j];
- }
}
- returnCode(result);
+ returnCode(0); /* Solaris does this */
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-tgetflag(NCURSES_CONST char *id)
-{
- return NCURSES_SP_NAME(tgetflag) (CURRENT_SCREEN, id);
-}
-#endif
-
/***************************************************************************
*
* tgetnum(str)
@@ -271,48 +215,25 @@ tgetflag(NCURSES_CONST char *id)
***************************************************************************/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx NCURSES_CONST char *id)
+tgetnum(NCURSES_CONST char *id)
{
- int result = ABSENT_NUMERIC;
- int i, j;
-
- T((T_CALLED("tgetnum(%p, %s)"), (void *) SP_PARM, id));
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(id, NUMBER, TRUE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_number(i, tp) {
- const char *capname = ExtNumname(tp, i, numcodes);
- if (same_tcname(id, capname)) {
- j = i;
- break;
- }
+ unsigned i;
+
+ T((T_CALLED("tgetnum(%s)"), id));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_number(i, tp) {
+ const char *capname = ExtNumname(tp, i, numcodes);
+ if (!strncmp(id, capname, 2)) {
+ if (!VALID_NUMERIC(tp->Numbers[i]))
+ returnCode(ABSENT_NUMERIC);
+ returnCode(tp->Numbers[i]);
}
}
-#endif
- if (j >= 0) {
- if (VALID_NUMERIC(tp->Numbers[j]))
- result = tp->Numbers[j];
- }
}
- returnCode(result);
+ returnCode(ABSENT_NUMERIC);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-tgetnum(NCURSES_CONST char *id)
-{
- return NCURSES_SP_NAME(tgetnum) (CURRENT_SCREEN, id);
-}
-#endif
-
/***************************************************************************
*
* tgetstr(str, area)
@@ -323,62 +244,40 @@ tgetnum(NCURSES_CONST char *id)
***************************************************************************/
NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx NCURSES_CONST char *id, char **area)
+tgetstr(NCURSES_CONST char *id, char **area)
{
+ unsigned i;
char *result = NULL;
- int i, j;
- T((T_CALLED("tgetstr(%s,%p)"), id, (void *) area));
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(id, STRING, TRUE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_string(i, tp) {
- const char *capname = ExtStrname(tp, i, strcodes);
- if (same_tcname(id, capname)) {
- j = i;
- break;
- }
- }
- }
-#endif
- if (j >= 0) {
- result = tp->Strings[j];
- TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result)));
- /* setupterm forces canceled strings to null */
- if (VALID_STRING(result)) {
- if (result == exit_attribute_mode
- && FIX_SGR0 != 0) {
- result = FIX_SGR0;
- TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
- }
- if (area != 0
- && *area != 0) {
- (void) strcpy(*area, result);
- result = *area;
- *area += strlen(*area) + 1;
+ T((T_CALLED("tgetstr(%s,%p)"), id, area));
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_string(i, tp) {
+ const char *capname = ExtStrname(tp, i, strcodes);
+ if (!strncmp(id, capname, 2)) {
+ result = tp->Strings[i];
+ TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result)));
+ /* setupterm forces canceled strings to null */
+ if (VALID_STRING(result)) {
+ if (result == exit_attribute_mode
+ && FIX_SGR0 != 0) {
+ result = FIX_SGR0;
+ TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
+ }
+ if (area != 0
+ && *area != 0) {
+ (void) strcpy(*area, result);
+ result = *area;
+ *area += strlen(*area) + 1;
+ }
}
+ break;
}
}
}
returnPtr(result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char *)
-tgetstr(NCURSES_CONST char *id, char **area)
-{
- return NCURSES_SP_NAME(tgetstr) (CURRENT_SCREEN, id, area);
-}
-#endif
-
#if NO_LEAKS
NCURSES_EXPORT(void)
_nc_tgetent_leaks(void)
diff --git a/ncurses/tinfo/lib_termname.c b/ncurses/tinfo/lib_termname.c
index e3f6827ee018..713d0be8c360 100644
--- a/ncurses/tinfo/lib_termname.c
+++ b/ncurses/tinfo/lib_termname.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2003 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 *
@@ -28,31 +28,17 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_termname.c,v 1.12 2009/10/24 21:56:58 tom Exp $")
+MODULE_ID("$Id: lib_termname.c,v 1.8 2003/12/27 18:23:01 tom Exp $")
NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(termname) (NCURSES_SP_DCL0)
+termname(void)
{
char *name = 0;
- T((T_CALLED("termname(%p)"), (void *) SP_PARM));
+ T((T_CALLED("termname()")));
-#if NCURSES_SP_FUNCS
- if (TerminalOf(SP_PARM) != 0) {
- name = TerminalOf(SP_PARM)->_termname;
- }
-#else
if (cur_term != 0)
name = cur_term->_termname;
-#endif
returnPtr(name);
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char *)
-termname(void)
-{
- return NCURSES_SP_NAME(termname) (CURRENT_SCREEN);
-}
-#endif
diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c
index e41234210c85..df460f953ea7 100644
--- a/ncurses/tinfo/lib_ti.c
+++ b/ncurses/tinfo/lib_ti.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 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,159 +29,75 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
+#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: lib_ti.c,v 1.29 2010/01/23 17:57:43 tom Exp $")
-
-#if 0
-static bool
-same_name(const char *a, const char *b)
-{
- fprintf(stderr, "compare(%s,%s)\n", a, b);
- return !strcmp(a, b);
-}
-#else
-#define same_name(a,b) !strcmp(a,b)
-#endif
+MODULE_ID("$Id: lib_ti.c,v 1.23 2003/05/24 21:10:28 tom Exp $")
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+tigetflag(NCURSES_CONST char *str)
{
- int result = ABSENT_BOOLEAN;
- int i, j;
+ unsigned i;
- T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str));
+ T((T_CALLED("tigetflag(%s)"), str));
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_boolean(i, tp) {
- const char *capname = ExtBoolname(tp, i, boolnames);
- if (same_name(str, capname)) {
- j = i;
- break;
- }
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_boolean(i, tp) {
+ const char *capname = ExtBoolname(tp, i, boolnames);
+ if (!strcmp(str, capname)) {
+ /* setupterm forces invalid booleans to false */
+ returnCode(tp->Booleans[i]);
}
}
-#endif
- if (j >= 0) {
- /* note: setupterm forces invalid booleans to false */
- result = tp->Booleans[j];
- }
}
- returnCode(result);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-tigetflag(NCURSES_CONST char *str)
-{
- return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str);
+ returnCode(ABSENT_BOOLEAN);
}
-#endif
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+tigetnum(NCURSES_CONST char *str)
{
- int i, j;
- int result = CANCELLED_NUMERIC; /* Solaris returns a -1 on error */
-
- T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str));
-
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_number(i, tp) {
- const char *capname = ExtNumname(tp, i, numnames);
- if (same_name(str, capname)) {
- j = i;
- break;
- }
+ unsigned i;
+
+ T((T_CALLED("tigetnum(%s)"), str));
+
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_number(i, tp) {
+ const char *capname = ExtNumname(tp, i, numnames);
+ if (!strcmp(str, capname)) {
+ if (!VALID_NUMERIC(tp->Numbers[i]))
+ returnCode(ABSENT_NUMERIC);
+ returnCode(tp->Numbers[i]);
}
}
-#endif
- if (j >= 0) {
- if (VALID_NUMERIC(tp->Numbers[j]))
- result = tp->Numbers[j];
- else
- result = ABSENT_NUMERIC;
- }
}
- returnCode(result);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-tigetnum(NCURSES_CONST char *str)
-{
- return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str);
+ returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */
}
-#endif
NCURSES_EXPORT(char *)
-NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str)
+tigetstr(NCURSES_CONST char *str)
{
- char *result = CANCELLED_STRING;
- int i, j;
+ unsigned i;
- T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str));
+ T((T_CALLED("tigetstr(%s)"), str));
- if (HasTInfoTerminal(SP_PARM)) {
- TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
- struct name_table_entry const *entry_ptr;
-
- entry_ptr = _nc_find_type_entry(str, STRING, FALSE);
- if (entry_ptr != 0) {
- j = entry_ptr->nte_index;
- }
-#if NCURSES_XNAMES
- else {
- j = -1;
- for_each_ext_string(i, tp) {
- const char *capname = ExtStrname(tp, i, strnames);
- if (same_name(str, capname)) {
- j = i;
- break;
- }
+ if (cur_term != 0) {
+ TERMTYPE *tp = &(cur_term->type);
+ for_each_string(i, tp) {
+ const char *capname = ExtStrname(tp, i, strnames);
+ if (!strcmp(str, capname)) {
+ /* setupterm forces cancelled strings to null */
+ returnPtr(tp->Strings[i]);
}
}
-#endif
- if (j >= 0) {
- /* note: setupterm forces cancelled strings to null */
- result = tp->Strings[j];
- }
}
- returnPtr(result);
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(char *)
-tigetstr(NCURSES_CONST char *str)
-{
- return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str);
+ returnPtr(CANCELLED_STRING);
}
-#endif
diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c
index 7cd12f7f6845..ba2a8404030e 100644
--- a/ncurses/tinfo/lib_tparm.c
+++ b/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,9 +40,10 @@
#include <curses.priv.h>
#include <ctype.h>
+#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.82 2011/01/15 22:19:12 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.76 2008/08/16 19:22:55 tom Exp $")
/*
* char *
@@ -139,7 +140,7 @@ save_text(const char *fmt, const char *s, int len)
{
size_t s_len = strlen(s);
if (len > (int) s_len)
- s_len = (size_t) len;
+ s_len = len;
get_space(s_len + 1);
@@ -450,13 +451,12 @@ _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
}
static NCURSES_INLINE char *
-tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
+tparam_internal(const char *string, va_list ap)
{
char *p_is_s[NUM_PARM];
TPARM_ARG param[NUM_PARM];
- int popcount = 0;
+ int popcount;
int number;
- int num_args;
int len;
int level;
int x, y;
@@ -479,13 +479,7 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
if (TPS(fmt_buff) == 0)
return NULL;
- if (number > NUM_PARM)
- number = NUM_PARM;
- if (popcount > NUM_PARM)
- popcount = NUM_PARM;
- num_args = max(popcount, number);
-
- for (i = 0; i < num_args; i++) {
+ for (i = 0; i < max(popcount, number); i++) {
/*
* A few caps (such as plab_norm) have string-valued parms.
* We'll have to assume that the caller knows the difference, since
@@ -495,11 +489,8 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
*/
if (p_is_s[i] != 0) {
p_is_s[i] = va_arg(ap, char *);
- param[i] = 0;
- } else if (use_TPARM_ARG) {
- param[i] = va_arg(ap, TPARM_ARG);
} else {
- param[i] = (TPARM_ARG) va_arg(ap, int);
+ param[i] = va_arg(ap, TPARM_ARG);
}
}
@@ -517,7 +508,7 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
if (p_is_s[i])
spush(p_is_s[i]);
else
- npush((int) param[i]);
+ npush(param[i]);
}
}
#ifdef TRACE
@@ -526,7 +517,7 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
if (p_is_s[i] != 0)
save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
else
- save_number(", %d", (int) param[i], 0);
+ save_number(", %d", param[i], 0);
}
_tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
TPS(out_used) = 0;
@@ -573,7 +564,7 @@ tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
if (p_is_s[i])
spush(p_is_s[i]);
else
- npush((int) param[i]);
+ npush(param[i]);
}
break;
@@ -781,7 +772,7 @@ tparm_varargs(NCURSES_CONST char *string,...)
#ifdef TRACE
TPS(tname) = "tparm";
#endif /* TRACE */
- result = tparam_internal(TRUE, string, ap);
+ result = tparam_internal(string, ap);
va_end(ap);
return result;
}
@@ -802,19 +793,3 @@ tparm_proto(NCURSES_CONST char *string,
return tparm_varargs(string, a1, a2, a3, a4, a5, a6, a7, a8, a9);
}
#endif /* NCURSES_TPARM_VARARGS */
-
-NCURSES_EXPORT(char *)
-tiparm(const char *string,...)
-{
- va_list ap;
- char *result;
-
- _nc_tparm_err = 0;
- va_start(ap, string);
-#ifdef TRACE
- TPS(tname) = "tiparm";
-#endif /* TRACE */
- result = tparam_internal(FALSE, string, ap);
- va_end(ap);
- return result;
-}
diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c
index dc70f3e0b0b8..a8b7276895a5 100644
--- a/ncurses/tinfo/lib_tputs.c
+++ b/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,7 +30,6 @@
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2009 *
****************************************************************************/
/*
@@ -42,16 +41,12 @@
*/
#include <curses.priv.h>
-
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
-
#include <ctype.h>
+#include <term.h> /* padding_baud_rate, xon_xoff */
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.81 2010/12/20 00:42:50 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.66 2008/06/28 13:12:15 tom Exp $")
NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
@@ -74,136 +69,63 @@ _nc_set_no_padding(SCREEN *sp)
}
#endif
-#if NCURSES_SP_FUNCS
-#define SetOutCh(func) if (SP_PARM) SP_PARM->_outch = func; else _nc_prescreen._outch = func
-#define GetOutCh() (SP_PARM ? SP_PARM->_outch : _nc_prescreen._outch)
-#else
-#define SetOutCh(func) static_outch = func
-#define GetOutCh() static_outch
-static NCURSES_SP_OUTC static_outch = NCURSES_SP_NAME(_nc_outch);
-#endif
+static int (*my_outch) (int c) = _nc_outch;
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms)
+delay_output(int ms)
{
- T((T_CALLED("delay_output(%p,%d)"), (void *) SP_PARM, ms));
-
- if (!HasTInfoTerminal(SP_PARM))
- returnCode(ERR);
+ T((T_CALLED("delay_output(%d)"), ms));
if (no_pad_char) {
- NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+ _nc_flush();
napms(ms);
} else {
- NCURSES_SP_OUTC my_outch = GetOutCh();
register int nullcount;
nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000);
for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
- my_outch(NCURSES_SP_ARGx PC);
- if (my_outch == NCURSES_SP_NAME(_nc_outch))
- NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+ my_outch(PC);
+ if (my_outch == _nc_outch)
+ _nc_flush();
}
returnCode(OK);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-delay_output(int ms)
-{
- return NCURSES_SP_NAME(delay_output) (CURRENT_SCREEN, ms);
-}
-#endif
-
-NCURSES_EXPORT(void)
-NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
-{
- (void) fflush(NC_OUTPUT(SP_PARM));
-}
-
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(void)
_nc_flush(void)
{
- NCURSES_SP_NAME(_nc_flush) (CURRENT_SCREEN);
+ (void) fflush(NC_OUTPUT);
}
-#endif
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
+_nc_outch(int ch)
{
- int rc = OK;
-
COUNT_OUTCHARS(1);
- if (HasTInfoTerminal(SP_PARM)
- && SP_PARM != 0
- && SP_PARM->_cleanup) {
- char tmp = (char) ch;
+ if (SP != 0
+ && SP->_cleanup) {
+ char tmp = ch;
/*
* POSIX says write() is safe in a signal handler, but the
* buffered I/O is not.
*/
- if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, 1) == -1)
- rc = ERR;
+ write(fileno(NC_OUTPUT), &tmp, 1);
} else {
- if (putc(ch, NC_OUTPUT(SP_PARM)) == EOF)
- rc = ERR;
+ putc(ch, NC_OUTPUT);
}
- return rc;
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-_nc_outch(int ch)
-{
- return NCURSES_SP_NAME(_nc_outch) (CURRENT_SCREEN, ch);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(putp) (NCURSES_SP_DCLx const char *string)
-{
- return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- string, 1, NCURSES_SP_NAME(_nc_outch));
-}
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_DCLx
- const char *name GCC_UNUSED,
- const char *string)
-{
- int rc = ERR;
-
- if (string != 0) {
- TPUTS_TRACE(name);
- rc = NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx string);
- }
- return rc;
+ return OK;
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
putp(const char *string)
{
- return NCURSES_SP_NAME(putp) (CURRENT_SCREEN, string);
+ return tputs(string, 1, _nc_outch);
}
NCURSES_EXPORT(int)
-_nc_putp(const char *name, const char *string)
-{
- return NCURSES_SP_NAME(_nc_putp) (CURRENT_SCREEN, name, string);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
- const char *string,
- int affcnt,
- NCURSES_SP_OUTC outc)
+tputs(const char *string, int affcnt, int (*outc) (int))
{
- NCURSES_SP_OUTC my_outch = GetOutCh();
bool always_delay;
bool normal_delay;
int number;
@@ -215,7 +137,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
char addrbuf[32];
if (USE_TRACEF(TRACE_TPUTS)) {
- if (outc == NCURSES_SP_NAME(_nc_outch))
+ if (outc == _nc_outch)
(void) strcpy(addrbuf, "_nc_outch");
else
(void) sprintf(addrbuf, "%p", outc);
@@ -230,19 +152,10 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
}
#endif /* TRACE */
- if (SP_PARM != 0 && !HasTInfoTerminal(SP_PARM))
- return ERR;
-
if (!VALID_STRING(string))
return ERR;
- if (
-#if NCURSES_SP_FUNCS
- (SP_PARM != 0 && SP_PARM->_term == 0)
-#else
- cur_term == 0
-#endif
- ) {
+ if (cur_term == 0) {
always_delay = FALSE;
normal_delay = TRUE;
} else {
@@ -251,7 +164,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
!xon_xoff
&& padding_baud_rate
#if NCURSES_NO_PADDING
- && !GetNoPadding(SP_PARM)
+ && !GetNoPadding(SP)
#endif
&& (_nc_baudrate(ospeed) >= padding_baud_rate);
}
@@ -285,24 +198,24 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
}
#endif /* BSD_TPUTS */
- SetOutCh(outc); /* redirect delay_output() */
+ my_outch = outc; /* redirect delay_output() */
while (*string) {
if (*string != '$')
- (*outc) (NCURSES_SP_ARGx *string);
+ (*outc) (*string);
else {
string++;
if (*string != '<') {
- (*outc) (NCURSES_SP_ARGx '$');
+ (*outc) ('$');
if (*string)
- (*outc) (NCURSES_SP_ARGx *string);
+ (*outc) (*string);
} else {
bool mandatory;
string++;
if ((!isdigit(UChar(*string)) && *string != '.')
|| !strchr(string, '>')) {
- (*outc) (NCURSES_SP_ARGx '$');
- (*outc) (NCURSES_SP_ARGx '<');
+ (*outc) ('$');
+ (*outc) ('<');
continue;
}
@@ -337,7 +250,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
&& (always_delay
|| normal_delay
|| mandatory))
- NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx number / 10);
+ delay_output(number / 10);
} /* endelse (*string == '<') */
} /* endelse (*string == '$') */
@@ -357,25 +270,6 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
delay_output(trailpad / 10);
#endif /* BSD_TPUTS */
- SetOutCh(my_outch);
+ my_outch = _nc_outch;
return OK;
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-_nc_outc_wrapper(SCREEN *sp, int c)
-{
- if (0 == sp) {
- return (ERR);
- } else {
- return sp->jump(c);
- }
-}
-
-NCURSES_EXPORT(int)
-tputs(const char *string, int affcnt, int (*outc) (int))
-{
- SetSafeOutcWrapper(outc);
- return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx string, affcnt, _nc_outc_wrapper);
-}
-#endif
diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c
index 663a06898090..a2b38a3327f1 100644
--- a/ncurses/tinfo/lib_ttyflags.c
+++ b/ncurses/tinfo/lib_ttyflags.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -36,246 +36,159 @@
*/
#include <curses.priv.h>
+#include <term.h> /* cur_term */
-#ifndef CUR
-#define CUR SP_TERMTYPE
-#endif
-
-MODULE_ID("$Id: lib_ttyflags.c,v 1.27 2010/12/25 23:43:58 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.18 2008/08/03 22:10:44 tom Exp $")
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
+_nc_get_tty_mode(TTY * buf)
{
int result = OK;
- if (buf == 0 || SP_PARM == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- TERMINAL *termp = TerminalOf(SP_PARM);
-
- if (0 == termp) {
+ if (cur_term == 0) {
result = ERR;
} else {
-#ifdef USE_TERM_DRIVER
- result = CallDriver_2(SP_PARM, sgmode, FALSE, buf);
-#else
for (;;) {
- if (GET_TTY(termp->Filedes, buf) != 0) {
+ if (GET_TTY(cur_term->Filedes, buf) != 0) {
if (errno == EINTR)
continue;
result = ERR;
}
break;
}
-#endif
}
if (result == ERR)
memset(buf, 0, sizeof(*buf));
TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
- termp ? termp->Filedes : -1,
+ cur_term ? cur_term->Filedes : -1,
_nc_trace_ttymode(buf)));
}
return (result);
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-_nc_get_tty_mode(TTY * buf)
-{
- return NCURSES_SP_NAME(_nc_get_tty_mode) (CURRENT_SCREEN, buf);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf)
+_nc_set_tty_mode(TTY * buf)
{
int result = OK;
- if (buf == 0 || SP_PARM == 0) {
+ if (buf == 0) {
result = ERR;
} else {
- TERMINAL *termp = TerminalOf(SP_PARM);
-
- if (0 == termp) {
+ if (cur_term == 0) {
result = ERR;
} else {
-#ifdef USE_TERM_DRIVER
- result = CallDriver_2(SP_PARM, sgmode, TRUE, buf);
-#else
for (;;) {
- if (SET_TTY(termp->Filedes, buf) != 0) {
+ if (SET_TTY(cur_term->Filedes, buf) != 0) {
if (errno == EINTR)
continue;
- if ((errno == ENOTTY) && (SP_PARM != 0))
- SP_PARM->_notty = TRUE;
+ if ((errno == ENOTTY) && (SP != 0))
+ SP->_notty = TRUE;
result = ERR;
}
break;
}
-#endif
}
TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
- termp ? termp->Filedes : -1,
+ cur_term ? cur_term->Filedes : -1,
_nc_trace_ttymode(buf)));
}
return (result);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-_nc_set_tty_mode(TTY * buf)
-{
- return NCURSES_SP_NAME(_nc_set_tty_mode) (CURRENT_SCREEN, buf);
-}
-#endif
-
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0)
+def_shell_mode(void)
{
int rc = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
- T((T_CALLED("def_shell_mode(%p)"), (void *) SP_PARM));
+ T((T_CALLED("def_shell_mode()")));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- rc = CallDriver_2(SP_PARM, mode, FALSE, TRUE);
-#else
+ if (cur_term != 0) {
/*
* If XTABS was on, remove the tab and backtab capabilities.
*/
- if (_nc_get_tty_mode(&termp->Ottyb) == OK) {
+ if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) {
#ifdef TERMIOS
- if (termp->Ottyb.c_oflag & OFLAGS_TABS)
+ if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
tab = back_tab = NULL;
#else
- if (termp->Ottyb.sg_flags & XTABS)
+ if (cur_term->Ottyb.sg_flags & XTABS)
tab = back_tab = NULL;
#endif
rc = OK;
}
-#endif
}
returnCode(rc);
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-def_shell_mode(void)
-{
- return NCURSES_SP_NAME(def_shell_mode) (CURRENT_SCREEN);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0)
+def_prog_mode(void)
{
int rc = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
- T((T_CALLED("def_prog_mode(%p)"), (void *) SP_PARM));
+ T((T_CALLED("def_prog_mode()")));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- rc = CallDriver_2(SP_PARM, mode, TRUE, TRUE);
-#else
+ if (cur_term != 0) {
/*
* Turn off the XTABS bit in the tty structure if it was on.
*/
- if (_nc_get_tty_mode(&termp->Nttyb) == OK) {
+ if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) {
#ifdef TERMIOS
- termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
+ cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
#else
- termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
+ cur_term->Nttyb.sg_flags &= ~XTABS;
#endif
rc = OK;
}
-#endif
}
returnCode(rc);
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-def_prog_mode(void)
-{
- return NCURSES_SP_NAME(def_prog_mode) (CURRENT_SCREEN);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0)
+reset_prog_mode(void)
{
- int rc = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
-
- T((T_CALLED("reset_prog_mode(%p)"), (void *) SP_PARM));
+ T((T_CALLED("reset_prog_mode()")));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- rc = CallDriver_2(SP_PARM, mode, TRUE, FALSE);
-#else
- if (_nc_set_tty_mode(&termp->Nttyb) == OK) {
- if (SP_PARM) {
- if (SP_PARM->_keypad_on)
- _nc_keypad(SP_PARM, TRUE);
- NC_BUFFERED(SP_PARM, TRUE);
+ if (cur_term != 0) {
+ if (_nc_set_tty_mode(&cur_term->Nttyb) == OK) {
+ if (SP) {
+ if (SP->_keypad_on)
+ _nc_keypad(SP, TRUE);
+ NC_BUFFERED(TRUE);
}
- rc = OK;
+ returnCode(OK);
}
-#endif
}
- returnCode(rc);
+ returnCode(ERR);
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
-reset_prog_mode(void)
-{
- return NCURSES_SP_NAME(reset_prog_mode) (CURRENT_SCREEN);
-}
-#endif
-
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0)
+reset_shell_mode(void)
{
- int rc = ERR;
- TERMINAL *termp = TerminalOf(SP_PARM);
+ T((T_CALLED("reset_shell_mode()")));
- T((T_CALLED("reset_shell_mode(%p)"), (void *) SP_PARM));
-
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
- rc = CallDriver_2(SP_PARM, mode, FALSE, FALSE);
-#else
- if (SP_PARM) {
- _nc_keypad(SP_PARM, FALSE);
+ if (cur_term != 0) {
+ if (SP) {
+ _nc_keypad(SP, FALSE);
_nc_flush();
- NC_BUFFERED(SP_PARM, FALSE);
+ NC_BUFFERED(FALSE);
}
- rc = _nc_set_tty_mode(&termp->Ottyb);
-#endif
+ returnCode(_nc_set_tty_mode(&cur_term->Ottyb));
}
- returnCode(rc);
+ returnCode(ERR);
}
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
-reset_shell_mode(void)
-{
- return NCURSES_SP_NAME(reset_shell_mode) (CURRENT_SCREEN);
-}
-#endif
-
static TTY *
-saved_tty(NCURSES_SP_DCL0)
+saved_tty(void)
{
TTY *result = 0;
- if (SP_PARM != 0) {
- result = (TTY *) & (SP_PARM->_saved_tty);
+ if (SP != 0) {
+ result = &(SP->_saved_tty);
} else {
if (_nc_prescreen.saved_tty == 0) {
_nc_prescreen.saved_tty = typeCalloc(TTY, 1);
@@ -291,31 +204,17 @@ saved_tty(NCURSES_SP_DCL0)
*/
NCURSES_EXPORT(int)
-NCURSES_SP_NAME(savetty) (NCURSES_SP_DCL0)
-{
- T((T_CALLED("savetty(%p)"), (void *) SP_PARM));
- returnCode(NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG)));
-}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(int)
savetty(void)
{
- return NCURSES_SP_NAME(savetty) (CURRENT_SCREEN);
-}
-#endif
+ T((T_CALLED("savetty()")));
-NCURSES_EXPORT(int)
-NCURSES_SP_NAME(resetty) (NCURSES_SP_DCL0)
-{
- T((T_CALLED("resetty(%p)"), (void *) SP_PARM));
- returnCode(NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG)));
+ returnCode(_nc_get_tty_mode(saved_tty()));
}
-#if NCURSES_SP_FUNCS
NCURSES_EXPORT(int)
resetty(void)
{
- return NCURSES_SP_NAME(resetty) (CURRENT_SCREEN);
+ T((T_CALLED("resetty()")));
+
+ returnCode(_nc_set_tty_mode(saved_tty()));
}
-#endif
diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c
deleted file mode 100644
index 15c281def50c..000000000000
--- a/ncurses/tinfo/make_hash.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2009,2010 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
- ****************************************************************************/
-
-/*
- * make_hash.c --- build-time program for constructing comp_captab.c
- *
- */
-
-#include <build.priv.h>
-
-#include <tic.h>
-#include <hashsize.h>
-
-#include <ctype.h>
-
-MODULE_ID("$Id: make_hash.c,v 1.3 2010/05/22 18:02:50 tom Exp $")
-
-/*
- * _nc_make_hash_table()
- *
- * Takes the entries in table[] and hashes them into hash_table[]
- * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE
- * slots in hash_table[].
- *
- */
-
-#undef MODULE_ID
-#define MODULE_ID(id) /*nothing */
-#include <tinfo/doalloc.c>
-
-/*
- * int hash_function(string)
- *
- * Computes the hashing function on the given string.
- *
- * The current hash function is the sum of each consectutive pair
- * of characters, taken as two-byte integers, mod HASHTABSIZE.
- *
- */
-
-static int
-hash_function(const char *string)
-{
- long sum = 0;
-
- while (*string) {
- sum += (long) (*string + (*(string + 1) << 8));
- string++;
- }
-
- return (int) (sum % HASHTABSIZE);
-}
-
-static void
-_nc_make_hash_table(struct name_table_entry *table,
- HashValue * hash_table)
-{
- short 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] >= 0)
- collisions++;
-
- if (hash_table[hashvalue] != 0)
- table[i].nte_link = hash_table[hashvalue];
- hash_table[hashvalue] = i;
- }
-
- printf("/* %d collisions out of %d entries */\n", collisions, CAPTABSIZE);
-}
-
-/*
- * This filter reads from standard input a list of tab-delimited columns,
- * (e.g., from Caps.filtered) computes the hash-value of a specified column and
- * writes the hashed tables to standard output.
- *
- * By compiling the hash table at build time, we're able to make the entire
- * set of terminfo and termcap tables readonly (and also provide some runtime
- * performance enhancement).
- */
-
-#define MAX_COLUMNS BUFSIZ /* this _has_ to be worst-case */
-
-static char **
-parse_columns(char *buffer)
-{
- static char **list;
-
- int col = 0;
-
- if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
- return (0);
-
- if (*buffer != '#') {
- while (*buffer != '\0') {
- char *s;
- for (s = buffer; (*s != '\0') && !isspace(UChar(*s)); s++)
- /*EMPTY */ ;
- if (s != buffer) {
- char mark = *s;
- *s = '\0';
- if ((s - buffer) > 1
- && (*buffer == '"')
- && (s[-1] == '"')) { /* strip the quotes */
- assert(s > buffer + 1);
- s[-1] = '\0';
- buffer++;
- }
- list[col] = buffer;
- col++;
- if (mark == '\0')
- break;
- while (*++s && isspace(UChar(*s)))
- /*EMPTY */ ;
- buffer = s;
- } else
- break;
- }
- }
- return col ? list : 0;
-}
-
-int
-main(int argc, char **argv)
-{
- struct name_table_entry *name_table = typeCalloc(struct
- name_table_entry, CAPTABSIZE);
- HashValue *hash_table = typeCalloc(HashValue, HASHTABSIZE);
- const char *root_name = "";
- int column = 0;
- int bigstring = 0;
- int n;
- char buffer[BUFSIZ];
-
- static const char *typenames[] =
- {"BOOLEAN", "NUMBER", "STRING"};
-
- short BoolCount = 0;
- short NumCount = 0;
- short StrCount = 0;
-
- /* The first argument is the column-number (starting with 0).
- * The second is the root name of the tables to generate.
- */
- if (argc <= 3
- || (column = atoi(argv[1])) <= 0
- || (column >= MAX_COLUMNS)
- || *(root_name = argv[2]) == 0
- || (bigstring = atoi(argv[3])) < 0
- || name_table == 0
- || hash_table == 0) {
- fprintf(stderr, "usage: make_hash column root_name bigstring\n");
- exit(EXIT_FAILURE);
- }
-
- /*
- * Read the table into our arrays.
- */
- for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin);) {
- char **list, *nlp = strchr(buffer, '\n');
- if (nlp)
- *nlp = '\0';
- list = parse_columns(buffer);
- if (list == 0) /* blank or comment */
- continue;
- name_table[n].nte_link = -1; /* end-of-hash */
- name_table[n].nte_name = strdup(list[column]);
- if (!strcmp(list[2], "bool")) {
- name_table[n].nte_type = BOOLEAN;
- name_table[n].nte_index = BoolCount++;
- } else if (!strcmp(list[2], "num")) {
- name_table[n].nte_type = NUMBER;
- name_table[n].nte_index = NumCount++;
- } else if (!strcmp(list[2], "str")) {
- name_table[n].nte_type = STRING;
- name_table[n].nte_index = StrCount++;
- } else {
- fprintf(stderr, "Unknown type: %s\n", list[2]);
- exit(EXIT_FAILURE);
- }
- n++;
- }
- _nc_make_hash_table(name_table, hash_table);
-
- /*
- * Write the compiled tables to standard output
- */
- if (bigstring) {
- int len = 0;
- int nxt;
-
- printf("static const char %s_names_text[] = \\\n", root_name);
- for (n = 0; n < CAPTABSIZE; n++) {
- nxt = (int) 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 += (int) 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("static const HashValue _nc_%s_hash_table[%d] =\n",
- root_name,
- HASHTABSIZE + 1);
- printf("{\n");
- for (n = 0; n < HASHTABSIZE; n++) {
- printf("\t%3d,\n", hash_table[n]);
- }
- printf("\t0\t/* base-of-table */\n");
- printf("};\n\n");
-
- printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
- BoolCount, NumCount, StrCount);
- printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
- printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
- printf("#endif\n\n");
-
- free(hash_table);
- return EXIT_SUCCESS;
-}
diff --git a/ncurses/tinfo/make_keys.c b/ncurses/tinfo/make_keys.c
index a7854e3fe604..c084f87fb943 100644
--- a/ncurses/tinfo/make_keys.c
+++ b/ncurses/tinfo/make_keys.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,18 +37,18 @@
*/
#define USE_TERMLIB 1
-#include <build.priv.h>
+#include <curses.priv.h>
-MODULE_ID("$Id: make_keys.c,v 1.19 2010/06/05 22:08:00 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.14 2008/08/03 21:57:22 tom Exp $")
#include <names.c>
-#define UNKNOWN (unsigned) (SIZEOF(strnames) + SIZEOF(strfnames))
+#define UNKNOWN (SIZEOF(strnames) + SIZEOF(strfnames))
-static unsigned
+static size_t
lookup(const char *name)
{
- unsigned n;
+ size_t n;
bool found = FALSE;
for (n = 0; strnames[n] != 0; n++) {
if (!strcmp(name, strnames[n])) {
@@ -73,7 +73,7 @@ make_keys(FILE *ifp, FILE *ofp)
char buffer[BUFSIZ];
char from[256];
char to[256];
- unsigned maxlen = 16;
+ int maxlen = 16;
int scanned;
while (fgets(buffer, sizeof(buffer), ifp) != 0) {
@@ -85,14 +85,14 @@ make_keys(FILE *ifp, FILE *ofp)
scanned = sscanf(buffer, "%255s %255s", to, from);
if (scanned == 2) {
- unsigned code = lookup(from);
+ int code = lookup(from);
if (code == UNKNOWN)
continue;
- if (strlen(from) > maxlen)
- maxlen = (unsigned) strlen(from);
- fprintf(ofp, "\t{ %4u, %-*.*s },\t/* %s */\n",
+ if ((int) strlen(from) > maxlen)
+ maxlen = strlen(from);
+ fprintf(ofp, "\t{ %4d, %-*.*s },\t/* %s */\n",
code,
- (int) maxlen, (int) maxlen,
+ maxlen, maxlen,
to,
from);
}
diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c
index a9ac64278888..d576901fa2e9 100644
--- a/ncurses/tinfo/name_match.c
+++ b/ncurses/tinfo/name_match.c
@@ -31,9 +31,10 @@
****************************************************************************/
#include <curses.priv.h>
+#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: name_match.c,v 1.18 2008/11/16 00:19:59 juergen Exp $")
+MODULE_ID("$Id: name_match.c,v 1.17 2008/08/03 19:49:33 tom Exp $")
/*
* _nc_first_name(char *names)
diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c
index ddbc25204fec..cf7a5f409d7c 100644
--- a/ncurses/tinfo/parse_entry.c
+++ b/ncurses/tinfo/parse_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -46,8 +46,9 @@
#include <ctype.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: parse_entry.c,v 1.75 2010/05/01 19:35:09 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.69 2008/08/16 21:52:03 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -83,13 +84,13 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
case NUMBER:
first = tp->ext_Booleans;
last = tp->ext_Numbers + first;
- offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
+ offset = tp->ext_Booleans + tp->ext_Numbers;
tindex = tp->num_Numbers;
break;
case STRING:
- first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers);
+ first = tp->ext_Booleans + tp->ext_Numbers;
last = tp->ext_Strings + first;
- offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings);
+ offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
tindex = tp->num_Strings;
break;
case CANCEL:
@@ -136,31 +137,27 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
break;
}
}
-
-#define for_each_value(max) \
- for (last = (unsigned) (max - 1); last > tindex; last--)
-
if (!found) {
switch (token_type) {
case BOOLEAN:
- tp->ext_Booleans++;
- tp->num_Booleans++;
+ tp->ext_Booleans += 1;
+ tp->num_Booleans += 1;
tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
- for_each_value(tp->num_Booleans)
+ for (last = tp->num_Booleans - 1; last > tindex; last--)
tp->Booleans[last] = tp->Booleans[last - 1];
break;
case NUMBER:
- tp->ext_Numbers++;
- tp->num_Numbers++;
+ tp->ext_Numbers += 1;
+ tp->num_Numbers += 1;
tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
- for_each_value(tp->num_Numbers)
+ for (last = tp->num_Numbers - 1; last > tindex; last--)
tp->Numbers[last] = tp->Numbers[last - 1];
break;
case STRING:
- tp->ext_Strings++;
- tp->num_Strings++;
+ tp->ext_Strings += 1;
+ tp->num_Strings += 1;
tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
- for_each_value(tp->num_Strings)
+ for (last = tp->num_Strings - 1; last > tindex; last--)
tp->Strings[last] = tp->Strings[last - 1];
break;
}
@@ -173,7 +170,7 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
temp.nte_name = tp->ext_Names[offset];
temp.nte_type = token_type;
- temp.nte_index = (short) tindex;
+ temp.nte_index = tindex;
temp.nte_link = -1;
return &temp;
@@ -382,14 +379,16 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
&& !strcmp("ma", _nc_curr_token.tk_name)) {
/* tell max_attributes from arrow_key_map */
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_syntax != 0);
+ _nc_get_table(_nc_syntax
+ != 0));
assert(entry_ptr != 0);
} else if (token_type == STRING
&& !strcmp("MT", _nc_curr_token.tk_name)) {
/* map terminfo's string MT to MT */
entry_ptr = _nc_find_type_entry("MT", STRING,
- _nc_syntax != 0);
+ _nc_get_table(_nc_syntax
+ != 0));
assert(entry_ptr != 0);
} else if (token_type == BOOLEAN
@@ -445,7 +444,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
case NUMBER:
entryp->tterm.Numbers[entry_ptr->nte_index] =
- (short) _nc_curr_token.tk_valnumber;
+ _nc_curr_token.tk_valnumber;
break;
case STRING:
@@ -511,9 +510,9 @@ NCURSES_EXPORT(int)
_nc_capcmp(const char *s, const char *t)
/* compare two string capabilities, stripping out padding */
{
- if (!VALID_STRING(s) && !VALID_STRING(t))
+ if (!s && !t)
return (0);
- else if (!VALID_STRING(s) || !VALID_STRING(t))
+ else if (!s || !t)
return (1);
for (;;) {
@@ -668,7 +667,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
else if (PRESENT(backspace_if_not_bs))
cursor_left = backspace_if_not_bs;
}
- /* vi doesn't use "do", but it does seem to use nl (or '\n') instead */
+ /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
if (WANTED(cursor_down)) {
if (PRESENT(linefeed_if_not_lf))
cursor_down = linefeed_if_not_lf;
@@ -773,7 +772,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
* isn't from mytinfo...
*/
if (PRESENT(other_non_function_keys)) {
- char *base;
+ char *base = other_non_function_keys;
char *bp, *cp, *dp;
struct name_table_entry const *from_ptr;
struct name_table_entry const *to_ptr;
@@ -789,7 +788,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
for (base = other_non_function_keys;
(cp = strchr(base, ',')) != 0;
base = cp + 1) {
- size_t len = (unsigned) (cp - base);
+ size_t len = cp - base;
for (ap = ko_xlate; ap->from; ap++) {
if (len == strlen(ap->from)
@@ -841,7 +840,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
} else
*dp++ = *bp;
}
- *dp = '\0';
+ *dp++ = '\0';
tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
}
diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c
index e38b9cbe49d8..b4ea61ca194e 100644
--- a/ncurses/tinfo/read_entry.c
+++ b/ncurses/tinfo/read_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,8 +40,9 @@
#include <hashed_db.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.108 2011/02/26 15:36:06 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.102 2008/08/03 19:33:04 tom Exp $")
#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
@@ -56,7 +57,7 @@ convert_shorts(char *buf, short *Numbers, int count)
else if (IS_NEG2(buf + 2 * i))
Numbers[i] = CANCELLED_NUMERIC;
else
- Numbers[i] = (short) LOW_MSB(buf + 2 * i);
+ Numbers[i] = LOW_MSB(buf + 2 * i);
TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i]));
}
}
@@ -98,9 +99,9 @@ fake_read(char *src, int *offset, int limit, char *dst, unsigned want)
if (have > 0) {
if ((int) want > have)
- want = (unsigned) have;
+ want = have;
memcpy(dst, src + *offset, want);
- *offset += (int) want;
+ *offset += want;
} else {
want = 0;
}
@@ -154,7 +155,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
return (TGETENT_NO);
}
- want = (unsigned) (str_size + name_size + 1);
+ want = str_size + name_size + 1;
if (str_size) {
/* try to allocate space for the string table */
if (str_count * 2 >= (int) sizeof(buf)
@@ -172,14 +173,14 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
want = min(MAX_NAME_SIZE, (unsigned) name_size);
ptr->str_table = string_table;
ptr->term_names = string_table;
- if ((have = (unsigned) Read(ptr->term_names, want)) != want) {
+ if ((have = Read(ptr->term_names, want)) != want) {
memset(ptr->term_names + have, 0, want - have);
}
ptr->term_names[want] = '\0';
string_table += (want + 1);
if (have > MAX_NAME_SIZE)
- offset = (int) (have - MAX_NAME_SIZE);
+ offset = (have - MAX_NAME_SIZE);
/* grab the booleans */
if ((ptr->Booleans = TYPE_CALLOC(NCURSES_SBOOL,
@@ -233,7 +234,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
int ext_str_count = LOW_MSB(buf + 4);
int ext_str_size = LOW_MSB(buf + 6);
int ext_str_limit = LOW_MSB(buf + 8);
- unsigned need = (unsigned) (ext_bool_count + ext_num_count + ext_str_count);
+ unsigned need = (ext_bool_count + ext_num_count + ext_str_count);
int base = 0;
if (need >= sizeof(buf)
@@ -246,9 +247,9 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
|| ext_str_limit < 0)
return (TGETENT_NO);
- ptr->num_Booleans = UShort(BOOLCOUNT + ext_bool_count);
- ptr->num_Numbers = UShort(NUMCOUNT + ext_num_count);
- ptr->num_Strings = UShort(STRCOUNT + ext_str_count);
+ ptr->num_Booleans = BOOLCOUNT + ext_bool_count;
+ ptr->num_Numbers = NUMCOUNT + ext_num_count;
+ ptr->num_Strings = STRCOUNT + ext_str_count;
ptr->Booleans = typeRealloc(NCURSES_SBOOL, ptr->num_Booleans, ptr->Booleans);
ptr->Numbers = typeRealloc(short, ptr->num_Numbers, ptr->Numbers);
@@ -260,7 +261,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
ext_bool_count, offset));
- if ((ptr->ext_Booleans = UShort(ext_bool_count)) != 0) {
+ if ((ptr->ext_Booleans = ext_bool_count) != 0) {
if (Read(ptr->Booleans + BOOLCOUNT, (unsigned)
ext_bool_count) != ext_bool_count)
return (TGETENT_NO);
@@ -269,7 +270,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
ext_num_count, offset));
- if ((ptr->ext_Numbers = UShort(ext_num_count)) != 0) {
+ if ((ptr->ext_Numbers = ext_num_count) != 0) {
if (!read_shorts(buf, ext_num_count))
return (TGETENT_NO);
TR(TRACE_DATABASE, ("Before converting extended-numbers"));
@@ -278,22 +279,21 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
TR(TRACE_DATABASE, ("READ extended-offsets @%d", offset));
if ((ext_str_count || need)
- && !read_shorts(buf, ext_str_count + (int) need))
+ && !read_shorts(buf, ext_str_count + need))
return (TGETENT_NO);
TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
ext_str_limit, offset));
if (ext_str_limit) {
- ptr->ext_str_table = typeMalloc(char, (size_t) ext_str_limit);
- if (ptr->ext_str_table == 0)
- return (TGETENT_NO);
+ if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
+ return (TGETENT_NO);
if (Read(ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit)
return (TGETENT_NO);
TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
}
- if ((ptr->ext_Strings = UShort(ext_str_count)) != 0) {
+ if ((ptr->ext_Strings = ext_str_count) != 0) {
TR(TRACE_DATABASE,
("Before computing extended-string capabilities str_count=%d, ext_str_count=%d",
str_count, ext_str_count));
@@ -305,7 +305,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
_nc_visbuf(ptr->Strings[i + str_count])));
ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count];
if (VALID_STRING(ptr->Strings[i + STRCOUNT]))
- base += (int) (strlen(ptr->Strings[i + STRCOUNT]) + 1);
+ base += (strlen(ptr->Strings[i + STRCOUNT]) + 1);
TR(TRACE_DATABASE, ("... to [%d] %s",
i + STRCOUNT,
_nc_visbuf(ptr->Strings[i + STRCOUNT])));
@@ -314,7 +314,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
if (need) {
if (ext_str_count >= (MAX_ENTRY_SIZE * 2))
- return (TGETENT_NO);
+ return (TGETENT_NO);
if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
return (TGETENT_NO);
TR(TRACE_DATABASE,
@@ -364,18 +364,16 @@ NCURSES_EXPORT(int)
_nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
/* return 1 if read, 0 if not found or garbled */
{
- FILE *fp = 0;
- int code;
+ int code, fd = -1;
int limit;
char buffer[MAX_ENTRY_SIZE + 1];
if (_nc_access(filename, R_OK) < 0
- || (fp = fopen(filename, "rb")) == 0) {
+ || (fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
T(("cannot open terminfo %s (errno=%d)", filename, errno));
code = TGETENT_NO;
} else {
- if ((limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp))
- > 0) {
+ if ((limit = read(fd, buffer, sizeof(buffer))) > 0) {
T(("read terminfo %s", filename));
if ((code = _nc_read_termtype(ptr, buffer, limit)) == TGETENT_NO) {
@@ -384,7 +382,7 @@ _nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
} else {
code = TGETENT_NO;
}
- fclose(fp);
+ close(fd);
}
return (code);
@@ -406,22 +404,26 @@ _nc_read_tic_entry(char *filename,
/*
* If we are looking in a directory, assume the entry is a file under that,
* according to the normal rules.
+ *
+ * FIXME - add caseless-filename fixup.
*/
- unsigned need = (unsigned) (LEAF_LEN + 3 + strlen(path) + strlen(name));
- if (need <= limit)
- (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name);
+ if (_nc_is_dir_path(path)) {
+ unsigned need = 4 + strlen(path) + strlen(name);
- if (_nc_is_dir_path(path))
- result = _nc_read_file_entry(filename, tp);
+ if (need <= limit) {
+ (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name);
+ result = _nc_read_file_entry(filename, tp);
+ }
+ }
#if USE_HASHED_DB
else {
static const char suffix[] = DBM_SUFFIX;
DB *capdbp;
unsigned lens = sizeof(suffix) - 1;
unsigned size = strlen(path);
- unsigned test = lens + size;
+ unsigned need = lens + size;
- if (test < limit) {
+ if (need <= limit) {
if (size >= lens
&& !strcmp(path + size - lens, suffix))
(void) strcpy(filename, path);
@@ -513,7 +515,6 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp)
{
int code = TGETENT_NO;
- sprintf(filename, "%.*s", PATH_MAX - 1, name);
if (strlen(name) == 0
|| strcmp(name, ".") == 0
|| strcmp(name, "..") == 0
diff --git a/ncurses/tinfo/read_termcap.c b/ncurses/tinfo/read_termcap.c
index b39a5bebaa47..d94d1a42466d 100644
--- a/ncurses/tinfo/read_termcap.c
+++ b/ncurses/tinfo/read_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 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 *
@@ -56,8 +56,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: read_termcap.c,v 1.74 2010/01/23 17:57:43 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.71 2006/07/29 12:06:51 tom Exp $")
#if !PURE_TERMINFO
@@ -78,15 +79,6 @@ get_termpath(void)
return result;
}
-/*
- * Note:
- * getcap(), cgetent(), etc., are BSD functions. A copy of those was added to
- * this file in November 1995, derived from the BSD4.4 Lite sources.
- *
- * The initial adaptation uses 518 lines from that source.
- * The current source (in 2009) uses 183 lines of BSD4.4 Lite (441 ignoring
- * whitespace).
- */
#if USE_GETCAP
#if HAVE_BSD_CGETENT
@@ -115,7 +107,11 @@ static int _nc_nfcmp(const char *, char *);
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgment:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/ncurses/tinfo/setbuf.c b/ncurses/tinfo/setbuf.c
index a2e2660c8664..ba910e8983a4 100644
--- a/ncurses/tinfo/setbuf.c
+++ b/ncurses/tinfo/setbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 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 *
@@ -29,8 +29,6 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996-on *
- * and: Juergen Pfeifer 2008 *
****************************************************************************/
/*
@@ -42,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: setbuf.c,v 1.16 2010/08/28 21:08:31 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
@@ -100,20 +98,11 @@ MODULE_ID("$Id: setbuf.c,v 1.16 2010/08/28 21:08:31 tom Exp $")
* buffer. So we disable this by default (there may yet be a workaround).
*/
NCURSES_EXPORT(void)
-NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
+_nc_set_buffer(FILE *ofp, bool buffered)
{
- int Cols;
- int Lines;
-
- if (0 == SP_PARM)
- return;
-
- Cols = *(ptrCols(SP_PARM));
- Lines = *(ptrLines(SP_PARM));
-
/* optional optimization hack -- do before any output to ofp */
#if HAVE_SETVBUF || HAVE_SETBUFFER
- if (SP_PARM->_buffered != buffered) {
+ if (SP->_buffered != buffered) {
unsigned buf_len;
char *buf_ptr;
@@ -125,11 +114,11 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
setmode(ofp, O_BINARY);
#endif
if (buffered != 0) {
- buf_len = (unsigned) min(Lines * (Cols + 6), 2800);
- if ((buf_ptr = SP_PARM->_setbuf) == 0) {
+ buf_len = min(LINES * (COLS + 6), 2800);
+ if ((buf_ptr = SP->_setbuf) == 0) {
if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
return;
- SP_PARM->_setbuf = buf_ptr;
+ SP->_setbuf = buf_ptr;
/* Don't try to free this! */
}
#if !USE_SETBUF_0
@@ -155,15 +144,7 @@ NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered)
(void) setbuffer(ofp, buf_ptr, (int) buf_len);
#endif
- SP_PARM->_buffered = buffered;
+ SP->_buffered = buffered;
}
#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
}
-
-#if NCURSES_SP_FUNCS
-NCURSES_EXPORT(void)
-_nc_set_buffer(FILE *ofp, bool buffered)
-{
- NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered);
-}
-#endif
diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c
deleted file mode 100644
index 5b3b55a4519e..000000000000
--- a/ncurses/tinfo/tinfo_driver.c
+++ /dev/null
@@ -1,1337 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2008-2009,2010 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: Juergen Pfeifer *
- * *
- ****************************************************************************/
-
-#include <curses.priv.h>
-#define CUR ((TERMINAL*)TCB)->type.
-#include <tic.h>
-
-#if HAVE_NANOSLEEP
-#include <time.h>
-#if HAVE_SYS_TIME_H
-#include <sys/time.h> /* needed for MacOS X DP3 */
-#endif
-#endif
-
-#if HAVE_SIZECHANGE
-# if !defined(sun) || !TERMIOS
-# if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-# endif
-# endif
-#endif
-
-MODULE_ID("$Id: tinfo_driver.c,v 1.13 2010/12/20 01:47:09 tom Exp $")
-
-/*
- * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
- * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
- */
-#ifdef TIOCGSIZE
-# define IOCTL_WINSIZE TIOCGSIZE
-# define STRUCT_WINSIZE struct ttysize
-# define WINSIZE_ROWS(n) (int)n.ts_lines
-# define WINSIZE_COLS(n) (int)n.ts_cols
-#else
-# ifdef TIOCGWINSZ
-# define IOCTL_WINSIZE TIOCGWINSZ
-# define STRUCT_WINSIZE struct winsize
-# define WINSIZE_ROWS(n) (int)n.ws_row
-# define WINSIZE_COLS(n) (int)n.ws_col
-# endif
-#endif
-
-/*
- * These should be screen structure members. They need to be globals for
- * historical reasons. So we assign them in start_color() and also in
- * set_term()'s screen-switching logic.
- */
-#if USE_REENTRANT
-NCURSES_EXPORT(int)
-NCURSES_PUBLIC_VAR(COLOR_PAIRS) (void)
-{
- return CURRENT_SCREEN ? CURRENT_SCREEN->_pair_count : -1;
-}
-NCURSES_EXPORT(int)
-NCURSES_PUBLIC_VAR(COLORS) (void)
-{
- return CURRENT_SCREEN ? CURRENT_SCREEN->_color_count : -1;
-}
-#else
-NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
-NCURSES_EXPORT_VAR(int) COLORS = 0;
-#endif
-
-#define TCBMAGIC NCDRV_MAGIC(NCDRV_TINFO)
-#define AssertTCB() assert(TCB!=0 && TCB->magic==TCBMAGIC)
-#define SetSP() assert(TCB->csp!=0); sp = TCB->csp
-
-/*
- * This routine needs to do all the work to make curscr look
- * like newscr.
- */
-static int
-drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
-{
- AssertTCB();
- return TINFO_DOUPDATE(TCB->csp);
-}
-
-#define ret_error(code, fmt, arg) if (errret) {\
- *errret = code;\
- return(FALSE); \
- } else {\
- fprintf(stderr, fmt, arg);\
- exit(EXIT_FAILURE);\
- }
-
-#define ret_error0(code, msg) if (errret) {\
- *errret = code;\
- return(FALSE);\
- } else {\
- fprintf(stderr, msg);\
- exit(EXIT_FAILURE);\
- }
-
-static bool
-drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)
-{
- bool result = FALSE;
- int status;
- TERMINAL *termp;
- SCREEN *sp;
-
- assert(TCB != 0 && tname != 0);
- termp = (TERMINAL *) TCB;
- sp = TCB->csp;
- TCB->magic = TCBMAGIC;
-
-#if (USE_DATABASE || USE_TERMCAP)
- status = _nc_setup_tinfo(tname, &termp->type);
-#else
- status = TGETENT_NO;
-#endif
-
- /* try fallback list if entry on disk */
- if (status != TGETENT_YES) {
- const TERMTYPE *fallback = _nc_fallback(tname);
-
- if (fallback) {
- termp->type = *fallback;
- status = TGETENT_YES;
- }
- }
-
- if (status != TGETENT_YES) {
- NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx termp);
- if (status == TGETENT_ERR) {
- ret_error0(status, "terminals database is inaccessible\n");
- } else if (status == TGETENT_NO) {
- ret_error(status, "'%s': unknown terminal type.\n", tname);
- }
- }
- result = TRUE;
-#if !USE_REENTRANT
- strncpy(ttytype, termp->type.term_names, NAMESIZE - 1);
- ttytype[NAMESIZE - 1] = '\0';
-#endif
-
- if (command_character)
- _nc_tinfo_cmdch(termp, *command_character);
-
- if (generic_type) {
- ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
- }
- if (hard_copy) {
- ret_error(TGETENT_YES, "'%s': I can't handle hardcopy terminals.\n", tname);
- }
-
- return result;
-}
-
-static int
-drv_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB, bool beepFlag)
-{
- SCREEN *sp;
- int res = ERR;
-
- AssertTCB();
- SetSP();
-
- /* FIXME: should make sure that we are not in altchar mode */
- if (beepFlag) {
- if (bell) {
- res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "bell", bell);
- NCURSES_SP_NAME(_nc_flush) (sp);
- } else if (flash_screen) {
- res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
- "flash_screen",
- flash_screen);
- NCURSES_SP_NAME(_nc_flush) (sp);
- }
- } else {
- if (flash_screen) {
- res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
- "flash_screen",
- flash_screen);
- NCURSES_SP_NAME(_nc_flush) (sp);
- } else if (bell) {
- res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "bell", bell);
- NCURSES_SP_NAME(_nc_flush) (sp);
- }
- }
- return res;
-}
-
-/*
- * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
- * to maintain compatibility with a pre-ANSI scheme. The same scheme is
- * also used in the FreeBSD syscons.
- */
-static int
-toggled_colors(int c)
-{
- if (c < 16) {
- static const int table[] =
- {0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15};
- c = table[c];
- }
- return c;
-}
-
-static int
-drv_print(TERMINAL_CONTROL_BLOCK * TCB, char *data, int len)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-#if NCURSES_EXT_FUNCS
- return NCURSES_SP_NAME(mcprint) (TCB->csp, data, len);
-#else
- return ERR;
-#endif
-}
-
-static int
-drv_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB, int fg, int bg)
-{
- SCREEN *sp;
- int code = ERR;
-
- AssertTCB();
- SetSP();
-
- if (sp != 0 && orig_pair && orig_colors && (initialize_pair != 0)) {
-#if NCURSES_EXT_FUNCS
- sp->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
- sp->_has_sgr_39_49 = (NCURSES_SP_NAME(tigetflag) (NCURSES_SP_ARGx
- "AX")
- == TRUE);
- sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
- sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
- if (sp->_color_pairs != 0) {
- bool save = sp->_default_color;
- sp->_default_color = TRUE;
- NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx
- 0,
- (short)fg,
- (short)bg);
- sp->_default_color = save;
- }
-#endif
- code = OK;
- }
- return (code);
-}
-
-static void
-drv_setcolor(TERMINAL_CONTROL_BLOCK * TCB,
- bool fore,
- int color,
- NCURSES_SP_OUTC outc)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- if (fore) {
- if (set_a_foreground) {
- TPUTS_TRACE("set_a_foreground");
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_a_foreground, color), 1, outc);
- } else {
- TPUTS_TRACE("set_foreground");
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_foreground,
- toggled_colors(color)), 1, outc);
- }
- } else {
- if (set_a_background) {
- TPUTS_TRACE("set_a_background");
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_a_background, color), 1, outc);
- } else {
- TPUTS_TRACE("set_background");
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_background,
- toggled_colors(color)), 1, outc);
- }
- }
-}
-
-static bool
-drv_rescol(TERMINAL_CONTROL_BLOCK * TCB)
-{
- bool result = FALSE;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- if (orig_pair != 0) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "orig_pair", orig_pair);
- result = TRUE;
- }
- return result;
-}
-
-static bool
-drv_rescolors(TERMINAL_CONTROL_BLOCK * TCB)
-{
- int result = FALSE;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- if (orig_colors != 0) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "orig_colors", orig_colors);
- result = TRUE;
- }
- return result;
-}
-
-static int
-drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
-{
- SCREEN *sp;
- bool useEnv = TRUE;
-
- AssertTCB();
- sp = TCB->csp; /* can be null here */
-
- if (sp) {
- useEnv = sp->_use_env;
- } else
- useEnv = _nc_prescreen.use_env;
-
- /* figure out the size of the screen */
- T(("screen size: terminfo lines = %d columns = %d", lines, columns));
-
- *linep = (int) lines;
- *colp = (int) columns;
-
- if (useEnv) {
- int value;
-
-#ifdef __EMX__
- {
- int screendata[2];
- _scrsize(screendata);
- *colp = screendata[0];
- *linep = screendata[1];
- T(("EMX screen size: environment LINES = %d COLUMNS = %d",
- *linep, *colp));
- }
-#endif
-#if HAVE_SIZECHANGE
- /* try asking the OS */
- {
- TERMINAL *termp = (TERMINAL *) TCB;
- if (isatty(termp->Filedes)) {
- STRUCT_WINSIZE size;
-
- errno = 0;
- do {
- if (ioctl(termp->Filedes, IOCTL_WINSIZE, &size) >= 0) {
- *linep = ((sp != 0 && sp->_filtered)
- ? 1
- : WINSIZE_ROWS(size));
- *colp = WINSIZE_COLS(size);
- T(("SYS screen size: environment LINES = %d COLUMNS = %d",
- *linep, *colp));
- break;
- }
- } while
- (errno == EINTR);
- }
- }
-#endif /* HAVE_SIZECHANGE */
-
- /*
- * Finally, look for environment variables.
- *
- * Solaris lets users override either dimension with an environment
- * variable.
- */
- if ((value = _nc_getenv_num("LINES")) > 0) {
- *linep = value;
- T(("screen size: environment LINES = %d", *linep));
- }
- if ((value = _nc_getenv_num("COLUMNS")) > 0) {
- *colp = value;
- T(("screen size: environment COLUMNS = %d", *colp));
- }
-
- /* if we can't get dynamic info about the size, use static */
- if (*linep <= 0) {
- *linep = (int) lines;
- }
- if (*colp <= 0) {
- *colp = (int) columns;
- }
-
- /* the ultimate fallback, assume fixed 24x80 size */
- if (*linep <= 0) {
- *linep = 24;
- }
- if (*colp <= 0) {
- *colp = 80;
- }
-
- /*
- * Put the derived values back in the screen-size caps, so
- * tigetnum() and tgetnum() will do the right thing.
- */
- lines = (short) (*linep);
- columns = (short) (*colp);
- }
-
- T(("screen size is %dx%d", *linep, *colp));
- return OK;
-}
-
-static int
-drv_getsize(TERMINAL_CONTROL_BLOCK * TCB, int *l, int *c)
-{
- AssertTCB();
- assert(l != 0 && c != 0);
- *l = lines;
- *c = columns;
- return OK;
-}
-
-static int
-drv_setsize(TERMINAL_CONTROL_BLOCK * TCB, int l, int c)
-{
- AssertTCB();
- lines = (short) l;
- columns = (short) c;
- return OK;
-}
-
-static int
-drv_sgmode(TERMINAL_CONTROL_BLOCK * TCB, bool setFlag, TTY * buf)
-{
- SCREEN *sp = TCB->csp;
- TERMINAL *_term = (TERMINAL *) TCB;
- int result = OK;
-
- AssertTCB();
- if (setFlag) {
- for (;;) {
- if (SET_TTY(_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- if (errno == ENOTTY) {
- if (sp)
- sp->_notty = TRUE;
- }
- result = ERR;
- }
- break;
- }
- } else {
- for (;;) {
- if (GET_TTY(_term->Filedes, buf) != 0) {
- if (errno == EINTR)
- continue;
- result = ERR;
- }
- break;
- }
- }
- return result;
-}
-
-static int
-drv_mode(TERMINAL_CONTROL_BLOCK * TCB, bool progFlag, bool defFlag)
-{
- SCREEN *sp;
- TERMINAL *_term = (TERMINAL *) TCB;
- int code = ERR;
-
- AssertTCB();
- sp = TCB->csp;
-
- if (progFlag) /* prog mode */
- {
- if (defFlag) {
- /* def_prog_mode */
- /*
- * Turn off the XTABS bit in the tty structure if it was on.
- */
- if ((drv_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
-#ifdef TERMIOS
- _term->Nttyb.c_oflag &= (unsigned) ~OFLAGS_TABS;
-#else
- _term->Nttyb.sg_flags &= (unsigned) ~XTABS;
-#endif
- code = OK;
- }
- } else {
- /* reset_prog_mode */
- if (drv_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) {
- if (sp) {
- if (sp->_keypad_on)
- _nc_keypad(sp, TRUE);
- NC_BUFFERED(sp, TRUE);
- }
- code = OK;
- }
- }
- } else { /* shell mode */
- if (defFlag) {
- /* def_shell_mode */
- /*
- * If XTABS was on, remove the tab and backtab capabilities.
- */
- if (drv_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) {
-#ifdef TERMIOS
- if (_term->Ottyb.c_oflag & OFLAGS_TABS)
- tab = back_tab = NULL;
-#else
- if (_term->Ottyb.sg_flags & XTABS)
- tab = back_tab = NULL;
-#endif
- code = OK;
- }
- } else {
- /* reset_shell_mode */
- if (sp) {
- _nc_keypad(sp, FALSE);
- NCURSES_SP_NAME(_nc_flush) (sp);
- NC_BUFFERED(sp, FALSE);
- }
- code = drv_sgmode(TCB, TRUE, &(_term->Ottyb));
- }
- }
- return (code);
-}
-
-static void
-drv_wrap(SCREEN *sp)
-{
- if (sp) {
- sp->_mouse_wrap(sp);
- NCURSES_SP_NAME(_nc_screen_wrap) (sp);
- NCURSES_SP_NAME(_nc_mvcur_wrap) (sp); /* wrap up cursor addressing */
- }
-}
-
-static void
-drv_release(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED)
-{
-}
-
-# define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
-
-static void
-drv_screen_init(SCREEN *sp)
-{
- TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
-
- AssertTCB();
-
- /*
- * Check for mismatched graphic-rendition capabilities. Most SVr4
- * terminfo trees contain entries that have rmul or rmso equated to
- * sgr0 (Solaris curses copes with those entries). We do this only
- * for curses, since many termcap applications assume that
- * smso/rmso and smul/rmul are paired, and will not function
- * properly if we remove rmso or rmul. Curses applications
- * shouldn't be looking at this detail.
- */
- sp->_use_rmso = SGR0_TEST(exit_standout_mode);
- sp->_use_rmul = SGR0_TEST(exit_underline_mode);
-
- /*
- * Check whether we can optimize scrolling under dumb terminals in
- * case we do not have any of these capabilities, scrolling
- * optimization will be useless.
- */
- sp->_scrolling = ((scroll_forward && scroll_reverse) ||
- ((parm_rindex ||
- parm_insert_line ||
- insert_line) &&
- (parm_index ||
- parm_delete_line ||
- delete_line)));
-
- NCURSES_SP_NAME(baudrate) (sp);
-
- NCURSES_SP_NAME(_nc_mvcur_init) (sp);
- /* initialize terminal to a sane state */
- NCURSES_SP_NAME(_nc_screen_init) (sp);
-}
-
-static void
-drv_init(TERMINAL_CONTROL_BLOCK * TCB)
-{
- SCREEN *sp;
- TERMINAL *trm;
-
- AssertTCB();
-
- trm = (TERMINAL *) TCB;
- sp = TCB->csp;
-
- TCB->info.initcolor = initialize_color;
- TCB->info.canchange = can_change;
- TCB->info.hascolor = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs)
- && (((set_foreground != NULL)
- && (set_background != NULL))
- || ((set_a_foreground != NULL)
- && (set_a_background != NULL))
- || set_color_pair)) ? TRUE : FALSE);
-
- TCB->info.caninit = !(exit_ca_mode && non_rev_rmcup);
-
- TCB->info.maxpairs = VALID_NUMERIC(max_pairs) ? max_pairs : 0;
- TCB->info.maxcolors = VALID_NUMERIC(max_colors) ? max_colors : 0;
- TCB->info.numlabels = VALID_NUMERIC(num_labels) ? num_labels : 0;
- TCB->info.labelwidth = VALID_NUMERIC(label_width) ? label_width : 0;
- TCB->info.labelheight = VALID_NUMERIC(label_height) ? label_height : 0;
- TCB->info.nocolorvideo = VALID_NUMERIC(no_color_video) ? no_color_video
- : 0;
- TCB->info.tabsize = VALID_NUMERIC(init_tabs) ? (int) init_tabs : 8;
-
- TCB->info.defaultPalette = hue_lightness_saturation ? _nc_hls_palette : _nc_cga_palette;
-
- /*
- * If an application calls setupterm() rather than initscr() or
- * newterm(), we will not have the def_prog_mode() call in
- * _nc_setupscreen(). Do it now anyway, so we can initialize the
- * baudrate.
- */
- if (isatty(trm->Filedes)) {
- TCB->drv->mode(TCB, TRUE, TRUE);
- }
-}
-
-#define MAX_PALETTE 8
-#define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE)
-
-static void
-drv_initpair(TERMINAL_CONTROL_BLOCK * TCB, short pair, short f, short b)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- if ((initialize_pair != NULL) && InPalette(f) && InPalette(b)) {
- const color_t *tp = InfoOf(sp).defaultPalette;
-
- TR(TRACE_ATTRS,
- ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
-
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
- "initialize_pair",
- TPARM_7(initialize_pair,
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
- }
-}
-
-static int
-default_fg(SCREEN *sp)
-{
-#if NCURSES_EXT_FUNCS
- return (sp != 0) ? sp->_default_fg : COLOR_WHITE;
-#else
- return COLOR_WHITE;
-#endif
-}
-
-static int
-default_bg(SCREEN *sp)
-{
-#if NCURSES_EXT_FUNCS
- return sp != 0 ? sp->_default_bg : COLOR_BLACK;
-#else
- return COLOR_BLACK;
-#endif
-}
-
-static void
-drv_initcolor(TERMINAL_CONTROL_BLOCK * TCB,
- short color, short r, short g, short b)
-{
- SCREEN *sp = TCB->csp;
-
- AssertTCB();
- if (initialize_color != NULL) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
- "initialize_color",
- TPARM_4(initialize_color, color, r, g, b));
- }
-}
-
-static void
-drv_do_color(TERMINAL_CONTROL_BLOCK * TCB,
- short old_pair,
- short pair,
- bool reverse,
- NCURSES_SP_OUTC outc)
-{
- SCREEN *sp = TCB->csp;
- NCURSES_COLOR_T fg = COLOR_DEFAULT;
- NCURSES_COLOR_T bg = COLOR_DEFAULT;
- NCURSES_COLOR_T old_fg, old_bg;
-
- AssertTCB();
- if (sp == 0)
- return;
-
- if (pair < 0 || pair >= COLOR_PAIRS) {
- return;
- } else if (pair != 0) {
- if (set_color_pair) {
- TPUTS_TRACE("set_color_pair");
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_color_pair, pair), 1, outc);
- return;
- } else if (sp != 0) {
- NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
- (short) pair,
- &fg,
- &bg);
- }
- }
-
- if (old_pair >= 0
- && sp != 0
- && NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
- old_pair,
- &old_fg,
- &old_bg) !=ERR) {
- if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
- || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
-#if NCURSES_EXT_FUNCS
- /*
- * A minor optimization - but extension. If "AX" is specified in
- * the terminal description, treat it as screen's indicator of ECMA
- * SGR 39 and SGR 49, and assume the two sequences are independent.
- */
- if (sp->_has_sgr_39_49
- && isDefaultColor(old_bg)
- && !isDefaultColor(old_fg)) {
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc);
- } else if (sp->_has_sgr_39_49
- && isDefaultColor(old_fg)
- && !isDefaultColor(old_bg)) {
- NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc);
- } else
-#endif
- drv_rescol(TCB);
- }
- } else {
- drv_rescol(TCB);
- if (old_pair < 0)
- return;
- }
-
-#if NCURSES_EXT_FUNCS
- if (isDefaultColor(fg))
- fg = (NCURSES_COLOR_T) default_fg(sp);
- if (isDefaultColor(bg))
- bg = (NCURSES_COLOR_T) default_bg(sp);
-#endif
-
- if (reverse) {
- NCURSES_COLOR_T xx = fg;
- fg = bg;
- bg = xx;
- }
-
- TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
- fg, bg));
-
- if (!isDefaultColor(fg)) {
- drv_setcolor(TCB, TRUE, fg, outc);
- }
- if (!isDefaultColor(bg)) {
- drv_setcolor(TCB, FALSE, bg, outc);
- }
-}
-
-#define xterm_kmous "\033[M"
-static void
-init_xterm_mouse(SCREEN *sp)
-{
- sp->_mouse_type = M_XTERM;
- sp->_mouse_xtermcap = NCURSES_SP_NAME(tigetstr) (NCURSES_SP_ARGx "XM");
- if (!VALID_STRING(sp->_mouse_xtermcap))
- sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
-}
-
-static void
-drv_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- /* we know how to recognize mouse events under "xterm" */
- if (sp != 0) {
- if (key_mouse != 0) {
- if (!strcmp(key_mouse, xterm_kmous)
- || strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
- init_xterm_mouse(sp);
- }
- } else if (strstr(TerminalOf(sp)->type.term_names, "xterm") != 0) {
- if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
- init_xterm_mouse(sp);
- }
- }
-}
-
-static int
-drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay)
-{
- int rc = 0;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
-#if USE_SYSMOUSE
- if ((sp->_mouse_type == M_SYSMOUSE)
- && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
- rc = TW_MOUSE;
- } else
-#endif
- {
- rc = TCBOf(sp)->drv->twait(TCBOf(sp),
- TWAIT_MASK,
- delay,
- (int *) 0
- EVENTLIST_2nd(evl));
-#if USE_SYSMOUSE
- if ((sp->_mouse_type == M_SYSMOUSE)
- && (sp->_sysmouse_head < sp->_sysmouse_tail)
- && (rc == 0)
- && (errno == EINTR)) {
- rc |= TW_MOUSE;
- }
-#endif
- }
- return rc;
-}
-
-static int
-drv_mvcur(TERMINAL_CONTROL_BLOCK * TCB, int yold, int xold, int ynew, int xnew)
-{
- SCREEN *sp = TCB->csp;
- AssertTCB();
- return TINFO_MVCUR(sp, yold, xold, ynew, xnew);
-}
-
-static void
-drv_hwlabel(TERMINAL_CONTROL_BLOCK * TCB, int labnum, char *text)
-{
- SCREEN *sp = TCB->csp;
-
- AssertTCB();
- if (labnum > 0 && labnum <= num_labels) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx
- "plab_norm",
- TPARM_2(plab_norm, labnum, text));
- }
-}
-
-static void
-drv_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB, bool OnFlag)
-{
- SCREEN *sp = TCB->csp;
-
- AssertTCB();
- if (OnFlag) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "label_on", label_on);
- } else {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "label_off", label_off);
- }
-}
-
-static chtype
-drv_conattr(TERMINAL_CONTROL_BLOCK * TCB)
-{
- SCREEN *sp = TCB->csp;
- chtype attrs = A_NORMAL;
-
- AssertTCB();
- if (enter_alt_charset_mode)
- attrs |= A_ALTCHARSET;
-
- if (enter_blink_mode)
- attrs |= A_BLINK;
-
- if (enter_bold_mode)
- attrs |= A_BOLD;
-
- if (enter_dim_mode)
- attrs |= A_DIM;
-
- if (enter_reverse_mode)
- attrs |= A_REVERSE;
-
- if (enter_standout_mode)
- attrs |= A_STANDOUT;
-
- if (enter_protected_mode)
- attrs |= A_PROTECT;
-
- if (enter_secure_mode)
- attrs |= A_INVIS;
-
- if (enter_underline_mode)
- attrs |= A_UNDERLINE;
-
- if (sp && sp->_coloron)
- attrs |= A_COLOR;
-
- return (attrs);
-}
-
-static void
-drv_setfilter(TERMINAL_CONTROL_BLOCK * TCB)
-{
- AssertTCB();
-
- clear_screen = 0;
- cursor_down = parm_down_cursor = 0;
- cursor_address = 0;
- cursor_up = parm_up_cursor = 0;
- row_address = 0;
- cursor_home = carriage_return;
-}
-
-static void
-drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map)
-{
- SCREEN *sp = TCB->csp;
-
- AssertTCB();
- assert(sp != 0);
- if (ena_acs != NULL) {
- NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "ena_acs", ena_acs);
- }
-#if NCURSES_EXT_FUNCS
- /*
- * Linux console "supports" the "PC ROM" character set by the coincidence
- * that smpch/rmpch and smacs/rmacs have the same values. ncurses has
- * no codepage support (see SCO Merge for an example). Outside of the
- * values defined in acsc, there are no definitions for the "PC ROM"
- * character set (assumed by some applications to be codepage 437), but we
- * allow those applications to use those codepoints.
- *
- * test/blue.c uses this feature.
- */
-#define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b))
- if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) &&
- PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) {
- size_t i;
- for (i = 1; i < ACS_LEN; ++i) {
- if (real_map[i] == 0) {
- real_map[i] = i;
- if (real_map != fake_map) {
- if (sp != 0)
- sp->_screen_acs_map[i] = TRUE;
- }
- }
- }
- }
-#endif
-
- if (acs_chars != NULL) {
- size_t i = 0;
- size_t length = strlen(acs_chars);
-
- while (i + 1 < length) {
- if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
- real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
- if (sp != 0)
- sp->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
- }
- i += 2;
- }
- }
-#ifdef TRACE
- /* Show the equivalent mapping, noting if it does not match the
- * given attribute, whether by re-ordering or duplication.
- */
- if (USE_TRACEF(TRACE_CALLS)) {
- size_t n, m;
- char show[ACS_LEN * 2 + 1];
- for (n = 1, m = 0; n < ACS_LEN; n++) {
- if (real_map[n] != 0) {
- show[m++] = (char) n;
- show[m++] = (char) ChCharOf(real_map[n]);
- }
- }
- show[m] = 0;
- if (acs_chars == NULL || strcmp(acs_chars, show))
- _tracef("%s acs_chars %s",
- (acs_chars == NULL) ? "NULL" : "READ",
- _nc_visbuf(acs_chars));
- _tracef("%s acs_chars %s",
- (acs_chars == NULL)
- ? "NULL"
- : (strcmp(acs_chars, show)
- ? "DIFF"
- : "SAME"),
- _nc_visbuf(show));
-
- _nc_unlock_global(tracef);
- }
-#endif /* TRACE */
-}
-
-#define ENSURE_TINFO(sp) (TCBOf(sp)->drv->isTerminfo)
-
-NCURSES_EXPORT(void)
-_nc_cookie_init(SCREEN *sp)
-{
- bool support_cookies = USE_XMC_SUPPORT;
- TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) (sp->_term);
-
- if (sp == 0 || !ENSURE_TINFO(sp))
- return;
-
-#if USE_XMC_SUPPORT
- /*
- * If we have no magic-cookie support compiled-in, or if it is suppressed
- * in the environment, reset the support-flag.
- */
- if (magic_cookie_glitch >= 0) {
- if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) {
- support_cookies = FALSE;
- }
- }
-#endif
-
- if (!support_cookies && magic_cookie_glitch >= 0) {
- T(("will disable attributes to work w/o magic cookies"));
- }
-
- if (magic_cookie_glitch > 0) { /* tvi, wyse */
-
- sp->_xmc_triggers = sp->_ok_attributes & (
- A_STANDOUT |
- A_UNDERLINE |
- A_REVERSE |
- A_BLINK |
- A_DIM |
- A_BOLD |
- A_INVIS |
- A_PROTECT
- );
-#if 0
- /*
- * We "should" treat colors as an attribute. The wyse350 (and its
- * clones) appear to be the only ones that have both colors and magic
- * cookies.
- */
- if (has_colors()) {
- sp->_xmc_triggers |= A_COLOR;
- }
-#endif
- sp->_xmc_suppress = sp->_xmc_triggers & (chtype) ~(A_BOLD);
-
- T(("magic cookie attributes %s", _traceattr(sp->_xmc_suppress)));
- /*
- * Supporting line-drawing may be possible. But make the regular
- * video attributes work first.
- */
- acs_chars = ABSENT_STRING;
- ena_acs = ABSENT_STRING;
- enter_alt_charset_mode = ABSENT_STRING;
- exit_alt_charset_mode = ABSENT_STRING;
-#if USE_XMC_SUPPORT
- /*
- * To keep the cookie support simple, suppress all of the optimization
- * hooks except for clear_screen and the cursor addressing.
- */
- if (support_cookies) {
- clr_eol = ABSENT_STRING;
- clr_eos = ABSENT_STRING;
- set_attributes = ABSENT_STRING;
- }
-#endif
- } else if (magic_cookie_glitch == 0) { /* hpterm */
- }
-
- /*
- * If magic cookies are not supported, cancel the strings that set
- * video attributes.
- */
- if (!support_cookies && magic_cookie_glitch >= 0) {
- magic_cookie_glitch = ABSENT_NUMERIC;
- set_attributes = ABSENT_STRING;
- enter_blink_mode = ABSENT_STRING;
- enter_bold_mode = ABSENT_STRING;
- enter_dim_mode = ABSENT_STRING;
- enter_reverse_mode = ABSENT_STRING;
- enter_standout_mode = ABSENT_STRING;
- enter_underline_mode = ABSENT_STRING;
- }
-
- /* initialize normal acs before wide, since we use mapping in the latter */
-#if !USE_WIDEC_SUPPORT
- if (_nc_unicode_locale() && _nc_locale_breaks_acs(sp->_term)) {
- acs_chars = NULL;
- ena_acs = NULL;
- enter_alt_charset_mode = NULL;
- exit_alt_charset_mode = NULL;
- set_attributes = NULL;
- }
-#endif
-}
-
-static int
-drv_twait(TERMINAL_CONTROL_BLOCK * TCB,
- int mode,
- int milliseconds,
- int *timeleft
- EVENTLIST_2nd(_nc_eventlist * evl))
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- return _nc_timed_wait(sp, mode, milliseconds, timeleft EVENTLIST_2nd(evl));
-}
-
-static int
-drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
-{
- SCREEN *sp;
- unsigned char c2 = 0;
- int n;
-
- AssertTCB();
- assert(buf);
- SetSP();
-
-# if USE_PTHREADS_EINTR
- if ((pthread_self) && (pthread_kill) && (pthread_equal))
- _nc_globals.read_thread = pthread_self();
-# endif
- n = read(sp->_ifd, &c2, 1);
-#if USE_PTHREADS_EINTR
- _nc_globals.read_thread = 0;
-#endif
- *buf = (int) c2;
- return n;
-}
-
-static int
-drv_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms)
-{
-#if HAVE_NANOSLEEP
- {
- struct timespec request, remaining;
- request.tv_sec = ms / 1000;
- request.tv_nsec = (ms % 1000) * 1000000;
- while (nanosleep(&request, &remaining) == -1
- && errno == EINTR) {
- request = remaining;
- }
- }
-#else
- _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
-#endif
- return OK;
-}
-
-static int
-__nc_putp(SCREEN *sp, const char *name GCC_UNUSED, const char *value)
-{
- int rc = ERR;
-
- if (value) {
- rc = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx name, value);
- }
- return rc;
-}
-
-static int
-__nc_putp_flush(SCREEN *sp, const char *name, const char *value)
-{
- int rc = __nc_putp(sp, name, value);
- if (rc != ERR) {
- NCURSES_SP_NAME(_nc_flush) (sp);
- }
- return rc;
-}
-
-static int
-drv_kpad(TERMINAL_CONTROL_BLOCK * TCB, bool flag)
-{
- int ret = ERR;
- SCREEN *sp;
-
- AssertTCB();
-
- sp = TCB->csp;
-
- if (sp) {
- if (flag) {
- (void) __nc_putp_flush(sp, "keypad_xmit", keypad_xmit);
- } else if (!flag && keypad_local) {
- (void) __nc_putp_flush(sp, "keypad_local", keypad_local);
- }
- if (flag && !sp->_tried) {
- _nc_init_keytry(sp);
- sp->_tried = TRUE;
- }
- ret = OK;
- }
-
- return ret;
-}
-
-static int
-drv_keyok(TERMINAL_CONTROL_BLOCK * TCB, int c, bool flag)
-{
- SCREEN *sp;
- int code = ERR;
- int count = 0;
- char *s;
-
- AssertTCB();
- SetSP();
-
- if (c >= 0) {
- unsigned ch = (unsigned) c;
- if (flag) {
- while ((s = _nc_expand_try(sp->_key_ok, ch, &count, 0)) != 0
- && _nc_remove_key(&(sp->_key_ok), ch)) {
- code = _nc_add_to_try(&(sp->_keytry), s, ch);
- free(s);
- count = 0;
- if (code != OK)
- break;
- }
- } else {
- while ((s = _nc_expand_try(sp->_keytry, ch, &count, 0)) != 0
- && _nc_remove_key(&(sp->_keytry), ch)) {
- code = _nc_add_to_try(&(sp->_key_ok), s, ch);
- free(s);
- count = 0;
- if (code != OK)
- break;
- }
- }
- }
- return (code);
-}
-
-static bool
-drv_kyExist(TERMINAL_CONTROL_BLOCK * TCB, int key)
-{
- bool res = FALSE;
-
- AssertTCB();
- if (TCB->csp)
- res = TINFO_HAS_KEY(TCB->csp, key) == 0 ? FALSE : TRUE;
-
- return res;
-}
-
-NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_TINFO_DRIVER = {
- TRUE,
- drv_CanHandle, /* CanHandle */
- drv_init, /* init */
- drv_release, /* release */
- drv_size, /* size */
- drv_sgmode, /* sgmode */
- drv_conattr, /* conattr */
- drv_mvcur, /* hwcur */
- drv_mode, /* mode */
- drv_rescol, /* rescol */
- drv_rescolors, /* rescolors */
- drv_setcolor, /* color */
- drv_dobeepflash, /* doBeepOrFlash */
- drv_initpair, /* initpair */
- drv_initcolor, /* initcolor */
- drv_do_color, /* docolor */
- drv_initmouse, /* initmouse */
- drv_testmouse, /* testmouse */
- drv_setfilter, /* setfilter */
- drv_hwlabel, /* hwlabel */
- drv_hwlabelOnOff, /* hwlabelOnOff */
- drv_doupdate, /* update */
- drv_defaultcolors, /* defaultcolors */
- drv_print, /* print */
- drv_getsize, /* getsize */
- drv_setsize, /* setsize */
- drv_initacs, /* initacs */
- drv_screen_init, /* scinit */
- drv_wrap, /* scexit */
- drv_twait, /* twait */
- drv_read, /* read */
- drv_nap, /* nap */
- drv_kpad, /* kpad */
- drv_keyok, /* kyOk */
- drv_kyExist /* kyExist */
-};
diff --git a/ncurses/tinfo/trim_sgr0.c b/ncurses/tinfo/trim_sgr0.c
index 1f99208667ec..80c8f77fbebe 100644
--- a/ncurses/tinfo/trim_sgr0.c
+++ b/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2005-2007,2010 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 *
@@ -35,8 +35,9 @@
#include <ctype.h>
#include <tic.h>
+#include <term_entry.h>
-MODULE_ID("$Id: trim_sgr0.c,v 1.12 2010/12/25 23:03: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->
@@ -99,8 +100,8 @@ rewrite_sgr(char *s, char *attr)
{
if (PRESENT(s)) {
if (PRESENT(attr)) {
- size_t len_s = strlen(s);
- size_t len_a = strlen(attr);
+ unsigned len_s = strlen(s);
+ unsigned len_a = strlen(attr);
if (len_s > len_a && !strncmp(attr, s, len_a)) {
unsigned n;
@@ -123,8 +124,8 @@ similar_sgr(char *a, char *b)
bool result = FALSE;
int csi_a = is_csi(a);
int csi_b = is_csi(b);
- size_t len_a;
- size_t len_b;
+ unsigned len_a;
+ unsigned len_b;
TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
_nc_visbuf2(1, a),
@@ -169,13 +170,13 @@ chop_out(char *string, unsigned i, unsigned j)
* Returns the number of chars from 'full' that we matched. If any mismatch
* occurs, return zero.
*/
-static unsigned
+static int
compare_part(const char *part, const char *full)
{
const char *next_part;
const char *next_full;
- unsigned used_full = 0;
- unsigned used_delay = 0;
+ int used_full = 0;
+ int used_delay = 0;
while (*part != 0) {
if (*part != *full) {
@@ -198,7 +199,7 @@ compare_part(const char *part, const char *full)
next_part = skip_delay(part);
next_full = skip_delay(full);
if (next_part != part && next_full != full) {
- used_delay += (unsigned) (next_full - full);
+ used_delay += (next_full - full);
full = next_full;
part = next_part;
continue;
@@ -260,11 +261,10 @@ _nc_trim_sgr0(TERMTYPE *tp)
k = strlen(exit_alt_charset_mode);
if (j > k) {
for (i = 0; i <= (j - k); ++i) {
- unsigned k2 = compare_part(exit_alt_charset_mode,
- off + i);
+ int k2 = compare_part(exit_alt_charset_mode, off + i);
if (k2 != 0) {
found = TRUE;
- chop_out(off, (unsigned) i, (unsigned) (i + k2));
+ chop_out(off, i, i + k2);
break;
}
}
@@ -274,18 +274,18 @@ _nc_trim_sgr0(TERMTYPE *tp)
* SGR 10 would reset to normal font.
*/
if (!found) {
- if ((i = (size_t) is_csi(off)) != 0
+ if ((i = is_csi(off)) != 0
&& off[strlen(off) - 1] == 'm') {
TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
_nc_visbuf(off)));
tmp = skip_zero(off + i);
if (tmp[0] == '1'
&& skip_zero(tmp + 1) != tmp + 1) {
- i = (size_t) (tmp - off);
+ i = tmp - off;
if (off[i - 1] == ';')
i--;
- j = (size_t) (skip_zero(tmp + 1) - off);
- (void) chop_out(off, (unsigned) i, (unsigned) j);
+ j = skip_zero(tmp + 1) - off;
+ i = chop_out(off, i, j);
found = TRUE;
}
}
@@ -293,10 +293,10 @@ _nc_trim_sgr0(TERMTYPE *tp)
if (!found
&& (tmp = strstr(end, off)) != 0
&& strcmp(end, off) != 0) {
- i = (size_t) (tmp - end);
+ i = tmp - end;
j = strlen(off);
tmp = strdup(end);
- chop_out(tmp, (unsigned) i, (unsigned) j);
+ chop_out(tmp, i, j);
free(off);
result = tmp;
}
diff --git a/ncurses/tinfo/use_screen.c b/ncurses/tinfo/use_screen.c
index 6a0297cebd51..6c3b12fb9238 100644
--- a/ncurses/tinfo/use_screen.c
+++ b/ncurses/tinfo/use_screen.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2007-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: use_screen.c,v 1.8 2009/10/24 22:40:20 tom Exp $")
+MODULE_ID("$Id: use_screen.c,v 1.6 2008/06/07 19:16:56 tom Exp $")
NCURSES_EXPORT(int)
use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data)
@@ -40,14 +40,14 @@ use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data)
SCREEN *save_SP;
int code = OK;
- T((T_CALLED("use_screen(%p,%p,%p)"), (void *) screen, func, (void *) data));
+ 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(curses);
- save_SP = CURRENT_SCREEN;
+ save_SP = SP;
set_term(screen);
code = func(screen, data);
diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c
index a86c11267e93..b53bb210230d 100644
--- a/ncurses/tinfo/write_entry.c
+++ b/ncurses/tinfo/write_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,6 +42,7 @@
#include <sys/stat.h>
#include <tic.h>
+#include <term_entry.h>
#ifndef S_ISDIR
#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
@@ -53,7 +54,7 @@
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$Id: write_entry.c,v 1.78 2010/12/25 23:23:08 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.72 2008/08/03 19:24:00 tom Exp $")
static int total_written;
@@ -136,12 +137,10 @@ make_db_path(char *dst, const char *src, unsigned limit)
if (_nc_is_dir_path(dst)) {
rc = -1;
} else {
- static const char suffix[] = DBM_SUFFIX;
unsigned have = strlen(dst);
- unsigned need = strlen(suffix);
- if (have > need && strcmp(dst + have - need, suffix)) {
- if (have + need <= limit)
- strcat(dst, suffix);
+ if (have > 3 && strcmp(dst + have - 3, DBM_SUFFIX)) {
+ if (have + 3 <= limit)
+ strcat(dst, DBM_SUFFIX);
else
rc = -1;
}
@@ -172,11 +171,7 @@ make_db_root(const char *path)
struct stat statbuf;
if ((rc = stat(path, &statbuf)) < 0) {
- rc = mkdir(path
-#if !defined(__MINGW32__)
- ,0777
-#endif
- );
+ rc = mkdir(path, 0777);
} else if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
rc = -1; /* permission denied */
} else if (!(S_ISDIR(statbuf.st_mode))) {
@@ -343,7 +338,6 @@ _nc_write_entry(TERMTYPE *const tp)
while (*other_names != '\0') {
ptr = other_names++;
- assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
@@ -363,7 +357,7 @@ _nc_write_entry(TERMTYPE *const tp)
start_time = 0;
}
- if (strlen(first_name) >= sizeof(filename) - (2 + LEAF_LEN))
+ if (strlen(first_name) >= sizeof(filename) - 3)
_nc_warning("terminal name too long.");
sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
@@ -391,13 +385,14 @@ _nc_write_entry(TERMTYPE *const tp)
}
while (*other_names != '\0') {
ptr = other_names++;
+ assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
if (*other_names != '\0')
*(other_names++) = '\0';
- if (strlen(ptr) > sizeof(linkname) - (2 + LEAF_LEN)) {
+ if (strlen(ptr) > sizeof(linkname) - 3) {
_nc_warning("terminal alias %s too long.", ptr);
continue;
}
@@ -419,12 +414,8 @@ _nc_write_entry(TERMTYPE *const tp)
{
int code;
#if USE_SYMLINKS
- if (first_name[0] == linkname[0])
- strncpy(symlinkname, first_name, sizeof(symlinkname) - 1);
- else {
- strcpy(symlinkname, "../");
- strncat(symlinkname, filename, sizeof(symlinkname) - 4);
- }
+ strcpy(symlinkname, "../");
+ strncat(symlinkname, filename, sizeof(symlinkname) - 4);
symlinkname[sizeof(symlinkname) - 1] = '\0';
#endif /* USE_SYMLINKS */
#if HAVE_REMOVE
@@ -469,26 +460,26 @@ _nc_write_entry(TERMTYPE *const tp)
#endif /* USE_HASHED_DB */
}
-static size_t
+static unsigned
fake_write(char *dst,
unsigned *offset,
- size_t limit,
+ unsigned limit,
char *src,
- size_t want,
- size_t size)
+ unsigned want,
+ unsigned size)
{
- size_t have = (limit - *offset);
+ int have = (limit - *offset);
want *= size;
if (have > 0) {
- if (want > have)
+ if ((int) want > have)
want = have;
memcpy(dst + *offset, src, want);
- *offset += (unsigned) want;
+ *offset += want;
} else {
want = 0;
}
- return (want / size);
+ return (int) (want / size);
}
#define Write(buf, size, count) fake_write(buffer, offset, limit, (char *) buf, count, size)
@@ -496,16 +487,15 @@ fake_write(char *dst,
#undef LITTLE_ENDIAN /* BSD/OS defines this as a feature macro */
#define HI(x) ((x) / 256)
#define LO(x) ((x) % 256)
-#define LITTLE_ENDIAN(p, x) (p)[0] = (unsigned char)LO(x), \
- (p)[1] = (unsigned char)HI(x)
+#define LITTLE_ENDIAN(p, x) (p)[0] = LO(x), (p)[1] = HI(x)
#define WRITE_STRING(str) (Write(str, sizeof(char), strlen(str) + 1) == strlen(str) + 1)
static int
-compute_offsets(char **Strings, size_t strmax, short *offsets)
+compute_offsets(char **Strings, unsigned strmax, short *offsets)
{
- int nextfree = 0;
- size_t i;
+ size_t nextfree = 0;
+ unsigned i;
for (i = 0; i < strmax; i++) {
if (Strings[i] == ABSENT_STRING) {
@@ -513,8 +503,8 @@ compute_offsets(char **Strings, size_t strmax, short *offsets)
} else if (Strings[i] == CANCELLED_STRING) {
offsets[i] = -2;
} else {
- offsets[i] = (short) nextfree;
- nextfree += (int) strlen(Strings[i]) + 1;
+ offsets[i] = nextfree;
+ nextfree += strlen(Strings[i]) + 1;
TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i,
_nc_visbuf(Strings[i]), (int) nextfree));
}
@@ -523,9 +513,9 @@ compute_offsets(char **Strings, size_t strmax, short *offsets)
}
static void
-convert_shorts(unsigned char *buf, short *Numbers, size_t count)
+convert_shorts(unsigned char *buf, short *Numbers, unsigned count)
{
- size_t i;
+ unsigned i;
for (i = 0; i < count; i++) {
if (Numbers[i] == ABSENT_NUMERIC) { /* HI/LO won't work */
buf[2 * i] = buf[2 * i + 1] = 0377;
@@ -534,7 +524,7 @@ convert_shorts(unsigned char *buf, short *Numbers, size_t count)
buf[2 * i + 1] = 0377;
} else {
LITTLE_ENDIAN(buf + 2 * i, Numbers[i]);
- TRACE_OUT(("put Numbers[%u]=%d", (unsigned) i, Numbers[i]));
+ TRACE_OUT(("put Numbers[%d]=%d", i, Numbers[i]));
}
}
}
@@ -546,8 +536,8 @@ convert_shorts(unsigned char *buf, short *Numbers, size_t count)
static unsigned
extended_Booleans(TERMTYPE *tp)
{
- unsigned result = 0;
- unsigned i;
+ unsigned short result = 0;
+ unsigned short i;
for (i = 0; i < tp->ext_Booleans; ++i) {
if (tp->Booleans[BOOLCOUNT + i] == TRUE)
@@ -559,8 +549,8 @@ extended_Booleans(TERMTYPE *tp)
static unsigned
extended_Numbers(TERMTYPE *tp)
{
- unsigned result = 0;
- unsigned i;
+ unsigned short result = 0;
+ unsigned short i;
for (i = 0; i < tp->ext_Numbers; ++i) {
if (tp->Numbers[NUMCOUNT + i] != ABSENT_NUMERIC)
@@ -577,7 +567,7 @@ extended_Strings(TERMTYPE *tp)
for (i = 0; i < tp->ext_Strings; ++i) {
if (tp->Strings[STRCOUNT + i] != ABSENT_STRING)
- result = (unsigned short) (i + 1);
+ result = (i + 1);
}
return result;
}
@@ -607,7 +597,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
size_t namelen, boolmax, nummax, strmax;
char zero = '\0';
size_t i;
- int nextfree;
+ short nextfree;
short offsets[MAX_ENTRY_SIZE / 2];
unsigned char buf[MAX_ENTRY_SIZE];
unsigned last_bool = BOOLWRITE;
@@ -700,7 +690,7 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
#if NCURSES_XNAMES
if (extended_object(tp)) {
- unsigned extcnt = (unsigned) NUM_EXT_NAMES(tp);
+ unsigned extcnt = NUM_EXT_NAMES(tp);
if (even_boundary(nextfree))
return (ERR);