aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/base
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2007-12-30 11:08:14 +0000
committerRong-En Fan <rafan@FreeBSD.org>2007-12-30 11:08:14 +0000
commit5ca44d1c915a0e0c87f8f347e61f7bfa65d609af (patch)
tree319eb1471eaf8c0c9cfc606e7cb8987ca9167507 /contrib/ncurses/ncurses/base
parent01b82453a3d0c6d76d4afc340c07cfc2be4a6b7a (diff)
downloadsrc-5ca44d1c915a0e0c87f8f347e61f7bfa65d609af.tar.gz
src-5ca44d1c915a0e0c87f8f347e61f7bfa65d609af.zip
Import ncurses 5.6-20071222 snapshot onto the vender branch
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=174993
Diffstat (limited to 'contrib/ncurses/ncurses/base')
-rw-r--r--contrib/ncurses/ncurses/base/MKkeyname.awk83
-rwxr-xr-xcontrib/ncurses/ncurses/base/MKlib_gen.sh12
-rw-r--r--contrib/ncurses/ncurses/base/MKunctrl.awk92
-rw-r--r--contrib/ncurses/ncurses/base/define_key.c13
-rw-r--r--contrib/ncurses/ncurses/base/key_defined.c22
-rw-r--r--contrib/ncurses/ncurses/base/keyok.c14
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c48
-rw-r--r--contrib/ncurses/ncurses/base/lib_delwin.c31
-rw-r--r--contrib/ncurses/ncurses/base/lib_freeall.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c39
-rw-r--r--contrib/ncurses/ncurses/base/lib_initscr.c9
-rw-r--r--contrib/ncurses/ncurses/base/lib_instr.c10
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c24
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c34
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c75
-rw-r--r--contrib/ncurses/ncurses/base/lib_overlay.c11
-rw-r--r--contrib/ncurses/ncurses/base/lib_redrawln.c10
-rw-r--r--contrib/ncurses/ncurses/base/lib_refresh.c144
-rw-r--r--contrib/ncurses/ncurses/base/lib_restart.c18
-rw-r--r--contrib/ncurses/ncurses/base/lib_screen.c19
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c147
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkinit.c15
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkset.c13
-rw-r--r--contrib/ncurses/ncurses/base/lib_ungetch.c8
-rw-r--r--contrib/ncurses/ncurses/base/lib_window.c6
-rw-r--r--contrib/ncurses/ncurses/base/memmove.c6
-rw-r--r--contrib/ncurses/ncurses/base/resizeterm.c113
-rw-r--r--contrib/ncurses/ncurses/base/safe_sprintf.c56
-rw-r--r--contrib/ncurses/ncurses/base/tries.c22
-rw-r--r--contrib/ncurses/ncurses/base/use_window.c80
-rw-r--r--contrib/ncurses/ncurses/base/wresize.c17
32 files changed, 851 insertions, 410 deletions
diff --git a/contrib/ncurses/ncurses/base/MKkeyname.awk b/contrib/ncurses/ncurses/base/MKkeyname.awk
index 11dcfe5c2375..c1d9475045d0 100644
--- a/contrib/ncurses/ncurses/base/MKkeyname.awk
+++ b/contrib/ncurses/ncurses/base/MKkeyname.awk
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.30 2006/05/20 17:35:30 tom Exp $
+# $Id: MKkeyname.awk,v 1.38 2007/08/18 18:41:18 tom Exp $
##############################################################################
-# Copyright (c) 1999-2005,2006 Free Software Foundation, Inc. #
+# Copyright (c) 1999-2006,2007 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -33,18 +33,39 @@ BEGIN {
print "#include <tic.h>"
print "#include <term_entry.h>"
print ""
- print "const struct kn _nc_key_names[] = {"
+ first = 1;
}
/^[^#]/ {
- printf "\t{ \"%s\", %s },\n", $1, $1;
+ if (bigstrings) {
+ if (first) {
+ print "struct kn { short offset; int code; };"
+ print "static const struct kn _nc_key_names[] = {"
+ }
+ printf "\t{ %d, %s },\n", offset, $1
+ offset += length($1) + 1
+ names = names"\n\t\""$1"\\0\""
+ } else {
+ if (first) {
+ print "struct kn { const char *name; int code; };"
+ print "static const struct kn _nc_key_names[] = {"
+ }
+ printf "\t{ \"%s\", %s },\n", $1, $1;
+ }
+ first = 0;
}
END {
- printf "\t{ 0, 0 }};\n"
+ if (bigstrings) {
+ printf "\t{ -1, 0 }};\n"
+ print ""
+ print "static const char key_names[] = "names";"
+ } else {
+ printf "\t{ 0, 0 }};\n"
+ }
print ""
print "#define SIZEOF_TABLE 256"
- print "static char **keyname_table;"
+ print "#define MyTable _nc_globals.keyname_table"
print ""
print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
print "{"
@@ -56,21 +77,30 @@ END {
print " if (c == -1) {"
print " result = \"-1\";"
print " } else {"
- print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
- print " if (_nc_key_names[i].code == c) {"
- print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
- print " break;"
- print " }"
- print " }"
+ if (bigstrings) {
+ print " for (i = 0; _nc_key_names[i].offset != -1; i++) {"
+ print " if (_nc_key_names[i].code == c) {"
+ print " result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;"
+ print " break;"
+ print " }"
+ print " }"
+ } else {
+ print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
+ print " if (_nc_key_names[i].code == c) {"
+ print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
+ print " break;"
+ print " }"
+ print " }"
+ }
print ""
print " if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
- print " if (keyname_table == 0)"
- print " keyname_table = typeCalloc(char *, SIZEOF_TABLE);"
- print " if (keyname_table != 0) {"
- print " if (keyname_table[c] == 0) {"
+ print " if (MyTable == 0)"
+ print " MyTable = typeCalloc(char *, SIZEOF_TABLE);"
+ print " if (MyTable != 0) {"
+ print " if (MyTable[c] == 0) {"
print " int cc = c;"
print " p = name;"
- print " if (cc >= 128) {"
+ print " if (cc >= 128 && (SP == 0 || SP->_use_meta)) {"
print " strcpy(p, \"M-\");"
print " p += 2;"
print " cc -= 128;"
@@ -81,9 +111,9 @@ END {
print " strcpy(p, \"^?\");"
print " else"
print " sprintf(p, \"%c\", cc);"
- print " keyname_table[c] = strdup(name);"
+ print " MyTable[c] = strdup(name);"
print " }"
- print " result = keyname_table[c];"
+ print " result = MyTable[c];"
print " }"
print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
print " } else if (result == 0 && cur_term != 0) {"
@@ -111,24 +141,15 @@ END {
print " return result;"
print "}"
print ""
- print "#if USE_WIDEC_SUPPORT"
- print "NCURSES_EXPORT(NCURSES_CONST char *) key_name (wchar_t c)"
- print "{"
- print " NCURSES_CONST char *result = keyname((int)c);"
- print " if (!strncmp(result, \"M-\", 2)) result = 0;"
- print " return result;"
- print "}"
- print "#endif"
- print ""
print "#if NO_LEAKS"
print "void _nc_keyname_leaks(void)"
print "{"
print " int j;"
- print " if (keyname_table != 0) {"
+ print " if (MyTable != 0) {"
print " for (j = 0; j < SIZEOF_TABLE; ++j) {"
- print " FreeIfNeeded(keyname_table[j]);"
+ print " FreeIfNeeded(MyTable[j]);"
print " }"
- print " FreeAndNull(keyname_table);"
+ print " FreeAndNull(MyTable);"
print " }"
print "}"
print "#endif /* NO_LEAKS */"
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh
index 30c44fff6f83..b5b07140b55f 100755
--- a/contrib/ncurses/ncurses/base/MKlib_gen.sh
+++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh
@@ -2,10 +2,10 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.27 2006/07/01 21:25:39 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.29 2007/08/18 13:17:14 tom Exp $)
#
##############################################################################
-# Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -62,7 +62,7 @@ if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
if test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi
-preprocessor="$1 -I../include"
+preprocessor="$1 -DNCURSES_INTERNALS -I../include"
AWK="$2"
USE="$3"
@@ -406,7 +406,11 @@ sed -n -f $ED1 \
| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \
| sed -f $ED2 \
| $AWK -f $AW1 using=$USE \
-| sed -e 's/^\([a-z_][a-z_]*[ *]*\)/\1 gen_/' -e 's/ / /g' >>$TMP
+| sed \
+ -e 's/ [ ]*$//g' \
+ -e 's/^\([a-zA-Z_][a-zA-Z_]*[ *]*\)/\1 gen_/' \
+ -e 's/gen_$//' \
+ -e 's/ / /g' >>$TMP
$preprocessor $TMP 2>/dev/null \
| sed \
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
index e153fa8c95c4..5d187a8cfb7e 100644
--- a/contrib/ncurses/ncurses/base/MKunctrl.awk
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -1,6 +1,6 @@
-# $Id: MKunctrl.awk,v 1.11 2005/12/17 22:48:37 tom Exp $
+# $Id: MKunctrl.awk,v 1.14 2007/07/28 21:13:21 tom Exp $
##############################################################################
-# Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -42,63 +42,111 @@ END {
print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)"
print "{"
- printf "static const char* const table[] = {"
+ blob=""
+ offset=0
+ if (bigstrings) {
+ printf "static const short unctrl_table[] = {"
+ } else {
+ printf "static const char* const unctrl_table[] = {"
+ }
for ( ch = 0; ch < 256; ch++ ) {
gap = ","
- if ((ch % 8) == 0)
+ part=""
+ if ((ch % 8) == 0) {
printf "\n "
+ if (ch != 0)
+ blob = blob "\""
+ blob = blob "\n \""
+ }
+ if (bigstrings)
+ printf "%4d%s", offset, gap;
if (ch < 32) {
- printf "\"^\\%03o\"", ch + 64
+ part = sprintf ("^\\%03o", ch + 64);
+ offset = offset + 3;
} else if (ch == 127) {
- printf "\"^?\""
+ part = "^?";
+ offset = offset + 3;
} else if (ch >= 128 && ch < 160) {
- printf "\"~\\%03o\"", ch - 64
+ part = sprintf("~\\%03o", ch - 64);
+ offset = offset + 3;
} else {
- printf "\"\\%03o\"", ch
gap = gap " "
+ part = sprintf("\\%03o", ch);
+ offset = offset + 2;
}
if (ch == 255)
gap = "\n"
else if (((ch + 1) % 8) != 0)
gap = gap " "
- printf "%s", gap
+ if (bigstrings) {
+ blob = blob part "\\0";
+ } else {
+ printf "\"%s\"%s", part, gap
+ }
}
print "};"
+ blob = blob "\"";
print ""
print "#if NCURSES_EXT_FUNCS"
- printf "static const char* const table2[] = {"
+ if (bigstrings) {
+ blob = blob "\n#if NCURSES_EXT_FUNCS"
+ printf "static const short unctrl_c1[] = {"
+ } else {
+ printf "static const char* const unctrl_c1[] = {"
+ }
for ( ch = 128; ch < 160; ch++ ) {
gap = ","
- if ((ch % 8) == 0)
+ if ((ch % 8) == 0) {
+ if (ch != 128)
+ blob = blob "\""
printf "\n "
- if (ch >= 128 && ch < 160) {
- printf "\"\\%03o\"", ch
- gap = gap " "
+ blob = blob "\n \""
+ }
+ if (bigstrings) {
+ printf "%4d%s", offset, gap;
+ part = sprintf("\\%03o\\0", ch);
+ blob = blob part
+ offset = offset + 2;
+ if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ } else {
+ if (ch >= 128 && ch < 160) {
+ printf "\"\\%03o\"", ch
+ gap = gap " "
+ }
+ if (ch == 255)
+ gap = "\n"
+ else if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ printf "%s", gap
}
- if (ch == 255)
- gap = "\n"
- else if (((ch + 1) % 8) != 0)
- gap = gap " "
- printf "%s", gap
}
print "};"
print "#endif /* NCURSES_EXT_FUNCS */"
+ blob = blob "\"\n#endif /* NCURSES_EXT_FUNCS */\n"
print ""
+ if (bigstrings) {
+ print "static const char unctrl_blob[] = "blob";"
+ print ""
+ stringname = "unctrl_blob + unctrl"
+ } else {
+ stringname = "unctrl"
+ }
print "\tint check = ChCharOf(ch);"
print "\tconst char *result;"
print ""
- print "\tif (check >= 0 && check < (int)SIZEOF(table)) {"
+ print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
print "#if NCURSES_EXT_FUNCS"
print "\t\tif ((SP != 0)"
print "\t\t && (SP->_legacy_coding > 1)"
print "\t\t && (check >= 128)"
print "\t\t && (check < 160))"
- print "\t\t\tresult = table2[check - 128];"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
print "#endif /* NCURSES_EXT_FUNCS */"
- print "\t\t\tresult = table[check];"
+ printf "\t\t\tresult = %s_table[check];\n", stringname;
print "\t} else {"
print "\t\tresult = 0;"
print "\t}"
diff --git a/contrib/ncurses/ncurses/base/define_key.c b/contrib/ncurses/ncurses/base/define_key.c
index 3b5299a338e4..3d5815f906d6 100644
--- a/contrib/ncurses/ncurses/base/define_key.c
+++ b/contrib/ncurses/ncurses/base/define_key.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: define_key.c,v 1.10 2006/06/17 18:19:48 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.13 2006/12/30 23:23:31 tom Exp $")
NCURSES_EXPORT(int)
define_key(const char *str, int keycode)
@@ -43,16 +43,21 @@ define_key(const char *str, int keycode)
if (SP == 0) {
code = ERR;
} else if (keycode > 0) {
+ unsigned ukey = (unsigned) keycode;
+
if (str != 0) {
define_key(str, 0);
} else if (has_key(keycode)) {
- while (_nc_remove_key(&(SP->_keytry), (unsigned) keycode))
+ while (_nc_remove_key(&(SP->_keytry), ukey))
code = OK;
}
if (str != 0) {
if (key_defined(str) == 0) {
- (void) _nc_add_to_try(&(SP->_keytry), str, (unsigned) keycode);
- code = OK;
+ if (_nc_add_to_try(&(SP->_keytry), str, ukey) == OK) {
+ code = OK;
+ } else {
+ code = ERR;
+ }
} else {
code = ERR;
}
diff --git a/contrib/ncurses/ncurses/base/key_defined.c b/contrib/ncurses/ncurses/base/key_defined.c
index dac188748770..759ad824318d 100644
--- a/contrib/ncurses/ncurses/base/key_defined.c
+++ b/contrib/ncurses/ncurses/base/key_defined.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2003 Free Software Foundation, Inc. *
+ * Copyright (c) 2003,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 *
@@ -32,26 +32,27 @@
#include <curses.priv.h>
-MODULE_ID("$Id: key_defined.c,v 1.3 2003/05/17 23:12:27 tom Exp $")
+MODULE_ID("$Id: key_defined.c,v 1.6 2006/12/30 23:22:55 tom Exp $")
static int
-find_definition(struct tries *tree, const char *str)
+find_definition(TRIES * tree, const char *str)
{
- struct tries *ptr;
- int result = 0;
+ TRIES *ptr;
+ int result = OK;
if (str != 0 && *str != '\0') {
for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
if (UChar(*str) == UChar(ptr->ch)) {
if (str[1] == '\0' && ptr->child != 0) {
- result = -1;
- } else if ((result = find_definition(ptr->child, str + 1)) == 0) {
+ result = ERR;
+ } else if ((result = find_definition(ptr->child, str + 1))
+ == OK) {
result = ptr->value;
} else if (str[1] == '\0') {
- result = -1;
+ result = ERR;
}
}
- if (result != 0)
+ if (result != OK)
break;
}
}
@@ -60,7 +61,8 @@ find_definition(struct tries *tree, const char *str)
/*
* Returns the keycode associated with the given string. If none is found,
- * return 0. If the string is only a prefix to other strings, return -1.
+ * return OK. If the string is only a prefix to other strings, return ERR.
+ * Otherwise, return the keycode's value (neither OK/ERR).
*/
NCURSES_EXPORT(int)
key_defined(const char *str)
diff --git a/contrib/ncurses/ncurses/base/keyok.c b/contrib/ncurses/ncurses/base/keyok.c
index 4c9950600c33..ad8988cded3b 100644
--- a/contrib/ncurses/ncurses/base/keyok.c
+++ b/contrib/ncurses/ncurses/base/keyok.c
@@ -27,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: keyok.c,v 1.6 2006/06/17 18:18:43 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.7 2006/12/30 16:22:33 tom Exp $")
/*
* Enable (or disable) ncurses' interpretation of a keycode by adding (or
@@ -57,18 +57,20 @@ keyok(int c, bool flag)
if (flag) {
while ((s = _nc_expand_try(SP->_key_ok, ch, &count, 0)) != 0
&& _nc_remove_key(&(SP->_key_ok), ch)) {
- _nc_add_to_try(&(SP->_keytry), s, ch);
+ code = _nc_add_to_try(&(SP->_keytry), s, ch);
free(s);
- code = OK;
count = 0;
+ if (code != OK)
+ break;
}
} else {
while ((s = _nc_expand_try(SP->_keytry, ch, &count, 0)) != 0
&& _nc_remove_key(&(SP->_keytry), ch)) {
- _nc_add_to_try(&(SP->_key_ok), s, ch);
+ code = _nc_add_to_try(&(SP->_key_ok), s, ch);
free(s);
- code = OK;
count = 0;
+ if (code != OK)
+ break;
}
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
index b7a0b40ef948..4e3a040cf032 100644
--- a/contrib/ncurses/ncurses/base/lib_addstr.c
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.46 2006/05/27 19:22:19 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.48 2007/10/13 19:56:57 tom Exp $")
NCURSES_EXPORT(int)
waddnstr(WINDOW *win, const char *astr, int n)
@@ -80,8 +80,7 @@ waddnstr(WINDOW *win, const char *astr, int n)
NCURSES_EXPORT(int)
waddchnstr(WINDOW *win, const chtype *astr, int n)
{
- NCURSES_SIZE_T y = win->_cury;
- NCURSES_SIZE_T x = win->_curx;
+ NCURSES_SIZE_T y, x;
int code = OK;
int i;
struct ldat *line;
@@ -91,6 +90,8 @@ waddchnstr(WINDOW *win, const chtype *astr, int n)
if (!win)
returnCode(ERR);
+ y = win->_cury;
+ x = win->_curx;
if (n < 0) {
const chtype *str;
n = 0;
@@ -128,8 +129,8 @@ NCURSES_EXPORT(int)
wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
{
static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
- NCURSES_SIZE_T y = win->_cury;
- NCURSES_SIZE_T x = win->_curx;
+ NCURSES_SIZE_T y;
+ NCURSES_SIZE_T x;
int code = OK;
struct ldat *line;
int i, j, start, len, end;
@@ -139,6 +140,8 @@ wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
if (!win)
returnCode(ERR);
+ y = win->_cury;
+ x = win->_curx;
if (n < 0) {
n = _nc_wchstrlen(astr);
}
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index a90ca9d34308..9cae495436fe 100644
--- a/contrib/ncurses/ncurses/base/lib_color.c
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,21 +42,37 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.80 2006/11/26 01:33:16 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.85 2007/04/07 17:07:28 tom Exp $")
/*
* 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 SP ? SP->_pair_count : -1;
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLORS) (void)
+{
+ return SP ? SP->_color_count : -1;
+}
+#else
NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
NCURSES_EXPORT_VAR(int) COLORS = 0;
+#endif
#define DATA(r,g,b) {r,g,b, 0,0,0, 0}
#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+#define MAX_PALETTE 8
+
#define OkColorHi(n) (((n) < COLORS) && ((n) < max_colors))
+#define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE)
/*
* Given a RGB range of 0..1000, we'll normally set the individual values
@@ -162,10 +178,10 @@ init_color_table(void)
tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
for (n = 0; n < COLORS; n++) {
- if (n < 8) {
+ if (InPalette(n)) {
SP->_color_table[n] = tp[n];
} else {
- SP->_color_table[n] = tp[n % 8];
+ SP->_color_table[n] = tp[n % MAX_PALETTE];
if (hue_lightness_saturation) {
SP->_color_table[n].green = 100;
} else {
@@ -239,8 +255,12 @@ start_color(void)
}
if (max_pairs > 0 && max_colors > 0) {
- COLOR_PAIRS = SP->_pair_count = max_pairs;
- COLORS = SP->_color_count = max_colors;
+ SP->_pair_count = max_pairs;
+ SP->_color_count = max_colors;
+#if !USE_REENTRANT
+ COLOR_PAIRS = max_pairs;
+ COLORS = max_colors;
+#endif
if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
max_pairs)) != 0) {
@@ -365,13 +385,14 @@ init_pair(short pair, short f, short b)
if (GET_SCREEN_PAIR(SP) == pair)
SET_SCREEN_PAIR(SP, (chtype) (~0)); /* force attribute update */
- if (initialize_pair) {
+ if (initialize_pair && InPalette(f) && InPalette(b)) {
const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
- T(("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));
+ 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));
TPUTS_TRACE("initialize_pair");
putp(TPARM_7(initialize_pair,
@@ -461,7 +482,8 @@ color_content(short color, short *r, short *g, short *b)
if (b)
*b = c_b;
- T(("...color_content(%d,%d,%d,%d)", color, c_r, c_g, c_b));
+ TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+ color, c_r, c_g, c_b));
result = OK;
}
returnCode(result);
@@ -492,7 +514,7 @@ pair_content(short pair, short *f, short *b)
if (b)
*b = bg;
- T(("...pair_content(%d,%d,%d)", pair, fg, bg));
+ TR(TRACE_ATTRS, ("...pair_content(%d,%d,%d)", pair, fg, bg));
result = OK;
}
returnCode(result);
diff --git a/contrib/ncurses/ncurses/base/lib_delwin.c b/contrib/ncurses/ncurses/base/lib_delwin.c
index 89d8e7c32ece..fc68f9d68dee 100644
--- a/contrib/ncurses/ncurses/base/lib_delwin.c
+++ b/contrib/ncurses/ncurses/base/lib_delwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_delwin.c,v 1.13 2001/08/26 00:40:20 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.15 2007/12/22 23:34:26 tom Exp $")
static bool
cannot_delete(WINDOW *win)
@@ -63,16 +63,27 @@ cannot_delete(WINDOW *win)
NCURSES_EXPORT(int)
delwin(WINDOW *win)
{
+ int result = ERR;
+
T((T_CALLED("delwin(%p)"), win));
- if (win == 0
- || cannot_delete(win))
- returnCode(ERR);
+ if (_nc_try_global(windowlist) == 0) {
+ _nc_lock_window(win);
+ if (win == 0
+ || cannot_delete(win)) {
+ result = ERR;
+ _nc_unlock_window(win);
+ } else {
- if (win->_flags & _SUBWIN)
- touchwin(win->_parent);
- else if (curscr != 0)
- touchwin(curscr);
+ if (win->_flags & _SUBWIN)
+ touchwin(win->_parent);
+ else if (curscr != 0)
+ touchwin(curscr);
- returnCode(_nc_freewin(win));
+ _nc_unlock_window(win);
+ result = _nc_freewin(win);
+ }
+ _nc_unlock_global(windowlist);
+ }
+ returnCode(result);
}
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
index 27897a9f6a2a..dbf0483f2401 100644
--- a/contrib/ncurses/ncurses/base/lib_freeall.c
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996,1997 *
+ * Author: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
@@ -40,7 +40,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.38 2006/12/02 22:36:43 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.45 2007/12/22 23:29:37 tom Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -50,18 +50,22 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
WINDOWLIST *p, *q;
- char *s;
static va_list empty_va;
T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
- _nc_free_tparm();
- if (_nc_oldnums != 0) {
- FreeAndNull(_nc_oldnums);
+ if (SP != 0) {
+ if (SP->_oldnum_list != 0) {
+ FreeAndNull(SP->_oldnum_list);
+ }
}
#endif
if (SP != 0) {
+ _nc_lock_global(windowlist);
+
while (_nc_windows != 0) {
+ bool deleted = FALSE;
+
/* Delete only windows that're not a parent */
for (p = _nc_windows; p != 0; p = p->next) {
bool found = FALSE;
@@ -76,39 +80,38 @@ _nc_freeall(void)
}
if (!found) {
- delwin(&(p->win));
+ if (delwin(&(p->win)) != ERR)
+ deleted = TRUE;
break;
}
}
+
+ /*
+ * Don't continue to loop if the list is trashed.
+ */
+ if (!deleted)
+ break;
}
delscreen(SP);
+ _nc_unlock_global(windowlist);
}
-#if NO_LEAKS
- _nc_tgetent_leaks();
-#endif
- del_curterm(cur_term);
- _nc_free_entries(_nc_head);
- _nc_get_type(0);
- _nc_first_name(0);
+ if (cur_term != 0)
+ del_curterm(cur_term);
+
#if USE_WIDEC_SUPPORT
FreeIfNeeded(_nc_wacs);
#endif
-#if NO_LEAKS
- _nc_alloc_entry_leaks();
- _nc_captoinfo_leaks();
- _nc_comp_scan_leaks();
- _nc_keyname_leaks();
- _nc_tic_expand(0, FALSE, 0);
-#endif
-
- if ((s = _nc_home_terminfo()) != 0)
- free(s);
-
(void) _nc_printf_string(0, empty_va);
#ifdef TRACE
(void) _nc_trace_buf(-1, 0);
#endif
+#if BROKEN_LINKER || USE_REENTRANT
+ FreeIfNeeded(_nc_prescreen.real_acs_map);
+#endif
+
+ _nc_leaks_tinfo();
+
#if HAVE_LIBDBMALLOC
malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index 7891edf3b079..64566ccc7629 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,12 +41,20 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.75 2006/03/04 20:06:09 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.80 2007/09/29 20:39:34 tom Exp $")
#include <fifo_defs.h>
+#if USE_REENTRANT
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(ESCDELAY) (void)
+{
+ return SP ? SP->_ESCDELAY : 1000;
+}
+#else
NCURSES_EXPORT_VAR(int)
ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+#endif
#ifdef NCURSES_WGETCH_EVENTS
#define TWAIT_MASK 7
@@ -104,8 +112,10 @@ fifo_pull(void)
h_inc();
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
+ if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump();
+ _nc_unlock_global(tracef);
+ }
#endif
return ch;
}
@@ -200,8 +210,10 @@ fifo_push(EVENTLIST_0th(_nc_eventlist * evl))
t_inc();
TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
+ if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump();
+ _nc_unlock_global(tracef);
+ }
#endif
return ch;
}
@@ -234,15 +246,16 @@ _nc_wgetch(WINDOW *win,
T((T_CALLED("_nc_wgetch(%p)"), win));
*result = 0;
- if (win == 0 || SP == 0)
+ if (win == 0 || SP == 0) {
returnCode(ERR);
+ }
if (cooked_key_in_fifo()) {
if (wgetch_should_refresh(win))
wrefresh(win);
*result = fifo_pull();
- returnCode(OK);
+ returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
#ifdef NCURSES_WGETCH_EVENTS
if (evl && (evl->count == 0))
@@ -281,12 +294,10 @@ _nc_wgetch(WINDOW *win,
/* Return it first */
if (rc == KEY_EVENT) {
*result = rc;
- returnCode(OK);
- }
+ } else
#endif
-
- *result = fifo_pull();
- returnCode(OK);
+ *result = fifo_pull();
+ returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
if (win->_use_keypad != SP->_keypad_on)
@@ -318,7 +329,7 @@ _nc_wgetch(WINDOW *win,
#ifdef NCURSES_WGETCH_EVENTS
if (rc & 4) {
*result = KEY_EVENT;
- returnCode(OK);
+ returnCode(KEY_CODE_YES);
}
#endif
if (!rc)
@@ -384,7 +395,7 @@ _nc_wgetch(WINDOW *win,
if (ch == ERR) {
#if USE_SIZECHANGE
- if (SP->_sig_winch) {
+ if (_nc_handle_sigwinch(FALSE)) {
_nc_update_screensize();
/* resizeterm can push KEY_RESIZE */
if (cooked_key_in_fifo()) {
@@ -493,7 +504,7 @@ wgetch(WINDOW *win)
static int
kgetch(EVENTLIST_0th(_nc_eventlist * evl))
{
- struct tries *ptr;
+ TRIES *ptr;
int ch = 0;
int timeleft = ESCDELAY;
diff --git a/contrib/ncurses/ncurses/base/lib_initscr.c b/contrib/ncurses/ncurses/base/lib_initscr.c
index d2ae281972a9..38744738cbb6 100644
--- a/contrib/ncurses/ncurses/base/lib_initscr.c
+++ b/contrib/ncurses/ncurses/base/lib_initscr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -45,19 +45,18 @@
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.34 2005/10/22 20:30:38 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.35 2007/04/21 20:43:02 tom Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
{
- static bool initialized = FALSE;
NCURSES_CONST char *name;
START_TRACE();
T((T_CALLED("initscr()")));
/* Portable applications must not call initscr() more than once */
- if (!initialized) {
- initialized = TRUE;
+ if (!_nc_globals.init_screen) {
+ _nc_globals.init_screen = TRUE;
if ((name = getenv("TERM")) == 0
|| *name == '\0')
diff --git a/contrib/ncurses/ncurses/base/lib_instr.c b/contrib/ncurses/ncurses/base/lib_instr.c
index 809952fdf82f..3fb29490ad06 100644
--- a/contrib/ncurses/ncurses/base/lib_instr.c
+++ b/contrib/ncurses/ncurses/base/lib_instr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_instr.c,v 1.15 2005/11/20 01:38:03 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.16 2007/07/21 20:18:10 tom Exp $")
NCURSES_EXPORT(int)
winnstr(WINDOW *win, char *str, int n)
@@ -81,7 +81,7 @@ winnstr(WINDOW *win, char *str, int n)
n3 = wcstombs(0, wch, 0);
if (isEILSEQ(n3) || (n3 == 0)) {
;
- } else if ((int) (n3 + i) >= n) {
+ } else if ((int) (n3 + i) > n) {
done = TRUE;
} else if ((tmp = typeCalloc(char, n3 + 10)) == 0) {
done = TRUE;
@@ -102,9 +102,7 @@ winnstr(WINDOW *win, char *str, int n)
str[i++] = (char) CharOf(win->_line[row].text[col]);
#endif
if (++col > win->_maxx) {
- col = 0;
- if (++row > win->_maxy)
- break;
+ break;
}
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
index f30232795be4..aace7deb4c7f 100644
--- a/contrib/ncurses/ncurses/base/lib_mouse.c
+++ b/contrib/ncurses/ncurses/base/lib_mouse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -79,7 +79,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_mouse.c,v 1.85 2006/11/25 22:30:28 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.88 2007/09/29 21:50:04 tom Exp $")
#include <term.h>
#include <tic.h>
@@ -403,11 +403,11 @@ enable_gpm_mouse(int enable)
}
#endif /* USE_GPM_SUPPORT */
+#define xterm_kmous "\033[M"
+
static void
initialize_mousetype(void)
{
- static const char *xterm_kmous = "\033[M";
-
T((T_CALLED("initialize_mousetype()")));
/* Try gpm first, because gpm may be configured to run in xterm */
@@ -565,8 +565,8 @@ initialize_mousetype(void)
init_xterm_mouse();
}
} else if (strstr(cur_term->type.term_names, "xterm") != 0) {
- (void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
- init_xterm_mouse();
+ if (_nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE) == OK)
+ init_xterm_mouse();
}
returnVoid;
}
@@ -985,12 +985,13 @@ _nc_mouse_parse(int runcount)
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
+ if (USE_TRACEF(TRACE_IEVENT)) {
_trace_slot("before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - SP->_mouse_events),
(long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -1028,12 +1029,13 @@ _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
+ if (USE_TRACEF(TRACE_IEVENT)) {
_trace_slot("before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - SP->_mouse_events),
(long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -1099,12 +1101,13 @@ _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
+ if (USE_TRACEF(TRACE_IEVENT)) {
_trace_slot("before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - SP->_mouse_events),
(long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -1117,12 +1120,13 @@ _nc_mouse_parse(int runcount)
SP->_mouse_eventp = eventp = prev;
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
+ if (USE_TRACEF(TRACE_IEVENT)) {
_trace_slot("after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - SP->_mouse_events),
(long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
runcount);
+ _nc_unlock_global(tracef);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
if (ep->id != INVALID_EVENT)
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index fe201d6b8e27..05cd9b8a5b00 100644
--- a/contrib/ncurses/ncurses/base/lib_newterm.c
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -48,7 +48,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.64 2006/01/14 15:36:24 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.67 2007/04/21 20:47:32 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -94,14 +94,12 @@ _nc_initscr(void)
* aside from possibly delaying a filter() call until some terminals have been
* initialized.
*/
-static bool filter_mode = FALSE;
-
NCURSES_EXPORT(void)
filter(void)
{
START_TRACE();
T((T_CALLED("filter")));
- filter_mode = TRUE;
+ _nc_prescreen.filter_mode = TRUE;
returnVoid;
}
@@ -115,7 +113,7 @@ nofilter(void)
{
START_TRACE();
T((T_CALLED("nofilter")));
- filter_mode = FALSE;
+ _nc_prescreen.filter_mode = FALSE;
returnVoid;
}
#endif
@@ -132,13 +130,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- _nc_handle_sigwinch(0);
-
- /* allow user to set maximum escape delay from the environment */
- if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
- ESCDELAY = value;
- }
-
/* this loads the capability entry, then sets LINES and COLS */
if (setupterm(name, fileno(ofp), &errret) == ERR) {
result = 0;
@@ -149,7 +140,21 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
*/
current = SP;
_nc_set_screen(0);
- if (_nc_setupscreen(LINES, COLS, ofp, filter_mode, slk_format) == ERR) {
+
+ /* allow user to set maximum escape delay from the environment */
+ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+#if USE_REENTRANT
+ SP->_ESCDELAY = value;
+#else
+ ESCDELAY = value;
+#endif
+ }
+
+ if (_nc_setupscreen(LINES,
+ COLS,
+ ofp,
+ _nc_prescreen.filter_mode,
+ slk_format) == ERR) {
_nc_set_screen(current);
result = 0;
} else {
@@ -211,6 +216,5 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
result = SP;
}
}
- _nc_handle_sigwinch(1);
returnSP(result);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index ba516337b996..b0f4603ae7ab 100644
--- a/contrib/ncurses/ncurses/base/lib_newwin.c
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.38 2006/10/14 20:31:19 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.42 2007/12/22 23:20:18 tom Exp $")
static WINDOW *
remove_window_from_screen(WINDOW *win)
@@ -52,16 +52,22 @@ remove_window_from_screen(WINDOW *win)
SCREEN *sp = *scan;
if (sp->_curscr == win) {
sp->_curscr = 0;
+#if !USE_REENTRANT
if (win == curscr)
curscr = 0;
+#endif
} else if (sp->_stdscr == win) {
sp->_stdscr = 0;
+#if !USE_REENTRANT
if (win == stdscr)
stdscr = 0;
+#endif
} else if (sp->_newscr == win) {
sp->_newscr = 0;
+#if !USE_REENTRANT
if (win == newscr)
newscr = 0;
+#endif
} else {
scan = &(*scan)->_next_screen;
continue;
@@ -79,29 +85,34 @@ _nc_freewin(WINDOW *win)
int i;
int result = ERR;
+ T((T_CALLED("_nc_freewin(%p)"), win));
+
if (win != 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
- if (&(p->win) == win) {
- remove_window_from_screen(win);
- if (q == 0)
- _nc_windows = p->next;
- else
- q->next = p->next;
-
- if (!(win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy; i++)
- FreeIfNeeded(win->_line[i].text);
+ if (_nc_try_global(windowlist) == 0) {
+ for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ if (&(p->win) == win) {
+ remove_window_from_screen(win);
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+
+ if (!(win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy; i++)
+ FreeIfNeeded(win->_line[i].text);
+ }
+ free(win->_line);
+ free(p);
+
+ result = OK;
+ T(("...deleted win=%p", win));
+ break;
}
- free(win->_line);
- free(p);
-
- result = OK;
- T(("...deleted win=%p", win));
- break;
}
+ _nc_unlock_global(windowlist);
}
}
- return result;
+ returnCode(result);
}
NCURSES_EXPORT(WINDOW *)
@@ -208,24 +219,35 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
WINDOW *win;
bool is_pad = (flags & _ISPAD);
- T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+ T((T_CALLED("_nc_makenew(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
if (SP == 0)
- return 0;
+ returnWin(0);
if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
- return 0;
+ returnWin(0);
if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
- return 0;
+ returnWin(0);
+
+#ifdef USE_PTHREADS
+ {
+ pthread_mutexattr_t recattr;
+ memset(&recattr, 0, sizeof(recattr));
+ pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&(wp->mutex_use_window), &recattr);
+ }
+#endif
win = &(wp->win);
if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
free(win);
- return 0;
+ returnWin(0);
}
+ _nc_lock_global(windowlist);
+
win->_curx = 0;
win->_cury = 0;
win->_maxy = num_lines - 1;
@@ -303,5 +325,6 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
T((T_CREATE("window %p"), win));
- return (win);
+ _nc_unlock_global(windowlist);
+ returnWin(win);
}
diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c
index 9ecc45821591..22bd2f80ba72 100644
--- a/contrib/ncurses/ncurses/base/lib_overlay.c
+++ b/contrib/ncurses/ncurses/base/lib_overlay.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_overlay.c,v 1.22 2006/10/14 20:43:31 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.23 2007/04/07 17:13:52 tom Exp $")
static int
overlap(const WINDOW *const s, WINDOW *const d, int const flag)
@@ -139,8 +139,8 @@ copywin(const WINDOW *src, WINDOW *dst,
{
int sx, sy, dx, dy;
bool touched;
- attr_t bk = AttrOf(dst->_nc_bkgd);
- attr_t mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);
+ attr_t bk;
+ attr_t mask;
T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
@@ -148,6 +148,9 @@ copywin(const WINDOW *src, WINDOW *dst,
if (!src || !dst)
returnCode(ERR);
+ bk = AttrOf(dst->_nc_bkgd);
+ mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);
+
/* make sure rectangle exists in source */
if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) ||
(smincol + dmaxcol - dmincol) > (src->_maxx + 1)) {
diff --git a/contrib/ncurses/ncurses/base/lib_redrawln.c b/contrib/ncurses/ncurses/base/lib_redrawln.c
index 548ca97e24c4..6b0905f07d67 100644
--- a/contrib/ncurses/ncurses/base/lib_redrawln.c
+++ b/contrib/ncurses/ncurses/base/lib_redrawln.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,17 +39,20 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_redrawln.c,v 1.11 2006/11/04 23:08:47 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.12 2007/10/13 20:08:56 tom Exp $")
NCURSES_EXPORT(int)
wredrawln(WINDOW *win, int beg, int num)
{
int i;
int end;
- size_t len = (win->_maxx + 1);
+ size_t len;
T((T_CALLED("wredrawln(%p,%d,%d)"), win, beg, num));
+ if (win == 0)
+ returnCode(ERR);
+
if (beg < 0)
beg = 0;
@@ -65,6 +68,7 @@ wredrawln(WINDOW *win, int beg, int num)
if (end > win->_maxy + 1)
end = win->_maxy + 1;
+ len = (win->_maxx + 1);
if (len > (size_t) (curscr->_maxx + 1))
len = (size_t) (curscr->_maxx + 1);
len *= sizeof(curscr->_line[0].text[0]);
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
index 27649df0669a..2a9cafb7b0ad 100644
--- a/contrib/ncurses/ncurses/base/lib_refresh.c
+++ b/contrib/ncurses/ncurses/base/lib_refresh.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_refresh.c,v 1.34 2006/05/27 19:21:19 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.41 2007/09/29 20:39:34 tom Exp $")
NCURSES_EXPORT(int)
wrefresh(WINDOW *win)
@@ -74,18 +74,20 @@ NCURSES_EXPORT(int)
wnoutrefresh(WINDOW *win)
{
NCURSES_SIZE_T limit_x;
- NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T src_row, src_col;
NCURSES_SIZE_T begx;
NCURSES_SIZE_T begy;
- NCURSES_SIZE_T m, n;
+ NCURSES_SIZE_T dst_row, dst_col;
#if USE_SCROLL_HINTS
bool wide;
#endif
T((T_CALLED("wnoutrefresh(%p)"), win));
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...win", win);
+ _nc_unlock_global(tracef);
+ }
#endif /* TRACE */
/*
@@ -132,28 +134,121 @@ wnoutrefresh(WINDOW *win)
* so we'll force the issue.
*/
- /* limit(n) */
+ /* limit(dst_col) */
limit_x = win->_maxx;
- /* limit(j) */
+ /* limit(src_col) */
if (limit_x > newscr->_maxx - begx)
limit_x = newscr->_maxx - begx;
- for (i = 0, m = begy + win->_yoffset;
- i <= win->_maxy && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
+ for (src_row = 0, dst_row = begy + win->_yoffset;
+ src_row <= win->_maxy && dst_row <= newscr->_maxy;
+ src_row++, dst_row++) {
+ register struct ldat *nline = &newscr->_line[dst_row];
+ register struct ldat *oline = &win->_line[src_row];
if (oline->firstchar != _NOCHANGE) {
- int last = oline->lastchar;
+ int last_src = oline->lastchar;
+
+ if (last_src > limit_x)
+ last_src = limit_x;
+
+ src_col = oline->firstchar;
+ dst_col = src_col + begx;
+
+ if_WIDEC({
+ register int j;
+
+ /*
+ * Ensure that we will copy complete multi-column characters
+ * on the left-boundary.
+ */
+ if (isWidecExt(oline->text[src_col])) {
+ j = 1 + dst_col - WidecExt(oline->text[src_col]);
+ if (j < 0)
+ j = 0;
+ if (dst_col > j) {
+ src_col -= (dst_col - j);
+ dst_col = j;
+ }
+ }
+
+ /*
+ * Ensure that we will copy complete multi-column characters
+ * on the right-boundary.
+ */
+ j = last_src;
+ if (WidecExt(oline->text[j])) {
+ ++j;
+ while (j <= limit_x) {
+ if (isWidecBase(oline->text[j])) {
+ break;
+ } else {
+ last_src = j;
+ }
+ ++j;
+ }
+ }
+ });
- if (last > limit_x)
- last = limit_x;
+ if_WIDEC({
+ static cchar_t blank = BLANK;
+ int last_dst = begx + ((last_src < win->_maxx)
+ ? last_src
+ : win->_maxx);
+ int fix_left = dst_col;
+ int fix_right = last_dst;
+ register int j;
- for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
- if (!CharEq(oline->text[j], nline->text[n])) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline, n);
+ /*
+ * Check for boundary cases where we may overwrite part of a
+ * multi-column character. For those, wipe the remainder of
+ * the character to blanks.
+ */
+ j = dst_col;
+ if (isWidecExt(nline->text[j])) {
+ /*
+ * On the left, we only care about multi-column characters
+ * that extend into the changed region.
+ */
+ fix_left = 1 + j - WidecExt(nline->text[j]);
+ if (fix_left < 0)
+ fix_left = 0; /* only if cell is corrupt */
+ }
+
+ j = last_dst;
+ if (WidecExt(nline->text[j]) != 0) {
+ /*
+ * On the right, any multi-column character is a problem,
+ * unless it happens to be contained in the change, and
+ * ending at the right boundary of the change. The
+ * computation for 'fix_left' accounts for the left-side of
+ * this character. Find the end of the character.
+ */
+ ++j;
+ while (j <= newscr->_maxx && isWidecExt(nline->text[j])) {
+ fix_right = j++;
+ }
+ }
+
+ /*
+ * The analysis is simpler if we do the clearing afterwards.
+ * Do that now.
+ */
+ if (fix_left < dst_col || fix_right > last_dst) {
+ for (j = fix_left; j <= fix_right; ++j) {
+ nline->text[j] = blank;
+ CHANGED_CELL(nline, j);
+ }
+ }
+ });
+
+ /*
+ * Copy the changed text.
+ */
+ for (; src_col <= last_src; src_col++, dst_col++) {
+ if (!CharEq(oline->text[src_col], nline->text[dst_col])) {
+ nline->text[dst_col] = oline->text[src_col];
+ CHANGED_CELL(nline, dst_col);
}
}
@@ -162,13 +257,14 @@ wnoutrefresh(WINDOW *win)
if (wide) {
int oind = oline->oldindex;
- nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind
- + win->_yoffset;
+ nline->oldindex = ((oind == _NEWINDEX)
+ ? _NEWINDEX
+ : (begy + oind + win->_yoffset));
}
#endif /* USE_SCROLL_HINTS */
oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
+ if_USE_SCROLL_HINTS(oline->oldindex = src_row);
}
if (win->_clear) {
@@ -183,8 +279,10 @@ wnoutrefresh(WINDOW *win)
newscr->_leaveok = win->_leaveok;
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("newscr", newscr);
+ _nc_unlock_global(tracef);
+ }
#endif /* TRACE */
returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c
index ca27a0fc4c60..858ef65a645d 100644
--- a/contrib/ncurses/ncurses/base/lib_restart.c
+++ b/contrib/ncurses/ncurses/base/lib_restart.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -48,23 +48,22 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_restart.c,v 1.6 2006/01/14 15:58:23 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.8 2007/10/13 19:59:47 tom Exp $")
NCURSES_EXPORT(int)
restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
- int saveecho = SP->_echo;
- int savecbreak = SP->_cbreak;
- int saveraw = SP->_raw;
- int savenl = SP->_nl;
int result;
T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- _nc_handle_sigwinch(0);
if (setupterm(termp, filenum, errret) != OK) {
result = ERR;
- } else {
+ } else if (SP != 0) {
+ int saveecho = SP->_echo;
+ int savecbreak = SP->_cbreak;
+ int saveraw = SP->_raw;
+ int savenl = SP->_nl;
if (saveecho)
echo();
@@ -93,7 +92,8 @@ restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
#endif
result = OK;
+ } else {
+ result = ERR;
}
- _nc_handle_sigwinch(1);
returnCode(result);
}
diff --git a/contrib/ncurses/ncurses/base/lib_screen.c b/contrib/ncurses/ncurses/base/lib_screen.c
index 5d67e1993cd9..e6aecbdaab47 100644
--- a/contrib/ncurses/ncurses/base/lib_screen.c
+++ b/contrib/ncurses/ncurses/base/lib_screen.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_screen.c,v 1.29 2006/05/27 19:21:38 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.30 2007/03/10 23:20:41 tom Exp $")
NCURSES_EXPORT(WINDOW *)
getwin(FILE *filep)
@@ -146,7 +146,10 @@ scr_restore(const char *file)
returnCode(ERR);
} else {
delwin(newscr);
- SP->_newscr = newscr = getwin(fp);
+ SP->_newscr = getwin(fp);
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+#endif
(void) fclose(fp);
returnCode(OK);
}
@@ -184,7 +187,10 @@ scr_init(const char *file)
returnCode(ERR);
} else {
delwin(curscr);
- SP->_curscr = curscr = getwin(fp);
+ SP->_curscr = getwin(fp);
+#if !USE_REENTRANT
+ curscr = SP->_curscr;
+#endif
(void) fclose(fp);
returnCode(OK);
}
@@ -199,7 +205,10 @@ scr_set(const char *file)
returnCode(ERR);
} else {
delwin(newscr);
- SP->_newscr = newscr = dupwin(curscr);
+ SP->_newscr = dupwin(curscr);
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+#endif
returnCode(OK);
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
index bcc42d12298c..2b1387ad7a02 100644
--- a/contrib/ncurses/ncurses/base/lib_set_term.c
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -44,7 +44,7 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.91 2006/05/20 14:58:02 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.100 2007/09/08 21:23:43 tom Exp $")
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
@@ -53,22 +53,28 @@ set_term(SCREEN *screenp)
T((T_CALLED("set_term(%p)"), screenp));
+ _nc_lock_global(set_SP);
+
oldSP = SP;
_nc_set_screen(screenp);
set_curterm(SP->_term);
+#if !USE_REENTRANT
curscr = SP->_curscr;
newscr = SP->_newscr;
stdscr = SP->_stdscr;
COLORS = SP->_color_count;
COLOR_PAIRS = SP->_pair_count;
+#endif
+
+ _nc_unlock_global(set_SP);
T((T_RETURN("%p"), oldSP));
return (oldSP);
}
static void
-_nc_free_keytry(struct tries *kt)
+_nc_free_keytry(TRIES * kt)
{
if (kt != 0) {
_nc_free_keytry(kt->child);
@@ -88,6 +94,7 @@ delscreen(SCREEN *sp)
T((T_CALLED("delscreen(%p)"), sp));
+ _nc_lock_global(set_SP);
while (*scan) {
if (*scan == sp) {
*scan = sp->_next_screen;
@@ -152,20 +159,20 @@ delscreen(SCREEN *sp)
* multiple references in different screens).
*/
if (sp == SP) {
+#if !USE_REENTRANT
curscr = 0;
newscr = 0;
stdscr = 0;
COLORS = 0;
COLOR_PAIRS = 0;
+#endif
_nc_set_screen(0);
}
+ _nc_unlock_global(set_SP);
+
returnVoid;
}
-static ripoff_t rippedoff[5];
-static ripoff_t *rsp = rippedoff;
-#define N_RIPS SIZEOF(SP->_rippedoff)
-
static bool
no_mouse_event(SCREEN *sp GCC_UNUSED)
{
@@ -214,17 +221,20 @@ extract_fgbg(char *src, int *result)
}
#endif
+#define ripoff_sp _nc_prescreen.rsp
+#define ripoff_stack _nc_prescreen.rippedoff
+
/* OS-independent screen initializations */
NCURSES_EXPORT(int)
-_nc_setupscreen(int slines,
- int scolumns,
+_nc_setupscreen(int slines GCC_UNUSED,
+ int scolumns GCC_UNUSED,
FILE *output,
bool filtered,
int slk_format)
{
int bottom_stolen = 0;
- int i;
bool support_cookies = USE_XMC_SUPPORT;
+ ripoff_t *rop;
T((T_CALLED("_nc_setupscreen(%d, %d, %p, %d, %d)"),
slines, scolumns, output, filtered, slk_format));
@@ -243,12 +253,20 @@ _nc_setupscreen(int slines,
if ((SP->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
returnCode(ERR);
+ /*
+ * We should always check the screensize, just in case.
+ */
+ _nc_get_screensize(&slines, &scolumns);
+ SET_LINES(slines);
+ SET_COLS(scolumns);
+ T((T_CREATE("screen %s %dx%d"), termname(), LINES, COLS));
+
SP->_filtered = filtered;
/* implement filter mode */
if (filtered) {
- slines = LINES = 1;
-
+ slines = 1;
+ SET_LINES(slines);
clear_screen = 0;
cursor_down = parm_down_cursor = 0;
cursor_address = 0;
@@ -258,18 +276,6 @@ _nc_setupscreen(int slines,
cursor_home = carriage_return;
T(("filter screensize %dx%d", LINES, COLS));
}
-
- /* If we must simulate soft labels, grab off the line to be used.
- We assume that we must simulate, if it is none of the standard
- formats (4-4 or 3-2-3) for which there may be some hardware
- support. */
- if (num_labels <= 0 || !SLK_STDFMT(slk_format)) {
- if (slk_format) {
- if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
- _nc_slk_initialize))
- returnCode(ERR);
- }
- }
#ifdef __DJGPP__
T(("setting output mode to binary"));
fflush(output);
@@ -484,6 +490,15 @@ _nc_setupscreen(int slines,
}
/* initialize normal acs before wide, since we use mapping in the latter */
+#if !USE_WIDEC_SUPPORT
+ if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
+ acs_chars = NULL;
+ ena_acs = NULL;
+ enter_alt_charset_mode = NULL;
+ exit_alt_charset_mode = NULL;
+ set_attributes = NULL;
+ }
+#endif
_nc_init_acs();
#if USE_WIDEC_SUPPORT
_nc_init_wacs();
@@ -506,15 +521,17 @@ _nc_setupscreen(int slines,
SP->newhash = 0;
T(("creating newscr"));
- if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
+ if ((SP->_newscr = newwin(slines, scolumns, 0, 0)) == 0)
returnCode(ERR);
T(("creating curscr"));
- if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
+ if ((SP->_curscr = newwin(slines, scolumns, 0, 0)) == 0)
returnCode(ERR);
- SP->_newscr = newscr;
- SP->_curscr = curscr;
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+ curscr = SP->_curscr;
+#endif
#if USE_SIZECHANGE
SP->_resize = resizeterm;
#endif
@@ -525,46 +542,63 @@ _nc_setupscreen(int slines,
def_shell_mode();
def_prog_mode();
- for (i = 0, rsp = rippedoff; rsp->line && (i < (int) N_RIPS); rsp++, i++) {
- T(("ripping off line %d at %s", i, rsp->line < 0 ? "bottom" : "top"));
- SP->_rippedoff[i] = rippedoff[i];
- if (rsp->hook) {
- int count = (rsp->line < 0) ? -rsp->line : rsp->line;
-
- SP->_rippedoff[i].w = newwin(count,
- scolumns,
- ((rsp->line < 0)
- ? SP->_lines_avail - count
- : 0),
- 0);
- if (SP->_rippedoff[i].w != 0)
- SP->_rippedoff[i].hook(SP->_rippedoff[i].w, scolumns);
+ for (rop = ripoff_stack;
+ rop != ripoff_sp && (rop - ripoff_stack) < N_RIPS;
+ rop++) {
+
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (rop->hook == _nc_slk_initialize)
+ if (!(num_labels <= 0 || !SLK_STDFMT(slk_format)))
+ continue;
+ if (rop->hook) {
+ int count;
+ WINDOW *w;
+
+ count = (rop->line < 0) ? -rop->line : rop->line;
+ T(("ripping off %i lines at %s", count,
+ ((rop->line < 0)
+ ? "bottom"
+ : "top")));
+
+ w = newwin(count, scolumns,
+ ((rop->line < 0)
+ ? SP->_lines_avail - count
+ : 0),
+ 0);
+ if (w)
+ rop->hook(w, scolumns);
else
returnCode(ERR);
- if (rsp->line < 0)
+ if (rop->line < 0)
bottom_stolen += count;
else
SP->_topstolen += count;
SP->_lines_avail -= count;
}
- rsp->line = 0;
}
- SP->_rip_count = i;
/* reset the stack */
- rsp = rippedoff;
+ ripoff_sp = ripoff_stack;
T(("creating stdscr"));
assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
- if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
+ if ((SP->_stdscr = newwin(SP->_lines_avail, scolumns, 0, 0)) == 0)
returnCode(ERR);
- SP->_stdscr = stdscr;
+
+ SET_LINES(SP->_lines_avail);
+#if !USE_REENTRANT
+ stdscr = SP->_stdscr;
+#endif
returnCode(OK);
}
-/* The internal implementation interprets line as the number of
- lines to rip off from the top or bottom.
- */
+/*
+ * The internal implementation interprets line as the number of lines to rip
+ * off from the top or bottom.
+ */
NCURSES_EXPORT(int)
_nc_ripoffline(int line, int (*init) (WINDOW *, int))
{
@@ -572,13 +606,14 @@ _nc_ripoffline(int line, int (*init) (WINDOW *, int))
if (line != 0) {
- if (rsp >= rippedoff + N_RIPS)
+ if (ripoff_sp == 0)
+ ripoff_sp = ripoff_stack;
+ if (ripoff_sp >= ripoff_stack + N_RIPS)
returnCode(ERR);
- rsp->line = line;
- rsp->hook = init;
- rsp->w = 0;
- rsp++;
+ ripoff_sp->line = line;
+ ripoff_sp->hook = init;
+ ripoff_sp++;
}
returnCode(OK);
diff --git a/contrib/ncurses/ncurses/base/lib_slkinit.c b/contrib/ncurses/ncurses/base/lib_slkinit.c
index f003b5f033f0..20c0baa59646 100644
--- a/contrib/ncurses/ncurses/base/lib_slkinit.c
+++ b/contrib/ncurses/ncurses/base/lib_slkinit.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,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,14 +38,17 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkinit.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkinit.c,v 1.6 2007/05/12 18:14:21 tom Exp $")
NCURSES_EXPORT(int)
slk_init(int format)
{
+ int code = ERR;
+
T((T_CALLED("slk_init(%d)"), format));
- if (format < 0 || format > 3)
- returnCode(ERR);
- _nc_slk_format = 1 + format;
- returnCode(OK);
+ if (format >= 0 && format <= 3 && !_nc_slk_format) {
+ _nc_slk_format = 1 + format;
+ code = _nc_ripoffline(-SLK_LINES(_nc_slk_format), _nc_slk_initialize);
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_slkset.c b/contrib/ncurses/ncurses/base/lib_slkset.c
index 9379b36322e2..e19f88e60ac4 100644
--- a/contrib/ncurses/ncurses/base/lib_slkset.c
+++ b/contrib/ncurses/ncurses/base/lib_slkset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -44,12 +44,12 @@
#endif
#endif
-MODULE_ID("$Id: lib_slkset.c,v 1.16 2006/12/17 19:47:09 tom Exp $")
+MODULE_ID("$Id: lib_slkset.c,v 1.17 2007/10/13 20:08:46 tom Exp $")
NCURSES_EXPORT(int)
slk_set(int i, const char *astr, int format)
{
- SLK *slk = SP->_slk;
+ SLK *slk;
int offset;
int numchrs;
int numcols;
@@ -59,7 +59,12 @@ slk_set(int i, const char *astr, int format)
T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format));
- if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2)
+ if (SP == 0
+ || (slk = SP->_slk) == 0
+ || i < 1
+ || i > slk->labcnt
+ || format < 0
+ || format > 2)
returnCode(ERR);
if (str == NULL)
str = "";
diff --git a/contrib/ncurses/ncurses/base/lib_ungetch.c b/contrib/ncurses/ncurses/base/lib_ungetch.c
index a6164df5edc1..9570a33edc5e 100644
--- a/contrib/ncurses/ncurses/base/lib_ungetch.c
+++ b/contrib/ncurses/ncurses/base/lib_ungetch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ungetch.c,v 1.8 2002/08/24 22:08:48 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.9 2007/09/29 21:49:56 tom Exp $")
#include <fifo_defs.h>
@@ -72,8 +72,10 @@ ungetch(int ch)
SP->_fifo[head] = ch;
T(("ungetch %s ok", _tracechar(ch)));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
+ if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump();
+ _nc_unlock_global(tracef);
+ }
#endif
returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c
index bb20f4faf2a2..530b08e5ed1f 100644
--- a/contrib/ncurses/ncurses/base/lib_window.c
+++ b/contrib/ncurses/ncurses/base/lib_window.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_window.c,v 1.22 2006/05/27 19:21:19 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.23 2007/06/30 23:36:11 tom Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -149,7 +149,7 @@ wsyncdown(WINDOW *win)
/* left and right character in child coordinates */
int left = pp->_line[win->_pary + y].firstchar - win->_parx;
int right = pp->_line[win->_pary + y].lastchar - win->_parx;
- /* The change maybe outside the childs range */
+ /* The change may be outside the child's range */
if (left < 0)
left = 0;
if (right > win->_maxx)
diff --git a/contrib/ncurses/ncurses/base/memmove.c b/contrib/ncurses/ncurses/base/memmove.c
index 4fafc4cda9d8..093ad72954ff 100644
--- a/contrib/ncurses/ncurses/base/memmove.c
+++ b/contrib/ncurses/ncurses/base/memmove.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,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 *
@@ -28,7 +28,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: memmove.c,v 1.4 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: memmove.c,v 1.5 2007/08/11 17:12:43 tom Exp $")
/****************************************************************************
* Author: Thomas E. Dickey <dickey@clark.net> 1998 *
@@ -51,7 +51,7 @@ _nc_memmove(void *s1, const void *s2, size_t n)
}
for (j = 0; j < n; j++)
bfr[j] = SRC[j];
- SRC = bfr;
+ s2 = bfr;
}
while (n-- != 0)
DST[n] = SRC[n];
diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c
index 46faccb74380..8bea743a3d22 100644
--- a/contrib/ncurses/ncurses/base/resizeterm.c
+++ b/contrib/ncurses/ncurses/base/resizeterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,12 +41,24 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.18 2006/10/14 20:43:31 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.24 2007/12/22 23:20:31 tom Exp $")
#define stolen_lines (screen_lines - SP->_lines_avail)
+/*
+ * If we're trying to be reentrant, do not want any local statics.
+ */
+#if USE_REENTRANT
+#define EXTRA_ARGS , CurLines, CurCols
+#define EXTRA_DCLS , int CurLines, int CurCols
+#else
static int current_lines;
static int current_cols;
+#define CurLines current_lines
+#define CurCols current_cols
+#define EXTRA_ARGS /* nothing */
+#define EXTRA_DCLS /* nothing */
+#endif
#ifdef TRACE
static void
@@ -54,6 +66,7 @@ show_window_sizes(const char *name)
{
WINDOWLIST *wp;
+ _nc_lock_global(windowlist);
_tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
screen_lines, screen_columns);
for (wp = _nc_windows; wp != 0; wp = wp->next) {
@@ -64,6 +77,7 @@ show_window_sizes(const char *name)
(long) wp->win._begy,
(long) wp->win._begx);
}
+ _nc_unlock_global(windowlist);
}
#endif
@@ -121,10 +135,10 @@ parent_depth(WINDOW *cmp)
* FIXME: must adjust position so it's within the parent!
*/
static int
-adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
+adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
{
int result;
- int bottom = current_lines + SP->_topstolen - stolen;
+ int bottom = CurLines + SP->_topstolen - stolen;
int myLines = win->_maxy + 1;
int myCols = win->_maxx + 1;
@@ -134,13 +148,13 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
(long) getbegy(win), (long) getbegx(win)));
if (win->_begy >= bottom) {
- win->_begy += (ToLines - current_lines);
+ win->_begy += (ToLines - CurLines);
} else {
- if (myLines == current_lines - stolen
- && ToLines != current_lines)
+ if (myLines == CurLines - stolen
+ && ToLines != CurLines)
myLines = ToLines - stolen;
- else if (myLines == current_lines
- && ToLines != current_lines)
+ else if (myLines == CurLines
+ && ToLines != CurLines)
myLines = ToLines;
}
@@ -150,12 +164,12 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
if (myCols > ToCols)
myCols = ToCols;
- if (myLines == current_lines
- && ToLines != current_lines)
+ if (myLines == CurLines
+ && ToLines != CurLines)
myLines = ToLines;
- if (myCols == current_cols
- && ToCols != current_cols)
+ if (myCols == CurCols
+ && ToCols != CurCols)
myCols = ToCols;
result = wresize(win, myLines, myCols);
@@ -167,7 +181,7 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
* children, decrease those to fit, then decrease the containing window, etc.
*/
static int
-decrease_size(int ToLines, int ToCols, int stolen)
+decrease_size(int ToLines, int ToCols, int stolen EXTRA_DCLS)
{
bool found;
int depth = 0;
@@ -185,7 +199,8 @@ decrease_size(int ToLines, int ToCols, int stolen)
if (!(win->_flags & _ISPAD)) {
if (child_depth(win) == depth) {
found = TRUE;
- if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ if (adjust_window(win, ToLines, ToCols,
+ stolen EXTRA_ARGS) != OK)
returnCode(ERR);
}
}
@@ -200,7 +215,7 @@ decrease_size(int ToLines, int ToCols, int stolen)
* parent, increase those to fit, then increase the contained window, etc.
*/
static int
-increase_size(int ToLines, int ToCols, int stolen)
+increase_size(int ToLines, int ToCols, int stolen EXTRA_DCLS)
{
bool found;
int depth = 0;
@@ -218,7 +233,8 @@ increase_size(int ToLines, int ToCols, int stolen)
if (!(win->_flags & _ISPAD)) {
if (parent_depth(win) == depth) {
found = TRUE;
- if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ if (adjust_window(win, ToLines, ToCols,
+ stolen EXTRA_ARGS) != OK)
returnCode(ERR);
}
}
@@ -235,36 +251,45 @@ increase_size(int ToLines, int ToCols, int stolen)
NCURSES_EXPORT(int)
resize_term(int ToLines, int ToCols)
{
- int result = OK;
- int was_stolen = (screen_lines - SP->_lines_avail);
+ int result = OK EXTRA_ARGS;
+ int was_stolen;
T((T_CALLED("resize_term(%d,%d) old(%d,%d)"),
ToLines, ToCols,
screen_lines, screen_columns));
+ if (SP == 0) {
+ returnCode(ERR);
+ }
+
+ _nc_lock_global(windowlist);
+
+ was_stolen = (screen_lines - SP->_lines_avail);
if (is_term_resized(ToLines, ToCols)) {
- int myLines = current_lines = screen_lines;
- int myCols = current_cols = screen_columns;
+ int myLines = CurLines = screen_lines;
+ int myCols = CurCols = screen_columns;
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
show_window_sizes("before");
+ _nc_unlock_global(tracef);
+ }
#endif
if (ToLines > screen_lines) {
- increase_size(myLines = ToLines, myCols, was_stolen);
- current_lines = myLines;
- current_cols = myCols;
+ increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS);
+ CurLines = myLines;
+ CurCols = myCols;
}
if (ToCols > screen_columns) {
- increase_size(myLines, myCols = ToCols, was_stolen);
- current_lines = myLines;
- current_cols = myCols;
+ increase_size(myLines, myCols = ToCols, was_stolen EXTRA_ARGS);
+ CurLines = myLines;
+ CurCols = myCols;
}
if (ToLines < myLines ||
ToCols < myCols) {
- decrease_size(ToLines, ToCols, was_stolen);
+ decrease_size(ToLines, ToCols, was_stolen EXTRA_ARGS);
}
screen_lines = lines = ToLines;
@@ -279,10 +304,11 @@ resize_term(int ToLines, int ToCols)
FreeAndNull(SP->newhash);
}
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE) {
- LINES = ToLines - was_stolen;
- COLS = ToCols;
+ if (USE_TRACEF(TRACE_UPDATE)) {
+ SET_LINES(ToLines - was_stolen);
+ SET_COLS(ToCols);
show_window_sizes("after");
+ _nc_unlock_global(tracef);
}
#endif
}
@@ -291,8 +317,10 @@ resize_term(int ToLines, int ToCols)
* Always update LINES, to allow for call from lib_doupdate.c which
* needs to have the count adjusted by the stolen (ripped off) lines.
*/
- LINES = ToLines - was_stolen;
- COLS = ToCols;
+ SET_LINES(ToLines - was_stolen);
+ SET_COLS(ToCols);
+
+ _nc_unlock_global(windowlist);
returnCode(result);
}
@@ -308,22 +336,25 @@ resize_term(int ToLines, int ToCols)
NCURSES_EXPORT(int)
resizeterm(int ToLines, int ToCols)
{
- int result = OK;
-
- SP->_sig_winch = FALSE;
+ int result = ERR;
T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
ToLines, ToCols,
screen_lines, screen_columns));
- if (is_term_resized(ToLines, ToCols)) {
+ if (SP != 0) {
+ result = OK;
+ SP->_sig_winch = FALSE;
+
+ if (is_term_resized(ToLines, ToCols)) {
#if USE_SIGWINCH
- ungetch(KEY_RESIZE); /* so application can know this */
- clearok(curscr, TRUE); /* screen contents are unknown */
+ ungetch(KEY_RESIZE); /* so application can know this */
+ clearok(curscr, TRUE); /* screen contents are unknown */
#endif
- result = resize_term(ToLines, ToCols);
+ result = resize_term(ToLines, ToCols);
+ }
}
returnCode(result);
diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c
index 81fe44f0c783..8fc5d89dd210 100644
--- a/contrib/ncurses/ncurses/base/safe_sprintf.c
+++ b/contrib/ncurses/ncurses/base/safe_sprintf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,7 +33,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: safe_sprintf.c,v 1.18 2003/08/09 21:52:04 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.20 2007/04/21 22:28:06 tom Exp $")
#if USE_SAFE_SPRINTF
@@ -207,56 +207,58 @@ _nc_printf_length(const char *fmt, va_list ap)
}
#endif
+#define my_buffer _nc_globals.safeprint_buf
+#define my_length _nc_globals.safeprint_used
+
/*
* Wrapper for vsprintf that allocates a buffer big enough to hold the result.
*/
NCURSES_EXPORT(char *)
_nc_printf_string(const char *fmt, va_list ap)
{
- static char *buf;
- static size_t used;
char *result = 0;
if (fmt != 0) {
#if USE_SAFE_SPRINTF
int len = _nc_printf_length(fmt, ap);
- if ((int) used < len + 1) {
- used = 2 * (len + 1);
- buf = typeRealloc(char, used, buf);
+ if ((int) my_length < len + 1) {
+ my_length = 2 * (len + 1);
+ my_buffer = typeRealloc(char, my_length, my_buffer);
}
- if (buf != 0) {
- *buf = '\0';
+ if (my_buffer != 0) {
+ *my_buffer = '\0';
if (len >= 0) {
- vsprintf(buf, fmt, ap);
+ vsprintf(my_buffer, fmt, ap);
}
- result = buf;
+ result = my_buffer;
}
#else
- static int rows, cols;
+#define MyCols _nc_globals.safeprint_cols
+#define MyRows _nc_globals.safeprint_rows
- if (screen_lines > rows || screen_columns > cols) {
- if (screen_lines > rows)
- rows = screen_lines;
- if (screen_columns > cols)
- cols = screen_columns;
- used = (rows * (cols + 1)) + 1;
- buf = typeRealloc(char, used, buf);
+ if (screen_lines > MyRows || screen_columns > MyCols) {
+ if (screen_lines > MyRows)
+ MyRows = screen_lines;
+ if (screen_columns > MyCols)
+ MyCols = screen_columns;
+ my_length = (MyRows * (MyCols + 1)) + 1;
+ my_buffer = typeRealloc(char, my_length, my_buffer);
}
- if (buf != 0) {
+ if (my_buffer != 0) {
# if HAVE_VSNPRINTF
- vsnprintf(buf, used, fmt, ap); /* GNU extension */
+ vsnprintf(my_buffer, my_length, fmt, ap); /* GNU extension */
# else
- vsprintf(buf, fmt, ap); /* ANSI */
+ vsprintf(my_buffer, fmt, ap); /* ANSI */
# endif
- result = buf;
+ result = my_buffer;
}
#endif
- } else if (buf != 0) { /* see _nc_freeall() */
- free(buf);
- buf = 0;
- used = 0;
+ } else if (my_buffer != 0) { /* see _nc_freeall() */
+ free(my_buffer);
+ my_buffer = 0;
+ my_length = 0;
}
return result;
}
diff --git a/contrib/ncurses/ncurses/base/tries.c b/contrib/ncurses/ncurses/base/tries.c
index 4edb7317483c..983a75ae7882 100644
--- a/contrib/ncurses/ncurses/base/tries.c
+++ b/contrib/ncurses/ncurses/base/tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2003,2005 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 *
@@ -39,16 +39,16 @@
#include <curses.priv.h>
-MODULE_ID("$Id: tries.c,v 1.22 2005/11/26 20:09:18 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.25 2007/09/29 20:37:13 tom Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
* no match was found, otherwise allocating a string of the result.
*/
NCURSES_EXPORT(char *)
-_nc_expand_try(struct tries *tree, unsigned code, int *count, size_t len)
+_nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
{
- struct tries *ptr = tree;
+ TRIES *ptr = tree;
char *result = 0;
if (code != 0) {
@@ -68,11 +68,13 @@ _nc_expand_try(struct tries *tree, unsigned code, int *count, size_t len)
}
}
if (result != 0) {
- if ((result[len] = ptr->ch) == 0)
+ if (ptr != 0 && (result[len] = ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
- if (len == 0 && _nc_tracing != 0)
+ if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
_tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
+ _nc_unlock_global(tracef);
+ }
#endif
}
return result;
@@ -83,7 +85,7 @@ _nc_expand_try(struct tries *tree, unsigned code, int *count, size_t len)
* true if the code was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_key(struct tries **tree, unsigned code)
+_nc_remove_key(TRIES ** tree, unsigned code)
{
T((T_CALLED("_nc_remove_key(%p,%d)"), tree, code));
@@ -99,7 +101,7 @@ _nc_remove_key(struct tries **tree, unsigned code)
/* don't cut the whole sub-tree */
(*tree)->value = 0;
} else {
- struct tries *to_free = *tree;
+ TRIES *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
}
@@ -115,7 +117,7 @@ _nc_remove_key(struct tries **tree, unsigned code)
* true if the string was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_string(struct tries **tree, const char *string)
+_nc_remove_string(TRIES ** tree, const char *string)
{
T((T_CALLED("_nc_remove_string(%p,%s)"), tree, _nc_visbuf(string)));
@@ -127,7 +129,7 @@ _nc_remove_string(struct tries **tree, const char *string)
if (string[1] != 0)
returnCode(_nc_remove_string(&(*tree)->child, string + 1));
if ((*tree)->child == 0) {
- struct tries *to_free = *tree;
+ TRIES *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
returnCode(TRUE);
diff --git a/contrib/ncurses/ncurses/base/use_window.c b/contrib/ncurses/ncurses/base/use_window.c
new file mode 100644
index 000000000000..8792cb47c37e
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/use_window.c
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * Copyright (c) 2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2007 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: use_window.c,v 1.2 2007/10/20 19:57:55 tom Exp $")
+
+#ifdef USE_PTHREADS
+NCURSES_EXPORT(void)
+_nc_lock_window(WINDOW *win)
+{
+ WINDOWLIST *p;
+
+ _nc_lock_global(windowlist);
+ for (p = _nc_windows; p != 0; p = p->next) {
+ if (&(p->win) == win) {
+ pthread_mutex_lock(&(p->mutex_use_window));
+ break;
+ }
+ }
+ _nc_unlock_global(windowlist);
+}
+
+NCURSES_EXPORT(void)
+_nc_unlock_window(WINDOW *win)
+{
+ WINDOWLIST *p;
+
+ _nc_lock_global(windowlist);
+ for (p = _nc_windows; p != 0; p = p->next) {
+ if (&(p->win) == win) {
+ pthread_mutex_unlock(&(p->mutex_use_window));
+ break;
+ }
+ }
+ _nc_unlock_global(windowlist);
+}
+#endif
+
+NCURSES_EXPORT(int)
+use_window(WINDOW *win, NCURSES_CALLBACK func, void *data)
+{
+ int code = OK;
+
+ T((T_CALLED("use_window(%p,%p,%p)"), win, func, data));
+ _nc_lock_window(win);
+ code = func(win, data);
+ _nc_unlock_window(win);
+
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
index ca6336dc94b5..f756f0f237f7 100644
--- a/contrib/ncurses/ncurses/base/wresize.c
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,13 +32,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.24 2006/10/14 20:43:31 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.27 2007/12/22 23:20:53 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
{
while (--length >= 0)
- free(data->text);
+ free(data[length].text);
free(data);
return ERR;
}
@@ -54,6 +54,8 @@ repair_subwindows(WINDOW *cmp)
struct ldat *pline = cmp->_line;
int row;
+ _nc_lock_global(windowlist);
+
for (wp = _nc_windows; wp != 0; wp = wp->next) {
WINDOW *tst = &(wp->win);
@@ -75,6 +77,7 @@ repair_subwindows(WINDOW *cmp)
repair_subwindows(tst);
}
}
+ _nc_unlock_global(windowlist);
}
/*
@@ -96,8 +99,10 @@ wresize(WINDOW *win, int ToLines, int ToCols)
(long) win->_begy, (long) win->_begx,
(long) win->_maxy, (long) win->_maxx,
(long) win->_regtop, (long) win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...before", win);
+ _nc_unlock_global(tracef);
+ }
}
#endif
@@ -232,8 +237,10 @@ wresize(WINDOW *win, int ToLines, int ToCols)
(long) win->_begy, (long) win->_begx,
(long) win->_maxy, (long) win->_maxx,
(long) win->_regtop, (long) win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...after:", win);
+ _nc_unlock_global(tracef);
+ }
#endif
returnCode(OK);
}