aboutsummaryrefslogtreecommitdiff
path: root/ncurses/base/lib_newterm.c
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/base/lib_newterm.c
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/base/lib_newterm.c')
-rw-r--r--ncurses/base/lib_newterm.c26
1 files changed, 22 insertions, 4 deletions
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);
}