aboutsummaryrefslogtreecommitdiff
path: root/ncurses/tinfo
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses/tinfo')
-rw-r--r--ncurses/tinfo/MKcodes.awk7
-rw-r--r--ncurses/tinfo/MKnames.awk9
-rw-r--r--ncurses/tinfo/alloc_entry.c70
-rw-r--r--ncurses/tinfo/alloc_ttype.c15
-rw-r--r--ncurses/tinfo/captoinfo.c17
-rw-r--r--ncurses/tinfo/comp_expand.c12
-rw-r--r--ncurses/tinfo/comp_hash.c18
-rw-r--r--ncurses/tinfo/comp_parse.c7
-rw-r--r--ncurses/tinfo/comp_scan.c99
-rw-r--r--ncurses/tinfo/entries.c11
-rw-r--r--ncurses/tinfo/home_terminfo.c12
-rw-r--r--ncurses/tinfo/init_keytry.c9
-rw-r--r--ncurses/tinfo/lib_acs.c9
-rw-r--r--ncurses/tinfo/lib_baudrate.c21
-rw-r--r--ncurses/tinfo/lib_cur_term.c47
-rw-r--r--ncurses/tinfo/lib_data.c72
-rw-r--r--ncurses/tinfo/lib_options.c185
-rw-r--r--ncurses/tinfo/lib_setup.c93
-rw-r--r--ncurses/tinfo/lib_termcap.c7
-rw-r--r--ncurses/tinfo/lib_tgoto.c6
-rw-r--r--ncurses/tinfo/lib_tparm.c14
-rw-r--r--ncurses/tinfo/lib_tputs.c23
-rw-r--r--ncurses/tinfo/lib_ttyflags.c56
-rw-r--r--ncurses/tinfo/make_keys.c18
-rw-r--r--ncurses/tinfo/name_match.c27
-rw-r--r--ncurses/tinfo/parse_entry.c30
-rw-r--r--ncurses/tinfo/read_entry.c8
-rw-r--r--ncurses/tinfo/use_screen.c8
-rw-r--r--ncurses/tinfo/write_entry.c24
29 files changed, 603 insertions, 331 deletions
diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk
index db8ad5541841..b9ba636e0ccd 100644
--- a/ncurses/tinfo/MKcodes.awk
+++ b/ncurses/tinfo/MKcodes.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 1998-2006,2007 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.4 2007/11/03 20:24:15 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;
@@ -140,6 +140,7 @@ END {
print ""
print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
print ""
+ print "#if NO_LEAKS"
print "NCURSES_EXPORT(void)"
print "_nc_codes_leaks(void)"
print "{"
@@ -149,6 +150,8 @@ END {
print "FREE_FIX(strcodes)"
}
print "}"
+ print "#endif"
+ print ""
print "#else"
print ""
print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk
index 93e682c2d28d..7e5074480864 100644
--- a/ncurses/tinfo/MKnames.awk
+++ b/ncurses/tinfo/MKnames.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 2007 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.18 2007/11/03 20:24:15 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;
@@ -126,7 +126,7 @@ END {
print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
print " unsigned n;"
print " for (n = 0; n < size; ++n) {"
- print " (*value)[n] = _nc_name_blob + offsets[n];"
+ print " (*value)[n] = (NCURSES_CONST char *) _nc_name_blob + offsets[n];"
print " }"
print " }"
print " }"
@@ -156,6 +156,7 @@ END {
print ""
print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
print ""
+ print "#if NO_LEAKS"
print "NCURSES_EXPORT(void)"
print "_nc_names_leaks(void)"
print "{"
@@ -168,6 +169,8 @@ END {
print "FREE_FIX(strfnames)"
}
print "}"
+ print "#endif"
+ print ""
print "#else"
print ""
print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c
index 1496752f1956..4638e99c4d58 100644
--- a/ncurses/tinfo/alloc_entry.c
+++ b/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 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,7 +48,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_entry.c,v 1.47 2006/12/16 19:06:58 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
@@ -145,7 +145,8 @@ NCURSES_EXPORT(void)
_nc_wrap_entry(ENTRY * const ep, bool copy_strings)
/* copy the string parts to allocated storage, preserving pointers to it */
{
- int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES];
+ int offsets[MAX_ENTRY_SIZE / sizeof(short)];
+ int useoffsets[MAX_USES];
unsigned i, n;
unsigned nuses = ep->nuses;
TERMTYPE *tp = &(ep->tterm);
@@ -171,14 +172,18 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
free(tp->str_table);
}
- n = tp->term_names - stringbuf;
+ assert(tp->term_names >= stringbuf);
+ n = (unsigned) (tp->term_names - stringbuf);
for_each_string(i, &(ep->tterm)) {
- if (tp->Strings[i] == ABSENT_STRING)
- offsets[i] = ABSENT_OFFSET;
- else if (tp->Strings[i] == CANCELLED_STRING)
- offsets[i] = CANCELLED_OFFSET;
- else
- offsets[i] = tp->Strings[i] - stringbuf;
+ if (i < SIZEOF(offsets)) {
+ if (tp->Strings[i] == ABSENT_STRING) {
+ offsets[i] = ABSENT_OFFSET;
+ } else if (tp->Strings[i] == CANCELLED_STRING) {
+ offsets[i] = CANCELLED_OFFSET;
+ } else {
+ offsets[i] = tp->Strings[i] - stringbuf;
+ }
+ }
}
for (i = 0; i < nuses; i++) {
@@ -194,28 +199,33 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
tp->term_names = tp->str_table + n;
for_each_string(i, &(ep->tterm)) {
- if (offsets[i] == ABSENT_OFFSET)
- tp->Strings[i] = ABSENT_STRING;
- else if (offsets[i] == CANCELLED_OFFSET)
- tp->Strings[i] = CANCELLED_STRING;
- else
- tp->Strings[i] = tp->str_table + offsets[i];
+ if (i < SIZEOF(offsets)) {
+ if (offsets[i] == ABSENT_OFFSET) {
+ tp->Strings[i] = ABSENT_STRING;
+ } else if (offsets[i] == CANCELLED_OFFSET) {
+ tp->Strings[i] = CANCELLED_STRING;
+ } else {
+ tp->Strings[i] = tp->str_table + offsets[i];
+ }
+ }
}
#if NCURSES_XNAMES
if (!copy_strings) {
- if ((n = NUM_EXT_NAMES(tp)) != 0) {
- unsigned length = 0;
- for (i = 0; i < n; i++) {
- length += strlen(tp->ext_Names[i]) + 1;
- offsets[i] = tp->ext_Names[i] - stringbuf;
- }
- if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
- _nc_err_abort(MSG_NO_MEMORY);
- for (i = 0, length = 0; i < n; i++) {
- tp->ext_Names[i] = tp->ext_str_table + length;
- strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
- length += strlen(tp->ext_Names[i]) + 1;
+ if ((n = (unsigned) NUM_EXT_NAMES(tp)) != 0) {
+ if (n < SIZEOF(offsets)) {
+ unsigned length = 0;
+ for (i = 0; i < n; i++) {
+ length += strlen(tp->ext_Names[i]) + 1;
+ offsets[i] = tp->ext_Names[i] - stringbuf;
+ }
+ if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ for (i = 0, length = 0; i < n; i++) {
+ tp->ext_Names[i] = tp->ext_str_table + length;
+ strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
+ length += strlen(tp->ext_Names[i]) + 1;
+ }
}
}
}
@@ -245,13 +255,13 @@ _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
if (mergebool == CANCELLED_BOOLEAN)
to->Booleans[i] = FALSE;
else if (mergebool == TRUE)
- to->Booleans[i] = mergebool;
+ to->Booleans[i] = (char) mergebool;
}
}
for_each_number(i, from) {
if (to->Numbers[i] != CANCELLED_NUMERIC) {
- int mergenum = from->Numbers[i];
+ short mergenum = from->Numbers[i];
if (mergenum == CANCELLED_NUMERIC)
to->Numbers[i] = ABSENT_NUMERIC;
diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c
index 9f31ed3ffab7..b2b06d1b79ce 100644
--- a/ncurses/tinfo/alloc_ttype.c
+++ b/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2003,2006 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 *
@@ -43,7 +43,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.16 2006/07/08 19:18:38 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.17 2008/10/12 16:12:00 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -365,6 +365,17 @@ adjust_cancels(TERMTYPE *to, TERMTYPE *from)
} else {
j++;
}
+ } 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);
+ to->Strings[k] = CANCELLED_STRING;
+ } else {
+ j++;
+ }
+ } else {
+ j++;
}
} else {
j++;
diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c
index 0e3baa845693..93300c1be3e4 100644
--- a/ncurses/tinfo/captoinfo.c
+++ b/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 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.49 2006/12/16 19:16:53 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 */
@@ -149,7 +149,7 @@ static void
push(void)
/* push onstack on to the stack */
{
- if (stackptr > MAX_PUSHED)
+ if (stackptr >= MAX_PUSHED)
_nc_warning("string too complex to convert");
else
stack[stackptr++] = onstack;
@@ -183,7 +183,7 @@ cvtchar(register const char *sp)
case '$':
case '\\':
case '%':
- c = *sp;
+ c = (unsigned char) (*sp);
len = 2;
break;
case '\0':
@@ -201,7 +201,7 @@ cvtchar(register const char *sp)
}
break;
default:
- c = *sp;
+ c = (unsigned char) (*sp);
len = 2;
break;
}
@@ -211,7 +211,7 @@ cvtchar(register const char *sp)
len = 2;
break;
default:
- c = *sp;
+ c = (unsigned char) (*sp);
len = 1;
}
if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
@@ -788,6 +788,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
} /* endswitch (*str) */
} /* endelse (*str == '%') */
+ /*
+ * 'str' always points to the end of what was scanned in this step,
+ * but that may not be the end of the string.
+ */
+ assert(str != 0);
if (*str == '\0')
break;
diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c
index ef419d84cd2c..6e79a926b5ac 100644
--- a/ncurses/tinfo/comp_expand.c
+++ b/ncurses/tinfo/comp_expand.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2006 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.18 2006/06/17 19:37:14 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)
@@ -56,7 +56,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
static size_t length;
int bufp;
- const char *str = VALID_STRING(srcp) ? srcp : "";
+ const char *str = VALID_STRING(srcp) ? srcp : "\0\0";
bool islong = (strlen(str) > 3);
size_t need = (2 + strlen(str)) * 4;
int ch;
@@ -119,7 +119,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
if (ch == '\\'
|| ch == S_QUOTE)
buffer[bufp++] = '\\';
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
buffer[bufp++] = S_QUOTE;
str = dst;
} else {
@@ -148,13 +148,13 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
buffer[bufp++] = 's';
} else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) {
buffer[bufp++] = '\\';
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
} else if (REALPRINT(str)
&& (ch != ','
&& ch != ':'
&& !(ch == '!' && !tic_format)
&& ch != '^'))
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
#if 0 /* FIXME: this would be more readable (in fact the whole 'islong' logic should be removed) */
else if (ch == '\b') {
buffer[bufp++] = '\\';
diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c
index 8b85eee6ced8..b7fbd0616345 100644
--- a/ncurses/tinfo/comp_hash.c
+++ b/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2007 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 *
@@ -50,7 +50,7 @@
#define DEBUG(level, params) /*nothing */
#endif
-MODULE_ID("$Id: comp_hash.c,v 1.33 2007/08/18 21:42:25 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.36 2008/08/16 17:06:53 tom Exp $")
static int hash_function(const char *);
@@ -73,7 +73,7 @@ static void
_nc_make_hash_table(struct name_table_entry *table,
short *hash_table)
{
- int i;
+ short i;
int hashvalue;
int collisions = 0;
@@ -215,8 +215,9 @@ parse_columns(char *buffer)
if ((s - buffer) > 1
&& (*buffer == '"')
&& (s[-1] == '"')) { /* strip the quotes */
- buffer++;
+ assert(s > buffer + 1);
s[-1] = '\0';
+ buffer++;
}
list[col] = buffer;
col++;
@@ -258,7 +259,9 @@ main(int argc, char **argv)
|| (column = atoi(argv[1])) <= 0
|| (column >= MAX_COLUMNS)
|| *(root_name = argv[2]) == 0
- || (bigstring = atoi(argv[3])) < 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);
}
@@ -301,7 +304,7 @@ main(int argc, char **argv)
printf("static const char %s_names_text[] = \\\n", root_name);
for (n = 0; n < CAPTABSIZE; n++) {
- nxt = strlen(name_table[n].nte_name) + 5;
+ nxt = (int) strlen(name_table[n].nte_name) + 5;
if (nxt + len > 72) {
printf("\\\n");
len = 0;
@@ -322,7 +325,7 @@ main(int argc, char **argv)
name_table[n].nte_index,
name_table[n].nte_link,
n < CAPTABSIZE - 1 ? ',' : ' ');
- len += strlen(name_table[n].nte_name) + 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);
@@ -361,6 +364,7 @@ main(int argc, char **argv)
printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
printf("#endif\n\n");
+ free(hash_table);
return EXIT_SUCCESS;
}
#endif
diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c
index aa60047b0aad..3325a0ddae6c 100644
--- a/ncurses/tinfo/comp_parse.c
+++ b/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -53,7 +53,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: comp_parse.c,v 1.68 2007/11/03 20:41:46 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;
@@ -183,7 +183,8 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
{
ENTRY *qp, *rp, *lastread = 0;
bool keepgoing;
- int i, unresolved, total_unresolved, multiples;
+ unsigned i;
+ int unresolved, total_unresolved, multiples;
DEBUG(2, ("RESOLUTION BEGINNING"));
diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c
index e937f7eb5ada..5ad750f930dd 100644
--- a/ncurses/tinfo/comp_scan.c
+++ b/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 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 *
@@ -51,7 +51,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.78 2006/12/16 19:17:01 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.
@@ -203,6 +203,7 @@ next_char(void)
result = typeRealloc(char, allocated, result);
if (result == 0)
return (EOF);
+ bufstart = result;
}
if (used == 0)
_nc_curr_file_pos = ftell(yyin);
@@ -293,6 +294,15 @@ eat_escaped_newline(int ch)
return ch;
}
+#define TOK_BUF_SIZE MAX_ENTRY_SIZE
+
+#define OkToAdd() \
+ ((tok_ptr - tok_buf) < (TOK_BUF_SIZE - 2))
+
+#define AddCh(ch) \
+ *tok_ptr++ = (char) ch; \
+ *tok_ptr = '\0'
+
/*
* int
* get_token()
@@ -330,12 +340,12 @@ NCURSES_EXPORT(int)
_nc_get_token(bool silent)
{
static const char terminfo_punct[] = "@%&*!#";
- static char *buffer;
+ static char *tok_buf;
char *after_list;
char *after_name;
char *numchk;
- char *ptr;
+ char *tok_ptr;
char *s;
char numbuf[80];
int ch;
@@ -367,10 +377,10 @@ _nc_get_token(bool silent)
if (end_of_stream()) {
yyin = 0;
next_char(); /* frees its allocated memory */
- if (buffer != 0) {
- if (_nc_curr_token.tk_name == buffer)
+ if (tok_buf != 0) {
+ if (_nc_curr_token.tk_name == tok_buf)
_nc_curr_token.tk_name = 0;
- FreeAndNull(buffer);
+ FreeAndNull(tok_buf);
}
return (EOF);
}
@@ -426,15 +436,15 @@ _nc_get_token(bool silent)
goto start_token;
}
- if (buffer == 0)
- buffer = typeMalloc(char, MAX_ENTRY_SIZE);
+ if (tok_buf == 0)
+ tok_buf = typeMalloc(char, TOK_BUF_SIZE);
#ifdef TRACE
old_line = _nc_curr_line;
old_col = _nc_curr_col;
#endif
- ptr = buffer;
- *(ptr++) = ch;
+ tok_ptr = tok_buf;
+ AddCh(ch);
if (first_column) {
_nc_comment_start = token_start;
@@ -448,9 +458,9 @@ _nc_get_token(bool silent)
if (ch == EOF) {
_nc_err_abort(MSG_NO_INPUTS);
} else if (ch == '|') {
- after_list = ptr;
+ after_list = tok_ptr;
if (after_name == 0)
- after_name = ptr;
+ after_name = tok_ptr;
} else if (ch == ':' && last_char() != ',') {
_nc_syntax = SYN_TERMCAP;
separator = ':';
@@ -474,9 +484,14 @@ _nc_get_token(bool silent)
} else
ch = eat_escaped_newline(ch);
- *ptr++ = ch;
+ if (OkToAdd()) {
+ AddCh(ch);
+ } else {
+ ch = EOF;
+ break;
+ }
}
- ptr[0] = '\0';
+ *tok_ptr = '\0';
if (_nc_syntax == ERR) {
/*
* Grrr...what we ought to do here is barf, complaining that
@@ -488,9 +503,11 @@ _nc_get_token(bool silent)
separator = ':';
} else if (_nc_syntax == SYN_TERMINFO) {
/* throw away trailing /, *$/ */
- for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
+ for (--tok_ptr;
+ iswhite(*tok_ptr) || *tok_ptr == ',';
+ tok_ptr--)
continue;
- ptr[1] = '\0';
+ tok_ptr[1] = '\0';
}
/*
@@ -501,8 +518,8 @@ _nc_get_token(bool silent)
if (after_name != 0) {
ch = *after_name;
*after_name = '\0';
- _nc_set_type(buffer);
- *after_name = ch;
+ _nc_set_type(tok_buf);
+ *after_name = (char) ch;
}
/*
@@ -517,7 +534,7 @@ _nc_get_token(bool silent)
_nc_warning("older tic versions may treat the description field as an alias");
}
} else {
- after_list = buffer + strlen(buffer);
+ after_list = tok_buf + strlen(tok_buf);
DEBUG(1, ("missing description"));
}
@@ -526,7 +543,7 @@ _nc_get_token(bool silent)
* rdist and some termcap tools. Slashes are a no-no. Other
* special characters can be dangerous due to shell expansion.
*/
- for (s = buffer; s < after_list; ++s) {
+ for (s = tok_buf; s < after_list; ++s) {
if (isspace(UChar(*s))) {
if (!silent)
_nc_warning("whitespace in name or alias field");
@@ -542,7 +559,7 @@ _nc_get_token(bool silent)
}
}
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
type = NAMES;
} else {
if (had_newline && _nc_syntax == SYN_TERMCAP) {
@@ -559,30 +576,35 @@ _nc_get_token(bool silent)
break;
}
}
- *(ptr++) = ch;
+ if (OkToAdd()) {
+ AddCh(ch);
+ } else {
+ ch = EOF;
+ break;
+ }
}
- *ptr++ = '\0';
+ *tok_ptr++ = '\0'; /* separate name/value in buffer */
switch (ch) {
case ',':
case ':':
if (ch != separator)
_nc_err_abort("Separator inconsistent with syntax");
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
type = BOOLEAN;
break;
case '@':
if ((ch = next_char()) != separator && !silent)
_nc_warning("Missing separator after `%s', have %s",
- buffer, unctrl((chtype) ch));
- _nc_curr_token.tk_name = buffer;
+ tok_buf, unctrl((chtype) ch));
+ _nc_curr_token.tk_name = tok_buf;
type = CANCEL;
break;
case '#':
found = 0;
while (isalnum(ch = next_char())) {
- numbuf[found++] = ch;
+ numbuf[found++] = (char) ch;
if (found >= sizeof(numbuf) - 1)
break;
}
@@ -590,21 +612,21 @@ _nc_get_token(bool silent)
number = strtol(numbuf, &numchk, 0);
if (!silent) {
if (numchk == numbuf)
- _nc_warning("no value given for `%s'", buffer);
+ _nc_warning("no value given for `%s'", tok_buf);
if ((*numchk != '\0') || (ch != separator))
_nc_warning("Missing separator");
}
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
_nc_curr_token.tk_valnumber = number;
type = NUMBER;
break;
case '=':
- ch = _nc_trans_string(ptr, buffer + MAX_ENTRY_SIZE);
+ ch = _nc_trans_string(tok_ptr, tok_buf + TOK_BUF_SIZE);
if (!silent && ch != separator)
_nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valstring = ptr;
+ _nc_curr_token.tk_name = tok_buf;
+ _nc_curr_token.tk_valstring = tok_ptr;
type = STRING;
break;
@@ -713,8 +735,15 @@ _nc_trans_string(char *ptr, char *last)
bool long_warning = FALSE;
while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
- if (ptr == (last - 1))
+ 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 (ch == '^' && last_ch != '%') {
@@ -839,7 +868,7 @@ _nc_trans_string(char *ptr, char *last)
if (!ignored) {
if (_nc_curr_col <= 1) {
- push_back(ch);
+ push_back((char) ch);
ch = '\n';
break;
}
diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c
index 8b63f0d8965c..cf2a8337b870 100644
--- a/ncurses/tinfo/entries.c
+++ b/ncurses/tinfo/entries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2006,2007 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 *
@@ -37,7 +37,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: entries.c,v 1.4 2007/11/03 21:00:27 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.8 2008/09/27 13:11:10 tom Exp $")
/****************************************************************************
*
@@ -111,26 +111,27 @@ _nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
NCURSES_EXPORT(void)
_nc_leaks_tinfo(void)
{
+#if NO_LEAKS
char *s;
+#endif
T((T_CALLED("_nc_free_tinfo()")));
#if NO_LEAKS
_nc_free_tparm();
_nc_tgetent_leaks();
-#endif
_nc_free_entries(_nc_head);
_nc_get_type(0);
_nc_first_name(0);
-#if NO_LEAKS
_nc_keyname_leaks();
-#endif
#if BROKEN_LINKER || USE_REENTRANT
_nc_names_leaks();
_nc_codes_leaks();
+ FreeIfNeeded(_nc_prescreen.real_acs_map);
#endif
if ((s = _nc_home_terminfo()) != 0)
free(s);
+#endif /* NO_LEAKS */
returnVoid;
}
diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c
index 92c26705a016..4521c4a8da68 100644
--- a/ncurses/tinfo/home_terminfo.c
+++ b/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2007 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,9 +37,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.10 2007/04/21 23:11:53 tom Exp $")
-
-#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
+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 */
@@ -54,9 +52,9 @@ _nc_home_terminfo(void)
if (use_terminfo_vars()) {
if (MyBuffer == 0) {
- if ((home = getenv("HOME")) != 0
- && my_length <= PATH_MAX) {
- MyBuffer = typeMalloc(char, my_length);
+ if ((home = getenv("HOME")) != 0) {
+ unsigned want = (strlen(home) + sizeof(PRIVATE_INFO));
+ MyBuffer = typeMalloc(char, want);
if (MyBuffer == 0)
_nc_err_abort(MSG_NO_MEMORY);
(void) sprintf(MyBuffer, PRIVATE_INFO, home);
diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c
index d30d3ed16a87..2f6fe4f6fad7 100644
--- a/ncurses/tinfo/init_keytry.c
+++ b/ncurses/tinfo/init_keytry.c
@@ -36,7 +36,7 @@
#include <term_entry.h>
-MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $")
/*
** _nc_init_keytry()
@@ -45,6 +45,13 @@ MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $")
**
*/
+/*
+ * Internal entrypoints use SCREEN* parameter to obtain capabilities rather
+ * than cur_term.
+ */
+#undef CUR
+#define CUR (sp->_term)->type.
+
#if BROKEN_LINKER
#undef _nc_tinfo_fkeys
#endif
diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c
index 6a24285460b3..919e47287a7b 100644
--- a/ncurses/tinfo/lib_acs.c
+++ b/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 <curses.priv.h>
#include <term.h> /* ena_acs, acs_chars */
-MODULE_ID("$Id: lib_acs.c,v 1.34 2007/09/29 20:37:13 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
@@ -72,7 +72,8 @@ _nc_init_acs(void)
for (j = 1; j < ACS_LEN; ++j) {
real_map[j] = 0;
fake_map[j] = A_ALTCHARSET | j;
- SP->_screen_acs_map[j] = FALSE;
+ if (SP)
+ SP->_screen_acs_map[j] = FALSE;
}
} else {
for (j = 1; j < ACS_LEN; ++j) {
@@ -172,7 +173,7 @@ _nc_init_acs(void)
for (n = 1, m = 0; n < ACS_LEN; n++) {
if (real_map[n] != 0) {
show[m++] = (char) n;
- show[m++] = ChCharOf(real_map[n]);
+ show[m++] = (char) ChCharOf(real_map[n]);
}
}
show[m] = 0;
diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c
index 4070160da393..b9cdfda9acce 100644
--- a/ncurses/tinfo/lib_baudrate.c
+++ b/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -80,7 +80,7 @@
#undef USE_OLD_TTY
#endif /* USE_OLD_TTY */
-MODULE_ID("$Id: lib_baudrate.c,v 1.25 2007/10/20 15:00:41 Rong-En.Fan Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.27 2008/06/28 15:19:24 tom Exp $")
/*
* int
@@ -207,7 +207,7 @@ baudrate(void)
* that take into account costs that depend on baudrate.
*/
#ifdef TRACE
- if (SP && !isatty(fileno(SP->_ofp))
+ if (!isatty(fileno(SP ? SP->_ofp : stdout))
&& getenv("BAUDRATE") != 0) {
int ret;
if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
@@ -217,19 +217,22 @@ baudrate(void)
}
#endif
+ if (cur_term != 0) {
#ifdef USE_OLD_TTY
- result = cfgetospeed(&cur_term->Nttyb);
- ospeed = _nc_ospeed(result);
+ result = cfgetospeed(&cur_term->Nttyb);
+ ospeed = _nc_ospeed(result);
#else /* !USE_OLD_TTY */
#ifdef TERMIOS
- ospeed = cfgetospeed(&cur_term->Nttyb);
+ ospeed = cfgetospeed(&cur_term->Nttyb);
#else
- ospeed = cur_term->Nttyb.sg_ospeed;
+ ospeed = cur_term->Nttyb.sg_ospeed;
#endif
- result = _nc_baudrate(ospeed);
+ result = _nc_baudrate(ospeed);
#endif
- if (cur_term != 0)
cur_term->_baudrate = result;
+ } else {
+ result = ERR;
+ }
returnCode(result);
}
diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c
index 8fccc2f88d08..626578d5c08b 100644
--- a/ncurses/tinfo/lib_cur_term.c
+++ b/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000,2003 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 *
@@ -40,21 +40,45 @@
#include <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
-MODULE_ID("$Id: lib_cur_term.c,v 1.13 2003/12/27 18:21:30 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(TERMINAL *)
+NCURSES_PUBLIC_VAR(cur_term) (void)
+{
+ return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term;
+}
+#else
NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
+#endif
NCURSES_EXPORT(TERMINAL *)
set_curterm(TERMINAL * termp)
{
- TERMINAL *oldterm = cur_term;
+ TERMINAL *oldterm;
T((T_CALLED("set_curterm(%p)"), termp));
- if ((cur_term = termp) != 0) {
- ospeed = _nc_ospeed(cur_term->_baudrate);
- PC = (pad_char != NULL) ? pad_char[0] : 0;
+ _nc_lock_global(curses);
+ oldterm = cur_term;
+ if (SP)
+ SP->_term = termp;
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_prescreen._cur_term = termp;
+#else
+ cur_term = termp;
+#endif
+ if (termp != 0) {
+ ospeed = _nc_ospeed(termp->_baudrate);
+ if (termp->type.Strings) {
+ PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
+ }
}
+ _nc_unlock_global(curses);
+
T((T_RETURN("%p"), oldterm));
return (oldterm);
}
@@ -62,15 +86,20 @@ set_curterm(TERMINAL * termp)
NCURSES_EXPORT(int)
del_curterm(TERMINAL * termp)
{
+ int rc = ERR;
+
T((T_CALLED("del_curterm(%p)"), termp));
+ _nc_lock_global(curses);
if (termp != 0) {
_nc_free_termtype(&(termp->type));
FreeIfNeeded(termp->_termname);
free(termp);
if (termp == cur_term)
- cur_term = 0;
- returnCode(OK);
+ set_curterm(0);
+ rc = OK;
}
- returnCode(ERR);
+ _nc_unlock_global(curses);
+
+ returnCode(rc);
}
diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c
index ba37e5dc8c49..e84209d4022c 100644
--- a/ncurses/tinfo/lib_data.c
+++ b/ncurses/tinfo/lib_data.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_data.c,v 1.43 2008/03/29 21:16:49 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
@@ -168,8 +168,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
NULL, /* tracedmp_buf */
0, /* tracedmp_used */
- CHARS_0s, /* tracemse_buf */
-
NULL, /* tracetry_buf */
0, /* tracetry_used */
@@ -179,13 +177,11 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
#endif /* TRACE */
#ifdef USE_PTHREADS
- PTHREAD_MUTEX_INITIALIZER, /* mutex_set_SP */
- PTHREAD_MUTEX_INITIALIZER, /* mutex_use_screen */
- PTHREAD_MUTEX_INITIALIZER, /* mutex_use_window */
- PTHREAD_MUTEX_INITIALIZER, /* mutex_windowlist */
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */
PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
0, /* nested_tracef */
+ 0, /* use_pthreads */
#endif
};
@@ -222,10 +218,14 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
NUM_VARS_0s, /* static_vars */
},
NULL, /* saved_tty */
+#if NCURSES_NO_PADDING
+ FALSE, /* flag to set if padding disabled */
+#endif
#if BROKEN_LINKER || USE_REENTRANT
NULL, /* real_acs_map */
0, /* LINES */
0, /* COLS */
+ 0, /* cur_term */
#ifdef TRACE
0L, /* _outchars */
NULL, /* _tputs_trace */
@@ -243,15 +243,33 @@ init_global_mutexes(void)
if (!initialized) {
initialized = TRUE;
- _nc_mutex_init(&_nc_globals.mutex_set_SP);
- _nc_mutex_init(&_nc_globals.mutex_use_screen);
- _nc_mutex_init(&_nc_globals.mutex_use_window);
- _nc_mutex_init(&_nc_globals.mutex_windowlist);
+ _nc_mutex_init(&_nc_globals.mutex_curses);
_nc_mutex_init(&_nc_globals.mutex_tst_tracef);
_nc_mutex_init(&_nc_globals.mutex_tracef);
}
}
+NCURSES_EXPORT(void)
+_nc_init_pthreads(void)
+{
+ if (_nc_use_pthreads)
+ return;
+# if USE_WEAK_SYMBOLS
+ if ((pthread_mutex_init) == 0)
+ return;
+ if ((pthread_mutex_lock) == 0)
+ return;
+ if ((pthread_mutex_unlock) == 0)
+ return;
+ if ((pthread_mutex_trylock) == 0)
+ return;
+ if ((pthread_mutexattr_settype) == 0)
+ return;
+# endif
+ _nc_use_pthreads = 1;
+ init_global_mutexes();
+}
+
/*
* Use recursive mutexes if we have them - they're part of Unix98.
* For the cases where we do not, _nc_mutex_trylock() is used to avoid a
@@ -266,29 +284,49 @@ _nc_mutex_init(pthread_mutex_t * obj)
{
pthread_mutexattr_t recattr;
- memset(&recattr, 0, sizeof(recattr));
- pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(obj, &recattr);
+ if (_nc_use_pthreads) {
+ pthread_mutexattr_init(&recattr);
+ pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(obj, &recattr);
+ }
}
NCURSES_EXPORT(int)
_nc_mutex_lock(pthread_mutex_t * obj)
{
- init_global_mutexes();
+ if (_nc_use_pthreads == 0)
+ return 0;
return pthread_mutex_lock(obj);
}
NCURSES_EXPORT(int)
_nc_mutex_trylock(pthread_mutex_t * obj)
{
- init_global_mutexes();
+ if (_nc_use_pthreads == 0)
+ return 0;
return pthread_mutex_trylock(obj);
}
NCURSES_EXPORT(int)
_nc_mutex_unlock(pthread_mutex_t * obj)
{
- init_global_mutexes();
+ if (_nc_use_pthreads == 0)
+ return 0;
return pthread_mutex_unlock(obj);
}
+
+#if USE_WEAK_SYMBOLS
+/*
+ * NB: sigprocmask(2) is global but pthread_sigmask(3p)
+ * only for the calling thread.
+ */
+NCURSES_EXPORT(int)
+_nc_sigprocmask(int how, const sigset_t * newmask, sigset_t * oldmask)
+{
+ if ((pthread_sigmask))
+ return pthread_sigmask(how, newmask, oldmask);
+ else
+ return sigprocmask(how, newmask, oldmask);
+}
+#endif
#endif /* USE_PTHREADS */
diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c
index 98aae24baacb..f3b1485bf111 100644
--- a/ncurses/tinfo/lib_options.c
+++ b/ncurses/tinfo/lib_options.c
@@ -43,7 +43,10 @@
#include <term.h>
-MODULE_ID("$Id: lib_options.c,v 1.52 2008/05/03 23:09:20 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.58 2008/08/16 21:20:48 Werner.Fink Exp $")
+
+static int _nc_curs_set(SCREEN *, int);
+static int _nc_meta(SCREEN *, bool);
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
@@ -134,23 +137,11 @@ keypad(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
meta(WINDOW *win GCC_UNUSED, bool flag)
{
- int result = ERR;
+ int result;
/* Ok, we stay relaxed and don't signal an error if win is NULL */
T((T_CALLED("meta(%p,%d)"), win, flag));
-
- if (SP != 0) {
- SP->_use_meta = flag;
-
- if (flag && meta_on) {
- TPUTS_TRACE("meta_on");
- putp(meta_on);
- } else if (!flag && meta_off) {
- TPUTS_TRACE("meta_off");
- putp(meta_off);
- }
- result = OK;
- }
+ result = _nc_meta(SP, flag);
returnCode(result);
}
@@ -159,43 +150,10 @@ meta(WINDOW *win GCC_UNUSED, bool flag)
NCURSES_EXPORT(int)
curs_set(int vis)
{
- int result = ERR;
+ int result;
T((T_CALLED("curs_set(%d)"), vis));
- if (SP != 0 && vis >= 0 && vis <= 2) {
- int cursor = SP->_cursor;
-
- if (vis == cursor) {
- result = cursor;
- } else {
- result = (cursor == -1 ? 1 : cursor);
- switch (vis) {
- case 2:
- if (cursor_visible) {
- TPUTS_TRACE("cursor_visible");
- putp(cursor_visible);
- } else
- result = ERR;
- break;
- case 1:
- if (cursor_normal) {
- TPUTS_TRACE("cursor_normal");
- putp(cursor_normal);
- } else
- result = ERR;
- break;
- case 0:
- if (cursor_invisible) {
- TPUTS_TRACE("cursor_invisible");
- putp(cursor_invisible);
- } else
- result = ERR;
- break;
- }
- SP->_cursor = vis;
- _nc_flush();
- }
- }
+ result = _nc_curs_set(SP, vis);
returnCode(result);
}
@@ -239,6 +197,35 @@ has_key(int keycode)
}
#endif /* NCURSES_EXT_FUNCS */
+/*
+ * 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 = ERR;
+
+ if (value) {
+ TPUTS_TRACE(name);
+ rc = putp(value);
+ }
+ return rc;
+}
+
+static int
+_nc_putp_flush(const char *name, const char *value)
+{
+ int rc = _nc_putp(name, value);
+ if (rc != ERR) {
+ _nc_flush();
+ }
+ return rc;
+}
+
/* Turn the keypad on/off
*
* Note: we flush the output because changing this mode causes some terminals
@@ -249,22 +236,92 @@ has_key(int keycode)
NCURSES_EXPORT(int)
_nc_keypad(SCREEN *sp, bool flag)
{
- if (flag && keypad_xmit) {
- TPUTS_TRACE("keypad_xmit");
- putp(keypad_xmit);
- _nc_flush();
- } else if (!flag && keypad_local) {
- TPUTS_TRACE("keypad_local");
- putp(keypad_local);
- _nc_flush();
- }
+ int rc = ERR;
if (sp != 0) {
- if (flag && !sp->_tried) {
- _nc_init_keytry(sp);
- sp->_tried = TRUE;
+#ifdef USE_PTHREADS
+ /*
+ * We might have this situation in a multithreaded application that
+ * has wgetch() reading in more than one thread. putp() and below
+ * may use SP explicitly.
+ */
+ 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 = SP;
+ _nc_set_screen(sp);
+ rc = _nc_keypad(sp, flag);
+ _nc_set_screen(save_sp);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ if (flag) {
+ (void) _nc_putp_flush("keypad_xmit", keypad_xmit);
+ } else if (!flag && keypad_local) {
+ (void) _nc_putp_flush("keypad_local", keypad_local);
+ }
+
+ if (flag && !sp->_tried) {
+ _nc_init_keytry(sp);
+ sp->_tried = TRUE;
+ }
+ sp->_keypad_on = flag;
+ rc = OK;
}
- sp->_keypad_on = flag;
}
- return (OK);
+ 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_setup.c b/ncurses/tinfo/lib_setup.c
index 08cb783c5942..8cfaf12c5348 100644
--- a/ncurses/tinfo/lib_setup.c
+++ b/ncurses/tinfo/lib_setup.c
@@ -53,7 +53,7 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_setup.c,v 1.105 2008/05/03 22:41:42 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.111 2008/08/03 22:42:33 tom Exp $")
/****************************************************************************
*
@@ -100,6 +100,12 @@ MODULE_ID("$Id: lib_setup.c,v 1.105 2008/05/03 22:41:42 tom Exp $")
#endif
/*
+ * Reduce explicit use of "cur_term" global variable.
+ */
+#undef CUR
+#define CUR termp->type.
+
+/*
* Wrap global variables in this module.
*/
#if USE_REENTRANT
@@ -109,15 +115,25 @@ NCURSES_PUBLIC_VAR(ttytype) (void)
static char empty[] = "";
return cur_term ? cur_term->type.term_names : empty;
}
+NCURSES_EXPORT(int *)
+_nc_ptr_Lines(void)
+{
+ return ptrLines();
+}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(LINES) (void)
{
- return (SP ? SP->_LINES : _nc_prescreen._LINES);
+ return *_nc_ptr_Lines();
+}
+NCURSES_EXPORT(int *)
+_nc_ptr_Cols(void)
+{
+ return ptrCols();
}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(COLS) (void)
{
- return SP ? SP->_COLS : _nc_prescreen._COLS;
+ return *_nc_ptr_Cols();
}
NCURSES_EXPORT(int)
NCURSES_PUBLIC_VAR(TABSIZE) (void)
@@ -183,6 +199,7 @@ NCURSES_EXPORT(void)
_nc_get_screensize(SCREEN *sp, int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
+ TERMINAL *termp = cur_term;
int my_tabsize;
/* figure out the size of the screen */
@@ -287,6 +304,7 @@ _nc_get_screensize(SCREEN *sp, int *linep, int *colp)
NCURSES_EXPORT(void)
_nc_update_screensize(SCREEN *sp)
{
+ TERMINAL *termp = cur_term;
int old_lines = lines;
int new_lines;
int old_cols = columns;
@@ -369,21 +387,23 @@ grab_entry(const char *const tn, TERMTYPE *const tp)
** and substitute it in for the prototype given in 'command_character'.
*/
static void
-do_prototype(void)
+do_prototype(TERMINAL * termp)
{
- int i;
+ unsigned i;
char CC;
char proto;
char *tmp;
- tmp = getenv("CC");
- CC = *tmp;
- proto = *command_character;
+ if ((tmp = getenv("CC")) != 0) {
+ if ((CC = *tmp) != 0) {
+ proto = *command_character;
- for_each_string(i, &(cur_term->type)) {
- for (tmp = cur_term->type.Strings[i]; *tmp; tmp++) {
- if (*tmp == proto)
- *tmp = CC;
+ for_each_string(i, &(termp->type)) {
+ for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
+ if (*tmp == proto)
+ *tmp = CC;
+ }
+ }
}
}
}
@@ -443,7 +463,7 @@ _nc_unicode_locale(void)
* character set.
*/
NCURSES_EXPORT(int)
-_nc_locale_breaks_acs(void)
+_nc_locale_breaks_acs(TERMINAL * termp)
{
char *env;
@@ -473,6 +493,7 @@ _nc_locale_breaks_acs(void)
NCURSES_EXPORT(int)
_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
{
+ TERMINAL *termp;
int status;
START_TRACE();
@@ -517,23 +538,22 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
* properly with this feature).
*/
if (reuse
- && cur_term != 0
- && cur_term->Filedes == Filedes
- && cur_term->_termname != 0
- && !strcmp(cur_term->_termname, tname)
- && _nc_name_match(cur_term->type.term_names, tname, "|")) {
+ && (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"));
} else {
- TERMINAL *term_ptr;
- term_ptr = typeCalloc(TERMINAL, 1);
+ termp = typeCalloc(TERMINAL, 1);
- if (term_ptr == 0) {
+ if (termp == 0) {
ret_error0(TGETENT_ERR,
"Not enough memory to create terminal structure.\n");
}
#if USE_DATABASE || USE_TERMCAP
- status = grab_entry(tname, &term_ptr->type);
+ status = grab_entry(tname, &termp->type);
#else
status = TGETENT_NO;
#endif
@@ -543,32 +563,31 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
const TERMTYPE *fallback = _nc_fallback(tname);
if (fallback) {
- term_ptr->type = *fallback;
+ termp->type = *fallback;
status = TGETENT_YES;
}
}
if (status != TGETENT_YES) {
- del_curterm(term_ptr);
+ del_curterm(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);
}
}
-
- set_curterm(term_ptr);
-
- if (command_character && getenv("CC"))
- do_prototype();
-
#if !USE_REENTRANT
- strncpy(ttytype, cur_term->type.term_names, NAMESIZE - 1);
+ strncpy(ttytype, termp->type.term_names, NAMESIZE - 1);
ttytype[NAMESIZE - 1] = '\0';
#endif
- cur_term->Filedes = Filedes;
- cur_term->_termname = strdup(tname);
+ termp->Filedes = Filedes;
+ termp->_termname = strdup(tname);
+
+ set_curterm(termp);
+
+ if (command_character && getenv("CC"))
+ do_prototype(termp);
/*
* If an application calls setupterm() rather than initscr() or
@@ -585,13 +604,7 @@ _nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
/*
* We should always check the screensize, just in case.
*/
-#if USE_REENTRANT
- _nc_get_screensize(SP,
- SP ? &(SP->_LINES) : &(_nc_prescreen._LINES),
- SP ? &(SP->_COLS) : &(_nc_prescreen._COLS));
-#else
- _nc_get_screensize(SP, &LINES, &COLS);
-#endif
+ _nc_get_screensize(SP, ptrLines(), ptrCols());
if (errret)
*errret = TGETENT_YES;
diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c
index ff97eea920f8..2d245ffbb61f 100644
--- a/ncurses/tinfo/lib_termcap.c
+++ b/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -45,7 +45,7 @@
#include <term_entry.h>
-MODULE_ID("$Id: lib_termcap.c,v 1.61 2007/06/02 19:36:03 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;
@@ -142,7 +142,7 @@ tgetent(char *bufp, const char *name)
if (errcode == 1) {
if (cursor_left)
- if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0)
+ if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0)
backspace_if_not_bs = cursor_left;
/* we're required to export these */
@@ -164,6 +164,7 @@ tgetent(char *bufp, const char *name)
LAST_BUF = bufp;
LAST_USE = TRUE;
+ SetNoPadding(SP);
(void) baudrate(); /* sets ospeed as a side-effect */
/* LINT_PREPRO
diff --git a/ncurses/tinfo/lib_tgoto.c b/ncurses/tinfo/lib_tgoto.c
index 37553f712394..e07f4643138b 100644
--- a/ncurses/tinfo/lib_tgoto.c
+++ b/ncurses/tinfo/lib_tgoto.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2000-2003,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2000-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 *
@@ -35,7 +35,7 @@
#include <ctype.h>
#include <termcap.h>
-MODULE_ID("$Id: lib_tgoto.c,v 1.12 2006/11/26 00:26:24 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.13 2008/08/16 19:29:32 tom Exp $")
#if !PURE_TERMINFO
static bool
@@ -128,7 +128,7 @@ tgoto_internal(const char *string, int x, int y)
*value = 0200; /* tputs will treat this as \0 */
}
}
- result[used++] = *value++;
+ result[used++] = (char) *value++;
break;
case '%':
result[used++] = *string;
diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c
index d11fcf80cfbf..ba2a8404030e 100644
--- a/ncurses/tinfo/lib_tparm.c
+++ b/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -43,7 +43,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.74 2007/09/29 20:37:13 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.76 2008/08/16 19:22:55 tom Exp $")
/*
* char *
@@ -166,7 +166,7 @@ save_char(int c)
if (c == 0)
c = 0200;
get_space(1);
- TPS(out_buff)[TPS(out_used)++] = c;
+ TPS(out_buff)[TPS(out_used)++] = (char) c;
}
static NCURSES_INLINE void
@@ -504,8 +504,12 @@ tparam_internal(const char *string, va_list ap)
TPS(stack_ptr) = 0;
if (popcount == 0) {
popcount = number;
- for (i = number - 1; i >= 0; i--)
- npush(param[i]);
+ for (i = number - 1; i >= 0; i--) {
+ if (p_is_s[i])
+ spush(p_is_s[i]);
+ else
+ npush(param[i]);
+ }
}
#ifdef TRACE
if (USE_TRACEF(TRACE_CALLS)) {
diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c
index aab3351905ce..a8b7276895a5 100644
--- a/ncurses/tinfo/lib_tputs.c
+++ b/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2007 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -45,13 +46,29 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.64 2007/09/29 20:37:13 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 */
NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0; /* used by 'tack' program */
+#if NCURSES_NO_PADDING
+NCURSES_EXPORT(void)
+_nc_set_no_padding(SCREEN *sp)
+{
+ bool no_padding = (getenv("NCURSES_NO_PADDING") != 0);
+
+ if (sp)
+ sp->_no_padding = no_padding;
+ else
+ _nc_prescreen._no_padding = no_padding;
+
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
+ GetNoPadding(sp) ? " not" : ""));
+}
+#endif
+
static int (*my_outch) (int c) = _nc_outch;
NCURSES_EXPORT(int)
@@ -147,7 +164,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
!xon_xoff
&& padding_baud_rate
#if NCURSES_NO_PADDING
- && (SP == 0 || !(SP->_no_padding))
+ && !GetNoPadding(SP)
#endif
&& (_nc_baudrate(ospeed) >= padding_baud_rate);
}
diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c
index 2cb9fd67b4dd..a2b38a3327f1 100644
--- a/ncurses/tinfo/lib_ttyflags.c
+++ b/ncurses/tinfo/lib_ttyflags.c
@@ -38,7 +38,7 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_ttyflags.c,v 1.16 2008/05/03 22:39:03 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.18 2008/08/03 22:10:44 tom Exp $")
NCURSES_EXPORT(int)
_nc_get_tty_mode(TTY * buf)
@@ -65,7 +65,8 @@ _nc_get_tty_mode(TTY * buf)
memset(buf, 0, sizeof(*buf));
TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
+ cur_term ? cur_term->Filedes : -1,
+ _nc_trace_ttymode(buf)));
}
return (result);
}
@@ -93,7 +94,8 @@ _nc_set_tty_mode(TTY * buf)
}
}
TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
- cur_term->Filedes, _nc_trace_ttymode(buf)));
+ cur_term ? cur_term->Filedes : -1,
+ _nc_trace_ttymode(buf)));
}
return (result);
}
@@ -101,41 +103,49 @@ _nc_set_tty_mode(TTY * buf)
NCURSES_EXPORT(int)
def_shell_mode(void)
{
- T((T_CALLED("def_shell_mode()")));
+ int rc = ERR;
- /*
- * If XTABS was on, remove the tab and backtab capabilities.
- */
+ T((T_CALLED("def_shell_mode()")));
- if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
- returnCode(ERR);
+ if (cur_term != 0) {
+ /*
+ * If XTABS was on, remove the tab and backtab capabilities.
+ */
+ if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) {
#ifdef TERMIOS
- if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
- tab = back_tab = NULL;
+ if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
+ tab = back_tab = NULL;
#else
- if (cur_term->Ottyb.sg_flags & XTABS)
- tab = back_tab = NULL;
+ if (cur_term->Ottyb.sg_flags & XTABS)
+ tab = back_tab = NULL;
#endif
- returnCode(OK);
+ rc = OK;
+ }
+ }
+ returnCode(rc);
}
NCURSES_EXPORT(int)
def_prog_mode(void)
{
- T((T_CALLED("def_prog_mode()")));
+ int rc = ERR;
- /*
- * Turn off the XTABS bit in the tty structure if it was on.
- */
+ T((T_CALLED("def_prog_mode()")));
- if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
- returnCode(ERR);
+ if (cur_term != 0) {
+ /*
+ * Turn off the XTABS bit in the tty structure if it was on.
+ */
+ if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) {
#ifdef TERMIOS
- cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
+ cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
#else
- cur_term->Nttyb.sg_flags &= ~XTABS;
+ cur_term->Nttyb.sg_flags &= ~XTABS;
#endif
- returnCode(OK);
+ rc = OK;
+ }
+ }
+ returnCode(rc);
}
NCURSES_EXPORT(int)
diff --git a/ncurses/tinfo/make_keys.c b/ncurses/tinfo/make_keys.c
index 00367185a45c..c084f87fb943 100644
--- a/ncurses/tinfo/make_keys.c
+++ b/ncurses/tinfo/make_keys.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2007 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
@@ -39,7 +39,7 @@
#define USE_TERMLIB 1
#include <curses.priv.h>
-MODULE_ID("$Id: make_keys.c,v 1.13 2007/01/07 00:00:14 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.14 2008/08/03 21:57:22 tom Exp $")
#include <names.c>
@@ -71,14 +71,20 @@ static void
make_keys(FILE *ifp, FILE *ofp)
{
char buffer[BUFSIZ];
- char from[BUFSIZ];
- char to[BUFSIZ];
+ char from[256];
+ char to[256];
int maxlen = 16;
+ int scanned;
while (fgets(buffer, sizeof(buffer), ifp) != 0) {
if (*buffer == '#')
continue;
- if (sscanf(buffer, "%s %s", to, from) == 2) {
+
+ to[sizeof(to) - 1] = '\0';
+ from[sizeof(from) - 1] = '\0';
+
+ scanned = sscanf(buffer, "%255s %255s", to, from);
+ if (scanned == 2) {
int code = lookup(from);
if (code == UNKNOWN)
continue;
diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c
index c8d728faa7c4..d576901fa2e9 100644
--- a/ncurses/tinfo/name_match.c
+++ b/ncurses/tinfo/name_match.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2005,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-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 *
@@ -27,14 +27,14 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: name_match.c,v 1.16 2007/04/21 21:28:13 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.17 2008/08/03 19:49:33 tom Exp $")
/*
* _nc_first_name(char *names)
@@ -53,18 +53,21 @@ _nc_first_name(const char *const sp)
if (sp == 0) {
if (FirstName != 0)
FreeAndNull(FirstName);
- return 0;
- }
+ } else
#endif
+ {
+ if (FirstName == 0)
+ FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
- if (FirstName == 0)
- FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
- for (n = 0; n < MAX_NAME_SIZE; n++) {
- if ((FirstName[n] = sp[n]) == '\0'
- || (FirstName[n] == '|'))
- break;
+ if (FirstName != 0) {
+ for (n = 0; n < MAX_NAME_SIZE; n++) {
+ if ((FirstName[n] = sp[n]) == '\0'
+ || (FirstName[n] == '|'))
+ break;
+ }
+ FirstName[n] = '\0';
+ }
}
- FirstName[n] = '\0';
return (FirstName);
}
diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c
index 375ce8ff9957..cf7a5f409d7c 100644
--- a/ncurses/tinfo/parse_entry.c
+++ b/ncurses/tinfo/parse_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -48,7 +48,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: parse_entry.c,v 1.65 2007/08/11 16:19:02 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[] =
@@ -245,6 +245,9 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
+ if (entryp->tterm.str_table == 0)
+ return (ERR);
+
DEBUG(1, ("Starting '%s'", ptr));
/*
@@ -372,26 +375,28 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* type, this will do the job.
*/
- /* tell max_attributes from arrow_key_map */
if (token_type == NUMBER
&& !strcmp("ma", _nc_curr_token.tk_name)) {
+ /* tell max_attributes from arrow_key_map */
entry_ptr = _nc_find_type_entry("ma", NUMBER,
_nc_get_table(_nc_syntax
!= 0));
+ assert(entry_ptr != 0);
- /* map terminfo's string MT to MT */
} 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_get_table(_nc_syntax
!= 0));
+ assert(entry_ptr != 0);
- /* treat strings without following "=" as empty strings */
} else if (token_type == BOOLEAN
&& entry_ptr->nte_type == STRING) {
+ /* treat strings without following "=" as empty strings */
token_type = STRING;
- /* we couldn't recover; skip this token */
} else {
+ /* we couldn't recover; skip this token */
if (!silent) {
const char *type_name;
switch (entry_ptr->nte_type) {
@@ -454,7 +459,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
default:
if (!silent)
_nc_warning("unknown token type");
- _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
+ _nc_panic_mode((char) ((_nc_syntax == SYN_TERMCAP) ? ':' : ','));
continue;
}
} /* end else cur_token.name != "use" */
@@ -474,7 +479,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (!literal) {
if (_nc_syntax == SYN_TERMCAP) {
bool has_base_entry = FALSE;
- int i;
+ unsigned i;
/*
* Don't insert defaults if this is a `+' entry meant only
@@ -549,8 +554,8 @@ append_acs0(string_desc * dst, int code, int src)
{
if (src != 0) {
char temp[3];
- temp[0] = code;
- temp[1] = src;
+ temp[0] = (char) code;
+ temp[1] = (char) src;
temp[2] = 0;
_nc_safe_strcat(dst, temp);
}
@@ -785,11 +790,12 @@ postprocess_termcap(TERMTYPE *tp, bool has_base)
base = cp + 1) {
size_t len = cp - base;
- for (ap = ko_xlate; ap->from; ap++)
+ for (ap = ko_xlate; ap->from; ap++) {
if (len == strlen(ap->from)
&& strncmp(ap->from, base, len) == 0)
break;
- if (!ap->to) {
+ }
+ if (!(ap->from && ap->to)) {
_nc_warning("unknown capability `%.*s' in ko string",
(int) len, base);
continue;
diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c
index 6a050ee78e66..b4ea61ca194e 100644
--- a/ncurses/tinfo/read_entry.c
+++ b/ncurses/tinfo/read_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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,7 +42,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$Id: read_entry.c,v 1.100 2007/11/17 23:56:50 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))
@@ -73,7 +73,7 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
Strings[i] = ABSENT_STRING;
} else if (IS_NEG2(buf + 2 * i)) {
Strings[i] = CANCELLED_STRING;
- } else if (LOW_MSB(buf + 2 * i) > size) {
+ } else if ((int) LOW_MSB(buf + 2 * i) > size) {
Strings[i] = ABSENT_STRING;
} else {
Strings[i] = (LOW_MSB(buf + 2 * i) + table);
@@ -313,6 +313,8 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
}
if (need) {
+ if (ext_str_count >= (MAX_ENTRY_SIZE * 2))
+ return (TGETENT_NO);
if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
return (TGETENT_NO);
TR(TRACE_DATABASE,
diff --git a/ncurses/tinfo/use_screen.c b/ncurses/tinfo/use_screen.c
index a4f34c0e4520..6c3b12fb9238 100644
--- a/ncurses/tinfo/use_screen.c
+++ b/ncurses/tinfo/use_screen.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: use_screen.c,v 1.4 2008/03/29 21:19:58 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)
@@ -46,15 +46,13 @@ use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data)
* FIXME - add a flag so a given thread can check if _it_ has already
* recurred through this point, return an error if so.
*/
- _nc_lock_global(use_screen);
+ _nc_lock_global(curses);
save_SP = SP;
set_term(screen);
code = func(screen, data);
set_term(save_SP);
- _nc_unlock_global(use_screen);
+ _nc_unlock_global(curses);
returnCode(code);
-
- return 0;
}
diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c
index 05027e0021a2..b53bb210230d 100644
--- a/ncurses/tinfo/write_entry.c
+++ b/ncurses/tinfo/write_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2006,2007 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 *
@@ -54,7 +54,7 @@
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$Id: write_entry.c,v 1.70 2007/11/17 23:38:28 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.72 2008/08/03 19:24:00 tom Exp $")
static int total_written;
@@ -275,6 +275,9 @@ _nc_write_entry(TERMTYPE *const tp)
char *first_name, *other_names;
char *ptr;
+ assert(strlen(tp->term_names) != 0);
+ assert(strlen(tp->term_names) < sizeof(name_list));
+
(void) strcpy(name_list, tp->term_names);
DEBUG(7, ("Name list = '%s'", name_list));
@@ -354,7 +357,7 @@ _nc_write_entry(TERMTYPE *const tp)
start_time = 0;
}
- if (strlen(first_name) > sizeof(filename) - 3)
+ if (strlen(first_name) >= sizeof(filename) - 3)
_nc_warning("terminal name too long.");
sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
@@ -382,6 +385,7 @@ _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++;
@@ -502,7 +506,7 @@ compute_offsets(char **Strings, unsigned strmax, short *offsets)
offsets[i] = nextfree;
nextfree += strlen(Strings[i]) + 1;
TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i,
- _nc_visbuf(Strings[i]), nextfree));
+ _nc_visbuf(Strings[i]), (int) nextfree));
}
}
return nextfree;
@@ -691,9 +695,17 @@ write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
if (even_boundary(nextfree))
return (ERR);
- nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
+ nextfree = compute_offsets(tp->Strings + STRCOUNT,
+ tp->ext_Strings,
+ offsets);
TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
- nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
+
+ if (tp->ext_Strings >= SIZEOF(offsets))
+ return (ERR);
+
+ nextfree += compute_offsets(tp->ext_Names,
+ extcnt,
+ offsets + tp->ext_Strings);
TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
strmax = tp->ext_Strings + extcnt;