]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080524
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 25 May 2008 00:49:27 +0000 (00:49 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 25 May 2008 00:49:27 +0000 (00:49 +0000)
+ modify _nc_keypad() to make it switch temporarily as needed to the
  screen which must be updated.
+ wrap cur_term variable to help make _nc_keymap() thread-safe, and
  always set the screen's copy of this variable in set_curterm().
+ restore curs_set() state after endwin()/refresh() (report/patch
  Miroslav Lichvar)

NEWS
dist.mk
include/MKterm.h.awk.in
ncurses/curses.priv.h
ncurses/tinfo/init_keytry.c
ncurses/tinfo/lib_cur_term.c
ncurses/tinfo/lib_data.c
ncurses/tinfo/lib_options.c
ncurses/tty/lib_mvcur.c
ncurses/tty/lib_twait.c
test/rain.c

diff --git a/NEWS b/NEWS
index 0ff555403708f6533c1fc73fa0f5cb50e855ee48..f14402b69ef804a40dfe2fdff592b9de0e6c0cd1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1235 2008/05/17 19:51:30 tom Exp $
+-- $Id: NEWS,v 1.1237 2008/05/24 22:23:07 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,14 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20080524
+       + modify _nc_keypad() to make it switch temporarily as needed to the
+         screen which must be updated.
+       + wrap cur_term variable to help make _nc_keymap() thread-safe, and
+         always set the screen's copy of this variable in set_curterm().
+       + restore curs_set() state after endwin()/refresh() (report/patch
+         Miroslav Lichvar)
+
 20080517
        + modify configure script to note that --enable-ext-colors and
          --enable-ext-mouse are not experimental, but extensions from
diff --git a/dist.mk b/dist.mk
index 2429baa8976d9add236329d1f8a3e0f7bee746af..fc57d6af0f42775312fab2fb99619f49da8a0d20 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.642 2008/05/17 18:44:56 tom Exp $
+# $Id: dist.mk,v 1.643 2008/05/24 12:05:32 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 6
-NCURSES_PATCH = 20080517
+NCURSES_PATCH = 20080524
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 6f0fca33c7c8bfd01cb400280f75943e961453c3..5fc20529b11b360cd40f6231da3ac24dba140d3c 100644 (file)
@@ -1,7 +1,7 @@
 # vile:awkmode
 BEGIN          {
                    print  "/****************************************************************************"
-                   print  " * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *"
+                   print  " * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *"
                    print  " *                                                                          *"
                    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
                    print  " * copy of this software and associated documentation files (the            *"
@@ -34,7 +34,7 @@ BEGIN         {
                    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
                    print  "/****************************************************************************/"
                    print  ""
-                   print  "/* $Id: MKterm.h.awk.in,v 1.49 2007/08/18 11:44:26 tom Exp $ */"
+                   print  "/* $Id: MKterm.h.awk.in,v 1.50 2008/05/24 23:13:59 tom Exp $ */"
                    print  ""
                    print  "/*"
                    print  "**  term.h -- Definition of struct term"
@@ -228,9 +228,8 @@ END         {
                        print  "    char *      _termname;      /* used for termname() */"
                        print  "} TERMINAL;"
                        print  ""
-                       print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
-                       print  ""
                        print  "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
+                       print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
                        print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
                        print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
                        print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
@@ -241,6 +240,7 @@ END         {
                        print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
                        print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
                        print  ""
+                       print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
                        print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
                        print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
                        print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
@@ -253,6 +253,8 @@ END         {
                        print  ""
                        print  "#else"
                        print  ""
+                       print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
+                       print  ""
                        print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
                        print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
                        print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
index 03fe1937bc2dbef27248b26ee13666397662eda5..b6447723c5db80156b6cab9b1cc075fdbe4daf82 100644 (file)
@@ -34,7 +34,7 @@
 
 
 /*
- * $Id: curses.priv.h,v 1.374 2008/05/17 21:24:44 tom Exp $
+ * $Id: curses.priv.h,v 1.375 2008/05/24 23:08:27 tom Exp $
  *
  *     curses.priv.h
  *
@@ -645,6 +645,7 @@ typedef struct {
        chtype          *real_acs_map;
        int             _LINES;
        int             _COLS;
+       TERMINAL        *_cur_term;
 #ifdef TRACE
        long            _outchars;
        const char      *_tputs_trace;
index d30d3ed16a876d3de2bcb0913fb4fedd42141da6..2f6fe4f6fad791972a16f5f79669b6162b3ad085 100644 (file)
@@ -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
index 8fccc2f88d08bd3c2d9672e440725d886f4f631b..e1b4f942997d5274965e9be69fe83f5e5335af75 100644 (file)
@@ -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            *
 #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.15 2008/05/24 23:11:18 tom Exp $")
 
+#if 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)
@@ -51,10 +59,18 @@ set_curterm(TERMINAL * termp)
 
     T((T_CALLED("set_curterm(%p)"), termp));
 
-    if ((cur_term = termp) != 0) {
-       ospeed = _nc_ospeed(cur_term->_baudrate);
+    if (SP)
+       SP->_term = termp;
+#if USE_REENTRANT
+    _nc_prescreen._cur_term = termp;
+#else
+    cur_term = termp;
+#endif
+    if (termp != 0) {
+       ospeed = _nc_ospeed(termp->_baudrate);
        PC = (pad_char != NULL) ? pad_char[0] : 0;
     }
+
     T((T_RETURN("%p"), oldterm));
     return (oldterm);
 }
@@ -69,7 +85,7 @@ del_curterm(TERMINAL * termp)
        FreeIfNeeded(termp->_termname);
        free(termp);
        if (termp == cur_term)
-           cur_term = 0;
+           set_curterm(0);
        returnCode(OK);
     }
     returnCode(ERR);
index ba37e5dc8c49b34b594bf33f3bf4e4d6227b2a7c..ff61d69a7e8c984159c045415498d0a29ecb22ef 100644 (file)
@@ -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.44 2008/05/24 23:09:21 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -226,6 +226,7 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
     NULL,                      /* real_acs_map */
     0,                         /* LINES */
     0,                         /* COLS */
+    0,                         /* cur_term */
 #ifdef TRACE
     0L,                                /* _outchars */
     NULL,                      /* _tputs_trace */
index 98aae24baacbfc1aca8a6fa8c4f536a56a76b36c..ae6b2c5b745f707d2bf731ee98c4c309c18ab2b2 100644 (file)
 
 #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.55 2008/05/25 00:32:17 tom 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 (sp != SP) {
+           SCREEN *save_sp;
+
+           /* cannot use use_screen(), since that is not in tinfo library */
+           _nc_lock_global(use_screen);
+           save_sp = SP;
+           SP = sp;
+           rc = _nc_keypad(sp, flag);
+           SP = save_sp;
+           _nc_unlock_global(use_screen);
+       } 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;
 }
index 19984c92333e497da0741a9c4b70740051472deb..891b6487acc9632cf50ed444cb0befe60d726804 100644 (file)
@@ -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            *
 #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.111 2008/05/24 14:36:54 Miroslav.Lichvar Exp $")
 
 #define WANT_CHAR(y, x)        SP->_newscr->_line[y].text[x]   /* desired state */
 #define BAUDRATE       cur_term->_baudrate     /* bits per second */
@@ -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");
index 6d46081862fdc13eb9fdd253c22c136c94a2e0cb..6973379ab383f1e00c7b611fd81ddf18b71a7545 100644 (file)
@@ -62,7 +62,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.58 2008/05/24 15:08:01 tom Exp $")
 
 static long
 _nc_gettime(TimeType * t0, bool first)
index 411306a71f9dbcdf55690b415cf1621be44ca6e3..f4a5e7f332ea9265e5a21f776eb2ca8d8d03c35d 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: rain.c,v 1.33 2008/03/22 18:12:01 tom Exp $
+ * $Id: rain.c,v 1.34 2008/05/24 23:34:34 tom Exp $
  */
 #include <test.priv.h>
 
@@ -323,6 +323,7 @@ main(int argc GCC_UNUSED,
        last[j].x = random_x();
        last[j].y = random_y();
     }
+    j = 0;
 #endif
 
     while (!done) {