]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20070929
authorThomas E. Dickey <dickey@invisible-island.net>
Sat, 29 Sep 2007 23:30:37 +0000 (23:30 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sat, 29 Sep 2007 23:30:37 +0000 (23:30 +0000)
+ add new functions to lib_trace.c to setup mutex's for the _tracef()
  calls within the ncurses library.
+ for the reentrant model, move _nc_tputs_trace and _nc_outchars into
  the SCREEN.
+ start modifying test/worm.c to provide threading demo (incomplete).
+ separated ifdef's for some BSD-related symbols in tset.c, to make
  it compile on LynxOS (report by Greg Gemmer).

20 files changed:
NEWS
dist.mk
ncurses/base/lib_getch.c
ncurses/base/lib_mouse.c
ncurses/base/lib_refresh.c
ncurses/base/lib_ungetch.c
ncurses/base/resizeterm.c
ncurses/base/tries.c
ncurses/base/wresize.c
ncurses/curses.priv.h
ncurses/tinfo/lib_acs.c
ncurses/tinfo/lib_data.c
ncurses/tinfo/lib_raw.c
ncurses/tinfo/lib_tparm.c
ncurses/tinfo/lib_tputs.c
ncurses/trace/lib_trace.c
ncurses/tty/hardscroll.c
ncurses/tty/tty_update.c
progs/tset.c
test/worm.c

diff --git a/NEWS b/NEWS
index c4b4f665e622fa2bbd9449fb3ee57d44d8d5f70e..cf97f16364df296a16ade7aa08778f72d7c6dd1f 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.1168 2007/09/15 21:33:37 tom Exp $
+-- $Id: NEWS,v 1.1171 2007/09/29 21:53:42 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.
 
+20070929
+       + add new functions to lib_trace.c to setup mutex's for the _tracef()
+         calls within the ncurses library.
+       + for the reentrant model, move _nc_tputs_trace and _nc_outchars into
+         the SCREEN. 
+       + start modifying test/worm.c to provide threading demo (incomplete).
+       + separated ifdef's for some BSD-related symbols in tset.c, to make
+         it compile on LynxOS (report by Greg Gemmer).
 20070915
        + modify Ada95/gen/Makefile to use shlib script, to simplify building
          shared-library configuration on platforms lacking rpath support.
diff --git a/dist.mk b/dist.mk
index 5c3eba1611762cdf1e8bed8b269853b589f8a262..397e43c0ccad751a1619470a1e2e71edff64d55a 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.610 2007/09/15 14:29:36 tom Exp $
+# $Id: dist.mk,v 1.611 2007/09/29 15:48:09 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 = 20070915
+NCURSES_PATCH = 20070929
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index d8906daec63b7de903b3b82465e1c40a69bd813f..64566ccc762943f87e7257898890a229bf70c346 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.79 2007/04/19 20:57:49 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.80 2007/09/29 20:39:34 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -112,8 +112,10 @@ fifo_pull(void)
        h_inc();
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT)
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _nc_fifo_dump();
+       _nc_unlock_global(tracef);
+    }
 #endif
     return ch;
 }
@@ -208,8 +210,10 @@ fifo_push(EVENTLIST_0th(_nc_eventlist * evl))
     t_inc();
     TR(TRACE_IEVENT, ("pushed %s at %d", _tracechar(ch), tail));
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT)
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _nc_fifo_dump();
+       _nc_unlock_global(tracef);
+    }
 #endif
     return ch;
 }
index 7ea35e821a6137184bbfabed255e6717c8373aa8..aace7deb4c7fc7a334d15a169cc6a5198bdf2195 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -79,7 +79,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mouse.c,v 1.87 2006/12/30 16:30:06 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.88 2007/09/29 21:50:04 tom Exp $")
 
 #include <term.h>
 #include <tic.h>
@@ -985,12 +985,13 @@ _nc_mouse_parse(int runcount)
     }
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT) {
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _trace_slot("before mouse press/release merge:");
        _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
                (long) (runp - SP->_mouse_events),
                (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
@@ -1028,12 +1029,13 @@ _nc_mouse_parse(int runcount)
        (merge);
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT) {
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _trace_slot("before mouse click merge:");
        _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
                (long) (runp - SP->_mouse_events),
                (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
@@ -1099,12 +1101,13 @@ _nc_mouse_parse(int runcount)
        (merge);
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT) {
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _trace_slot("before mouse event queue compaction:");
        _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
                (long) (runp - SP->_mouse_events),
                (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
@@ -1117,12 +1120,13 @@ _nc_mouse_parse(int runcount)
            SP->_mouse_eventp = eventp = prev;
        }
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT) {
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _trace_slot("after mouse event queue compaction:");
        _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
                (long) (runp - SP->_mouse_events),
                (long) ((eventp - SP->_mouse_events) + (EV_MAX - 1)) % EV_MAX,
                runcount);
+       _nc_unlock_global(tracef);
     }
     for (ep = runp; ep != eventp; ep = NEXT(ep))
        if (ep->id != INVALID_EVENT)
index bc4d21e80136ff3a06616655ff3bb76362e1d184..2a9cafb7b0ad97dfbe5fdef4b56dc13fc44693b4 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.40 2007/07/07 22:08:38 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.41 2007/09/29 20:39:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -84,8 +84,10 @@ wnoutrefresh(WINDOW *win)
 
     T((T_CALLED("wnoutrefresh(%p)"), win));
 #ifdef TRACE
-    if (_nc_tracing & TRACE_UPDATE)
+    if (USE_TRACEF(TRACE_UPDATE)) {
        _tracedump("...win", win);
+       _nc_unlock_global(tracef);
+    }
 #endif /* TRACE */
 
     /*
@@ -277,8 +279,10 @@ wnoutrefresh(WINDOW *win)
     newscr->_leaveok = win->_leaveok;
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_UPDATE)
+    if (USE_TRACEF(TRACE_UPDATE)) {
        _tracedump("newscr", newscr);
+       _nc_unlock_global(tracef);
+    }
 #endif /* TRACE */
     returnCode(OK);
 }
index a6164df5edc1c48c2f4246afdba8f67cbe83cd16..9570a33edc5eb45e034d2f4dc8b5e20d778b0106 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ungetch.c,v 1.8 2002/08/24 22:08:48 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.9 2007/09/29 21:49:56 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -72,8 +72,10 @@ ungetch(int ch)
     SP->_fifo[head] = ch;
     T(("ungetch %s ok", _tracechar(ch)));
 #ifdef TRACE
-    if (_nc_tracing & TRACE_IEVENT)
+    if (USE_TRACEF(TRACE_IEVENT)) {
        _nc_fifo_dump();
+       _nc_unlock_global(tracef);
+    }
 #endif
     returnCode(OK);
 }
index 01b5cb60f28d4d194e39add0667436288001f98c..61761bfa65b7339e53cc89aed8f30d689034b9b7 100644 (file)
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: resizeterm.c,v 1.21 2007/03/10 23:45:14 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.22 2007/09/29 20:37:13 tom Exp $")
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
@@ -261,8 +261,10 @@ resize_term(int ToLines, int ToCols)
        int myCols = CurCols = screen_columns;
 
 #ifdef TRACE
-       if (_nc_tracing & TRACE_UPDATE)
+       if (USE_TRACEF(TRACE_UPDATE)) {
            show_window_sizes("before");
+           _nc_unlock_global(tracef);
+       }
 #endif
        if (ToLines > screen_lines) {
            increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS);
@@ -293,10 +295,11 @@ resize_term(int ToLines, int ToCols)
            FreeAndNull(SP->newhash);
        }
 #ifdef TRACE
-       if (_nc_tracing & TRACE_UPDATE) {
+       if (USE_TRACEF(TRACE_UPDATE)) {
            SET_LINES(ToLines - was_stolen);
            SET_COLS(ToCols);
            show_window_sizes("after");
+           _nc_unlock_global(tracef);
        }
 #endif
     }
index c00ef20b7d828ade9c44d75bfd6302d037f33495..983a75ae788258bf833421ab25bd44ac52561930 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: tries.c,v 1.24 2007/04/07 17:14:27 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.25 2007/09/29 20:37:13 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -71,8 +71,10 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
        if (ptr != 0 && (result[len] = ptr->ch) == 0)
            *((unsigned char *) (result + len)) = 128;
 #ifdef TRACE
-       if (len == 0 && _nc_tracing != 0)
+       if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
            _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
+           _nc_unlock_global(tracef);
+       }
 #endif
     }
     return result;
index 604f7f9ae4f0405c7523f9695f9d175f0c2e653a..ae62806e02fc355598827f6a0e8979692721e165 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wresize.c,v 1.25 2007/04/07 17:13:42 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.26 2007/09/29 20:37:13 tom Exp $")
 
 static int
 cleanup_lines(struct ldat *data, int length)
@@ -96,8 +96,10 @@ wresize(WINDOW *win, int ToLines, int ToCols)
                          (long) win->_begy, (long) win->_begx,
                          (long) win->_maxy, (long) win->_maxx,
                          (long) win->_regtop, (long) win->_regbottom));
-       if (_nc_tracing & TRACE_UPDATE)
+       if (USE_TRACEF(TRACE_UPDATE)) {
            _tracedump("...before", win);
+           _nc_unlock_global(tracef);
+       }
     }
 #endif
 
@@ -232,8 +234,10 @@ wresize(WINDOW *win, int ToLines, int ToCols)
                      (long) win->_begy, (long) win->_begx,
                      (long) win->_maxy, (long) win->_maxx,
                      (long) win->_regtop, (long) win->_regbottom));
-    if (_nc_tracing & TRACE_UPDATE)
+    if (USE_TRACEF(TRACE_UPDATE)) {
        _tracedump("...after:", win);
+       _nc_unlock_global(tracef);
+    }
 #endif
     returnCode(OK);
 }
index 973eb998e3fd8119840df419306f7eeadcf68d64..0aa19fe263f6e486705e9fa39c44198ab35cbe9f 100644 (file)
@@ -34,7 +34,7 @@
 
 
 /*
- * $Id: curses.priv.h,v 1.340 2007/09/08 21:44:40 tom Exp $
+ * $Id: curses.priv.h,v 1.343 2007/09/29 21:33:24 tom Exp $
  *
  *     curses.priv.h
  *
@@ -560,6 +560,9 @@ typedef struct {
        pthread_mutex_t mutex_set_SP;
        pthread_mutex_t mutex_use_screen;
        pthread_mutex_t mutex_windowlist;
+       pthread_mutex_t mutex_tst_tracef;
+       pthread_mutex_t mutex_tracef;
+       int             nested_tracef;
 #endif
 } NCURSES_GLOBALS;
 
@@ -583,6 +586,10 @@ typedef struct {
        chtype          *real_acs_map;
        int             _LINES;
        int             _COLS;
+#ifdef TRACE
+       long            _outchars;
+       const char      *_tputs_trace;
+#endif
 #endif
 } NCURSES_PRESCREEN;
 
@@ -805,6 +812,10 @@ struct screen {
        int             _TABSIZE;
        int             _LINES;
        int             _COLS;
+#ifdef TRACE
+       int             _outchars;
+       const char      *_tputs_trace;
+#endif
 #endif
        /*
         * ncurses/ncursesw are the same up to this point.
@@ -895,11 +906,17 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #endif
 
 #ifdef TRACE
-#define TRACE_OUTCHARS(n) _nc_outchars += (n);
+#if USE_REENTRANT
+#define COUNT_OUTCHARS(n) _nc_count_outchars(n);
+#else
+#define COUNT_OUTCHARS(n) _nc_outchars += (n);
+#endif
 #else
-#define TRACE_OUTCHARS(n) /* nothing */
+#define COUNT_OUTCHARS(n) /* nothing */
 #endif
 
+#define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars)
+
 #define UChar(c)       ((unsigned char)(c))
 #define ChCharOf(c)    ((c) & (chtype)A_CHARTEXT)
 #define ChAttrOf(c)    ((c) & (chtype)A_ATTRIBUTES)
@@ -945,7 +962,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define PUTC(ch,b)     do { if(!isWidecExt(ch)) {                                  \
                        if (Charable(ch)) {                                         \
                            fputc(CharOf(ch), b);                                   \
-                           TRACE_OUTCHARS(1);                                      \
+                           COUNT_OUTCHARS(1);                                      \
                        } else {                                                    \
                            PUTC_INIT;                                              \
                            for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {       \
@@ -961,7 +978,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
                                }                                                   \
                                fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b);          \
                            }                                                       \
-                           TRACE_OUTCHARS(PUTC_i);                                 \
+                           COUNT_OUTCHARS(PUTC_i);                                 \
                        } } } while (0)
 
 #define BLANK          { WA_NORMAL, {' '} NulColor }
@@ -1091,6 +1108,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #ifdef TRACE
 
+#if USE_REENTRANT
+#define TPUTS_TRACE(s) _nc_set_tputs_trace(s);
+#else
+#define TPUTS_TRACE(s) _nc_tputs_trace = s;
+#endif
+
 #define START_TRACE() \
        if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
            int t = _nc_getenv_num("NCURSES_TRACE"); \
@@ -1098,9 +1121,21 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
                trace((unsigned) t); \
        }
 
-#define TR(n, a)       if (_nc_tracing & (n)) _tracef a
+/*
+ * Many of the _tracef() calls use static buffers; lock the trace state before
+ * trying to fill them.
+ */
+#if USE_REENTRANT
+#define USE_TRACEF(mask) _nc_use_tracef(mask)
+extern NCURSES_EXPORT(int)     _nc_use_tracef (unsigned);
+extern NCURSES_EXPORT(void)    _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
+#else
+#define USE_TRACEF(mask) (_nc_tracing & (mask))
+#define _nc_locked_tracef _tracef
+#endif
+
+#define TR(n, a)       if (USE_TRACEF(n)) _nc_locked_tracef a
 #define T(a)           TR(TRACE_CALLS, a)
-#define TPUTS_TRACE(s) _nc_tputs_trace = s;
 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
 
 #define returnAttr(code)       TRACE_RETURN(code,attr_t)
@@ -1131,8 +1166,19 @@ extern NCURSES_EXPORT(int)              _nc_retrace_int (int);
 extern NCURSES_EXPORT(unsigned)         _nc_retrace_unsigned (unsigned);
 extern NCURSES_EXPORT(void *)           _nc_retrace_void_ptr (void *);
 extern NCURSES_EXPORT(void)             _nc_fifo_dump (void);
+
+#if USE_REENTRANT
+NCURSES_WRAPPED_VAR(long, _nc_outchars);
+NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace);
+#define _nc_outchars       NCURSES_PUBLIC_VAR(_nc_outchars())
+#define _nc_tputs_trace    NCURSES_PUBLIC_VAR(_nc_tputs_trace())
+extern NCURSES_EXPORT(void)            _nc_set_tputs_trace (const char *);
+extern NCURSES_EXPORT(void)            _nc_count_outchars (long);
+#else
 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
 extern NCURSES_EXPORT_VAR(long)         _nc_outchars;
+#endif
+
 extern NCURSES_EXPORT_VAR(unsigned)     _nc_tracing;
 
 #if USE_WIDEC_SUPPORT
index b7909f05c272515a672e7b1fac70526b48813982..6a24285460b3401cc78d078e121f595c7f6bf37d 100644 (file)
@@ -35,7 +35,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* ena_acs, acs_chars */
 
-MODULE_ID("$Id: lib_acs.c,v 1.33 2007/04/21 23:31:24 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.34 2007/09/29 20:37:13 tom Exp $")
 
 #if BROKEN_LINKER || USE_REENTRANT
 #define MyBuffer _nc_prescreen.real_acs_map
@@ -166,7 +166,7 @@ _nc_init_acs(void)
     /* Show the equivalent mapping, noting if it does not match the
      * given attribute, whether by re-ordering or duplication.
      */
-    if (_nc_tracing & TRACE_CALLS) {
+    if (USE_TRACEF(TRACE_CALLS)) {
        size_t n, m;
        char show[ACS_LEN * 2 + 1];
        for (n = 1, m = 0; n < ACS_LEN; n++) {
@@ -187,6 +187,7 @@ _nc_init_acs(void)
                   ? "DIFF"
                   : "SAME"),
                _nc_visbuf(show));
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 }
index 063a566f2abc27ec80c8cdb4dbc4945f9c7855cb..65fb7db21ea82a14d5ba62a2464770e8176636f7 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.30 2007/09/08 21:59:56 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.32 2007/09/29 21:34:21 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -180,6 +180,9 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
     PTHREAD_MUTEX_INITIALIZER, /* mutex_set_SP */
     PTHREAD_MUTEX_INITIALIZER, /* mutex_use_screen */
     PTHREAD_MUTEX_INITIALIZER, /* mutex_windowlist */
+    PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
+    PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
+    0,                         /* nested_tracef */
 #endif
 };
 
@@ -220,6 +223,10 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
     NULL,                      /* real_acs_map */
     0,                         /* LINES */
     0,                         /* COLS */
+#ifdef TRACE
+    0L,                                /* _outchars */
+    NULL,                      /* _tputs_trace */
+#endif
 #endif
 };
 /* *INDENT-ON* */
index aa09f52c8c8d393e028b5760fb8f2be0d00fd67e..58e71889af12a9911b25ee64b0b813d1554e9762 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -49,7 +49,7 @@
 #include <curses.priv.h>
 #include <term.h>              /* cur_term */
 
-MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.14 2007/09/29 21:50:22 tom Exp $")
 
 #if SVR4_TERMIO && !defined(_POSIX_SOURCE)
 #define _POSIX_SOURCE
@@ -69,8 +69,8 @@ MODULE_ID("$Id: lib_raw.c,v 1.13 2002/07/06 22:00:45 tom Exp $")
 #define COOKED_INPUT   (IXON|BRKINT|PARMRK)
 
 #ifdef TRACE
-#define BEFORE(N)      if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _nc_tracebits())
-#define AFTER(N)       if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _nc_tracebits())
+#define BEFORE(N)      if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s before bits: %s", N, _nc_tracebits())
+#define AFTER(N)       if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s after bits: %s", N, _nc_tracebits())
 #else
 #define BEFORE(s)
 #define AFTER(s)
index 6a19ab9f2c3562f0b8d249812411621accf260d6..d11fcf80cfbfd66f2dde42f6a7dfbc7396ded591 100644 (file)
@@ -43,7 +43,7 @@
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.73 2007/04/21 20:43:19 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.74 2007/09/29 20:37:13 tom Exp $")
 
 /*
  *     char *
@@ -508,7 +508,7 @@ tparam_internal(const char *string, va_list ap)
            npush(param[i]);
     }
 #ifdef TRACE
-    if (_nc_tracing & TRACE_CALLS) {
+    if (USE_TRACEF(TRACE_CALLS)) {
        for (i = 0; i < popcount; i++) {
            if (p_is_s[i] != 0)
                save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
@@ -517,6 +517,7 @@ tparam_internal(const char *string, va_list ap)
        }
        _tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
        TPS(out_used) = 0;
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
index 3a18ffd7404f2fe50d87e8ef61e2a24b8f184047..aab3351905cef871bae6dba24bda48f1c1c1dae6 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 #include <termcap.h>           /* ospeed */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tputs.c,v 1.62 2003/08/23 21:39:20 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.64 2007/09/29 20:37:13 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(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 */
+NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;   /* used by 'tack' program */
 
 static int (*my_outch) (int c) = _nc_outch;
 
@@ -84,7 +84,7 @@ _nc_flush(void)
 NCURSES_EXPORT(int)
 _nc_outch(int ch)
 {
-    TRACE_OUTCHARS(1);
+    COUNT_OUTCHARS(1);
 
     if (SP != 0
        && SP->_cleanup) {
@@ -119,7 +119,7 @@ tputs(const char *string, int affcnt, int (*outc) (int))
 #ifdef TRACE
     char addrbuf[32];
 
-    if (_nc_tracing & TRACE_TPUTS) {
+    if (USE_TRACEF(TRACE_TPUTS)) {
        if (outc == _nc_outch)
            (void) strcpy(addrbuf, "_nc_outch");
        else
@@ -130,7 +130,8 @@ tputs(const char *string, int affcnt, int (*outc) (int))
        } else {
            _tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
        }
-       _nc_tputs_trace = (char *) NULL;
+       TPUTS_TRACE(NULL);
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
index 34973daae8294f5394ecf096f938dae18f11c1da..d634438a97ac6330ee6ead8066d9adc9b4fd4cbe 100644 (file)
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.62 2007/07/14 19:32:54 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.65 2007/09/29 21:47:46 tom Exp $")
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
 #ifdef TRACE
+
+#if USE_REENTRANT
+NCURSES_EXPORT(const char *)
+NCURSES_PUBLIC_VAR(_nc_tputs_trace) (void)
+{
+    return SP ? SP->_tputs_trace : _nc_prescreen._tputs_trace;
+}
+NCURSES_EXPORT(long)
+NCURSES_PUBLIC_VAR(_nc_outchars) (void)
+{
+    return SP ? SP->_outchars : _nc_prescreen._outchars;
+}
+NCURSES_EXPORT(void)
+_nc_set_tputs_trace(const char *s)
+{
+    if (SP)
+       SP->_tputs_trace = s;
+    else
+       _nc_prescreen._tputs_trace = s;
+}
+NCURSES_EXPORT(void)
+_nc_count_outchars(long increment)
+{
+    if (SP)
+       SP->_outchars += increment;
+    else
+       _nc_prescreen._outchars += increment;
+}
+#else
 NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace = "";
 NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
+#endif
 
 #define TraceFP                _nc_globals.trace_fp
 #define TracePath      _nc_globals.trace_fname
@@ -107,12 +137,12 @@ trace(const unsigned int tracelevel)
     }
 }
 
-NCURSES_EXPORT(void)
-_tracef(const char *fmt,...)
+static void
+_nc_va_tracef(const char *fmt, va_list ap)
 {
     static const char Called[] = T_CALLED("");
     static const char Return[] = T_RETURN("");
-    va_list ap;
+
     bool before = FALSE;
     bool after = FALSE;
     unsigned doit = _nc_tracing;
@@ -142,18 +172,27 @@ _tracef(const char *fmt,...)
            for (n = 1; n < TraceLevel; n++)
                fputs("+ ", TraceFP);
        }
-       va_start(ap, fmt);
        vfprintf(TraceFP, fmt, ap);
        fputc('\n', TraceFP);
-       va_end(ap);
        fflush(TraceFP);
     }
 
     if (after && TraceLevel)
        TraceLevel--;
+
     errno = save_err;
 }
 
+NCURSES_EXPORT(void)
+_tracef(const char *fmt,...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    _nc_va_tracef(fmt, ap);
+    va_end(ap);
+}
+
 /* Trace 'bool' return-values */
 NCURSES_EXPORT(NCURSES_BOOL)
 _nc_retrace_bool(NCURSES_BOOL code)
@@ -225,4 +264,53 @@ _nc_retrace_win(WINDOW *code)
     T((T_RETURN("%p"), code));
     return code;
 }
+
+#if USE_REENTRANT
+/*
+ * Check if the given trace-mask is enabled.
+ *
+ * This function may be called from within one of the functions that fills
+ * in parameters for _tracef(), but in that case we do not want to lock the
+ * mutex, since it is already locked.
+ */
+NCURSES_EXPORT(int)
+_nc_use_tracef(unsigned mask)
+{
+    bool result = FALSE;
+
+    _nc_lock_global(tst_tracef);
+    if (!_nc_globals.nested_tracef++) {
+       if ((result = (_nc_tracing & (mask))) != 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;
+       }
+    } else {
+       /* we may call _nc_locked_tracef(), but with nested_tracef > 0 */
+       result = (_nc_tracing & (mask));
+    }
+    _nc_unlock_global(tst_tracef);
+    return result;
+}
+
+/*
+ * We call this if _nc_use_tracef() returns true, which means we must unlock
+ * the tracef mutex.
+ */
+NCURSES_EXPORT(void)
+_nc_locked_tracef(const char *fmt,...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    _nc_va_tracef(fmt, ap);
+    va_end(ap);
+
+    if (--(_nc_globals.nested_tracef) == 0)
+       _nc_unlock_global(tracef);
+}
+#endif /* USE_REENTRANT */
+
 #endif /* TRACE */
index 0b227a109dcfba7b9a9c0ecef472b8bc53c4c5b1..7d8979a4f51b12a6071533bcd02bae6bdb1c782e 100644 (file)
@@ -145,7 +145,7 @@ AUTHOR
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.40 2007/06/30 21:11:01 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.41 2007/09/29 21:48:36 tom Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -158,7 +158,7 @@ oldnums[MAXLINES];
 # undef TR
 # define TR(n, a)      if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
 
-extern NCURSES_EXPORT_VAR(unsigned)     _nc_tracing;
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
 
 #else /* no debug */
 
@@ -204,8 +204,10 @@ _nc_scroll_optimize(void)
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
 #ifdef TRACE
-    if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE))
+    if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
        _nc_linedump();
+       _nc_unlock_global(tracef);
+    }
 #endif /* TRACE */
 
     /* pass 1 - from top to bottom scrolling up */
index 15510ce406a7d4e738eb7107b50f664ab7afb0e4..33c79c7c0d5118d6c756abefe562a4a25e30c72a 100644 (file)
@@ -74,7 +74,7 @@
 #include <ctype.h>
 #include <term.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.240 2007/06/30 21:07:51 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.242 2007/09/29 20:37:13 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -289,7 +289,7 @@ PutAttrChar(CARG_CH_T ch)
 #endif
     {
        PUTC(CHDEREF(ch), SP->_ofp);    /* macro's fastest... */
-       TRACE_OUTCHARS(1);
+       COUNT_OUTCHARS(1);
     }
     SP->_curscol += chlen;
     if (char_padding) {
@@ -625,12 +625,13 @@ doupdate(void)
     T((T_CALLED("doupdate()")));
 
 #ifdef TRACE
-    if (_nc_tracing & TRACE_UPDATE) {
+    if (USE_TRACEF(TRACE_UPDATE)) {
        if (curscr->_clear)
            _tracef("curscr is clear");
        else
            _tracedump("curscr", curscr);
        _tracedump("newscr", newscr);
+       _nc_unlock_global(tracef);
     }
 #endif /* TRACE */
 
@@ -666,7 +667,7 @@ doupdate(void)
     }
 #if USE_TRACE_TIMES
     /* zero the metering machinery */
-    _nc_outchars = 0;
+    RESET_OUTCHARS();
     (void) times(&before);
 #endif /* USE_TRACE_TIMES */
 
@@ -826,9 +827,10 @@ doupdate(void)
 
 #ifdef TRACE
        /* show altered highlights after magic-cookie check */
-       if (_nc_tracing & TRACE_UPDATE) {
+       if (USE_TRACEF(TRACE_UPDATE)) {
            _tracef("After magic-cookie check...");
            _tracedump("newscr", newscr);
+           _nc_unlock_global(tracef);
        }
 #endif /* TRACE */
     }
index b34e47e36c19be70832145be5e222f1dec75067f..20679c5e7d98b1eba2c6b32225cf96691e6e3540 100644 (file)
@@ -103,7 +103,7 @@ char *ttyname(int fd);
 #include <dump_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tset.c,v 1.68 2007/07/21 17:46:24 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.69 2007/09/29 15:51:35 tom Exp $")
 
 extern char **environ;
 
@@ -777,7 +777,22 @@ reset_mode(void)
                      | OFDEL
 #endif
 #ifdef NLDLY
-                     | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY
+                     | NLDLY
+#endif
+#ifdef CRDLY 
+                     | CRDLY
+#endif
+#ifdef TABDLY 
+                     | TABDLY
+#endif
+#ifdef BSDLY 
+                     | BSDLY
+#endif
+#ifdef VTDLY 
+                     | VTDLY
+#endif
+#ifdef FFDLY
+                     | FFDLY
 #endif
        );
 
index 4692668bdcfe6f43fcf4925ce641e0a1b04a431d..534e626e23b8b8e945201ae8edf1bcb4dd7f91e2 100644 (file)
@@ -61,11 +61,15 @@ Options:
   traces will be dumped.  The program stops and waits for one character of
   input at the beginning and end of the interval.
 
-  $Id: worm.c,v 1.48 2007/09/15 21:42:16 tom Exp $
+  $Id: worm.c,v 1.49 2007/09/29 17:35:57 tom Exp $
 */
 
 #include <test.priv.h>
 
+#ifdef USE_PTHREADS
+#include <pthread.h>
+#endif
+
 static chtype flavor[] =
 {
     'O', '*', '#', '$', '%', '0', '@',
@@ -84,6 +88,9 @@ typedef struct worm {
     short *xpos;
     short *ypos;
     chtype attrs;
+#ifdef USE_PTHREADS
+    pthread_t thread;
+#endif
 } WORM;
 
 static WORM worm[40];
@@ -299,12 +306,49 @@ draw_worm(WINDOW *win, void *data)
 
 #if !defined(NCURSES_VERSION_PATCH) || (NCURSES_VERSION_PATCH < 20070915)
 static int
-use_window(WINDOW *win, int (*func)(WINDOW *, void *), void *data)
+use_window(WINDOW *win, int (*func) (WINDOW *, void *), void *data)
 {
     return func(win, data);
 }
 #endif
 
+#ifdef USE_PTHREADS
+static void *
+start_worm(void *arg)
+{
+    for (;;) {
+       napms(20);
+       use_window(stdscr, draw_worm, arg);
+    }
+    return NULL;
+}
+#endif
+
+static bool
+draw_all_worms(void)
+{
+    bool done = FALSE;
+    int n;
+    struct worm *w;
+
+#ifdef USE_PTHREADS
+    static bool first = TRUE;
+    if (first) {
+       first = FALSE;
+       for (n = 0, w = &worm[0]; n < number; n++, w++) {
+           int rc;
+           rc = pthread_create(&(w->thread), NULL, start_worm, w);
+       }
+    }
+#else
+    for (n = 0, w = &worm[0]; n < number; n++, w++) {
+       if (use_window(stdscr, draw_worm, w))
+           done = TRUE;
+    }
+#endif
+    return done;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -498,10 +542,7 @@ main(int argc, char *argv[])
            }
        }
 
-       for (n = 0, w = &worm[0]; n < number; n++, w++) {
-           if (use_window(stdscr, draw_worm, w))
-               done = TRUE;
-       }
+       done = draw_all_worms();
        napms(10);
        refresh();
     }