aboutsummaryrefslogtreecommitdiff
path: root/ncurses
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
committerRong-En Fan <rafan@FreeBSD.org>2008-11-09 14:08:54 +0000
commit6181f4622a00a9de81df01cecb5fa73ffdb697bc (patch)
treec963ba08ac935d7f048b78517309fe6fc2f496e6 /ncurses
parentc0e48ca1322e978a8f9795a5ddb251df2479f930 (diff)
downloadsrc-6181f4622a00a9de81df01cecb5fa73ffdb697bc.tar.gz
src-6181f4622a00a9de81df01cecb5fa73ffdb697bc.zip
- Import ncurses 5.7-20081102 (5.7 release) onto vendor branchvendor/ncurses/5.7-20081102
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=184798 svn path=/vendor/ncurses/5.7-20081102/; revision=184799; tag=vendor/ncurses/5.7-20081102
Diffstat (limited to 'ncurses')
-rw-r--r--ncurses/Makefile.in14
-rw-r--r--ncurses/base/MKkeyname.awk15
-rwxr-xr-xncurses/base/MKlib_gen.sh15
-rw-r--r--ncurses/base/MKunctrl.awk27
-rw-r--r--ncurses/base/lib_addch.c13
-rw-r--r--ncurses/base/lib_delwin.c9
-rw-r--r--ncurses/base/lib_freeall.c33
-rw-r--r--ncurses/base/lib_getch.c101
-rw-r--r--ncurses/base/lib_getstr.c23
-rw-r--r--ncurses/base/lib_initscr.c8
-rw-r--r--ncurses/base/lib_mouse.c548
-rw-r--r--ncurses/base/lib_newterm.c26
-rw-r--r--ncurses/base/lib_newwin.c30
-rw-r--r--ncurses/base/lib_overlay.c17
-rw-r--r--ncurses/base/lib_restart.c4
-rw-r--r--ncurses/base/lib_screen.c16
-rw-r--r--ncurses/base/lib_set_term.c52
-rw-r--r--ncurses/base/lib_slk.c32
-rw-r--r--ncurses/base/lib_slkrefr.c28
-rw-r--r--ncurses/base/lib_ungetch.c8
-rw-r--r--ncurses/base/lib_window.c6
-rw-r--r--ncurses/base/resizeterm.c12
-rw-r--r--ncurses/base/tries.c8
-rw-r--r--ncurses/base/use_window.c36
-rw-r--r--ncurses/base/wresize.c6
-rw-r--r--ncurses/curses.priv.h116
-rw-r--r--ncurses/fifo_defs.h4
-rw-r--r--ncurses/llib-lncurses101
-rw-r--r--ncurses/llib-lncursest280
-rw-r--r--ncurses/llib-lncursesw101
-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
-rw-r--r--ncurses/trace/lib_trace.c16
-rw-r--r--ncurses/trace/lib_traceatr.c270
-rw-r--r--ncurses/trace/lib_tracebits.c81
-rw-r--r--ncurses/trace/lib_tracechr.c22
-rw-r--r--ncurses/trace/lib_tracedmp.c28
-rw-r--r--ncurses/trace/lib_tracemse.c16
-rw-r--r--ncurses/trace/trace_buf.c51
-rw-r--r--ncurses/trace/trace_tries.c6
-rw-r--r--ncurses/trace/varargs.c6
-rw-r--r--ncurses/trace/visbuf.c182
-rw-r--r--ncurses/tty/hardscroll.c19
-rw-r--r--ncurses/tty/lib_mvcur.c14
-rw-r--r--ncurses/tty/lib_twait.c8
-rw-r--r--ncurses/tty/tty_update.c6
-rw-r--r--ncurses/widechar/charable.c6
-rw-r--r--ncurses/widechar/lib_get_wch.c75
-rw-r--r--ncurses/widechar/lib_get_wstr.c27
-rw-r--r--ncurses/widechar/lib_key_name.c4
-rw-r--r--ncurses/widechar/lib_unget_wch.c6
78 files changed, 2098 insertions, 1368 deletions
diff --git a/ncurses/Makefile.in b/ncurses/Makefile.in
index 39826e3a4782..558f79f0bbf3 100644
--- a/ncurses/Makefile.in
+++ b/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.112 2007/09/01 20:45:53 tom Exp $
+# $Id: Makefile.in,v 1.113 2008/10/18 14:11:54 tom Exp $
##############################################################################
-# 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"), #
@@ -183,10 +183,10 @@ $(DESTDIR)$(libdir) :
../lib : ; mkdir $@
./fallback.c : $(tinfo)/MKfallback.sh
- sh $(tinfo)/MKfallback.sh @TERMINFO@ @TERMINFO_SRC@ $(FALLBACK_LIST) >$@
+ sh -e $(tinfo)/MKfallback.sh @TERMINFO@ @TERMINFO_SRC@ $(FALLBACK_LIST) >$@
./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
- sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
+ sh -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
./make_keys$(BUILD_EXEEXT) keys.list > $@
@@ -205,14 +205,14 @@ make_hash$(BUILD_EXEEXT) : \
$(BUILD_CC) -o $@ $(BUILD_CCFLAGS) -DMAIN_PROGRAM $(tinfo)/comp_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
./expanded.c : $(serial)/MKexpanded.sh
- sh $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
+ sh -e $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
./comp_captab.c: \
make_hash$(BUILD_EXEEXT) \
../include/hashsize.h \
$(tinfo)/MKcaptab.sh \
$(tinfo)/MKcaptab.awk
- sh $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@
+ sh -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(srcdir)/../include/@TERMINFO_CAPS@ > $@
./lib_keyname.c: keys.list $(base)/MKkeyname.awk
$(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@
@@ -257,7 +257,7 @@ realclean :: distclean
test_progs : $(TEST_PROGS)
./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
- sh $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
+ sh -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
@ECHO_LINK@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS)
diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk
index c1d9475045d0..b35ba2a98027 100644
--- a/ncurses/base/MKkeyname.awk
+++ b/ncurses/base/MKkeyname.awk
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.38 2007/08/18 18:41:18 tom Exp $
+# $Id: MKkeyname.awk,v 1.40 2008/07/12 18:40:00 tom Exp $
##############################################################################
-# Copyright (c) 1999-2006,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 "Software"), #
@@ -67,7 +67,7 @@ END {
print "#define SIZEOF_TABLE 256"
print "#define MyTable _nc_globals.keyname_table"
print ""
- print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)"
print "{"
print " int i;"
print " char name[20];"
@@ -100,7 +100,7 @@ END {
print " if (MyTable[c] == 0) {"
print " int cc = c;"
print " p = name;"
- print " if (cc >= 128 && (SP == 0 || SP->_use_meta)) {"
+ print " if (cc >= 128 && (sp == 0 || sp->_use_meta)) {"
print " strcpy(p, \"M-\");"
print " p += 2;"
print " cc -= 128;"
@@ -124,7 +124,7 @@ END {
print ""
print " _nc_tracing = 0; /* prevent recursion via keybound() */"
print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {"
- print " for(k = STRCOUNT; k < NUM_STRINGS(tp); k++) {"
+ print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {"
print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
print " result = ExtStrname(tp, k, strnames);"
print " break;"
@@ -141,6 +141,11 @@ END {
print " return result;"
print "}"
print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
+ print "{"
+ print "\treturn _nc_keyname(SP, c);"
+ print "}"
+ print ""
print "#if NO_LEAKS"
print "void _nc_keyname_leaks(void)"
print "{"
diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
index 09857834e7e0..a984e8545eff 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -2,7 +2,7 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.30 2008/01/05 23:21:10 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.34 2008/08/30 19:20:50 tom Exp $)
#
##############################################################################
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
@@ -152,7 +152,7 @@ cat >$ED3 <<EOF3
s/ )/)/g
s/ gen_/ /
s/^M_/#undef /
- s/^[ ]*%[ ]*%[ ]*/ /
+ s/^[ ]*@[ ]*@[ ]*/ /
:done
EOF3
@@ -252,7 +252,7 @@ $0 !~ /^P_/ {
dotrace = 0;
}
- call = "%%T((T_CALLED(\""
+ call = "@@T((T_CALLED(\""
args = ""
comma = ""
num = 0;
@@ -338,7 +338,7 @@ $0 !~ /^P_/ {
else if (dotrace)
call = sprintf("return%s( ", returnType);
else
- call = "%%return ";
+ call = "@@return ";
call = call $myfunc "(";
for (i = 1; i < argcount; i++) {
@@ -358,7 +358,7 @@ $0 !~ /^P_/ {
print call ";"
if (match($0, "^void"))
- print "%%returnVoid;"
+ print "@@returnVoid;"
print "}";
}
EOF1
@@ -416,11 +416,14 @@ $preprocessor $TMP 2>/dev/null \
| sed \
-e 's/ / /g' \
-e 's/^ //' \
- -e 's/^_Bool/bool/' \
+ -e 's/_Bool/NCURSES_BOOL/g' \
| $AWK -f $AW2 \
| sed -f $ED3 \
| sed \
-e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \
-e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \
-e 's/gen_//' \
+ -e 's/^[ ]*#/#/' \
+ -e '/#ident/d' \
+ -e '/#line/d' \
| sed -f $ED4
diff --git a/ncurses/base/MKunctrl.awk b/ncurses/base/MKunctrl.awk
index 1ba511d72323..36fbeecb2e76 100644
--- a/ncurses/base/MKunctrl.awk
+++ b/ncurses/base/MKunctrl.awk
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.21 2008/02/03 20:24:30 tom Exp $
+# $Id: MKunctrl.awk,v 1.23 2008/10/04 21:40:24 tom Exp $
##############################################################################
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
@@ -46,7 +46,7 @@ BEGIN {
print ""
}
END {
- print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)"
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *sp, chtype ch)"
print "{"
blob=""
@@ -101,6 +101,7 @@ END {
blob = blob "\"";
print ""
+ printf "#if NCURSES_EXT_FUNCS\n";
if (bigstrings) {
blob = blob "\n/* printable values in 128-255 range */"
printf "static const short unctrl_c1[] = {"
@@ -135,6 +136,7 @@ END {
}
}
print "};"
+ print "#endif /* NCURSES_EXT_FUNCS */"
blob = blob "\"\n"
print ""
@@ -150,8 +152,8 @@ END {
print ""
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\tif ((sp != 0)"
+ print "\t\t && (sp->_legacy_coding > 1)"
print "\t\t && (check >= 128)"
print "\t\t && (check < 160))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
@@ -159,18 +161,18 @@ END {
print "#if USE_WIDEC_SUPPORT"
print "\t\tif ((check >= 160)"
print "\t\t && (check < 256)"
- print "\t\t && ((SP != 0)"
- print "\t\t && ((SP->_legacy_coding > 0)"
- print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
print "\t\t && (isprint(check) || iswprint(check))))))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
print "#else"
print "\t\tif ((check >= 160)"
print "\t\t && (check < 256)"
- print "\t\t && ((SP != 0)"
- print "\t\t && ((SP->_legacy_coding > 0)"
- print "\t\t || (SP->_legacy_coding == 0"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
print "\t\t && isprint(check)))))"
printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
print "\t\telse"
@@ -182,4 +184,9 @@ END {
print "\t}"
print "\treturn (NCURSES_CONST char *)result;"
print "}"
+ print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)"
+ print "{"
+ print "\treturn _nc_unctrl(SP, ch);"
+ print "}"
}
diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c
index 17ba6e2bcd6c..20a97a01a011 100644
--- a/ncurses/base/lib_addch.c
+++ b/ncurses/base/lib_addch.c
@@ -36,7 +36,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.111 2008/03/29 18:48:02 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.113 2008/08/16 19:20:04 tom Exp $")
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
@@ -210,7 +210,7 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch)
WINDOW_EXT(win, addch_y) = y;
init_mb(state);
- buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch));
+ buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch));
WINDOW_EXT(win, addch_used) += 1;
buffer[WINDOW_EXT(win, addch_used)] = '\0';
if ((len = mbrtowc(&result,
@@ -290,12 +290,15 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
int len = wcwidth(CharOf(ch));
int i;
int j;
+ wchar_t *chars;
if (len == 0) { /* non-spacing */
if ((x > 0 && y >= 0)
- || ((y = win->_cury - 1) >= 0 &&
- (x = win->_maxx) > 0)) {
- wchar_t *chars = (win->_line[y].text[x - 1].chars);
+ || (win->_maxx >= 0 && win->_cury >= 1)) {
+ if (x > 0 && y >= 0)
+ chars = (win->_line[y].text[x - 1].chars);
+ else
+ chars = (win->_line[y - 1].text[win->_maxx].chars);
for (i = 0; i < CCHARW_MAX; ++i) {
if (chars[i] == 0) {
TR(TRACE_VIRTPUT,
diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c
index ba5f180d5f3c..b92c40335958 100644
--- a/ncurses/base/lib_delwin.c
+++ b/ncurses/base/lib_delwin.c
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_delwin.c,v 1.16 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.17 2008/06/07 14:10:56 tom Exp $")
static bool
cannot_delete(WINDOW *win)
@@ -67,12 +67,10 @@ delwin(WINDOW *win)
T((T_CALLED("delwin(%p)"), win));
- if (_nc_try_global(windowlist) == 0) {
- _nc_lock_window(win);
+ if (_nc_try_global(curses) == 0) {
if (win == 0
|| cannot_delete(win)) {
result = ERR;
- _nc_unlock_window(win);
} else {
if (win->_flags & _SUBWIN)
@@ -80,10 +78,9 @@ delwin(WINDOW *win)
else if (curscr != 0)
touchwin(curscr);
- _nc_unlock_window(win);
result = _nc_freewin(win);
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
returnCode(result);
}
diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c
index 4bb7ccc79995..564026582911 100644
--- a/ncurses/base/lib_freeall.c
+++ b/ncurses/base/lib_freeall.c
@@ -40,7 +40,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.46 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.54 2008/09/27 13:09:57 tom Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -58,10 +58,13 @@ _nc_freeall(void)
if (SP->_oldnum_list != 0) {
FreeAndNull(SP->_oldnum_list);
}
+ if (SP->_panelHook.destroy != 0) {
+ SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+ }
}
#endif
if (SP != 0) {
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
while (_nc_windows != 0) {
bool deleted = FALSE;
@@ -93,23 +96,18 @@ _nc_freeall(void)
break;
}
delscreen(SP);
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
if (cur_term != 0)
del_curterm(cur_term);
-#if USE_WIDEC_SUPPORT
- FreeIfNeeded(_nc_wacs);
-#endif
(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);
+#if USE_WIDEC_SUPPORT
+ FreeIfNeeded(_nc_wacs);
#endif
-
_nc_leaks_tinfo();
#if HAVE_LIBDBMALLOC
@@ -131,7 +129,10 @@ _nc_free_and_exit(int code)
_nc_freeall();
#ifdef TRACE
trace(0); /* close trace file, freeing its setbuf */
- free(_nc_varargs("?", 0));
+ {
+ static va_list fake;
+ free(_nc_varargs("?", fake));
+ }
#endif
fclose(stdout);
FreeIfNeeded(last_setbuf);
@@ -143,4 +144,14 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
}
+
+NCURSES_EXPORT(void)
+_nc_free_and_exit(int code)
+{
+ if (SP)
+ delscreen(SP);
+ if (cur_term != 0)
+ del_curterm(cur_term);
+ exit(code);
+}
#endif
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index d9f6b1795c77..a3812bee76e8 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.87 2008/05/03 22:42:10 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.99 2008/09/20 19:46:13 tom Exp $")
#include <fifo_defs.h>
@@ -76,6 +76,13 @@ set_escdelay(int value)
}
#endif
+static int
+_nc_use_meta(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ return (sp ? sp->_use_meta : 0);
+}
+
#ifdef NCURSES_WGETCH_EVENTS
#define TWAIT_MASK 7
#else
@@ -123,7 +130,7 @@ fifo_pull(SCREEN *sp)
{
int ch;
ch = sp->_fifo[head];
- TR(TRACE_IEVENT, ("pulling %s from %d", _tracechar(ch), head));
+ TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head));
if (peek == head) {
h_inc();
@@ -228,7 +235,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
if (head == -1)
head = peek = tail;
t_inc();
- TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail));
+ TR(TRACE_IEVENT, ("pushed %s at %d", _nc_tracechar(sp, ch), tail));
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump(sp);
@@ -248,9 +255,59 @@ fifo_clear(SCREEN *sp)
static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl));
-#define wgetch_should_refresh(win) (\
- (is_wintouched(win) || (win->_flags & _HASMOVED)) \
- && !(win->_flags & _ISPAD))
+static void
+recur_wrefresh(WINDOW *win)
+{
+#ifdef USE_PTHREADS
+ SCREEN *sp = _nc_screen_of(win);
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to check/refresh */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ recur_wrefresh(win);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ if ((is_wintouched(win) || (win->_flags & _HASMOVED))
+ && !(win->_flags & _ISPAD)) {
+ wrefresh(win);
+ }
+}
+
+static int
+recur_wgetnstr(WINDOW *win, char *buf)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ int rc;
+
+ if (sp != 0) {
+#ifdef USE_PTHREADS
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to get cooked input */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ rc = recur_wgetnstr(win, buf);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ sp->_called_wgetch = TRUE;
+ rc = wgetnstr(win, buf, MAXCOLUMNS);
+ sp->_called_wgetch = FALSE;
+ }
+ } else {
+ rc = ERR;
+ }
+ return rc;
+}
NCURSES_EXPORT(int)
_nc_wgetch(WINDOW *win,
@@ -258,7 +315,7 @@ _nc_wgetch(WINDOW *win,
int use_meta
EVENTLIST_2nd(_nc_eventlist * evl))
{
- SCREEN *sp = SP;
+ SCREEN *sp;
int ch;
#ifdef NCURSES_WGETCH_EVENTS
long event_delay = -1;
@@ -267,14 +324,14 @@ _nc_wgetch(WINDOW *win,
T((T_CALLED("_nc_wgetch(%p)"), win));
*result = 0;
+
+ sp = _nc_screen_of(win);
if (win == 0 || sp == 0) {
returnCode(ERR);
}
if (cooked_key_in_fifo()) {
- if (wgetch_should_refresh(win))
- wrefresh(win);
-
+ recur_wrefresh(win);
*result = fifo_pull(sp);
returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
@@ -299,9 +356,7 @@ _nc_wgetch(WINDOW *win,
TR(TRACE_IEVENT, ("filling queue in cooked mode"));
- sp->_called_wgetch = TRUE;
- rc = wgetnstr(win, buf, MAXCOLUMNS);
- sp->_called_wgetch = FALSE;
+ rc = recur_wgetnstr(win, buf);
/* ungetch in reverse order */
#ifdef NCURSES_WGETCH_EVENTS
@@ -324,10 +379,9 @@ _nc_wgetch(WINDOW *win,
if (win->_use_keypad != sp->_keypad_on)
_nc_keypad(sp, win->_use_keypad);
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ recur_wrefresh(win);
- if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) {
+ if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) {
if (head == -1) { /* fifo is empty */
int delay;
int rc;
@@ -353,8 +407,9 @@ _nc_wgetch(WINDOW *win,
returnCode(KEY_CODE_YES);
}
#endif
- if (!rc)
+ if (!rc) {
returnCode(ERR);
+ }
}
/* else go on to read data available */
}
@@ -388,7 +443,7 @@ _nc_wgetch(WINDOW *win,
&& (((rc = check_mouse_activity(sp, sp->_maxclick
EVENTLIST_2nd(evl))) != 0
&& !(rc & 4))
- || !sp->_mouse_parse(runcount)));
+ || !sp->_mouse_parse(sp, runcount)));
#ifdef NCURSES_WGETCH_EVENTS
if ((rc & 4) && !ch == KEY_EVENT) {
_nc_ungetch(sp, ch);
@@ -467,7 +522,7 @@ _nc_wgetch(WINDOW *win,
if ((ch < KEY_MIN) && (ch & 0x80))
ch &= 0x7f;
- T(("wgetch returning : %s", _tracechar(ch)));
+ T(("wgetch returning : %s", _nc_tracechar(sp, ch)));
*result = ch;
returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK);
@@ -477,14 +532,13 @@ _nc_wgetch(WINDOW *win,
NCURSES_EXPORT(int)
wgetch_events(WINDOW *win, _nc_eventlist * evl)
{
- SCREEN *sp = SP;
int code;
unsigned long value;
T((T_CALLED("wgetch_events(%p,%p)"), win, evl));
code = _nc_wgetch(win,
&value,
- sp->_use_meta
+ _nc_use_meta(win)
EVENTLIST_2nd(evl));
if (code != ERR)
code = value;
@@ -495,14 +549,13 @@ wgetch_events(WINDOW *win, _nc_eventlist * evl)
NCURSES_EXPORT(int)
wgetch(WINDOW *win)
{
- SCREEN *sp = SP;
int code;
unsigned long value;
T((T_CALLED("wgetch(%p)"), win));
code = _nc_wgetch(win,
&value,
- (sp ? sp->_use_meta : 0)
+ _nc_use_meta(win)
EVENTLIST_2nd((_nc_eventlist *) 0));
if (code != ERR)
code = value;
@@ -564,7 +617,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
return ch;
}
- TR(TRACE_IEVENT, ("ch: %s", _tracechar((unsigned char) ch)));
+ TR(TRACE_IEVENT, ("ch: %s", _nc_tracechar(sp, (unsigned char) ch)));
while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
ptr = ptr->sibling;
diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c
index 274e87887371..b17df03d2a41 100644
--- a/ncurses/base/lib_getstr.c
+++ b/ncurses/base/lib_getstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2002,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 *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_getstr.c,v 1.25 2006/01/12 00:33:52 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.27 2008/08/16 19:20:04 tom Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
@@ -75,6 +75,7 @@ wgetnstr_events(WINDOW *win,
int maxlen,
EVENTLIST_1st(_nc_eventlist * evl))
{
+ SCREEN *sp = _nc_screen_of(win);
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
char erasec;
@@ -90,10 +91,10 @@ wgetnstr_events(WINDOW *win,
_nc_get_tty_mode(&buf);
- oldnl = SP->_nl;
- oldecho = SP->_echo;
- oldraw = SP->_raw;
- oldcbreak = SP->_cbreak;
+ oldnl = sp->_nl;
+ oldecho = sp->_echo;
+ oldraw = sp->_raw;
+ oldcbreak = sp->_cbreak;
nl();
noecho();
noraw();
@@ -145,7 +146,7 @@ wgetnstr_events(WINDOW *win,
|| (maxlen >= 0 && str - oldstr >= maxlen)) {
beep();
} else {
- *str++ = ch;
+ *str++ = (char) ch;
if (oldecho == TRUE) {
int oldy = win->_cury;
if (waddch(win, (chtype) ch) == ERR) {
@@ -187,10 +188,10 @@ wgetnstr_events(WINDOW *win,
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- SP->_nl = oldnl;
- SP->_echo = oldecho;
- SP->_raw = oldraw;
- SP->_cbreak = oldcbreak;
+ sp->_nl = oldnl;
+ sp->_echo = oldecho;
+ sp->_raw = oldraw;
+ sp->_cbreak = oldcbreak;
_nc_set_tty_mode(&buf);
diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c
index ef360c03b642..b2fef0c1d085 100644
--- a/ncurses/base/lib_initscr.c
+++ b/ncurses/base/lib_initscr.c
@@ -45,7 +45,7 @@
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.36 2008/04/12 18:11:36 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.38 2008/08/16 21:20:48 Werner.Fink Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
@@ -57,7 +57,9 @@ initscr(void)
START_TRACE();
T((T_CALLED("initscr()")));
- _nc_lock_global(set_SP);
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
+
/* Portable applications must not call initscr() more than once */
if (!_nc_globals.init_screen) {
_nc_globals.init_screen = TRUE;
@@ -91,7 +93,7 @@ initscr(void)
def_prog_mode();
}
result = stdscr;
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnWin(result);
}
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index aace7deb4c7f..95f29aa69111 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.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 *
@@ -79,7 +79,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_mouse.c,v 1.88 2007/09/29 21:50:04 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.102 2008/10/18 21:48:55 tom Exp $")
#include <term.h>
#include <tic.h>
@@ -150,38 +150,47 @@ make an error
#define LIBGPM_SONAME "libgpm.so"
#endif
-#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name))
+#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(SP->_dlopen_gpm, #name))
#endif /* USE_GPM_SUPPORT */
-static bool _nc_mouse_parse(int);
+static bool _nc_mouse_parse(SCREEN *, int);
static void _nc_mouse_resume(SCREEN *);
static void _nc_mouse_wrap(SCREEN *);
/* maintain a circular list of mouse events */
+#define FirstEV(sp) ((sp)->_mouse_events)
+#define LastEV(sp) ((sp)->_mouse_events + EV_MAX - 1)
+
#undef NEXT
-#define NEXT(ep) ((ep == SP->_mouse_events + EV_MAX - 1) \
- ? SP->_mouse_events \
+#define NEXT(ep) ((ep >= LastEV(sp)) \
+ ? FirstEV(sp) \
: ep + 1)
#undef PREV
-#define PREV(ep) ((ep == SP->_mouse_events) \
- ? SP->_mouse_events + EV_MAX - 1 \
+#define PREV(ep) ((ep <= FirstEV(sp)) \
+ ? LastEV(sp) \
: ep - 1)
+#define IndexEV(sp, ep) (ep - FirstEV(sp))
+
+#define RunParams(sp, eventp, runp) \
+ (long) IndexEV(sp, runp), \
+ (long) (IndexEV(sp, eventp) + (EV_MAX - 1)) % EV_MAX
+
#ifdef TRACE
static void
-_trace_slot(const char *tag)
+_trace_slot(SCREEN *sp, const char *tag)
{
MEVENT *ep;
_tracef(tag);
- for (ep = SP->_mouse_events; ep < SP->_mouse_events + EV_MAX; ep++)
+ for (ep = FirstEV(sp); ep <= LastEV(sp); ep++)
_tracef("mouse event queue slot %ld = %s",
- (long) (ep - SP->_mouse_events),
- _tracemouse(ep));
+ (long) IndexEV(sp, ep),
+ _nc_tracemouse(sp, ep));
}
#endif
@@ -193,7 +202,7 @@ _trace_slot(const char *tag)
# define M_FD(sp) sp->_mouse_fd
static void
-write_event(int down, int button, int x, int y)
+write_event(SCREEN *sp, int down, int button, int x, int y)
{
char buf[6];
unsigned long ignore;
@@ -202,12 +211,13 @@ write_event(int down, int button, int x, int y)
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
- DosWrite(SP->_emxmouse_wfd, buf, 6, &ignore);
+ DosWrite(sp->_emxmouse_wfd, buf, 6, &ignore);
}
static void
-mouse_server(unsigned long ignored GCC_UNUSED)
+mouse_server(unsigned long param)
{
+ SCREEN *sp = (SCREEN *) param;
unsigned short fWait = MOU_WAIT;
/* NOPTRRECT mourt = { 0,0,24,79 }; */
MOUEVENTINFO mouev;
@@ -234,7 +244,7 @@ mouse_server(unsigned long ignored GCC_UNUSED)
sprintf(err, "Error reading mouse queue, rc=%lu.\r\n", rc);
break;
}
- if (!SP->_emxmouse_activated)
+ if (!sp->_emxmouse_activated)
goto finish;
/*
@@ -245,14 +255,14 @@ mouse_server(unsigned long ignored GCC_UNUSED)
* 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- SP->_emxmouse_buttons[1], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN1_DOWN,
+ sp->_emxmouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
- write_event(mouev.fs & MOUSE_BN2_DOWN,
- SP->_emxmouse_buttons[3], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN2_DOWN,
+ sp->_emxmouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
- write_event(mouev.fs & MOUSE_BN3_DOWN,
- SP->_emxmouse_buttons[2], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN3_DOWN,
+ sp->_emxmouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -271,134 +281,199 @@ mouse_server(unsigned long ignored GCC_UNUSED)
#if USE_SYSMOUSE
static void
-handle_sysmouse(int sig GCC_UNUSED)
+sysmouse_server(SCREEN *sp)
{
struct mouse_info the_mouse;
MEVENT *work;
the_mouse.operation = MOUSE_GETINFO;
- if (SP != 0
- && SP->_mouse_fd >= 0
- && SP->_sysmouse_tail < FIFO_SIZE
- && ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
-
- if (SP->_sysmouse_head > SP->_sysmouse_tail) {
- SP->_sysmouse_tail = 0;
- SP->_sysmouse_head = 0;
+ if (sp != 0
+ && sp->_mouse_fd >= 0
+ && sp->_sysmouse_tail < FIFO_SIZE
+ && ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+
+ if (sp->_sysmouse_head > sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
}
- work = &(SP->_sysmouse_fifo[SP->_sysmouse_tail]);
+ work = &(sp->_sysmouse_fifo[sp->_sysmouse_tail]);
memset(work, 0, sizeof(*work));
work->id = NORMAL_EVENT; /* there's only one mouse... */
- SP->_sysmouse_old_buttons = SP->_sysmouse_new_buttons;
- SP->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
+ sp->_sysmouse_old_buttons = sp->_sysmouse_new_buttons;
+ sp->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
- if (SP->_sysmouse_new_buttons) {
- if (SP->_sysmouse_new_buttons & 1)
+ if (sp->_sysmouse_new_buttons) {
+ if (sp->_sysmouse_new_buttons & 1)
work->bstate |= BUTTON1_PRESSED;
- if (SP->_sysmouse_new_buttons & 2)
+ if (sp->_sysmouse_new_buttons & 2)
work->bstate |= BUTTON2_PRESSED;
- if (SP->_sysmouse_new_buttons & 4)
+ if (sp->_sysmouse_new_buttons & 4)
work->bstate |= BUTTON3_PRESSED;
} else {
- if (SP->_sysmouse_old_buttons & 1)
+ if (sp->_sysmouse_old_buttons & 1)
work->bstate |= BUTTON1_RELEASED;
- if (SP->_sysmouse_old_buttons & 2)
+ if (sp->_sysmouse_old_buttons & 2)
work->bstate |= BUTTON2_RELEASED;
- if (SP->_sysmouse_old_buttons & 4)
+ if (sp->_sysmouse_old_buttons & 4)
work->bstate |= BUTTON3_RELEASED;
}
/* for cosmetic bug in syscons.c on FreeBSD 3.[34] */
the_mouse.operation = MOUSE_HIDE;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
the_mouse.operation = MOUSE_SHOW;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
/*
* We're only interested if the button is pressed or released.
* FIXME: implement continuous event-tracking.
*/
- if (SP->_sysmouse_new_buttons != SP->_sysmouse_old_buttons) {
- SP->_sysmouse_tail += 1;
+ if (sp->_sysmouse_new_buttons != sp->_sysmouse_old_buttons) {
+ sp->_sysmouse_tail += 1;
}
- work->x = the_mouse.u.data.x / SP->_sysmouse_char_width;
- work->y = the_mouse.u.data.y / SP->_sysmouse_char_height;
+ work->x = the_mouse.u.data.x / sp->_sysmouse_char_width;
+ work->y = the_mouse.u.data.y / sp->_sysmouse_char_height;
}
}
+
+static void
+handle_sysmouse(int sig GCC_UNUSED)
+{
+ sysmouse_server(SP);
+}
#endif /* USE_SYSMOUSE */
static void
-init_xterm_mouse(void)
+init_xterm_mouse(SCREEN *sp)
{
- SP->_mouse_type = M_XTERM;
- SP->_mouse_xtermcap = tigetstr("XM");
- if (!VALID_STRING(SP->_mouse_xtermcap))
- SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
+ sp->_mouse_type = M_XTERM;
+ sp->_mouse_xtermcap = tigetstr("XM");
+ if (!VALID_STRING(sp->_mouse_xtermcap))
+ sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
}
static void
-enable_xterm_mouse(int enable)
+enable_xterm_mouse(SCREEN *sp, int enable)
{
#if USE_EMX_MOUSE
- SP->_emxmouse_activated = enable;
+ sp->_emxmouse_activated = enable;
#else
- putp(TPARM_1(SP->_mouse_xtermcap, enable));
+ putp(TPARM_1(sp->_mouse_xtermcap, enable));
#endif
- SP->_mouse_active = enable;
+ sp->_mouse_active = enable;
}
#if USE_GPM_SUPPORT
-static int
+static bool
allow_gpm_mouse(void)
{
+ bool result = FALSE;
+
/* GPM does printf's without checking if stdout is a terminal */
if (isatty(fileno(stdout))) {
+ char *list = getenv("NCURSES_GPM_TERMS");
char *env = getenv("TERM");
- /* GPM checks the beginning of the $TERM variable to decide if
- * it should pass xterm events through. There is no real advantage
- * in allowing GPM to do this.
- */
- if (env == 0 || strncmp(env, "xterm", 5))
- return TRUE;
+ if (list != 0) {
+ if (env != 0) {
+ result = _nc_name_match(list, env, "|:");
+ }
+ } else {
+ /* GPM checks the beginning of the $TERM variable to decide if it
+ * should pass xterm events through. There is no real advantage in
+ * allowing GPM to do this. Recent versions relax that check, and
+ * pretend that GPM can work with any terminal having the kmous
+ * capability. Perhaps that works for someone. If so, they can
+ * set the environment variable (above).
+ */
+ if (env != 0 && strstr(env, "linux") != 0) {
+ result = TRUE;
+ }
+ }
+ }
+ return result;
+}
+
+#ifdef HAVE_LIBDL
+static void
+unload_gpm_library(SCREEN *sp)
+{
+ if (SP->_dlopen_gpm != 0) {
+ T(("unload GPM library"));
+ sp->_mouse_gpm_loaded = FALSE;
+ sp->_mouse_fd = -1;
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
}
- return FALSE;
}
+static void
+load_gpm_library(SCREEN *sp)
+{
+ sp->_mouse_gpm_found = FALSE;
+ if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ if (GET_DLSYM(gpm_fd) == 0 ||
+ GET_DLSYM(Gpm_Open) == 0 ||
+ GET_DLSYM(Gpm_Close) == 0 ||
+ GET_DLSYM(Gpm_GetEvent) == 0) {
+ T(("GPM initialization failed: %s", dlerror()));
+ unload_gpm_library(sp);
+ } else {
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
+ }
+ }
+}
+#endif
+
static bool
-enable_gpm_mouse(int enable)
+enable_gpm_mouse(SCREEN *sp, bool enable)
{
bool result;
T((T_CALLED("enable_gpm_mouse(%d)"), enable));
- if (enable && !SP->_mouse_active) {
- /* GPM: initialize connection to gpm server */
- SP->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
- SP->_mouse_gpm_connect.defaultMask =
- ~(SP->_mouse_gpm_connect.eventMask | GPM_HARD);
- SP->_mouse_gpm_connect.minMod = 0;
- SP->_mouse_gpm_connect.maxMod =
- (unsigned short) (~((1 << KG_SHIFT) |
- (1 << KG_SHIFTL) |
- (1 << KG_SHIFTR)));
- /*
- * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
- * The former is recognized by wscons (SunOS), and the latter by
- * xterm. Those will not show up in ncurses' traces.
- */
- result = (my_Gpm_Open(&SP->_mouse_gpm_connect, 0) >= 0);
- SP->_mouse_active = result;
+ if (enable && !sp->_mouse_active) {
+#ifdef HAVE_LIBDL
+ if (sp->_mouse_gpm_found && !sp->_mouse_gpm_loaded) {
+ load_gpm_library(sp);
+ }
+#endif
+ if (sp->_mouse_gpm_loaded) {
+ /* GPM: initialize connection to gpm server */
+ sp->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ sp->_mouse_gpm_connect.defaultMask =
+ (unsigned short) (~(sp->_mouse_gpm_connect.eventMask | GPM_HARD));
+ sp->_mouse_gpm_connect.minMod = 0;
+ sp->_mouse_gpm_connect.maxMod =
+ (unsigned short) (~((1 << KG_SHIFT) |
+ (1 << KG_SHIFTL) |
+ (1 << KG_SHIFTR)));
+ /*
+ * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
+ * The former is recognized by wscons (SunOS), and the latter by
+ * xterm. Those will not show up in ncurses' traces.
+ */
+ result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0);
+ } else {
+ result = FALSE;
+ }
+ sp->_mouse_active = result;
T(("GPM open %s", result ? "succeeded" : "failed"));
} else {
- if (!enable && SP->_mouse_active) {
+ if (!enable && sp->_mouse_active) {
/* GPM: close connection to gpm server */
my_Gpm_Close();
- SP->_mouse_active = FALSE;
+ sp->_mouse_active = FALSE;
T(("GPM closed"));
}
- result = FALSE;
+ result = enable;
+ }
+#ifdef HAVE_LIBDL
+ if (!result) {
+ unload_gpm_library(sp);
}
+#endif
returnBool(result);
}
#endif /* USE_GPM_SUPPORT */
@@ -406,32 +481,20 @@ enable_gpm_mouse(int enable)
#define xterm_kmous "\033[M"
static void
-initialize_mousetype(void)
+initialize_mousetype(SCREEN *sp)
{
T((T_CALLED("initialize_mousetype()")));
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
if (allow_gpm_mouse()) {
- if (!SP->_mouse_gpm_loaded) {
+ if (!sp->_mouse_gpm_loaded) {
#ifdef HAVE_LIBDL
- void *obj;
-
- if ((obj = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
- if (GET_DLSYM(gpm_fd) == 0 ||
- GET_DLSYM(Gpm_Open) == 0 ||
- GET_DLSYM(Gpm_Close) == 0 ||
- GET_DLSYM(Gpm_GetEvent) == 0) {
- T(("GPM initialization failed: %s", dlerror()));
- dlclose(obj);
- } else {
- SP->_mouse_gpm_found = TRUE;
- }
- }
+ load_gpm_library(sp);
#else /* !HAVE_LIBDL */
- SP->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
#endif
- SP->_mouse_gpm_loaded = TRUE;
}
/*
@@ -439,10 +502,10 @@ initialize_mousetype(void)
* maintain our notion of whether the mouse connection is active
* without testing the file-descriptor.
*/
- if (SP->_mouse_gpm_found && enable_gpm_mouse(TRUE)) {
- SP->_mouse_type = M_GPM;
- SP->_mouse_fd = *(my_gpm_fd);
- T(("GPM mouse_fd %d", SP->_mouse_fd));
+ if (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_type = M_GPM;
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
returnVoid;
}
}
@@ -450,7 +513,7 @@ initialize_mousetype(void)
/* OS/2 VIO */
#if USE_EMX_MOUSE
- if (!SP->_emxmouse_thread
+ if (!sp->_emxmouse_thread
&& strstr(cur_term->type.term_names, "xterm") == 0
&& key_mouse) {
int handles[2];
@@ -461,32 +524,32 @@ initialize_mousetype(void)
} else {
int rc;
- if (!SP->_emxmouse_buttons[0]) {
+ if (!sp->_emxmouse_buttons[0]) {
char *s = getenv("MOUSE_BUTTONS_123");
- SP->_emxmouse_buttons[0] = 1;
+ sp->_emxmouse_buttons[0] = 1;
if (s && strlen(s) >= 3) {
- SP->_emxmouse_buttons[1] = s[0] - '0';
- SP->_emxmouse_buttons[2] = s[1] - '0';
- SP->_emxmouse_buttons[3] = s[2] - '0';
+ sp->_emxmouse_buttons[1] = s[0] - '0';
+ sp->_emxmouse_buttons[2] = s[1] - '0';
+ sp->_emxmouse_buttons[3] = s[2] - '0';
} else {
- SP->_emxmouse_buttons[1] = 1;
- SP->_emxmouse_buttons[2] = 3;
- SP->_emxmouse_buttons[3] = 2;
+ sp->_emxmouse_buttons[1] = 1;
+ sp->_emxmouse_buttons[2] = 3;
+ sp->_emxmouse_buttons[3] = 2;
}
}
- SP->_emxmouse_wfd = handles[1];
- M_FD(SP) = handles[0];
+ sp->_emxmouse_wfd = handles[1];
+ M_FD(sp) = handles[0];
/* Needed? */
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long *) &SP->_emxmouse_thread,
- mouse_server, 0, 0, 8192);
+ rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread,
+ mouse_server, (long) sp, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
} else {
- SP->_mouse_type = M_XTERM;
+ sp->_mouse_type = M_XTERM;
}
returnVoid;
}
@@ -498,14 +561,14 @@ initialize_mousetype(void)
struct mouse_info the_mouse;
char *the_device = 0;
- if (isatty(SP->_ifd))
- the_device = ttyname(SP->_ifd);
+ if (isatty(sp->_ifd))
+ the_device = ttyname(sp->_ifd);
if (the_device == 0)
the_device = "/dev/tty";
- SP->_mouse_fd = open(the_device, O_RDWR);
+ sp->_mouse_fd = open(the_device, O_RDWR);
- if (SP->_mouse_fd >= 0) {
+ if (sp->_mouse_fd >= 0) {
/*
* sysmouse does not have a usable user interface for obtaining
* mouse events. The logical way to proceed (reading data on a
@@ -522,10 +585,10 @@ initialize_mousetype(void)
the_mouse.operation = MOUSE_MODE;
the_mouse.u.mode.mode = 0;
the_mouse.u.mode.signal = SIGUSR2;
- if (ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+ if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
signal(SIGUSR2, handle_sysmouse);
the_mouse.operation = MOUSE_SHOW;
- ioctl(SP->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */
{
@@ -535,23 +598,23 @@ initialize_mousetype(void)
#endif /* FBIO_GETMODE */
video_info_t the_video;
- if (ioctl(SP->_mouse_fd,
+ if (ioctl(sp->_mouse_fd,
FBIO_GETMODE,
&the_video.vi_mode) != -1
- && ioctl(SP->_mouse_fd,
+ && ioctl(sp->_mouse_fd,
FBIO_MODEINFO,
&the_video) != -1) {
- SP->_sysmouse_char_width = the_video.vi_cwidth;
- SP->_sysmouse_char_height = the_video.vi_cheight;
+ sp->_sysmouse_char_width = the_video.vi_cwidth;
+ sp->_sysmouse_char_height = the_video.vi_cheight;
}
}
#endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */
- if (SP->_sysmouse_char_width <= 0)
- SP->_sysmouse_char_width = 8;
- if (SP->_sysmouse_char_height <= 0)
- SP->_sysmouse_char_height = 16;
- SP->_mouse_type = M_SYSMOUSE;
+ if (sp->_sysmouse_char_width <= 0)
+ sp->_sysmouse_char_width = 8;
+ if (sp->_sysmouse_char_height <= 0)
+ sp->_sysmouse_char_height = 16;
+ sp->_mouse_type = M_SYSMOUSE;
returnVoid;
}
}
@@ -562,37 +625,37 @@ initialize_mousetype(void)
if (key_mouse != 0) {
if (!strcmp(key_mouse, xterm_kmous)
|| strstr(cur_term->type.term_names, "xterm") != 0) {
- init_xterm_mouse();
+ init_xterm_mouse(sp);
}
} else if (strstr(cur_term->type.term_names, "xterm") != 0) {
- if (_nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE) == OK)
- init_xterm_mouse();
+ if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
+ init_xterm_mouse(sp);
}
returnVoid;
}
static bool
-_nc_mouse_init(void)
+_nc_mouse_init(SCREEN *sp)
/* initialize the mouse */
{
bool result = FALSE;
int i;
- if (SP != 0) {
- if (!SP->_mouse_initialized) {
- SP->_mouse_initialized = TRUE;
+ if (sp != 0) {
+ if (!sp->_mouse_initialized) {
+ sp->_mouse_initialized = TRUE;
TR(MY_TRACE, ("_nc_mouse_init() called"));
- SP->_mouse_eventp = SP->_mouse_events;
+ sp->_mouse_eventp = FirstEV(sp);
for (i = 0; i < EV_MAX; i++)
- SP->_mouse_events[i].id = INVALID_EVENT;
+ sp->_mouse_events[i].id = INVALID_EVENT;
- initialize_mousetype();
+ initialize_mousetype(sp);
- T(("_nc_mouse_init() set mousetype to %d", SP->_mouse_type));
+ T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type));
}
- result = SP->_mouse_initialized;
+ result = sp->_mouse_initialized;
}
return result;
}
@@ -604,12 +667,12 @@ _nc_mouse_init(void)
static bool
_nc_mouse_event(SCREEN *sp GCC_UNUSED)
{
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
bool result = FALSE;
(void) eventp;
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
/* xterm: never have to query, mouse events are in the keyboard stream */
#if USE_EMX_MOUSE
@@ -666,7 +729,7 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
eventp->z = 0;
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
}
@@ -675,22 +738,22 @@ _nc_mouse_event(SCREEN *sp GCC_UNUSED)
#if USE_SYSMOUSE
case M_SYSMOUSE:
- if (SP->_sysmouse_head < SP->_sysmouse_tail) {
- *eventp = SP->_sysmouse_fifo[SP->_sysmouse_head];
+ if (sp->_sysmouse_head < sp->_sysmouse_tail) {
+ *eventp = sp->_sysmouse_fifo[sp->_sysmouse_head];
/*
* Point the fifo-head to the next possible location. If there
* are none, reset the indices. This may be interrupted by the
* signal handler, doing essentially the same reset.
*/
- SP->_sysmouse_head += 1;
- if (SP->_sysmouse_head == SP->_sysmouse_tail) {
- SP->_sysmouse_tail = 0;
- SP->_sysmouse_head = 0;
+ sp->_sysmouse_head += 1;
+ if (sp->_sysmouse_head == sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
}
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_eventp = eventp = NEXT(eventp);
result = TRUE;
}
break;
@@ -709,11 +772,11 @@ _nc_mouse_inline(SCREEN *sp)
{
int b;
bool result = FALSE;
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (SP->_mouse_type == M_XTERM) {
+ if (sp->_mouse_type == M_XTERM) {
unsigned char kbuf[4];
mmask_t prev;
size_t grabbed;
@@ -751,7 +814,7 @@ _nc_mouse_inline(SCREEN *sp)
* Wheel mice may return buttons 4 and 5 when the wheel is turned.
* We encode those as button presses.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res) {
+ for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
#if USE_EMX_MOUSE
@@ -781,9 +844,9 @@ _nc_mouse_inline(SCREEN *sp)
eventp->bstate = MASK_RELEASE(n)
#else
#define PRESS_POSITION(n) \
- eventp->bstate = (prev & MASK_PRESS(n) \
- ? REPORT_MOUSE_POSITION \
- : MASK_PRESS(n))
+ eventp->bstate = (mmask_t) (prev & MASK_PRESS(n) \
+ ? REPORT_MOUSE_POSITION \
+ : MASK_PRESS(n))
#endif
switch (kbuf[0] & 0x3) {
@@ -847,11 +910,11 @@ _nc_mouse_inline(SCREEN *sp)
eventp->y = (kbuf[2] - ' ') - 1;
TR(MY_TRACE,
("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
- _tracemouse(eventp),
- (long) (eventp - SP->_mouse_events)));
+ _nc_tracemouse(sp, eventp),
+ (long) IndexEV(sp, eventp)));
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_eventp = NEXT(eventp);
#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
return (TRUE);
#endif
@@ -861,36 +924,36 @@ _nc_mouse_inline(SCREEN *sp)
}
static void
-mouse_activate(bool on)
+mouse_activate(SCREEN *sp, bool on)
{
- if (!on && !SP->_mouse_initialized)
+ if (!on && !sp->_mouse_initialized)
return;
- if (!_nc_mouse_init())
+ if (!_nc_mouse_init(sp))
return;
if (on) {
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
- enable_xterm_mouse(1);
+ enable_xterm_mouse(sp, 1);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- if (enable_gpm_mouse(1)) {
- SP->_mouse_fd = *(my_gpm_fd);
- T(("GPM mouse_fd %d", SP->_mouse_fd));
+ if (enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
}
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
signal(SIGUSR2, handle_sysmouse);
- SP->_mouse_active = TRUE;
+ sp->_mouse_active = TRUE;
break;
#endif
case M_NONE:
@@ -899,27 +962,27 @@ mouse_activate(bool on)
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
- SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
- SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
+ sp->_mouse_event = _nc_mouse_event;
+ sp->_mouse_inline = _nc_mouse_inline;
+ sp->_mouse_parse = _nc_mouse_parse;
+ sp->_mouse_resume = _nc_mouse_resume;
+ sp->_mouse_wrap = _nc_mouse_wrap;
} else {
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
TPUTS_TRACE("xterm mouse deinitialization");
- enable_xterm_mouse(0);
+ enable_xterm_mouse(sp, 0);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- enable_gpm_mouse(0);
+ enable_gpm_mouse(sp, FALSE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
signal(SIGUSR2, SIG_IGN);
- SP->_mouse_active = FALSE;
+ sp->_mouse_active = FALSE;
break;
#endif
case M_NONE:
@@ -936,10 +999,10 @@ mouse_activate(bool on)
**************************************************************************/
static bool
-_nc_mouse_parse(int runcount)
+_nc_mouse_parse(SCREEN *sp, int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *eventp = SP->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_eventp;
MEVENT *ep, *runp, *next, *prev = PREV(eventp);
int n;
int b;
@@ -971,10 +1034,10 @@ _nc_mouse_parse(int runcount)
if (runcount == 1) {
TR(MY_TRACE,
("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - SP->_mouse_events)));
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
return (prev->id >= NORMAL_EVENT)
- ? ((prev->bstate & SP->_mouse_mask) ? TRUE : FALSE)
+ ? ((prev->bstate & sp->_mouse_mask) ? TRUE : FALSE)
: FALSE;
}
@@ -986,10 +1049,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse press/release merge:");
+ _trace_slot(sp, "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,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1014,7 +1076,7 @@ _nc_mouse_parse(int runcount)
#endif
) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_CLICK(b))
+ if ((sp->_mouse_mask & MASK_CLICK(b))
&& (ep->bstate & MASK_PRESS(b))) {
ep->bstate &= ~MASK_PRESS(b);
ep->bstate |= MASK_CLICK(b);
@@ -1030,10 +1092,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse click merge:");
+ _trace_slot(sp, "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,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1071,7 +1132,7 @@ _nc_mouse_parse(int runcount)
if ((ep->bstate & BUTTON_CLICKED)
&& (follower->bstate & BUTTON_CLICKED)) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_DOUBLE_CLICK(b))
+ if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
&& (follower->bstate & MASK_CLICK(b))) {
follower->bstate &= ~MASK_CLICK(b);
follower->bstate |= MASK_DOUBLE_CLICK(b);
@@ -1086,7 +1147,7 @@ _nc_mouse_parse(int runcount)
if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
&& (follower->bstate & BUTTON_CLICKED)) {
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((SP->_mouse_mask & MASK_TRIPLE_CLICK(b))
+ if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
&& (follower->bstate & MASK_CLICK(b))) {
follower->bstate &= ~MASK_CLICK(b);
follower->bstate |= MASK_TRIPLE_CLICK(b);
@@ -1102,10 +1163,9 @@ _nc_mouse_parse(int runcount)
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("before mouse event queue compaction:");
+ _trace_slot(sp, "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,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1116,15 +1176,14 @@ _nc_mouse_parse(int runcount)
* don't match the current event mask.
*/
for (; runcount; prev = PREV(eventp), runcount--)
- if (prev->id == INVALID_EVENT || !(prev->bstate & SP->_mouse_mask)) {
- SP->_mouse_eventp = eventp = prev;
+ if (prev->id == INVALID_EVENT || !(prev->bstate & sp->_mouse_mask)) {
+ sp->_mouse_eventp = eventp = prev;
}
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
- _trace_slot("after mouse event queue compaction:");
+ _trace_slot(sp, "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,
+ RunParams(sp, eventp, runp),
runcount);
_nc_unlock_global(tracef);
}
@@ -1132,8 +1191,8 @@ _nc_mouse_parse(int runcount)
if (ep->id != INVALID_EVENT)
TR(MY_TRACE,
("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - SP->_mouse_events)));
+ _nc_tracemouse(sp, ep),
+ (long) IndexEV(sp, ep)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
@@ -1141,26 +1200,26 @@ _nc_mouse_parse(int runcount)
}
static void
-_nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+_nc_mouse_wrap(SCREEN *sp)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
- if (SP->_mouse_mask)
- mouse_activate(FALSE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
case M_GPM:
- if (SP->_mouse_mask)
- mouse_activate(FALSE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
- mouse_activate(FALSE);
+ mouse_activate(sp, FALSE);
break;
#endif
case M_NONE:
@@ -1169,29 +1228,29 @@ _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
}
static void
-_nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+_nc_mouse_resume(SCREEN *sp)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
- switch (SP->_mouse_type) {
+ switch (sp->_mouse_type) {
case M_XTERM:
/* xterm: re-enable reporting */
- if (SP->_mouse_mask)
- mouse_activate(TRUE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
break;
#if USE_GPM_SUPPORT
case M_GPM:
/* GPM: reclaim our event set */
- if (SP->_mouse_mask)
- mouse_activate(TRUE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
break;
#endif
#if USE_SYSMOUSE
case M_SYSMOUSE:
- mouse_activate(TRUE);
+ mouse_activate(sp, TRUE);
break;
#endif
case M_NONE:
@@ -1205,14 +1264,13 @@ _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
*
**************************************************************************/
-NCURSES_EXPORT(int)
-getmouse(MEVENT * aevent)
-/* grab a copy of the current mouse event */
+static int
+_nc_getmouse(SCREEN *sp, MEVENT * aevent)
{
T((T_CALLED("getmouse(%p)"), aevent));
- if ((aevent != 0) && (SP != 0) && (SP->_mouse_type != M_NONE)) {
- MEVENT *eventp = SP->_mouse_eventp;
+ if ((aevent != 0) && (sp != 0) && (sp->_mouse_type != M_NONE)) {
+ MEVENT *eventp = sp->_mouse_eventp;
/* compute the current-event pointer */
MEVENT *prev = PREV(eventp);
@@ -1220,8 +1278,8 @@ getmouse(MEVENT * aevent)
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - SP->_mouse_events)));
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -1229,29 +1287,42 @@ getmouse(MEVENT * aevent)
returnCode(ERR);
}
+/* grab a copy of the current mouse event */
NCURSES_EXPORT(int)
-ungetmouse(MEVENT * aevent)
-/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+getmouse(MEVENT * aevent)
+{
+ return _nc_getmouse(SP, aevent);
+}
+
+static int
+_nc_ungetmouse(SCREEN *sp, MEVENT * aevent)
{
int result = ERR;
T((T_CALLED("ungetmouse(%p)"), aevent));
- if (aevent != 0 && SP != 0) {
- MEVENT *eventp = SP->_mouse_eventp;
+ if (aevent != 0 && sp != 0) {
+ MEVENT *eventp = sp->_mouse_eventp;
/* stick the given event in the next-free slot */
*eventp = *aevent;
/* bump the next-free pointer into the circular list */
- SP->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_eventp = NEXT(eventp);
/* push back the notification event on the keyboard queue */
- result = ungetch(KEY_MOUSE);
+ result = _nc_ungetch(sp, KEY_MOUSE);
}
returnCode(result);
}
+/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+NCURSES_EXPORT(int)
+ungetmouse(MEVENT * aevent)
+{
+ return _nc_ungetmouse(SP, aevent);
+}
+
NCURSES_EXPORT(mmask_t)
mousemask(mmask_t newmask, mmask_t * oldmask)
/* set the mouse event mask */
@@ -1265,7 +1336,7 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
*oldmask = SP->_mouse_mask;
if (newmask || SP->_mouse_initialized) {
- _nc_mouse_init();
+ _nc_mouse_init(SP);
if (SP->_mouse_type != M_NONE) {
result = newmask &
(REPORT_MOUSE_POSITION
@@ -1278,14 +1349,11 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
| BUTTON_DOUBLE_CLICKED
| BUTTON_TRIPLE_CLICKED);
- mouse_activate((bool) (result != 0));
+ mouse_activate(SP, (bool) (result != 0));
SP->_mouse_mask = result;
}
}
- } else {
- if (oldmask)
- *oldmask = SP->_mouse_mask;
}
returnBits(result);
}
diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c
index 3620a3fdbf2b..05982b84cee4 100644
--- a/ncurses/base/lib_newterm.c
+++ b/ncurses/base/lib_newterm.c
@@ -48,7 +48,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.69 2008/04/12 18:15:04 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.73 2008/08/16 21:20:48 Werner.Fink Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -125,11 +125,17 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
int errret;
SCREEN *current;
SCREEN *result = 0;
+ TERMINAL *its_term;
START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- _nc_lock_global(set_SP);
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
+
+ current = SP;
+ its_term = (SP ? SP->_term : 0);
+
/* this loads the capability entry, then sets LINES and COLS */
if (setupterm(name, fileno(ofp), &errret) != ERR) {
int slk_format = _nc_globals.slk_format;
@@ -138,7 +144,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
* This actually allocates the screen structure, and saves the original
* terminal settings.
*/
- current = SP;
_nc_set_screen(0);
/* allow user to set maximum escape delay from the environment */
@@ -154,6 +159,19 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
_nc_set_screen(current);
result = 0;
} else {
+ assert(SP != 0);
+ /*
+ * In setupterm() we did a set_curterm(), but it was before we set
+ * SP. So the "current" screen's terminal pointer was overwritten
+ * with a different terminal. Later, in _nc_setupscreen(), we set
+ * SP and the terminal pointer in the new screen.
+ *
+ * Restore the terminal-pointer for the pre-existing screen, if
+ * any.
+ */
+ if (current)
+ current->_term = its_term;
+
/* if the terminal type has real soft labels, set those up */
if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
_nc_slk_initialize(stdscr, COLS);
@@ -212,6 +230,6 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
result = SP;
}
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnSP(result);
}
diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c
index 7f7aa3e04f1e..587e83a92009 100644
--- a/ncurses/base/lib_newwin.c
+++ b/ncurses/base/lib_newwin.c
@@ -42,7 +42,7 @@
#include <curses.priv.h>
#include <stddef.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.50 2008/05/03 16:36:39 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.52 2008/06/07 13:58:09 tom Exp $")
#define window_is(name) ((sp)->_##name == win)
@@ -85,7 +85,7 @@ _nc_freewin(WINDOW *win)
T((T_CALLED("_nc_freewin(%p)"), win));
if (win != 0) {
- if (_nc_try_global(windowlist) == 0) {
+ if (_nc_try_global(curses) == 0) {
q = 0;
for (each_window(p)) {
if (&(p->win) == win) {
@@ -108,7 +108,7 @@ _nc_freewin(WINDOW *win)
}
q = p;
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
}
returnCode(result);
@@ -229,8 +229,6 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
returnWin(0);
- _nc_mutex_init(&(wp->mutex_use_window));
-
win = &(wp->win);
if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
@@ -238,7 +236,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
returnWin(0);
}
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
win->_curx = 0;
win->_cury = 0;
@@ -313,10 +311,28 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
}
wp->next = _nc_windows;
+ wp->screen = SP;
_nc_windows = wp;
T((T_CREATE("window %p"), win));
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
returnWin(win);
}
+
+/*
+ * wgetch() and other functions with a WINDOW* parameter may use a SCREEN*
+ * internally, and it is useful to allow those to be invoked without switching
+ * SCREEN's, e.g., for multi-threaded applications.
+ */
+NCURSES_EXPORT(SCREEN *)
+_nc_screen_of(WINDOW *win)
+{
+ SCREEN *sp = 0;
+
+ if (win != 0) {
+ WINDOWLIST *wp = (WINDOWLIST *) win;
+ sp = wp->screen;
+ }
+ return (sp);
+}
diff --git a/ncurses/base/lib_overlay.c b/ncurses/base/lib_overlay.c
index 26314de5e5fb..669e8e72c07f 100644
--- a/ncurses/base/lib_overlay.c
+++ b/ncurses/base/lib_overlay.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 *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_overlay.c,v 1.25 2008/04/12 17:21:59 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.27 2008/06/07 23:30:34 tom Exp $")
static int
overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
@@ -55,8 +55,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag));
if (src != 0 && dst != 0) {
- _nc_lock_window(src);
- _nc_lock_window(dst);
+ _nc_lock_global(curses);
T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
(long) src->_begy,
@@ -93,8 +92,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
dmaxrow, dmaxcol,
flag);
}
- _nc_unlock_window(dst);
- _nc_unlock_window(src);
+ _nc_unlock_global(curses);
}
returnCode(rc);
}
@@ -150,9 +148,7 @@ copywin(const WINDOW *src, WINDOW *dst,
src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
if (src && dst) {
-
- _nc_lock_window(src);
- _nc_lock_window(dst);
+ _nc_lock_global(curses);
bk = AttrOf(dst->_nc_bkgd);
mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);
@@ -204,8 +200,7 @@ copywin(const WINDOW *src, WINDOW *dst,
rc = OK;
}
}
- _nc_unlock_window(dst);
- _nc_unlock_window(src);
+ _nc_unlock_global(curses);
}
returnCode(rc);
}
diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c
index 9742ff629fbd..da770d4e7c92 100644
--- a/ncurses/base/lib_restart.c
+++ b/ncurses/base/lib_restart.c
@@ -36,8 +36,6 @@
* Terminfo-only terminal setup routines:
*
* int restartterm(const char *, int, int *)
- * TERMINAL *set_curterm(TERMINAL *)
- * int del_curterm(TERMINAL *)
*/
#include <curses.priv.h>
@@ -48,7 +46,7 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$Id: lib_restart.c,v 1.9 2008/05/03 22:43:52 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.10 2008/06/21 17:31:22 tom Exp $")
NCURSES_EXPORT(int)
restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index e6aecbdaab47..4aa58ea2a19c 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.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 *
@@ -29,12 +29,14 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
- * and: Thomas E. Dickey 1996 on *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_screen.c,v 1.30 2007/03/10 23:20:41 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.31 2008/08/16 19:05:37 tom Exp $")
+
+#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
NCURSES_EXPORT(WINDOW *)
getwin(FILE *filep)
@@ -46,7 +48,11 @@ getwin(FILE *filep)
clearerr(filep);
(void) fread(&tmp, sizeof(WINDOW), 1, filep);
- if (ferror(filep))
+ if (ferror(filep)
+ || tmp._maxy == 0
+ || tmp._maxy > MAX_SIZE
+ || tmp._maxx == 0
+ || tmp._maxx > MAX_SIZE)
returnWin(0);
if (tmp._flags & _ISPAD) {
@@ -115,7 +121,7 @@ putwin(WINDOW *win, FILE *filep)
T((T_CALLED("putwin(%p,%p)"), win, filep));
if (win != 0) {
- size_t len = (win->_maxx + 1);
+ size_t len = (size_t) (win->_maxx + 1);
clearerr(filep);
if (fwrite(win, sizeof(WINDOW), 1, filep) != 1
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index eee1cfc7b259..aff432bb9fd1 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -44,28 +44,30 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.108 2008/05/03 22:42:43 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.117 2008/08/04 18:11:12 tom Exp $")
NCURSES_EXPORT(SCREEN *)
set_term(SCREEN *screenp)
{
SCREEN *oldSP;
+ SCREEN *newSP;
T((T_CALLED("set_term(%p)"), screenp));
- _nc_lock_global(set_SP);
+ _nc_lock_global(curses);
oldSP = SP;
_nc_set_screen(screenp);
+ newSP = SP;
- if (SP != 0) {
- set_curterm(SP->_term);
+ if (newSP != 0) {
+ set_curterm(newSP->_term);
#if !USE_REENTRANT
- curscr = SP->_curscr;
- newscr = SP->_newscr;
- stdscr = SP->_stdscr;
- COLORS = SP->_color_count;
- COLOR_PAIRS = SP->_pair_count;
+ curscr = newSP->_curscr;
+ newscr = newSP->_newscr;
+ stdscr = newSP->_stdscr;
+ COLORS = newSP->_color_count;
+ COLOR_PAIRS = newSP->_pair_count;
#endif
} else {
set_curterm(0);
@@ -78,7 +80,7 @@ set_term(SCREEN *screenp)
#endif
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
T((T_RETURN("%p"), oldSP));
return (oldSP);
@@ -125,7 +127,7 @@ delscreen(SCREEN *sp)
T((T_CALLED("delscreen(%p)"), sp));
- _nc_lock_global(set_SP);
+ _nc_lock_global(curses);
if (delink_screen(sp)) {
(void) _nc_freewin(sp->_curscr);
@@ -162,8 +164,6 @@ delscreen(SCREEN *sp)
FreeIfNeeded(sp->_acs_map);
FreeIfNeeded(sp->_screen_acs_map);
- del_curterm(sp->_term);
-
/*
* If the associated output stream has been closed, we can discard the
* set-buffer. Limit the error check to EBADF, since fflush may fail
@@ -176,6 +176,7 @@ delscreen(SCREEN *sp)
free(sp->_setbuf);
}
+ del_curterm(sp->_term);
free(sp);
/*
@@ -194,7 +195,7 @@ delscreen(SCREEN *sp)
_nc_set_screen(0);
}
}
- _nc_unlock_global(set_SP);
+ _nc_unlock_global(curses);
returnVoid;
}
@@ -212,7 +213,7 @@ no_mouse_inline(SCREEN *sp GCC_UNUSED)
}
static bool
-no_mouse_parse(int code GCC_UNUSED)
+no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED)
{
return TRUE;
}
@@ -321,11 +322,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#if NCURSES_NO_PADDING
- SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
- TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
- SP->_no_padding ? " not" : ""));
-#endif
+ SetNoPadding(SP);
#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
@@ -362,11 +359,10 @@ _nc_setupscreen(int slines GCC_UNUSED,
* Allow those assumed/default color assumptions to be overridden at
* runtime:
*/
- if (getenv("NCURSES_ASSUMED_COLORS") != 0) {
- char *p = getenv("NCURSES_ASSUMED_COLORS");
+ if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
int fg, bg;
char sep1, sep2;
- int count = sscanf(p, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+ int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
if (count >= 1) {
SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
if (count >= 3) {
@@ -422,11 +418,6 @@ _nc_setupscreen(int slines GCC_UNUSED,
SP->_mouse_wrap = no_mouse_wrap;
SP->_mouse_fd = -1;
- /* initialize the panel hooks */
- SP->_panelHook.top_panel = (struct panel *) 0;
- SP->_panelHook.bottom_panel = (struct panel *) 0;
- SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
-
/*
* If we've no magic cookie support, we suppress attributes that xmc would
* affect, i.e., the attributes that affect the rendition of a space.
@@ -515,7 +506,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
/* initialize normal acs before wide, since we use mapping in the latter */
#if !USE_WIDEC_SUPPORT
- if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
+ if (_nc_unicode_locale() && _nc_locale_breaks_acs(cur_term)) {
acs_chars = NULL;
ena_acs = NULL;
enter_alt_charset_mode = NULL;
@@ -527,7 +518,8 @@ _nc_setupscreen(int slines GCC_UNUSED,
#if USE_WIDEC_SUPPORT
_nc_init_wacs();
- SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
+ SP->_screen_acs_fix = (_nc_unicode_locale()
+ && _nc_locale_breaks_acs(cur_term));
#endif
env = _nc_get_locale();
SP->_legacy_coding = ((env == 0)
diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c
index 27b21b08d718..662f7e45b116 100644
--- a/ncurses/base/lib_slk.c
+++ b/ncurses/base/lib_slk.c
@@ -45,32 +45,7 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $")
-
-/*
- * We'd like to move these into the screen context structure, but cannot,
- * because slk_init() is called before initscr()/newterm().
- */
-NCURSES_EXPORT_VAR(int)
-_nc_slk_format = 0; /* one more than format specified in slk_init() */
-
-/*
- * Paint the info line for the PC style SLK emulation.
- */
-static void
-slk_paint_info(WINDOW *win)
-{
- if (win && SP->slk_format == 4) {
- int i;
-
- mvwhline(win, 0, 0, 0, getmaxx(win));
- wmove(win, 0, 0);
-
- for (i = 0; i < SP->_slk->maxlab; i++) {
- mvwprintw(win, 0, SP->_slk->ent[i].ent_x, "F%d", i + 1);
- }
- }
-}
+MODULE_ID("$Id: lib_slk.c,v 1.35 2008/09/27 14:07:33 juergen Exp $")
/*
* Free any memory related to soft labels, return an error.
@@ -145,7 +120,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
memset(SP->_slk->ent[i].form_text, 0, used);
memset(SP->_slk->ent[i].form_text, ' ', max_length);
- SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
+ SP->_slk->ent[i].visible = (char) (i < SP->_slk->maxlab);
}
if (_nc_globals.slk_format >= 3) { /* PC style */
int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
@@ -158,7 +133,6 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
x += max_length;
x += (i == 3 || i == 7) ? gap : 1;
}
- slk_paint_info(stwin);
} else {
if (_nc_globals.slk_format == 2) { /* 4-4 */
int gap = cols - (SP->_slk->maxlab * max_length) - 6;
@@ -212,8 +186,6 @@ slk_restore(void)
return (ERR);
SP->_slk->hidden = FALSE;
SP->_slk->dirty = TRUE;
- /* we have to repaint info line eventually */
- slk_paint_info(SP->_slk->win);
returnCode(slk_refresh());
}
diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c
index c8ca28b9dd84..cb1beba0e2a1 100644
--- a/ncurses/base/lib_slkrefr.c
+++ b/ncurses/base/lib_slkrefr.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 *
@@ -40,7 +40,27 @@
#include <curses.priv.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.17 2008/09/27 14:07:53 juergen Exp $")
+
+/*
+ * Paint the info line for the PC style SLK emulation.
+ */
+static void
+slk_paint_info(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+
+ if (win && sp && (sp->slk_format == 4)) {
+ int i;
+
+ mvwhline(win, 0, 0, 0, getmaxx(win));
+ wmove(win, 0, 0);
+
+ for (i = 0; i < sp->_slk->maxlab; i++) {
+ mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
+ }
+ }
+}
/*
* Write the soft labels to the soft-key window.
@@ -60,8 +80,10 @@ slk_intern_refresh(SLK * slk)
putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text));
}
} else {
+ if (fmt == 4)
+ slk_paint_info(slk->win);
wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
- if (SP && SP->_slk) {
+ if (SP->_slk) {
wattrset(slk->win, AttrOf(SP->_slk->attr));
}
waddstr(slk->win, slk->ent[i].form_text);
diff --git a/ncurses/base/lib_ungetch.c b/ncurses/base/lib_ungetch.c
index 2eda99017bed..8742f867fa94 100644
--- a/ncurses/base/lib_ungetch.c
+++ b/ncurses/base/lib_ungetch.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ungetch.c,v 1.10 2008/05/03 20:20:58 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.11 2008/05/31 16:44:54 tom Exp $")
#include <fifo_defs.h>
@@ -52,7 +52,7 @@ _nc_fifo_dump(SCREEN *sp)
int i;
T(("head = %d, tail = %d, peek = %d", head, tail, peek));
for (i = 0; i < 10; i++)
- T(("char %d = %s", i, _tracechar(sp->_fifo[i])));
+ T(("char %d = %s", i, _nc_tracechar(sp, sp->_fifo[i])));
}
#endif /* TRACE */
@@ -70,7 +70,7 @@ _nc_ungetch(SCREEN *sp, int ch)
h_dec();
sp->_fifo[head] = ch;
- T(("ungetch %s ok", _tracechar(ch)));
+ T(("ungetch %s ok", _nc_tracechar(sp, ch)));
#ifdef TRACE
if (USE_TRACEF(TRACE_IEVENT)) {
_nc_fifo_dump(sp);
@@ -85,6 +85,6 @@ _nc_ungetch(SCREEN *sp, int ch)
NCURSES_EXPORT(int)
ungetch(int ch)
{
- T((T_CALLED("ungetch(%s)"), _tracechar(ch)));
+ T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP, ch)));
returnCode(_nc_ungetch(SP, ch));
}
diff --git a/ncurses/base/lib_window.c b/ncurses/base/lib_window.c
index ac61cb01da99..a3236e206a37 100644
--- a/ncurses/base/lib_window.c
+++ b/ncurses/base/lib_window.c
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_window.c,v 1.24 2008/04/12 22:40:21 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.25 2008/06/07 14:12:56 tom Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -186,7 +186,7 @@ dupwin(WINDOW *win)
if (win != 0) {
- _nc_lock_window(win);
+ _nc_lock_global(curses);
if (win->_flags & _ISPAD) {
nwin = newpad(win->_maxy + 1,
win->_maxx + 1);
@@ -244,7 +244,7 @@ dupwin(WINDOW *win)
nwin->_line[i].lastchar = win->_line[i].lastchar;
}
}
- _nc_unlock_window(win);
+ _nc_unlock_global(curses);
}
returnWin(nwin);
}
diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c
index cf2c998e239f..a94cfc3aaaa8 100644
--- a/ncurses/base/resizeterm.c
+++ b/ncurses/base/resizeterm.c
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.32 2008/05/03 14:28:55 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.34 2008/06/07 13:58:40 tom Exp $")
#define stolen_lines (screen_lines - SP->_lines_avail)
@@ -66,7 +66,7 @@ show_window_sizes(const char *name)
{
WINDOWLIST *wp;
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
_tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
screen_lines, screen_columns);
for (each_window(wp)) {
@@ -77,7 +77,7 @@ show_window_sizes(const char *name)
(long) wp->win._begy,
(long) wp->win._begx);
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
#endif
@@ -320,7 +320,7 @@ resize_term(int ToLines, int ToCols)
returnCode(ERR);
}
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
was_stolen = (screen_lines - SP->_lines_avail);
if (is_term_resized(ToLines, ToCols)) {
@@ -378,7 +378,7 @@ resize_term(int ToLines, int ToCols)
SET_LINES(ToLines - was_stolen);
SET_COLS(ToCols);
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
returnCode(result);
}
@@ -418,7 +418,7 @@ resizeterm(int ToLines, int ToCols)
result = resize_term(ToLines, ToCols);
#if USE_SIGWINCH
- ungetch(KEY_RESIZE); /* so application can know this */
+ _nc_ungetch(SP, KEY_RESIZE); /* so application can know this */
clearok(curscr, TRUE); /* screen contents are unknown */
/* ripped-off lines are a special case: if we did not lengthen
diff --git a/ncurses/base/tries.c b/ncurses/base/tries.c
index 983a75ae7882..c4263c7e50eb 100644
--- a/ncurses/base/tries.c
+++ b/ncurses/base/tries.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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: tries.c,v 1.25 2007/09/29 20:37:13 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.27 2008/08/16 19:22:55 tom Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
@@ -68,11 +68,11 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
}
}
if (result != 0) {
- if (ptr != 0 && (result[len] = ptr->ch) == 0)
+ if (ptr != 0 && (result[len] = (char) ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
- _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
+ _tracef("expand_key %s %s", _nc_tracechar(SP, code), _nc_visbuf(result));
_nc_unlock_global(tracef);
}
#endif
diff --git a/ncurses/base/use_window.c b/ncurses/base/use_window.c
index 4d0fdf6705be..f6408c37928e 100644
--- a/ncurses/base/use_window.c
+++ b/ncurses/base/use_window.c
@@ -32,37 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: use_window.c,v 1.7 2008/05/03 14:09:38 tom Exp $")
-
-#ifdef USE_PTHREADS
-NCURSES_EXPORT(void)
-_nc_lock_window(const WINDOW *win)
-{
- WINDOWLIST *p;
-
- _nc_lock_global(windowlist);
- for (each_window(p)) {
- if (&(p->win) == win) {
- _nc_mutex_lock(&(p->mutex_use_window));
- break;
- }
- }
-}
-
-NCURSES_EXPORT(void)
-_nc_unlock_window(const WINDOW *win)
-{
- WINDOWLIST *p;
-
- for (each_window(p)) {
- if (&(p->win) == win) {
- _nc_mutex_unlock(&(p->mutex_use_window));
- break;
- }
- }
- _nc_unlock_global(windowlist);
-}
-#endif
+MODULE_ID("$Id: use_window.c,v 1.8 2008/06/07 14:13:46 tom Exp $")
NCURSES_EXPORT(int)
use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
@@ -70,9 +40,9 @@ use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
int code = OK;
T((T_CALLED("use_window(%p,%p,%p)"), win, func, data));
- _nc_lock_window(win);
+ _nc_lock_global(curses);
code = func(win, data);
- _nc_unlock_window(win);
+ _nc_unlock_global(curses);
returnCode(code);
}
diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c
index ac808c4d2884..f46085af59fa 100644
--- a/ncurses/base/wresize.c
+++ b/ncurses/base/wresize.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.28 2008/05/03 14:13:51 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.29 2008/06/07 13:59:01 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
@@ -54,7 +54,7 @@ repair_subwindows(WINDOW *cmp)
struct ldat *pline = cmp->_line;
int row;
- _nc_lock_global(windowlist);
+ _nc_lock_global(curses);
for (each_window(wp)) {
WINDOW *tst = &(wp->win);
@@ -77,7 +77,7 @@ repair_subwindows(WINDOW *cmp)
repair_subwindows(tst);
}
}
- _nc_unlock_global(windowlist);
+ _nc_unlock_global(curses);
}
/*
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h
index 422c74cb2a3f..29e131953415 100644
--- a/ncurses/curses.priv.h
+++ b/ncurses/curses.priv.h
@@ -34,7 +34,7 @@
/*
- * $Id: curses.priv.h,v 1.373 2008/05/03 23:30:35 tom Exp $
+ * $Id: curses.priv.h,v 1.394 2008/10/04 21:37:45 tom Exp $
*
* curses.priv.h
*
@@ -147,7 +147,7 @@ extern int errno;
#define HAVE_SIZECHANGE 0
#endif
-#if HAVE_SIZECHANGE && defined(SIGWINCH)
+#if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH)
#define USE_SIZECHANGE 1
#else
#define USE_SIZECHANGE 0
@@ -286,6 +286,15 @@ color_t;
#define VIDATTR(attr, pair) vidattr(attr)
#endif
+#if NCURSES_NO_PADDING
+#define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding)
+#define SetNoPadding(sp) _nc_set_no_padding(sp)
+extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *);
+#else
+#define GetNoPadding(sp) FALSE
+#define SetNoPadding(sp) /*nothing*/
+#endif
+
#define WINDOW_ATTRS(w) ((w)->_attrs)
#define SCREEN_ATTRS(s) (*((s)->_current_attr))
@@ -293,9 +302,15 @@ color_t;
#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
#if USE_REENTRANT
-#define SET_LINES(value) SP->_LINES = value
-#define SET_COLS(value) SP->_COLS = value
+NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
+NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
+#define ptrLines() (SP ? &(SP->_LINES) : &(_nc_prescreen._LINES))
+#define ptrCols() (SP ? &(SP->_COLS) : &(_nc_prescreen._COLS))
+#define SET_LINES(value) *_nc_ptr_Lines() = value
+#define SET_COLS(value) *_nc_ptr_Cols() = value
#else
+#define ptrLines() &LINES
+#define ptrCols() &COLS
#define SET_LINES(value) LINES = value
#define SET_COLS(value) COLS = value
#endif
@@ -315,6 +330,7 @@ color_t;
#if USE_REENTRANT
#include <pthread.h>
+extern NCURSES_EXPORT(void) _nc_init_pthreads(void);
extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *);
extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *);
extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *);
@@ -323,13 +339,40 @@ extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
#define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name)
#define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name)
-extern NCURSES_EXPORT(void) _nc_lock_window(const WINDOW *);
-extern NCURSES_EXPORT(void) _nc_unlock_window(const WINDOW *);
-
#else
#error POSIX threads requires --enable-reentrant option
#endif
+#if USE_WEAK_SYMBOLS
+#if defined(__GNUC__)
+# if defined __USE_ISOC99
+# define _cat_pragma(exp) _Pragma(#exp)
+# define _weak_pragma(exp) _cat_pragma(weak name)
+# else
+# define _weak_pragma(exp)
+# endif
+# define _declare(name) __extension__ extern __typeof__(name) name
+# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak))
+#endif
+#endif
+
+#ifdef USE_PTHREADS
+# if USE_WEAK_SYMBOLS
+weak_symbol(pthread_sigmask);
+weak_symbol(pthread_self);
+weak_symbol(pthread_equal);
+weak_symbol(pthread_mutex_init);
+weak_symbol(pthread_mutex_lock);
+weak_symbol(pthread_mutex_unlock);
+weak_symbol(pthread_mutex_trylock);
+weak_symbol(pthread_mutexattr_settype);
+weak_symbol(pthread_mutexattr_init);
+extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
+# undef sigprocmask
+# define sigprocmask _nc_sigprocmask
+# endif
+#endif
+
#if HAVE_NANOSLEEP
#undef HAVE_NANOSLEEP
#define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */
@@ -337,15 +380,13 @@ extern NCURSES_EXPORT(void) _nc_unlock_window(const WINDOW *);
#else /* !USE_PTHREADS */
+#define _nc_init_pthreads() /* nothing */
#define _nc_mutex_init(obj) /* nothing */
#define _nc_lock_global(name) /* nothing */
#define _nc_try_global(name) 0
#define _nc_unlock_global(name) /* nothing */
-#define _nc_lock_window(name) (void) TRUE
-#define _nc_unlock_window(name) /* nothing */
-
#endif /* USE_PTHREADS */
#if HAVE_GETTIMEOFDAY
@@ -597,8 +638,6 @@ typedef struct {
char *tracedmp_buf;
size_t tracedmp_used;
- char tracemse_buf[TRACEMSE_MAX];
-
unsigned char *tracetry_buf;
size_t tracetry_used;
@@ -609,13 +648,12 @@ typedef struct {
#endif /* TRACE */
#ifdef USE_PTHREADS
- pthread_mutex_t mutex_set_SP;
- pthread_mutex_t mutex_use_screen;
- pthread_mutex_t mutex_use_window;
- pthread_mutex_t mutex_windowlist;
- pthread_mutex_t mutex_tst_tracef;
- pthread_mutex_t mutex_tracef;
- int nested_tracef;
+ pthread_mutex_t mutex_curses;
+ pthread_mutex_t mutex_tst_tracef;
+ pthread_mutex_t mutex_tracef;
+ int nested_tracef;
+ int use_pthreads;
+#define _nc_use_pthreads _nc_globals.use_pthreads
#endif
} NCURSES_GLOBALS;
@@ -635,10 +673,14 @@ typedef struct {
ripoff_t *rsp;
TPARM_STATE tparm_state;
TTY *saved_tty; /* savetty/resetty information */
+#if NCURSES_NO_PADDING
+ bool _no_padding; /* flag to set if padding disabled */
+#endif
#if BROKEN_LINKER || USE_REENTRANT
chtype *real_acs_map;
int _LINES;
int _COLS;
+ TERMINAL *_cur_term;
#ifdef TRACE
long _outchars;
const char *_tputs_trace;
@@ -704,7 +746,7 @@ struct screen {
int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
#if NCURSES_NO_PADDING
- int _no_padding; /* flag to set if padding disabled */
+ bool _no_padding; /* flag to set if padding disabled */
#endif
int _char_padding; /* cost of character put */
int _cr_cost; /* cost of (carriage_return) */
@@ -789,7 +831,7 @@ struct screen {
int _maxclick;
bool (*_mouse_event) (SCREEN *);
bool (*_mouse_inline)(SCREEN *);
- bool (*_mouse_parse) (int);
+ bool (*_mouse_parse) (SCREEN *, int);
void (*_mouse_resume)(SCREEN *);
void (*_mouse_wrap) (SCREEN *);
int _mouse_fd; /* file-descriptor, if any */
@@ -803,6 +845,7 @@ struct screen {
bool _mouse_gpm_loaded;
bool _mouse_gpm_found;
#ifdef HAVE_LIBDL
+ void *_dlopen_gpm;
TYPE_gpm_fd _mouse_gpm_fd;
TYPE_Gpm_Open _mouse_Gpm_Open;
TYPE_Gpm_Close _mouse_Gpm_Close;
@@ -867,6 +910,11 @@ struct screen {
const char *_tputs_trace;
#endif
#endif
+
+#ifdef TRACE
+ char tracechr_buf[40];
+ char tracemse_buf[TRACEMSE_MAX];
+#endif
/*
* ncurses/ncursesw are the same up to this point.
*/
@@ -882,17 +930,15 @@ extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
WINDOWLIST {
- WINDOW win; /* first, so WINDOW_EXT() works */
+ WINDOW win; /* first, so WINDOW_EXT() works */
WINDOWLIST *next;
+ SCREEN *screen; /* screen containing the window */
#ifdef _XOPEN_SOURCE_EXTENDED
char addch_work[(MB_LEN_MAX * 9) + 1];
unsigned addch_used; /* number of bytes in addch_work[] */
int addch_x; /* x-position for addch_work[] */
int addch_y; /* y-position for addch_work[] */
#endif
-#ifdef USE_PTHREADS
- pthread_mutex_t mutex_use_window;
-#endif
};
#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
@@ -1296,7 +1342,7 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
-#define empty_module(name) \
+#define EMPTY_MODULE(name) \
extern NCURSES_EXPORT(void) name (void); \
NCURSES_EXPORT(void) name (void) { }
@@ -1396,6 +1442,10 @@ extern NCURSES_EXPORT(void) _nc_expanded (void);
#endif
+#if !NCURSES_EXT_FUNCS
+#define set_escdelay(value) ESCDELAY = value
+#endif
+
#if !HAVE_GETCWD
#define getcwd(buf,len) getwd(buf)
#endif
@@ -1478,7 +1528,7 @@ extern NCURSES_EXPORT(int) _nc_has_mouse (void);
/* lib_setup.c */
extern NCURSES_EXPORT(char *) _nc_get_locale(void);
extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
-extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
+extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
@@ -1526,10 +1576,15 @@ extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned);
extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
/* elsewhere ... */
-extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry(ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
+extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
+extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
+extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
@@ -1539,10 +1594,11 @@ extern NCURSES_EXPORT(int) _nc_ospeed (int);
extern NCURSES_EXPORT(int) _nc_outch (int);
extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
-extern NCURSES_EXPORT(int) _nc_timed_wait(SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
extern NCURSES_EXPORT(void) _nc_flush (void);
-extern NCURSES_EXPORT(void) _nc_free_entry(ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_free_and_exit (int);
+extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *);
extern NCURSES_EXPORT(void) _nc_freeall (void);
extern NCURSES_EXPORT(void) _nc_hash_map (void);
extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
diff --git a/ncurses/fifo_defs.h b/ncurses/fifo_defs.h
index 9655b417d6e7..fa9ae2264635 100644
--- a/ncurses/fifo_defs.h
+++ b/ncurses/fifo_defs.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,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 *
@@ -34,7 +34,7 @@
/*
* Common macros for lib_getch.c, lib_ungetch.c
*
- * $Id: fifo_defs.h,v 1.5 2008/05/03 20:08:16 tom Exp $
+ * $Id: fifo_defs.h,v 1.6 2008/06/28 15:52:32 tom Exp $
*/
#ifndef FIFO_DEFS_H
diff --git a/ncurses/llib-lncurses b/ncurses/llib-lncurses
index bca3288b9df8..cc0e3667e681 100644
--- a/ncurses/llib-lncurses
+++ b/ncurses/llib-lncurses
@@ -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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996-2007 *
+ * Author: Thomas E. Dickey 1996-2008 *
****************************************************************************/
/* LINTLIBRARY */
@@ -1128,7 +1128,7 @@ int wgetscrreg(
NCURSES_BOOL mouse_trafo(
int *a1,
int *a2,
- NCURSES_BOOL z)
+ NCURSES_BOOL z)
{ return(*(NCURSES_BOOL *)0); }
/* ./base/lib_getch.c */
@@ -1138,6 +1138,11 @@ NCURSES_BOOL mouse_trafo(
#undef ESCDELAY
int ESCDELAY;
+#undef set_escdelay
+int set_escdelay(
+ int value)
+ { return(*(int *)0); }
+
#undef _nc_wgetch
int _nc_wgetch(
WINDOW *win,
@@ -1395,6 +1400,11 @@ WINDOW *_nc_makenew(
int flags)
{ return(*(WINDOW **)0); }
+#undef _nc_screen_of
+SCREEN *_nc_screen_of(
+ WINDOW *win)
+ { return(*(SCREEN **)0); }
+
/* ./base/lib_nl.c */
#undef nl
@@ -1691,9 +1701,6 @@ int ripoffline(
/* ./base/lib_slk.c */
-#undef _nc_slk_format
-int _nc_slk_format;
-
#undef _nc_slk_initialize
int _nc_slk_initialize(
WINDOW *stwin,
@@ -1823,6 +1830,12 @@ void _tracedump(
/* ./trace/lib_tracemse.c */
+#undef _nc_tracemouse
+char *_nc_tracemouse(
+ SCREEN *sp,
+ MEVENT const *ep)
+ { return(*(char **)0); }
+
#undef _tracemouse
char *_tracemouse(
MEVENT const *ep)
@@ -1840,9 +1853,16 @@ void _nc_signal_handler(
/* ./base/lib_ungetch.c */
#undef _nc_fifo_dump
-void _nc_fifo_dump(void)
+void _nc_fifo_dump(
+ SCREEN *sp)
{ /* void */ }
+#undef _nc_ungetch
+int _nc_ungetch(
+ SCREEN *sp,
+ int ch)
+ { return(*(int *)0); }
+
#undef ungetch
int ungetch(
int ch)
@@ -2020,6 +2040,11 @@ void _nc_vsscanf(void)
void _nc_freeall(void)
{ /* void */ }
+#undef _nc_free_and_exit
+void _nc_free_and_exit(
+ int code)
+ { /* void */ }
+
/* ./expanded.c */
#undef _nc_toggle_attr_on
@@ -2103,6 +2128,24 @@ void _nc_trace_xnames(
TERMTYPE *tp)
{ /* void */ }
+/* ./tinfo/use_screen.c */
+
+#undef use_screen
+int use_screen(
+ SCREEN *screen,
+ NCURSES_SCREEN_CB func,
+ void *data)
+ { return(*(int *)0); }
+
+/* ./base/use_window.c */
+
+#undef use_window
+int use_window(
+ WINDOW *win,
+ NCURSES_WINDOW_CB func,
+ void *data)
+ { return(*(int *)0); }
+
/* ./base/wresize.c */
#undef wresize
@@ -2345,7 +2388,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
#endif
#undef _nc_init_keytry
-void _nc_init_keytry(void)
+void _nc_init_keytry(
+ SCREEN *sp)
{ /* void */ }
/* ./tinfo/lib_acs.c */
@@ -2440,6 +2484,12 @@ int flushinp(void)
struct kn { short offset; int code; };
+#undef _nc_keyname
+char *_nc_keyname(
+ SCREEN *sp,
+ int c)
+ { return(*(char **)0); }
+
#undef keyname
char *keyname(
int c)
@@ -2526,6 +2576,7 @@ int has_key(
#undef _nc_keypad
int _nc_keypad(
+ SCREEN *sp,
NCURSES_BOOL flag)
{ return(*(int *)0); }
@@ -2576,9 +2627,14 @@ int COLS;
#undef TABSIZE
int TABSIZE;
+#undef set_tabsize
+int set_tabsize(
+ int value)
+ { return(*(int *)0); }
+
#undef _nc_handle_sigwinch
int _nc_handle_sigwinch(
- int update)
+ SCREEN *sp)
{ return(*(int *)0); }
#undef use_env
@@ -2588,12 +2644,14 @@ void use_env(
#undef _nc_get_screensize
void _nc_get_screensize(
+ SCREEN *sp,
int *linep,
int *colp)
{ /* void */ }
#undef _nc_update_screensize
-void _nc_update_screensize(void)
+void _nc_update_screensize(
+ SCREEN *sp)
{ /* void */ }
#undef _nc_get_locale
@@ -2605,7 +2663,8 @@ int _nc_unicode_locale(void)
{ return(*(int *)0); }
#undef _nc_locale_breaks_acs
-int _nc_locale_breaks_acs(void)
+int _nc_locale_breaks_acs(
+ TERMINAL *termp)
{ return(*(int *)0); }
#undef _nc_setupterm
@@ -2717,6 +2776,11 @@ NCURSES_OSPEED ospeed;
#undef _nc_nulls_sent
int _nc_nulls_sent;
+#undef _nc_set_no_padding
+void _nc_set_no_padding(
+ SCREEN *sp)
+ { /* void */ }
+
#undef delay_output
int delay_output(
int ms)
@@ -2867,6 +2931,12 @@ char *_nc_tracebits(void)
/* ./trace/lib_tracechr.c */
+#undef _nc_tracechar
+char *_nc_tracechar(
+ SCREEN *sp,
+ int ch)
+ { return(*(char **)0); }
+
#undef _tracechar
char *_tracechar(
int ch)
@@ -2912,6 +2982,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
+ SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
@@ -3073,9 +3144,15 @@ char *_nc_trim_sgr0(
/* ./unctrl.c */
+#undef _nc_unctrl
+char *_nc_unctrl(
+ SCREEN *sp,
+ chtype ch)
+ { return(*(char **)0); }
+
#undef unctrl
char *unctrl(
- chtype ch)
+ chtype ch)
{ return(*(char **)0); }
/* ./trace/visbuf.c */
diff --git a/ncurses/llib-lncursest b/ncurses/llib-lncursest
index 48acb8c51fa4..d29ef60d561b 100644
--- a/ncurses/llib-lncursest
+++ b/ncurses/llib-lncursest
@@ -926,7 +926,7 @@ int vw_printw(
#undef vw_scanw
int vw_scanw(
WINDOW *a1,
- const char *a2,
+ char *a2,
va_list z)
{ return(*(int *)0); }
@@ -1131,7 +1131,7 @@ int wgetscrreg(
NCURSES_BOOL mouse_trafo(
int *a1,
int *a2,
- NCURSES_BOOL z)
+ NCURSES_BOOL z)
{ return(*(NCURSES_BOOL *)0); }
/* ./base/lib_getch.c */
@@ -1357,7 +1357,7 @@ void nofilter(void)
#undef newterm
SCREEN *newterm(
- const char *name,
+ char *name,
FILE *ofp,
FILE *ifp)
{ return(*(SCREEN **)0); }
@@ -1404,6 +1404,11 @@ WINDOW *_nc_makenew(
int flags)
{ return(*(WINDOW **)0); }
+#undef _nc_screen_of
+SCREEN *_nc_screen_of(
+ WINDOW *win)
+ { return(*(SCREEN **)0); }
+
/* ./base/lib_nl.c */
#undef nl
@@ -1550,7 +1555,7 @@ int wnoutrefresh(
#undef restartterm
int restartterm(
- const char *termp,
+ char *termp,
int filenum,
int *errret)
{ return(*(int *)0); }
@@ -1560,20 +1565,20 @@ int restartterm(
#undef vwscanw
int vwscanw(
WINDOW *win,
- const char *fmt,
+ char *fmt,
va_list argp)
{ return(*(int *)0); }
#undef scanw
int scanw(
- const char *fmt,
+ char *fmt,
...)
{ return(*(int *)0); }
#undef wscanw
int wscanw(
WINDOW *win,
- const char *fmt,
+ char *fmt,
...)
{ return(*(int *)0); }
@@ -1581,7 +1586,7 @@ int wscanw(
int mvscanw(
int y,
int x,
- const char *fmt,
+ char *fmt,
...)
{ return(*(int *)0); }
@@ -1590,7 +1595,7 @@ int mvwscanw(
WINDOW *win,
int y,
int x,
- const char *fmt,
+ char *fmt,
...)
{ return(*(int *)0); }
@@ -1700,9 +1705,6 @@ int ripoffline(
/* ./base/lib_slk.c */
-#undef _nc_slk_format
-int _nc_slk_format;
-
#undef _nc_slk_initialize
int _nc_slk_initialize(
WINDOW *stwin,
@@ -1832,6 +1834,12 @@ void _tracedump(
/* ./trace/lib_tracemse.c */
+#undef _nc_tracemouse
+char *_nc_tracemouse(
+ SCREEN *sp,
+ MEVENT const *ep)
+ { return(*(char **)0); }
+
#undef _tracemouse
char *_tracemouse(
MEVENT const *ep)
@@ -1849,9 +1857,16 @@ void _nc_signal_handler(
/* ./base/lib_ungetch.c */
#undef _nc_fifo_dump
-void _nc_fifo_dump(void)
+void _nc_fifo_dump(
+ SCREEN *sp)
{ /* void */ }
+#undef _nc_ungetch
+int _nc_ungetch(
+ SCREEN *sp,
+ int ch)
+ { return(*(int *)0); }
+
#undef ungetch
int ungetch(
int ch)
@@ -1992,6 +2007,11 @@ void _nc_screen_init(void)
void _nc_screen_wrap(void)
{ /* void */ }
+#undef _nc_do_xmc_glitch
+void _nc_do_xmc_glitch(
+ attr_t previous)
+ { /* void */ }
+
/* ./trace/varargs.c */
typedef enum {
@@ -2031,8 +2051,31 @@ void _nc_free_and_exit(
/* ./expanded.c */
-#undef _nc_expanded
-void _nc_expanded(void)
+#undef _nc_toggle_attr_on
+void _nc_toggle_attr_on(
+ attr_t *S,
+ attr_t at)
+ { /* void */ }
+
+#undef _nc_toggle_attr_off
+void _nc_toggle_attr_off(
+ attr_t *S,
+ attr_t at)
+ { /* void */ }
+
+#undef _nc_DelCharCost
+int _nc_DelCharCost(
+ int count)
+ { return(*(int *)0); }
+
+#undef _nc_InsCharCost
+int _nc_InsCharCost(
+ int count)
+ { return(*(int *)0); }
+
+#undef _nc_UpdateAttrs
+void _nc_UpdateAttrs(
+ chtype c)
{ /* void */ }
/* ./base/legacy_coding.c */
@@ -2094,26 +2137,16 @@ void _nc_trace_xnames(
#undef use_screen
int use_screen(
SCREEN *screen,
- NCURSES_CALLBACK func,
+ NCURSES_SCREEN_CB func,
void *data)
{ return(*(int *)0); }
/* ./base/use_window.c */
-#undef _nc_lock_window
-void _nc_lock_window(
- WINDOW *win)
- { /* void */ }
-
-#undef _nc_unlock_window
-void _nc_unlock_window(
- WINDOW *win)
- { /* void */ }
-
#undef use_window
int use_window(
WINDOW *win,
- NCURSES_CALLBACK func,
+ NCURSES_WINDOW_CB func,
void *data)
{ return(*(int *)0); }
@@ -2167,6 +2200,10 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_env_access
+int _nc_env_access(void)
+ { return(*(int *)0); }
+
/* ./tinfo/add_tries.c */
#undef _nc_add_to_try
@@ -2193,20 +2230,16 @@ void _nc_copy_termtype(
/* ./codes.c */
#undef _nc_boolcodes
-const char *const *_nc_boolcodes(void)
- { return(*(const char **)0); }
+char *const *_nc_boolcodes(void)
+ { return(*(char **)0); }
#undef _nc_numcodes
-const char *const *_nc_numcodes(void)
- { return(*(const char **)0); }
+char *const *_nc_numcodes(void)
+ { return(*(char **)0); }
#undef _nc_strcodes
-const char *const *_nc_strcodes(void)
- { return(*(const char **)0); }
-
-#undef _nc_codes_leaks
-void _nc_codes_leaks(void)
- { /* void */ }
+char *const *_nc_strcodes(void)
+ { return(*(char **)0); }
/* ./tinfo/comp_error.c */
@@ -2318,11 +2351,6 @@ ENTRY *_nc_delink_entry(
void _nc_leaks_tinfo(void)
{ /* void */ }
-#undef _nc_free_tinfo
-void _nc_free_tinfo(
- int code)
- { /* void */ }
-
/* ./fallback.c */
#undef _nc_fallback
@@ -2370,7 +2398,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
#endif
#undef _nc_init_keytry
-void _nc_init_keytry(void)
+void _nc_init_keytry(
+ SCREEN *sp)
{ /* void */ }
/* ./tinfo/lib_acs.c */
@@ -2408,8 +2437,9 @@ int baudrate(void)
/* ./tinfo/lib_cur_term.c */
-#undef cur_term
-TERMINAL *cur_term;
+#undef _nc_cur_term
+TERMINAL *_nc_cur_term(void)
+ { return(*(TERMINAL **)0); }
#undef set_curterm
TERMINAL *set_curterm(
@@ -2444,6 +2474,15 @@ NCURSES_GLOBALS _nc_globals;
#undef _nc_prescreen
NCURSES_PRESCREEN _nc_prescreen;
+#undef _nc_init_pthreads
+void _nc_init_pthreads(void)
+ { /* void */ }
+
+#undef _nc_mutex_init
+void _nc_mutex_init(
+ pthread_mutex_t *obj)
+ { /* void */ }
+
#undef _nc_mutex_lock
int _nc_mutex_lock(
pthread_mutex_t *obj)
@@ -2487,14 +2526,16 @@ int flushinp(void)
struct kn { short offset; int code; };
-#undef keyname
-const char *keyname(
+#undef _nc_keyname
+char *_nc_keyname(
+ SCREEN *sp,
int c)
- { return(*(const char **)0); }
+ { return(*(char **)0); }
-#undef _nc_keyname_leaks
-void _nc_keyname_leaks(void)
- { /* void */ }
+#undef keyname
+char *keyname(
+ int c)
+ { return(*(char **)0); }
/* ./tinfo/lib_longname.c */
@@ -2504,8 +2545,6 @@ char *longname(void)
/* ./tinfo/lib_napms.c */
-#include <time.h>
-
#undef napms
int napms(
int ms)
@@ -2577,6 +2616,7 @@ int has_key(
#undef _nc_keypad
int _nc_keypad(
+ SCREEN *sp,
NCURSES_BOOL flag)
{ return(*(int *)0); }
@@ -2622,10 +2662,18 @@ int intrflush(
char *_nc_ttytype(void)
{ return(*(char **)0); }
+#undef _nc_ptr_Lines
+int *_nc_ptr_Lines(void)
+ { return(*(int **)0); }
+
#undef _nc_LINES
int _nc_LINES(void)
{ return(*(int *)0); }
+#undef _nc_ptr_Cols
+int *_nc_ptr_Cols(void)
+ { return(*(int **)0); }
+
#undef _nc_COLS
int _nc_COLS(void)
{ return(*(int *)0); }
@@ -2641,7 +2689,7 @@ int set_tabsize(
#undef _nc_handle_sigwinch
int _nc_handle_sigwinch(
- int update)
+ SCREEN *sp)
{ return(*(int *)0); }
#undef use_env
@@ -2651,12 +2699,14 @@ void use_env(
#undef _nc_get_screensize
void _nc_get_screensize(
+ SCREEN *sp,
int *linep,
int *colp)
{ /* void */ }
#undef _nc_update_screensize
-void _nc_update_screensize(void)
+void _nc_update_screensize(
+ SCREEN *sp)
{ /* void */ }
#undef _nc_get_locale
@@ -2668,12 +2718,13 @@ int _nc_unicode_locale(void)
{ return(*(int *)0); }
#undef _nc_locale_breaks_acs
-int _nc_locale_breaks_acs(void)
+int _nc_locale_breaks_acs(
+ TERMINAL *termp)
{ return(*(int *)0); }
#undef _nc_setupterm
int _nc_setupterm(
- const char *tname,
+ char *tname,
int Filedes,
int *errret,
NCURSES_BOOL reuse)
@@ -2681,7 +2732,7 @@ int _nc_setupterm(
#undef setupterm
int setupterm(
- const char *tname,
+ char *tname,
int Filedes,
int *errret)
{ return(*(int *)0); }
@@ -2707,24 +2758,20 @@ int tgetent(
#undef tgetflag
int tgetflag(
- const char *id)
+ char *id)
{ return(*(int *)0); }
#undef tgetnum
int tgetnum(
- const char *id)
+ char *id)
{ return(*(int *)0); }
#undef tgetstr
char *tgetstr(
- const char *id,
+ char *id,
char **area)
{ return(*(char **)0); }
-#undef _nc_tgetent_leaks
-void _nc_tgetent_leaks(void)
- { /* void */ }
-
/* ./tinfo/lib_termname.c */
#undef termname
@@ -2744,17 +2791,17 @@ char *tgoto(
#undef tigetflag
int tigetflag(
- const char *str)
+ char *str)
{ return(*(int *)0); }
#undef tigetnum
int tigetnum(
- const char *str)
+ char *str)
{ return(*(int *)0); }
#undef tigetstr
char *tigetstr(
- const char *str)
+ char *str)
{ return(*(char **)0); }
/* ./tinfo/lib_tparm.c */
@@ -2762,10 +2809,6 @@ char *tigetstr(
#undef _nc_tparm_err
int _nc_tparm_err;
-#undef _nc_free_tparm
-void _nc_free_tparm(void)
- { /* void */ }
-
#undef _nc_tparm_analyze
int _nc_tparm_analyze(
const char *string,
@@ -2775,7 +2818,7 @@ int _nc_tparm_analyze(
#undef tparm
char *tparm(
- const char *string,
+ char *string,
...)
{ return(*(char **)0); }
@@ -2788,6 +2831,11 @@ NCURSES_OSPEED ospeed;
#undef _nc_nulls_sent
int _nc_nulls_sent;
+#undef _nc_set_no_padding
+void _nc_set_no_padding(
+ SCREEN *sp)
+ { /* void */ }
+
#undef delay_output
int delay_output(
int ms)
@@ -2875,9 +2923,9 @@ const char *_nc_retrace_cptr(
{ return(*(const char **)0); }
#undef _nc_retrace_cvoid_ptr
-const void *_nc_retrace_cvoid_ptr(
- const void *code)
- { return(*(const void **)0); }
+void *_nc_retrace_cvoid_ptr(
+ void *code)
+ { return(*(void **)0); }
#undef _nc_retrace_void_ptr
void *_nc_retrace_void_ptr(
@@ -2963,6 +3011,12 @@ char *_nc_tracebits(void)
/* ./trace/lib_tracechr.c */
+#undef _nc_tracechar
+char *_nc_tracechar(
+ SCREEN *sp,
+ int ch)
+ { return(*(char **)0); }
+
#undef _tracechar
char *_tracechar(
int ch)
@@ -3008,6 +3062,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
+ SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
@@ -3030,32 +3085,28 @@ int _nc_name_match(
/* ./names.c */
#undef _nc_boolnames
-const char *const *_nc_boolnames(void)
- { return(*(const char **)0); }
+char *const *_nc_boolnames(void)
+ { return(*(char **)0); }
#undef _nc_boolfnames
-const char *const *_nc_boolfnames(void)
- { return(*(const char **)0); }
+char *const *_nc_boolfnames(void)
+ { return(*(char **)0); }
#undef _nc_numnames
-const char *const *_nc_numnames(void)
- { return(*(const char **)0); }
+char *const *_nc_numnames(void)
+ { return(*(char **)0); }
#undef _nc_numfnames
-const char *const *_nc_numfnames(void)
- { return(*(const char **)0); }
+char *const *_nc_numfnames(void)
+ { return(*(char **)0); }
#undef _nc_strnames
-const char *const *_nc_strnames(void)
- { return(*(const char **)0); }
+char *const *_nc_strnames(void)
+ { return(*(char **)0); }
#undef _nc_strfnames
-const char *const *_nc_strfnames(void)
- { return(*(const char **)0); }
-
-#undef _nc_names_leaks
-void _nc_names_leaks(void)
- { /* void */ }
+char *const *_nc_strfnames(void)
+ { return(*(char **)0); }
/* ./tinfo/read_entry.c */
@@ -3085,9 +3136,11 @@ int _nc_read_entry(
#include <sys/types.h>
-#undef _nc_read_termcap
-void _nc_read_termcap(void)
- { /* void */ }
+#undef _nc_read_termcap_entry
+int _nc_read_termcap_entry(
+ const char *const tn,
+ TERMTYPE *const tp)
+ { return(*(int *)0); }
/* ./tinfo/setbuf.c */
@@ -3182,10 +3235,16 @@ char *_nc_trim_sgr0(
/* ./unctrl.c */
+#undef _nc_unctrl
+char *_nc_unctrl(
+ SCREEN *sp,
+ chtype ch)
+ { return(*(char **)0); }
+
#undef unctrl
-const char *unctrl(
- chtype ch)
- { return(*(const char **)0); }
+char *unctrl(
+ chtype ch)
+ { return(*(char **)0); }
/* ./trace/visbuf.c */
@@ -3248,10 +3307,6 @@ void _nc_merge_entry(
TERMTYPE *const from)
{ /* void */ }
-#undef _nc_alloc_entry_leaks
-void _nc_alloc_entry_leaks(void)
- { /* void */ }
-
/* ./tinfo/captoinfo.c */
#undef _nc_captoinfo
@@ -3268,10 +3323,6 @@ char *_nc_infotocap(
int const parameterized)
{ return(*(char **)0); }
-#undef _nc_captoinfo_leaks
-void _nc_captoinfo_leaks(void)
- { /* void */ }
-
/* ./comp_captab.c */
#include <hashsize.h>
@@ -3291,10 +3342,6 @@ const struct alias *_nc_get_alias_table(
NCURSES_BOOL termcap)
{ return(*(const struct alias **)0); }
-#undef _nc_comp_captab_leaks
-void _nc_comp_captab_leaks(void)
- { /* void */ }
-
/* ./tinfo/comp_expand.c */
#undef _nc_tic_expand
@@ -3356,15 +3403,6 @@ int _nc_resolve_uses(
NCURSES_BOOL fullresolve)
{ return(*(int *)0); }
-#undef _nc_leaks_tic
-void _nc_leaks_tic(void)
- { /* void */ }
-
-#undef _nc_free_tic
-void _nc_free_tic(
- int code)
- { /* void */ }
-
/* ./tinfo/comp_scan.c */
#undef _nc_syntax
@@ -3409,10 +3447,6 @@ void _nc_panic_mode(
char ch)
{ /* void */ }
-#undef _nc_comp_scan_leaks
-void _nc_comp_scan_leaks(void)
- { /* void */ }
-
/* ./tinfo/parse_entry.c */
#undef _nc_parse_entry
diff --git a/ncurses/llib-lncursesw b/ncurses/llib-lncursesw
index 12522e123c59..96e7257691d8 100644
--- a/ncurses/llib-lncursesw
+++ b/ncurses/llib-lncursesw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2005,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-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 2001-2006 *
+ * Author: Thomas E. Dickey 2001-2008 *
****************************************************************************/
/* LINTLIBRARY */
@@ -1636,7 +1636,7 @@ int wins_wstr(
NCURSES_BOOL mouse_trafo(
int *a1,
int *a2,
- NCURSES_BOOL z)
+ NCURSES_BOOL z)
{ return(*(NCURSES_BOOL *)0); }
/* ./base/lib_getch.c */
@@ -1646,6 +1646,11 @@ NCURSES_BOOL mouse_trafo(
#undef ESCDELAY
int ESCDELAY;
+#undef set_escdelay
+int set_escdelay(
+ int value)
+ { return(*(int *)0); }
+
#undef _nc_wgetch
int _nc_wgetch(
WINDOW *win,
@@ -1903,6 +1908,11 @@ WINDOW *_nc_makenew(
int flags)
{ return(*(WINDOW **)0); }
+#undef _nc_screen_of
+SCREEN *_nc_screen_of(
+ WINDOW *win)
+ { return(*(SCREEN **)0); }
+
/* ./base/lib_nl.c */
#undef nl
@@ -2199,9 +2209,6 @@ int ripoffline(
/* ./base/lib_slk.c */
-#undef _nc_slk_format
-int _nc_slk_format;
-
#undef _nc_slk_initialize
int _nc_slk_initialize(
WINDOW *stwin,
@@ -2333,6 +2340,12 @@ void _tracedump(
/* ./trace/lib_tracemse.c */
+#undef _nc_tracemouse
+char *_nc_tracemouse(
+ SCREEN *sp,
+ MEVENT const *ep)
+ { return(*(char **)0); }
+
#undef _tracemouse
char *_tracemouse(
MEVENT const *ep)
@@ -2350,9 +2363,16 @@ void _nc_signal_handler(
/* ./base/lib_ungetch.c */
#undef _nc_fifo_dump
-void _nc_fifo_dump(void)
+void _nc_fifo_dump(
+ SCREEN *sp)
{ /* void */ }
+#undef _nc_ungetch
+int _nc_ungetch(
+ SCREEN *sp,
+ int ch)
+ { return(*(int *)0); }
+
#undef ungetch
int ungetch(
int ch)
@@ -2530,6 +2550,11 @@ void _nc_vsscanf(void)
void _nc_freeall(void)
{ /* void */ }
+#undef _nc_free_and_exit
+void _nc_free_and_exit(
+ int code)
+ { /* void */ }
+
/* ./widechar/charable.c */
#undef _nc_is_charable
@@ -2849,6 +2874,24 @@ void _nc_trace_xnames(
TERMTYPE *tp)
{ /* void */ }
+/* ./tinfo/use_screen.c */
+
+#undef use_screen
+int use_screen(
+ SCREEN *screen,
+ NCURSES_SCREEN_CB func,
+ void *data)
+ { return(*(int *)0); }
+
+/* ./base/use_window.c */
+
+#undef use_window
+int use_window(
+ WINDOW *win,
+ NCURSES_WINDOW_CB func,
+ void *data)
+ { return(*(int *)0); }
+
/* ./base/wresize.c */
#undef wresize
@@ -3091,7 +3134,8 @@ const struct tinfo_fkeys _nc_tinfo_fkeys[] = {0};
#endif
#undef _nc_init_keytry
-void _nc_init_keytry(void)
+void _nc_init_keytry(
+ SCREEN *sp)
{ /* void */ }
/* ./tinfo/lib_acs.c */
@@ -3186,6 +3230,12 @@ int flushinp(void)
struct kn { short offset; int code; };
+#undef _nc_keyname
+char *_nc_keyname(
+ SCREEN *sp,
+ int c)
+ { return(*(char **)0); }
+
#undef keyname
char *keyname(
int c)
@@ -3272,6 +3322,7 @@ int has_key(
#undef _nc_keypad
int _nc_keypad(
+ SCREEN *sp,
NCURSES_BOOL flag)
{ return(*(int *)0); }
@@ -3322,9 +3373,14 @@ int COLS;
#undef TABSIZE
int TABSIZE;
+#undef set_tabsize
+int set_tabsize(
+ int value)
+ { return(*(int *)0); }
+
#undef _nc_handle_sigwinch
int _nc_handle_sigwinch(
- int update)
+ SCREEN *sp)
{ return(*(int *)0); }
#undef use_env
@@ -3334,12 +3390,14 @@ void use_env(
#undef _nc_get_screensize
void _nc_get_screensize(
+ SCREEN *sp,
int *linep,
int *colp)
{ /* void */ }
#undef _nc_update_screensize
-void _nc_update_screensize(void)
+void _nc_update_screensize(
+ SCREEN *sp)
{ /* void */ }
#undef _nc_get_locale
@@ -3351,7 +3409,8 @@ int _nc_unicode_locale(void)
{ return(*(int *)0); }
#undef _nc_locale_breaks_acs
-int _nc_locale_breaks_acs(void)
+int _nc_locale_breaks_acs(
+ TERMINAL *termp)
{ return(*(int *)0); }
#undef _nc_setupterm
@@ -3463,6 +3522,11 @@ NCURSES_OSPEED ospeed;
#undef _nc_nulls_sent
int _nc_nulls_sent;
+#undef _nc_set_no_padding
+void _nc_set_no_padding(
+ SCREEN *sp)
+ { /* void */ }
+
#undef delay_output
int delay_output(
int ms)
@@ -3624,6 +3688,12 @@ char *_nc_tracebits(void)
/* ./trace/lib_tracechr.c */
+#undef _nc_tracechar
+char *_nc_tracechar(
+ SCREEN *sp,
+ int ch)
+ { return(*(char **)0); }
+
#undef _tracechar
char *_tracechar(
int ch)
@@ -3669,6 +3739,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
+ SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
@@ -3830,9 +3901,15 @@ char *_nc_trim_sgr0(
/* ./unctrl.c */
+#undef _nc_unctrl
+char *_nc_unctrl(
+ SCREEN *sp,
+ chtype ch)
+ { return(*(char **)0); }
+
#undef unctrl
char *unctrl(
- chtype ch)
+ chtype ch)
{ return(*(char **)0); }
/* ./trace/visbuf.c */
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;
diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c
index 03acb16cba91..743b1f64f1ae 100644
--- a/ncurses/trace/lib_trace.c
+++ b/ncurses/trace/lib_trace.c
@@ -46,7 +46,7 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_trace.c,v 1.66 2008/03/22 16:56:48 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.71 2008/08/23 18:04:29 tom Exp $")
NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
@@ -95,10 +95,13 @@ trace(const unsigned int tracelevel)
const char *mode = _nc_globals.init_trace ? "ab" : "wb";
if (TracePath[0] == '\0') {
- if (getcwd(TracePath, sizeof(TracePath) - 12) == 0) {
+ int size = sizeof(TracePath) - 12;
+ if (getcwd(TracePath, size) == 0) {
perror("curses: Can't get working directory");
exit(EXIT_FAILURE);
}
+ TracePath[size] = '\0';
+ assert(strlen(TracePath) <= size);
strcat(TracePath, "/trace");
if (_nc_is_dir_path(TracePath)) {
strcat(TracePath, ".log");
@@ -177,7 +180,10 @@ _nc_va_tracef(const char *fmt, va_list ap)
* Rather than add the complication of a per-thread stack, just
* show the thread-id in each line of the trace.
*/
- fprintf(TraceFP, "%#lx:", (long) pthread_self());
+# if USE_WEAK_SYMBOLS
+ if ((pthread_self))
+# endif
+ fprintf(TraceFP, "%#lx:", (long) (void *) pthread_self());
#endif
if (before || after) {
int n;
@@ -292,9 +298,9 @@ _nc_use_tracef(unsigned mask)
_nc_lock_global(tst_tracef);
if (!_nc_globals.nested_tracef++) {
- if ((result = (_nc_tracing & (mask))) != 0) {
+ if ((result = (_nc_tracing & (mask))) != 0
+ && _nc_try_global(tracef) == 0) {
/* we will call _nc_locked_tracef(), no nesting so far */
- _nc_lock_global(tracef);
} else {
/* we will not call _nc_locked_tracef() */
_nc_globals.nested_tracef = 0;
diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c
index 108eb8b4d335..45a03cea05fe 100644
--- a/ncurses/trace/lib_traceatr.c
+++ b/ncurses/trace/lib_traceatr.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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
#include <term.h> /* acs_chars */
-MODULE_ID("$Id: lib_traceatr.c,v 1.59 2007/06/09 17:22:10 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.63 2008/08/03 16:24:53 tom Exp $")
#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
@@ -75,8 +75,6 @@ color_of(int c)
NCURSES_EXPORT(char *)
_traceattr2(int bufnum, chtype newmode)
{
- char *buf = _nc_trace_buf(bufnum, BUFSIZ);
- char temp[80];
static const struct {
unsigned int val;
const char *name;
@@ -117,47 +115,54 @@ _traceattr2(int bufnum, chtype newmode)
#endif /* !USE_TERMLIB */
;
size_t n;
- unsigned save_nc_tracing = _nc_tracing;
- _nc_tracing = 0;
+ char temp[80];
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
+
+ if (result != 0) {
+ unsigned save_nc_tracing = _nc_tracing;
- strcpy(buf, l_brace);
+ _nc_tracing = 0;
- for (n = 0; n < SIZEOF(names); n++) {
- if ((newmode & names[n].val) != 0) {
- if (buf[1] != '\0')
- buf = _nc_trace_bufcat(bufnum, "|");
- buf = _nc_trace_bufcat(bufnum, names[n].name);
+ strcpy(result, l_brace);
- if (names[n].val == A_COLOR) {
- short pairnum = PAIR_NUMBER(newmode);
+ for (n = 0; n < SIZEOF(names); n++) {
+ if ((newmode & names[n].val) != 0) {
+ if (result[1] != '\0')
+ result = _nc_trace_bufcat(bufnum, "|");
+ result = _nc_trace_bufcat(bufnum, names[n].name);
+
+ if (names[n].val == A_COLOR) {
+ short pairnum = PAIR_NUMBER(newmode);
#ifdef USE_TERMLIB
- /* pair_content lives in libncurses */
- (void) sprintf(temp, "{%d}", pairnum);
-#else
- short fg, bg;
-
- if (pair_content(pairnum, &fg, &bg) == OK) {
- (void) sprintf(temp,
- "{%d = {%s, %s}}",
- pairnum,
- COLOR_OF(fg),
- COLOR_OF(bg));
- } else {
+ /* pair_content lives in libncurses */
(void) sprintf(temp, "{%d}", pairnum);
- }
+#else
+ short fg, bg;
+
+ if (pair_content(pairnum, &fg, &bg) == OK) {
+ (void) sprintf(temp,
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg));
+ } else {
+ (void) sprintf(temp, "{%d}", pairnum);
+ }
#endif
- buf = _nc_trace_bufcat(bufnum, temp);
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
}
}
- }
- if (ChAttrOf(newmode) == A_NORMAL) {
- if (buf[1] != '\0')
- (void) _nc_trace_bufcat(bufnum, "|");
- (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
- }
+ if (ChAttrOf(newmode) == A_NORMAL) {
+ if (result != 0 && result[1] != '\0')
+ (void) _nc_trace_bufcat(bufnum, "|");
+ (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
+ }
- _nc_tracing = save_nc_tracing;
- return (_nc_trace_bufcat(bufnum, r_brace));
+ _nc_tracing = save_nc_tracing;
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
NCURSES_EXPORT(char *)
@@ -181,50 +186,48 @@ _nc_altcharset_name(attr_t attr, chtype ch)
unsigned int val;
const char *name;
} ALT_NAMES;
+ static const ALT_NAMES names[] =
+ {
+ {'l', "ACS_ULCORNER"}, /* upper left corner */
+ {'m', "ACS_LLCORNER"}, /* lower left corner */
+ {'k', "ACS_URCORNER"}, /* upper right corner */
+ {'j', "ACS_LRCORNER"}, /* lower right corner */
+ {'t', "ACS_LTEE"}, /* tee pointing right */
+ {'u', "ACS_RTEE"}, /* tee pointing left */
+ {'v', "ACS_BTEE"}, /* tee pointing up */
+ {'w', "ACS_TTEE"}, /* tee pointing down */
+ {'q', "ACS_HLINE"}, /* horizontal line */
+ {'x', "ACS_VLINE"}, /* vertical line */
+ {'n', "ACS_PLUS"}, /* large plus or crossover */
+ {'o', "ACS_S1"}, /* scan line 1 */
+ {'s', "ACS_S9"}, /* scan line 9 */
+ {'`', "ACS_DIAMOND"}, /* diamond */
+ {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
+ {'f', "ACS_DEGREE"}, /* degree symbol */
+ {'g', "ACS_PLMINUS"}, /* plus/minus */
+ {'~', "ACS_BULLET"}, /* bullet */
+ {',', "ACS_LARROW"}, /* arrow pointing left */
+ {'+', "ACS_RARROW"}, /* arrow pointing right */
+ {'.', "ACS_DARROW"}, /* arrow pointing down */
+ {'-', "ACS_UARROW"}, /* arrow pointing up */
+ {'h', "ACS_BOARD"}, /* board of squares */
+ {'i', "ACS_LANTERN"}, /* lantern symbol */
+ {'0', "ACS_BLOCK"}, /* solid square block */
+ {'p', "ACS_S3"}, /* scan line 3 */
+ {'r', "ACS_S7"}, /* scan line 7 */
+ {'y', "ACS_LEQUAL"}, /* less/equal */
+ {'z', "ACS_GEQUAL"}, /* greater/equal */
+ {'{', "ACS_PI"}, /* Pi */
+ {'|', "ACS_NEQUAL"}, /* not equal */
+ {'}', "ACS_STERLING"}, /* UK pound sign */
+ {'\0', (char *) 0}
+ };
const char *result = 0;
if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
char *cp;
char *found = 0;
- /* *INDENT-OFF* */
- static const ALT_NAMES names[] =
- {
- { 'l', "ACS_ULCORNER" }, /* upper left corner */
- { 'm', "ACS_LLCORNER" }, /* lower left corner */
- { 'k', "ACS_URCORNER" }, /* upper right corner */
- { 'j', "ACS_LRCORNER" }, /* lower right corner */
- { 't', "ACS_LTEE" }, /* tee pointing right */
- { 'u', "ACS_RTEE" }, /* tee pointing left */
- { 'v', "ACS_BTEE" }, /* tee pointing up */
- { 'w', "ACS_TTEE" }, /* tee pointing down */
- { 'q', "ACS_HLINE" }, /* horizontal line */
- { 'x', "ACS_VLINE" }, /* vertical line */
- { 'n', "ACS_PLUS" }, /* large plus or crossover */
- { 'o', "ACS_S1" }, /* scan line 1 */
- { 's', "ACS_S9" }, /* scan line 9 */
- { '`', "ACS_DIAMOND" }, /* diamond */
- { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */
- { 'f', "ACS_DEGREE" }, /* degree symbol */
- { 'g', "ACS_PLMINUS" }, /* plus/minus */
- { '~', "ACS_BULLET" }, /* bullet */
- { ',', "ACS_LARROW" }, /* arrow pointing left */
- { '+', "ACS_RARROW" }, /* arrow pointing right */
- { '.', "ACS_DARROW" }, /* arrow pointing down */
- { '-', "ACS_UARROW" }, /* arrow pointing up */
- { 'h', "ACS_BOARD" }, /* board of squares */
- { 'i', "ACS_LANTERN" }, /* lantern symbol */
- { '0', "ACS_BLOCK" }, /* solid square block */
- { 'p', "ACS_S3" }, /* scan line 3 */
- { 'r', "ACS_S7" }, /* scan line 7 */
- { 'y', "ACS_LEQUAL" }, /* less/equal */
- { 'z', "ACS_GEQUAL" }, /* greater/equal */
- { '{', "ACS_PI" }, /* Pi */
- { '|', "ACS_NEQUAL" }, /* not equal */
- { '}', "ACS_STERLING" }, /* UK pound sign */
- { '\0', (char *) 0 }
- };
- /* *INDENT-OFF* */
const ALT_NAMES *sp;
for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
@@ -250,31 +253,35 @@ NCURSES_EXPORT(char *)
_tracechtype2(int bufnum, chtype ch)
{
const char *found;
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
- strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace);
- if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
- (void) _nc_trace_bufcat(bufnum, found);
- } else
- (void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));
+ if (result != 0) {
+ strcpy(result, l_brace);
+ if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
+ } else
+ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int) ChCharOf(ch)));
- if (ChAttrOf(ch) != A_NORMAL) {
- (void) _nc_trace_bufcat(bufnum, " | ");
- (void) _nc_trace_bufcat(bufnum,
- _traceattr2(bufnum + 20, ChAttrOf(ch)));
- }
+ if (ChAttrOf(ch) != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum,
+ _traceattr2(bufnum + 20, ChAttrOf(ch)));
+ }
- return (_nc_trace_bufcat(bufnum, r_brace));
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
NCURSES_EXPORT(char *)
-_tracechtype (chtype ch)
+_tracechtype(chtype ch)
{
return _tracechtype2(0, ch);
}
/* Trace 'chtype' return-values */
NCURSES_EXPORT(chtype)
-_nc_retrace_chtype (chtype code)
+_nc_retrace_chtype(chtype code)
{
T((T_RETURN("%s"), _tracechtype(code)));
return code;
@@ -282,63 +289,70 @@ _nc_retrace_chtype (chtype code)
#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(char *)
-_tracecchar_t2 (int bufnum, const cchar_t *ch)
+_tracecchar_t2(int bufnum, const cchar_t *ch)
{
- char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
attr_t attr;
const char *found;
- strcpy(buf, l_brace);
- if (ch != 0) {
- attr = AttrOfD(ch);
- if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
- (void) _nc_trace_bufcat(bufnum, found);
- attr &= ~A_ALTCHARSET;
- } else if (isWidecExt(CHDEREF(ch))) {
- (void) _nc_trace_bufcat(bufnum, "{NAC}");
- attr &= ~A_CHARTEXT;
- } else {
- PUTC_DATA;
- int n;
-
- PUTC_INIT;
- (void) _nc_trace_bufcat(bufnum, "{ ");
- for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
- PUTC_ch = ch->chars[PUTC_i];
- if (PUTC_ch == L'\0')
- break;
- PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
- if (PUTC_n <= 0) {
- if (PUTC_ch != L'\0') {
- /* it could not be a multibyte sequence */
- (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i])));
+ if (result != 0) {
+ strcpy(result, l_brace);
+ if (ch != 0) {
+ attr = AttrOfD(ch);
+ if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
+ } else if (isWidecExt(CHDEREF(ch))) {
+ (void) _nc_trace_bufcat(bufnum, "{NAC}");
+ attr &= ~A_CHARTEXT;
+ } else {
+ PUTC_DATA;
+ int n;
+
+ PUTC_INIT;
+ (void) _nc_trace_bufcat(bufnum, "{ ");
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ PUTC_ch = ch->chars[PUTC_i];
+ if (PUTC_ch == L'\0')
+ break;
+ PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+ if (PUTC_n <= 0) {
+ if (PUTC_ch != L'\0') {
+ /* it could not be a multibyte sequence */
+ (void) _nc_trace_bufcat(bufnum,
+ _nc_tracechar(SP,
+ UChar(ch->chars[PUTC_i])));
+ }
+ break;
+ }
+ for (n = 0; n < PUTC_n; n++) {
+ if (n)
+ (void) _nc_trace_bufcat(bufnum, ", ");
+ (void) _nc_trace_bufcat(bufnum,
+ _nc_tracechar(SP,
+ UChar(PUTC_buf[n])));
}
- break;
- }
- for (n = 0; n < PUTC_n; n++) {
- if (n)
- (void) _nc_trace_bufcat(bufnum, ", ");
- (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n])));
}
+ (void) _nc_trace_bufcat(bufnum, " }");
+ }
+ if (attr != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
}
- (void) _nc_trace_bufcat(bufnum, " }");
- }
- if (attr != A_NORMAL) {
- (void) _nc_trace_bufcat(bufnum, " | ");
- (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
}
- }
- return (_nc_trace_bufcat(bufnum, r_brace));
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
NCURSES_EXPORT(char *)
-_tracecchar_t (const cchar_t *ch)
+_tracecchar_t(const cchar_t *ch)
{
return _tracecchar_t2(0, ch);
}
#endif
#else
-empty_module(_nc_lib_traceatr)
+EMPTY_MODULE(_nc_lib_traceatr)
#endif /* TRACE */
diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c
index de2394c39225..cc441b391e5b 100644
--- a/ncurses/trace/lib_tracebits.c
+++ b/ncurses/trace/lib_tracebits.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> /* cur_term */
-MODULE_ID("$Id: lib_tracebits.c,v 1.15 2007/06/30 16:14:20 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.17 2008/08/03 16:09:26 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -165,58 +165,52 @@ _nc_trace_ttymode(TTY * tty)
8 + sizeof(cflags) +
8 + sizeof(lflags) +
8);
+ if (buf != 0) {
- if (tty->c_iflag & ALLIN)
- lookup_bits(buf, iflags, "iflags", tty->c_iflag);
+ if (tty->c_iflag & ALLIN)
+ lookup_bits(buf, iflags, "iflags", tty->c_iflag);
- if (tty->c_oflag & ALLOUT)
- lookup_bits(buf, oflags, "oflags", tty->c_oflag);
+ if (tty->c_oflag & ALLOUT)
+ lookup_bits(buf, oflags, "oflags", tty->c_oflag);
- if (tty->c_cflag & ALLCTRL)
- lookup_bits(buf, cflags, "cflags", tty->c_cflag);
+ if (tty->c_cflag & ALLCTRL)
+ lookup_bits(buf, cflags, "cflags", tty->c_cflag);
#if defined(CS5) && defined(CS8)
- {
- static struct {
- const char *name;
- int value;
- } csizes[] = {
- {
- "CS5 ", CS5
- },
+ {
+ static struct {
+ int value;
+ const char *name;
+ } csizes[] = {
+#define CS_DATA(name) { name, #name " " }
+ CS_DATA(CS5),
#ifdef CS6
- {
- "CS6 ", CS6
- },
+ CS_DATA(CS6),
#endif
#ifdef CS7
- {
- "CS7 ", CS7
- },
+ CS_DATA(CS7),
#endif
- {
- "CS8 ", CS8
- },
- };
- const char *result = "CSIZE? ";
- int value = (tty->c_cflag & CSIZE);
- unsigned n;
+ CS_DATA(CS8),
+ };
+ const char *result = "CSIZE? ";
+ int value = (tty->c_cflag & CSIZE);
+ unsigned n;
- if (value != 0) {
- for (n = 0; n < SIZEOF(csizes); n++) {
- if (csizes[n].value == value) {
- result = csizes[n].name;
- break;
+ if (value != 0) {
+ for (n = 0; n < SIZEOF(csizes); n++) {
+ if (csizes[n].value == value) {
+ result = csizes[n].name;
+ break;
+ }
}
}
+ strcat(buf, result);
}
- strcat(buf, result);
- }
#endif
- if (tty->c_lflag & ALLLOCAL)
- lookup_bits(buf, lflags, "lflags", tty->c_lflag);
-
+ if (tty->c_lflag & ALLLOCAL)
+ lookup_bits(buf, lflags, "lflags", tty->c_lflag);
+ }
#else
/* reference: ttcompat(4M) on SunOS 4.1 */
#ifndef EVENP
@@ -253,9 +247,10 @@ _nc_trace_ttymode(TTY * tty)
buf = _nc_trace_buf(0,
8 + sizeof(cflags));
-
- if (tty->sg_flags & ALLCTRL) {
- lookup_bits(buf, cflags, "cflags", tty->sg_flags);
+ if (buf != 0) {
+ if (tty->sg_flags & ALLCTRL) {
+ lookup_bits(buf, cflags, "cflags", tty->sg_flags);
+ }
}
#endif
return (buf);
@@ -267,5 +262,5 @@ _nc_tracebits(void)
return _nc_trace_ttymode(&(cur_term->Nttyb));
}
#else
-empty_module(_nc_tracebits)
+EMPTY_MODULE(_nc_tracebits)
#endif /* TRACE */
diff --git a/ncurses/trace/lib_tracechr.c b/ncurses/trace/lib_tracechr.c
index 479756ac59be..79cf03b4870c 100644
--- a/ncurses/trace/lib_tracechr.c
+++ b/ncurses/trace/lib_tracechr.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 *
@@ -39,18 +39,20 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_tracechr.c,v 1.13 2007/04/21 23:16:37 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.19 2008/08/03 15:39:29 tom Exp $")
#ifdef TRACE
-#define MyBuffer _nc_globals.tracechr_buf
NCURSES_EXPORT(char *)
-_tracechar(int ch)
+_nc_tracechar(SCREEN *sp, int ch)
{
NCURSES_CONST char *name;
+ char *MyBuffer = ((sp != 0)
+ ? sp->tracechr_buf
+ : _nc_globals.tracechr_buf);
if (ch > KEY_MIN || ch < 0) {
- name = keyname(ch);
+ name = _nc_keyname(sp, ch);
if (name == 0 || *name == '\0')
name = "NULL";
(void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
@@ -62,13 +64,19 @@ _tracechar(int ch)
*/
(void) sprintf(MyBuffer, "%#03o", ch);
} else {
- name = unctrl((chtype) ch);
+ name = _nc_unctrl(sp, (chtype) ch);
if (name == 0 || *name == 0)
name = "null"; /* shouldn't happen */
(void) sprintf(MyBuffer, "'%.30s' = %#03o", name, ch);
}
return (MyBuffer);
}
+
+NCURSES_EXPORT(char *)
+_tracechar(int ch)
+{
+ return _nc_tracechar(SP, ch);
+}
#else
-empty_module(_nc_lib_tracechr)
+EMPTY_MODULE(_nc_lib_tracechr)
#endif
diff --git a/ncurses/trace/lib_tracedmp.c b/ncurses/trace/lib_tracedmp.c
index d56d1a5d48b0..58732a06c246 100644
--- a/ncurses/trace/lib_tracedmp.c
+++ b/ncurses/trace/lib_tracedmp.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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_tracedmp.c,v 1.29 2007/06/30 23:01:19 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.31 2008/08/16 19:30:56 tom Exp $")
#ifdef TRACE
@@ -83,15 +83,15 @@ _tracedump(const char *name, WINDOW *win)
*/
for (j = 0; j < width; ++j) {
chtype test = CharOf(win->_line[n].text[j]);
- ep[j] = (UChar(test) == test
+ ep[j] = (char) ((UChar(test) == test
#if USE_WIDEC_SUPPORT
- && (win->_line[n].text[j].chars[1] == 0)
+ && (win->_line[n].text[j].chars[1] == 0)
#endif
- )
- ? (iscntrl(UChar(test))
- ? '.'
- : UChar(test))
- : '?';
+ )
+ ? (iscntrl(UChar(test))
+ ? '.'
+ : UChar(test))
+ : '?');
}
ep[j] = '\0';
_tracef("%s[%2d] %3ld%3ld ='%s'",
@@ -113,7 +113,7 @@ _tracedump(const char *name, WINDOW *win)
for (j = 0; j < width; ++j) {
int test = WidecExt(win->_line[n].text[j]);
if (test) {
- ep[j] = test + '0';
+ ep[j] = (char) (test + '0');
} else {
ep[j] = ' ';
}
@@ -138,11 +138,11 @@ _tracedump(const char *name, WINDOW *win)
if (pair >= 52)
ep[j] = '?';
else if (pair >= 36)
- ep[j] = pair + 'A';
+ ep[j] = (char) (pair + 'A');
else if (pair >= 10)
- ep[j] = pair + 'a';
+ ep[j] = (char) (pair + 'a');
else if (pair >= 1)
- ep[j] = pair + '0';
+ ep[j] = (char) (pair + '0');
else
ep[j] = ' ';
}
@@ -180,5 +180,5 @@ _tracedump(const char *name, WINDOW *win)
}
#else
-empty_module(_nc_lib_tracedmp)
+EMPTY_MODULE(_nc_lib_tracedmp)
#endif /* TRACE */
diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c
index 5edcc13a6ffa..74cc177d51bb 100644
--- a/ncurses/trace/lib_tracemse.c
+++ b/ncurses/trace/lib_tracemse.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 *
@@ -38,14 +38,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracemse.c,v 1.13 2007/04/21 21:23:00 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.15 2008/08/03 15:39:29 tom Exp $")
#ifdef TRACE
-#define my_buffer _nc_globals.tracemse_buf
+#define my_buffer sp->tracemse_buf
NCURSES_EXPORT(char *)
-_tracemouse(MEVENT const *ep)
+_nc_tracemouse(SCREEN *sp, MEVENT const *ep)
{
(void) sprintf(my_buffer, TRACEMSE_FMT,
ep->id,
@@ -114,6 +114,12 @@ _tracemouse(MEVENT const *ep)
return (my_buffer);
}
+NCURSES_EXPORT(char *)
+_tracemouse(MEVENT const *ep)
+{
+ return _nc_tracemouse(SP, ep);
+}
+
#else /* !TRACE */
-empty_module(_nc_lib_tracemouse)
+EMPTY_MODULE(_nc_lib_tracemouse)
#endif
diff --git a/ncurses/trace/trace_buf.c b/ncurses/trace/trace_buf.c
index 7bf91c674df3..6345acc035fc 100644
--- a/ncurses/trace/trace_buf.c
+++ b/ncurses/trace/trace_buf.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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
* trace_buf.c - Tracing/Debugging buffers (attributes)
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_buf.c,v 1.13 2007/04/21 22:50:08 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.14 2008/08/03 15:13:56 tom Exp $")
#define MyList _nc_globals.tracebuf_ptr
#define MySize _nc_globals.tracebuf_used
@@ -48,29 +48,35 @@ _nc_trace_alloc(int bufnum, size_t want)
if (bufnum >= 0) {
if ((size_t) (bufnum + 1) > MySize) {
size_t need = (bufnum + 1) * 2;
- if ((MyList = typeRealloc(TRACEBUF, need, MyList)) == 0)
- return (0);
- while (need > MySize)
- MyList[MySize++].text = 0;
+ if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
+ while (need > MySize)
+ MyList[MySize++].text = 0;
+ }
}
- if (MyList[bufnum].text == 0
- || want > MyList[bufnum].size) {
- MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
- if (MyList[bufnum].text != 0)
- MyList[bufnum].size = want;
+ if (MyList != 0) {
+ if (MyList[bufnum].text == 0
+ || want > MyList[bufnum].size) {
+ MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
+ if (MyList[bufnum].text != 0)
+ MyList[bufnum].size = want;
+ }
+ result = MyList[bufnum].text;
}
-
- result = MyList[bufnum].text;
}
#if NO_LEAKS
else {
if (MySize) {
- while (MySize--) {
- if (MyList[MySize].text != 0)
- free(MyList[MySize].text);
+ if (MyList) {
+ while (MySize--) {
+ if (MyList[MySize].text != 0) {
+ free(MyList[MySize].text);
+ }
+ }
+ free(MyList);
+ MyList = 0;
}
- free(MyList);
+ MySize = 0;
}
}
#endif
@@ -96,10 +102,13 @@ NCURSES_EXPORT(char *)
_nc_trace_bufcat(int bufnum, const char *value)
{
char *buffer = _nc_trace_alloc(bufnum, 0);
- size_t have = strlen(buffer);
+ if (buffer != 0) {
+ size_t have = strlen(buffer);
- buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
- (void) strcpy(buffer + have, value);
+ buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
+ if (buffer != 0)
+ (void) strcpy(buffer + have, value);
+ }
return buffer;
}
diff --git a/ncurses/trace/trace_tries.c b/ncurses/trace/trace_tries.c
index 0aa0b227d7d0..f813aba15825 100644
--- a/ncurses/trace/trace_tries.c
+++ b/ncurses/trace/trace_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2006,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 *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_tries.c,v 1.12 2007/04/21 21:55:41 tom Exp $")
+MODULE_ID("$Id: trace_tries.c,v 1.13 2008/08/03 15:43:30 tom Exp $")
#ifdef TRACE
#define my_buffer _nc_globals.tracetry_buf
@@ -74,5 +74,5 @@ _nc_trace_tries(TRIES * tree)
}
#else
-empty_module(_nc_trace_tries)
+EMPTY_MODULE(_nc_trace_tries)
#endif
diff --git a/ncurses/trace/varargs.c b/ncurses/trace/varargs.c
index 5e63d21a2cc5..f4ee46710abb 100644
--- a/ncurses/trace/varargs.c
+++ b/ncurses/trace/varargs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2003,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-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 *
@@ -34,7 +34,7 @@
#include <ctype.h>
-MODULE_ID("$Id: varargs.c,v 1.6 2007/07/14 15:51:27 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.7 2008/08/03 15:42:49 tom Exp $")
#ifdef TRACE
@@ -180,5 +180,5 @@ _nc_varargs(const char *fmt, va_list ap)
return (MyBuffer);
}
#else
-empty_module(_nc_varargs)
+EMPTY_MODULE(_nc_varargs)
#endif
diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c
index 74081efe6442..bf9fb1472003 100644
--- a/ncurses/trace/visbuf.c
+++ b/ncurses/trace/visbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-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,10 +42,10 @@
#include <tic.h>
#include <ctype.h>
-MODULE_ID("$Id: visbuf.c,v 1.26 2007/06/09 17:21:53 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.32 2008/08/04 23:07:39 tom Exp $")
-#define NormalLen(len) (unsigned) ((len + 1) * 4)
-#define WideLen(len) (unsigned) ((len + 1) * 4 * MB_CUR_MAX)
+#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4)
+#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX)
#ifdef TRACE
static const char d_quote[] = StringOf(D_QUOTE);
@@ -58,9 +58,9 @@ _nc_vischar(char *tp, unsigned c)
{
if (c == '"' || c == '\\') {
*tp++ = '\\';
- *tp++ = c;
+ *tp++ = (char) c;
} else if (is7bits(c) && (isgraph(c) || c == ' ')) {
- *tp++ = c;
+ *tp++ = (char) c;
} else if (c == '\n') {
*tp++ = '\\';
*tp++ = 'n';
@@ -80,7 +80,7 @@ _nc_vischar(char *tp, unsigned c)
} else if (is7bits(c) && iscntrl(UChar(c))) {
*tp++ = '\\';
*tp++ = '^';
- *tp++ = '@' + c;
+ *tp++ = (char) ('@' + c);
} else {
sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c));
tp += strlen(tp);
@@ -92,7 +92,7 @@ _nc_vischar(char *tp, unsigned c)
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
- char *vbuf;
+ const char *vbuf;
char *tp;
int c;
@@ -102,23 +102,27 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
return ("(cancelled)");
if (len < 0)
- len = strlen(buf);
+ len = (int) strlen(buf);
#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, NormalLen(len));
+ vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len));
#else
{
static char *mybuf[4];
mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
- tp = vbuf = mybuf[bufnum];
+ vbuf = tp = mybuf[bufnum];
}
#endif
- *tp++ = D_QUOTE;
- while ((--len >= 0) && (c = *buf++) != '\0') {
- tp = _nc_vischar(tp, UChar(c));
+ if (tp != 0) {
+ *tp++ = D_QUOTE;
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ tp = _nc_vischar(tp, UChar(c));
+ }
+ *tp++ = D_QUOTE;
+ *tp++ = '\0';
+ } else {
+ vbuf = ("(_nc_visbuf2n failed)");
}
- *tp++ = D_QUOTE;
- *tp++ = '\0';
return (vbuf);
}
@@ -159,7 +163,7 @@ _nc_wchstrlen(const cchar_t *s)
static const char *
_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
- char *vbuf;
+ const char *vbuf;
char *tp;
wchar_t c;
@@ -167,31 +171,35 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
return ("(null)");
if (len < 0)
- len = wcslen(buf);
+ len = (int) wcslen(buf);
#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, WideLen(len));
+ vbuf = tp = _nc_trace_buf(bufnum, WideLen(len));
#else
{
static char *mybuf[2];
mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
- tp = vbuf = mybuf[bufnum];
+ vbuf = tp = mybuf[bufnum];
}
#endif
- *tp++ = D_QUOTE;
- while ((--len >= 0) && (c = *buf++) != '\0') {
- char temp[CCHARW_MAX + 80];
- int j = wctomb(temp, c), k;
- if (j <= 0) {
- sprintf(temp, "\\u%08X", (wint_t) c);
- j = strlen(temp);
- }
- for (k = 0; k < j; ++k) {
- tp = _nc_vischar(tp, UChar(temp[k]));
+ if (tp != 0) {
+ *tp++ = D_QUOTE;
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ char temp[CCHARW_MAX + 80];
+ int j = wctomb(temp, c), k;
+ if (j <= 0) {
+ sprintf(temp, "\\u%08X", (unsigned) c);
+ j = (int) strlen(temp);
+ }
+ for (k = 0; k < j; ++k) {
+ tp = _nc_vischar(tp, UChar(temp[k]));
+ }
}
+ *tp++ = D_QUOTE;
+ *tp++ = '\0';
+ } else {
+ vbuf = ("(_nc_viswbuf2n failed)");
}
- *tp++ = D_QUOTE;
- *tp++ = '\0';
return (vbuf);
}
@@ -244,71 +252,73 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
int first;
const char *found;
+ if (result != 0) {
#if USE_WIDEC_SUPPORT
- if (len < 0)
- len = _nc_wchstrlen(buf);
+ if (len < 0)
+ len = _nc_wchstrlen(buf);
#endif /* USE_WIDEC_SUPPORT */
- /*
- * Display one or more strings followed by attributes.
- */
- first = 0;
- while (first < len) {
- attr_t attr = AttrOf(buf[first]);
- int last = len - 1;
- int j;
-
- for (j = first + 1; j < len; ++j) {
- if (!SameAttrOf(buf[j], buf[first])) {
- last = j - 1;
- break;
+ /*
+ * Display one or more strings followed by attributes.
+ */
+ first = 0;
+ while (first < len) {
+ attr_t attr = AttrOf(buf[first]);
+ int last = len - 1;
+ int j;
+
+ for (j = first + 1; j < len; ++j) {
+ if (!SameAttrOf(buf[j], buf[first])) {
+ last = j - 1;
+ break;
+ }
}
- }
- result = _nc_trace_bufcat(bufnum, l_brace);
- result = _nc_trace_bufcat(bufnum, d_quote);
- for (j = first; j <= last; ++j) {
- found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
- if (found != 0) {
- result = _nc_trace_bufcat(bufnum, found);
- attr &= ~A_ALTCHARSET;
- } else
+ result = _nc_trace_bufcat(bufnum, l_brace);
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ for (j = first; j <= last; ++j) {
+ found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
+ if (found != 0) {
+ result = _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
+ } else
#if USE_WIDEC_SUPPORT
- if (!isWidecExt(buf[j])) {
- PUTC_DATA;
-
- PUTC_INIT;
- for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
- int k;
-
- PUTC_ch = buf[j].chars[PUTC_i];
- if (PUTC_ch == L'\0')
- break;
- PUTC_n = wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
- if (PUTC_n <= 0)
- break;
- for (k = 0; k < PUTC_n; k++) {
- char temp[80];
- _nc_vischar(temp, UChar(PUTC_buf[k]));
- result = _nc_trace_bufcat(bufnum, temp);
+ if (!isWidecExt(buf[j])) {
+ PUTC_DATA;
+
+ PUTC_INIT;
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ int k;
+
+ PUTC_ch = buf[j].chars[PUTC_i];
+ if (PUTC_ch == L'\0')
+ break;
+ PUTC_n = (int) wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
+ if (PUTC_n <= 0)
+ break;
+ for (k = 0; k < PUTC_n; k++) {
+ char temp[80];
+ _nc_vischar(temp, UChar(PUTC_buf[k]));
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
}
}
- }
#else
- {
- char temp[80];
- _nc_vischar(temp, UChar(buf[j]));
- result = _nc_trace_bufcat(bufnum, temp);
- }
+ {
+ char temp[80];
+ _nc_vischar(temp, UChar(buf[j]));
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
#endif /* USE_WIDEC_SUPPORT */
+ }
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ if (attr != A_NORMAL) {
+ result = _nc_trace_bufcat(bufnum, " | ");
+ result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
+ }
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ first = last + 1;
}
- result = _nc_trace_bufcat(bufnum, d_quote);
- if (attr != A_NORMAL) {
- result = _nc_trace_bufcat(bufnum, " | ");
- result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
- }
- result = _nc_trace_bufcat(bufnum, r_brace);
- first = last + 1;
}
return result;
}
diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c
index 7d8979a4f51b..2c40997fb6b1 100644
--- a/ncurses/tty/hardscroll.c
+++ b/ncurses/tty/hardscroll.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 *
@@ -29,6 +29,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
+ * and: Alexander V Lukyanov 1997-1998 *
****************************************************************************/
/******************************************************************************
@@ -145,7 +147,7 @@ AUTHOR
#include <curses.priv.h>
-MODULE_ID("$Id: hardscroll.c,v 1.41 2007/09/29 21:48:36 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $")
#if defined(SCROLLDEBUG) || defined(HASHDEBUG)
@@ -270,13 +272,14 @@ _nc_linedump(void)
char *buf = 0;
size_t want = (screen_lines + 1) * 4;
- buf = typeMalloc(char, want);
+ if ((buf = typeMalloc(char, want)) != 0) {
- (void) strcpy(buf, "virt");
- for (n = 0; n < screen_lines; n++)
- (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
- TR(TRACE_UPDATE | TRACE_MOVE, (buf));
- free(buf);
+ (void) strcpy(buf, "virt");
+ for (n = 0; n < screen_lines; n++)
+ (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
+ TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+ free(buf);
+ }
}
#endif /* defined(TRACE) || defined(SCROLLDEBUG) */
diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c
index 19984c92333e..8e66fa3bf64c 100644
--- a/ncurses/tty/lib_mvcur.c
+++ b/ncurses/tty/lib_mvcur.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 *
@@ -155,7 +155,7 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.110 2007/08/11 16:15:57 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.113 2008/08/16 19:30:58 tom Exp $")
#define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */
#define BAUDRATE cur_term->_baudrate /* bits per second */
@@ -230,7 +230,7 @@ _nc_msec_cost(const char *const cap, int affcnt)
}
#if NCURSES_NO_PADDING
- if (!(SP->_no_padding))
+ if (!GetNoPadding(SP))
#endif
cum_cost += number * 10;
} else
@@ -426,8 +426,11 @@ _nc_mvcur_wrap(void)
mvcur(-1, -1, screen_lines - 1, 0);
/* set cursor to normal mode */
- if (SP->_cursor != -1)
+ if (SP->_cursor != -1) {
+ int cursor = SP->_cursor;
curs_set(1);
+ SP->_cursor = cursor;
+ }
if (exit_ca_mode) {
TPUTS_TRACE("exit_ca_mode");
@@ -628,7 +631,8 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
int i;
for (i = 0; i < n; i++)
- *check.s_tail++ = CharOf(WANT_CHAR(to_y, from_x + i));
+ *check.s_tail++ = (char) CharOf(WANT_CHAR(to_y,
+ from_x + i));
*check.s_tail = '\0';
check.s_size -= n;
lhcost += n * SP->_char_padding;
diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c
index 6d46081862fd..16d12edbbe3c 100644
--- a/ncurses/tty/lib_twait.c
+++ b/ncurses/tty/lib_twait.c
@@ -43,6 +43,10 @@
#include <curses.priv.h>
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
#ifdef __BEOS__
#undef false
#undef true
@@ -62,7 +66,9 @@
# endif
#endif
-MODULE_ID("$Id: lib_twait.c,v 1.57 2008/05/03 21:35:57 tom Exp $")
+#undef CUR
+
+MODULE_ID("$Id: lib_twait.c,v 1.59 2008/08/30 20:08:19 tom Exp $")
static long
_nc_gettime(TimeType * t0, bool first)
diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c
index 16fc17d27236..6a3a0c8e9341 100644
--- a/ncurses/tty/tty_update.c
+++ b/ncurses/tty/tty_update.c
@@ -44,6 +44,10 @@
#include <curses.priv.h>
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
#ifdef __BEOS__
#undef false
#undef true
@@ -74,7 +78,7 @@
#include <ctype.h>
#include <term.h>
-MODULE_ID("$Id: tty_update.c,v 1.245 2008/05/03 22:43:04 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.246 2008/08/30 20:08:19 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index cf7240780883..91ceb32ff738 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2003-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 2003-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,13 +32,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: charable.c,v 1.4 2005/04/16 18:08:56 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.5 2008/07/05 20:51:41 tom Exp $")
NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
{
bool result;
#if HAVE_WCTOB
- result = (wctob((wint_t) ch) == ch);
+ result = (wctob((wint_t) ch) == (int) ch);
#else
result = (_nc_to_char(ch) >= 0);
#endif
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 7985df2571db..6cf3129f2d18 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2006,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_get_wch.c,v 1.14 2007/05/12 19:03:16 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.17 2008/08/16 19:22:55 tom Exp $")
#if HAVE_MBTOWC && HAVE_MBLEN
#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
@@ -60,6 +60,7 @@ make an error
NCURSES_EXPORT(int)
wget_wch(WINDOW *win, wint_t *result)
{
+ SCREEN *sp;
int code;
char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */
int status;
@@ -76,44 +77,52 @@ wget_wch(WINDOW *win, wint_t *result)
* We can get a stream of single-byte characters and KEY_xxx codes from
* _nc_wgetch(), while we want to return a wide character or KEY_xxx code.
*/
- for (;;) {
- T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
- code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist *) 0));
- if (code == ERR) {
- break;
- } else if (code == KEY_CODE_YES) {
- /*
- * If we were processing an incomplete multibyte character, return
- * an error since we have a KEY_xxx code which interrupts it. For
- * some cases, we could improve this by writing a new version of
- * lib_getch.c(!), but it is not clear whether the improvement
- * would be worth the effort.
- */
- if (count != 0) {
- ungetch((int) value);
+ _nc_lock_global(curses);
+ sp = _nc_screen_of(win);
+ if (sp != 0) {
+ for (;;) {
+ T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer)));
+ code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist
+ *) 0));
+ if (code == ERR) {
+ break;
+ } else if (code == KEY_CODE_YES) {
+ /*
+ * If we were processing an incomplete multibyte character,
+ * return an error since we have a KEY_xxx code which
+ * interrupts it. For some cases, we could improve this by
+ * writing a new version of lib_getch.c(!), but it is not clear
+ * whether the improvement would be worth the effort.
+ */
+ if (count != 0) {
+ _nc_ungetch(sp, (int) value);
+ code = ERR;
+ }
+ break;
+ } else if (count + 1 >= sizeof(buffer)) {
+ _nc_ungetch(sp, (int) value);
code = ERR;
- }
- break;
- } else if (count + 1 >= sizeof(buffer)) {
- ungetch((int) value);
- code = ERR;
- break;
- } else {
- buffer[count++] = UChar(value);
- reset_mbytes(state);
- status = count_mbytes(buffer, count, state);
- if (status >= 0) {
+ break;
+ } else {
+ buffer[count++] = (char) UChar(value);
reset_mbytes(state);
- if (check_mbytes(wch, buffer, count, state) != status) {
- code = ERR; /* the two calls should match */
- ungetch((int) value);
+ status = count_mbytes(buffer, count, state);
+ if (status >= 0) {
+ reset_mbytes(state);
+ if (check_mbytes(wch, buffer, count, state) != status) {
+ code = ERR; /* the two calls should match */
+ _nc_ungetch(sp, (int) value);
+ }
+ value = wch;
+ break;
}
- value = wch;
- break;
}
}
+ } else {
+ code = ERR;
}
*result = value;
+ _nc_unlock_global(curses);
T(("result %#lo", value));
returnCode(code);
}
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index bf39aa1a188b..baa70a5a53f9 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2003,2004 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2004,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,7 +40,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.8 2004/10/16 21:55:36 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.10 2008/08/16 19:25:33 tom Exp $")
static int
wadd_wint(WINDOW *win, wint_t *src)
@@ -48,7 +48,7 @@ wadd_wint(WINDOW *win, wint_t *src)
cchar_t tmp;
wchar_t wch[2];
- wch[0] = *src;
+ wch[0] = (wchar_t) (*src);
wch[1] = 0;
setcchar(&tmp, wch, A_NORMAL, 0, NULL);
return wadd_wch(win, &tmp);
@@ -86,6 +86,7 @@ WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed)
NCURSES_EXPORT(int)
wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
{
+ SCREEN *sp = _nc_screen_of(win);
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
wint_t erasec;
@@ -102,17 +103,17 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
_nc_get_tty_mode(&buf);
- oldnl = SP->_nl;
- oldecho = SP->_echo;
- oldraw = SP->_raw;
- oldcbreak = SP->_cbreak;
+ oldnl = sp->_nl;
+ oldecho = sp->_echo;
+ oldraw = sp->_raw;
+ oldcbreak = sp->_cbreak;
nl();
noecho();
noraw();
cbreak();
- erasec = erasechar();
- killc = killchar();
+ erasec = (wint_t) erasechar();
+ killc = (wint_t) killchar();
getyx(win, y, x);
@@ -209,10 +210,10 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- SP->_nl = oldnl;
- SP->_echo = oldecho;
- SP->_raw = oldraw;
- SP->_cbreak = oldcbreak;
+ sp->_nl = oldnl;
+ sp->_echo = oldecho;
+ sp->_raw = oldraw;
+ sp->_cbreak = oldcbreak;
(void) _nc_set_tty_mode(&buf);
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index e24c9654d564..da65f219c266 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_key_name.c,v 1.2 2007/06/12 21:01:13 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.3 2008/10/11 20:15:14 tom Exp $")
NCURSES_EXPORT(NCURSES_CONST char *)
key_name(wchar_t c)
@@ -54,7 +54,7 @@ key_name(wchar_t c)
my_wchars = wunctrl(&my_cchar);
len = wcstombs(result, my_wchars, sizeof(result) - 1);
if (isEILSEQ(len) || (len == 0)) {
- return "UNKNOWN KEY";
+ return 0;
}
result[len] = '\0';
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index b2dc7ff96f1b..bb2c4a084b15 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2004,2007 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_unget_wch.c,v 1.9 2007/11/25 00:57:00 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.10 2008/06/07 14:50:37 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -86,7 +86,7 @@ unget_wch(const wchar_t wch)
wcrtomb(string, wch, &state);
for (n = (int) (length - 1); n >= 0; --n) {
- if (ungetch(string[n]) != OK) {
+ if (_nc_ungetch(SP, string[n]) != OK) {
result = ERR;
break;
}