aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo/read_entry.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-10-11 07:31:01 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-10-11 07:31:01 +0000
commit18259542b2f8fa7e3f76f4bb0dd37995dfd424aa (patch)
tree9ec00b41242bbe63b83c0ac5316c539466d9f9de /contrib/ncurses/ncurses/tinfo/read_entry.c
parent15589c42fa2774d2f8ee650f4f31eb8d3a861316 (diff)
downloadsrc-18259542b2f8fa7e3f76f4bb0dd37995dfd424aa.tar.gz
src-18259542b2f8fa7e3f76f4bb0dd37995dfd424aa.zip
Import ncurses-5.1-20001009 onto the vendor branch
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=66963
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo/read_entry.c')
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/read_entry.c b/contrib/ncurses/ncurses/tinfo/read_entry.c
index 85dc3e0bf6e9..deef49859a3e 100644
--- a/contrib/ncurses/ncurses/tinfo/read_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/read_entry.c
@@ -41,7 +41,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.67 2000/03/11 12:35:45 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.69 2000/10/10 00:57:40 Todd.Miller Exp $")
#if !HAVE_TELL
#define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */
@@ -79,7 +79,7 @@ _nc_tic_dir(const char *path)
if (path != 0) {
result = path;
have_tic_directory = TRUE;
- } else if (!have_tic_directory) {
+ } else if (!have_tic_directory && use_terminfo_vars()) {
char *envp;
if ((envp = getenv("TERMINFO")) != 0)
return _nc_tic_dir(envp);
@@ -176,9 +176,9 @@ read_termtype(int fd, TERMTYPE * ptr)
str_size = LOW_MSB(buf + 10);
TR(TRACE_DATABASE,
- ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)",
- name_size, bool_count, BOOLCOUNT, num_count, NUMCOUNT,
- str_count, STRCOUNT, str_size));
+ ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)",
+ name_size, bool_count, BOOLCOUNT, num_count, NUMCOUNT,
+ str_count, STRCOUNT, str_size));
if (name_size < 0
|| bool_count < 0
|| num_count < 0
@@ -281,19 +281,20 @@ read_termtype(int fd, TERMTYPE * ptr)
ptr->Strings = typeRealloc(char *, ptr->num_Strings, ptr->Strings);
TR(TRACE_DATABASE, ("extended header is %d/%d/%d(%d:%d)",
- ext_bool_count, ext_num_count, ext_str_count, ext_str_size, ext_str_limit));
+ ext_bool_count, ext_num_count, ext_str_count,
+ ext_str_size, ext_str_limit));
TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
- ext_bool_count, tell(fd)));
+ ext_bool_count, tell(fd)));
if ((ptr->ext_Booleans = ext_bool_count) != 0) {
if (read(fd, ptr->Booleans + BOOLCOUNT, (unsigned)
- ext_bool_count) != ext_bool_count)
+ ext_bool_count) != ext_bool_count)
return (0);
}
even_boundary(ext_bool_count);
TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
- ext_num_count, tell(fd)));
+ ext_num_count, tell(fd)));
if ((ptr->ext_Numbers = ext_num_count) != 0) {
if (!read_shorts(fd, buf, ext_num_count))
return (0);
@@ -307,7 +308,7 @@ read_termtype(int fd, TERMTYPE * ptr)
return (0);
TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
- ext_str_limit, tell(fd)));
+ ext_str_limit, tell(fd)));
if (ext_str_limit) {
if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
@@ -319,20 +320,20 @@ read_termtype(int fd, TERMTYPE * ptr)
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));
+ ("Before computing extended-string capabilities str_count=%d, ext_str_count=%d",
+ str_count, ext_str_count));
convert_strings(buf, ptr->Strings + str_count, ext_str_count,
- ext_str_limit, ptr->ext_str_table);
+ ext_str_limit, ptr->ext_str_table);
for (i = ext_str_count - 1; i >= 0; i--) {
TR(TRACE_DATABASE, ("MOVE from [%d:%d] %s",
- i, i + str_count,
- _nc_visbuf(ptr->Strings[i + str_count])));
+ i, i + str_count,
+ _nc_visbuf(ptr->Strings[i + str_count])));
ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count];
if (VALID_STRING(ptr->Strings[i + STRCOUNT]))
base += (strlen(ptr->Strings[i + STRCOUNT]) + 1);
TR(TRACE_DATABASE, ("... to [%d] %s",
- i + STRCOUNT,
- _nc_visbuf(ptr->Strings[i + STRCOUNT])));
+ i + STRCOUNT,
+ _nc_visbuf(ptr->Strings[i + STRCOUNT])));
}
}
@@ -340,23 +341,23 @@ read_termtype(int fd, TERMTYPE * ptr)
if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
return (0);
TR(TRACE_DATABASE,
- ("ext_NAMES starting @%d in extended_strings, first = %s",
- base, _nc_visbuf(ptr->ext_str_table + base)));
+ ("ext_NAMES starting @%d in extended_strings, first = %s",
+ base, _nc_visbuf(ptr->ext_str_table + base)));
convert_strings(buf + (2 * ext_str_count), ptr->ext_Names, need,
- ext_str_limit, ptr->ext_str_table + base);
+ ext_str_limit, ptr->ext_str_table + base);
}
T(("...done reading terminfo bool %d(%d) num %d(%d) str %d(%d)",
- ptr->num_Booleans, ptr->ext_Booleans,
- ptr->num_Numbers, ptr->ext_Numbers,
- ptr->num_Strings, ptr->ext_Strings));
+ ptr->num_Booleans, ptr->ext_Booleans,
+ ptr->num_Numbers, ptr->ext_Numbers,
+ ptr->num_Strings, ptr->ext_Strings));
TR(TRACE_DATABASE, ("extend: num_Booleans:%d", ptr->num_Booleans));
} else
#endif /* NCURSES_XNAMES */
{
T(("...done reading terminfo bool %d num %d str %d",
- bool_count, num_count, str_count));
+ bool_count, num_count, str_count));
#if NCURSES_XNAMES
TR(TRACE_DATABASE, ("normal: num_Booleans:%d", ptr->num_Booleans));
#endif
@@ -398,7 +399,7 @@ _nc_read_file_entry(const char *const filename, TERMTYPE * ptr)
*/
static int
_nc_read_tic_entry(char *const filename,
- const char *const dir, const char *ttn, TERMTYPE * const tp)
+ const char *const dir, const char *ttn, TERMTYPE * const tp)
{
/* maximum safe length of terminfo root directory name */
#define MAX_TPATH (PATH_MAX - MAX_ALIAS - 6)
@@ -415,7 +416,7 @@ _nc_read_tic_entry(char *const filename,
*/
static int
_nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
- ttn, TERMTYPE * const tp)
+ ttn, TERMTYPE * const tp)
{
char *list, *a;
const char *b;
@@ -471,19 +472,22 @@ _nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
&& _nc_read_tic_entry(filename, _nc_tic_dir(0), ttn, tp) == 1)
return 1;
- if ((envp = getenv("TERMINFO")) != 0
- && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
- return 1;
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMINFO")) != 0
+ && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
+ return 1;
- if ((envp = _nc_home_terminfo()) != 0) {
- if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
- return (1);
+ /* this is an ncurses extension */
+ if ((envp = _nc_home_terminfo()) != 0) {
+ if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
+ return (1);
+ }
}
- }
- /* this is an ncurses extension */
- if ((envp = getenv("TERMINFO_DIRS")) != 0)
- return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ /* this is an ncurses extension */
+ if ((envp = getenv("TERMINFO_DIRS")) != 0)
+ return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
+ }
/* Try the system directory. Note that the TERMINFO_DIRS value, if
* defined by the configure script, begins with a ":", which will be