diff --git a/curses.h b/curses.h index 5a98f6a5..75e082eb 100644 --- a/curses.h +++ b/curses.h @@ -27,11 +27,12 @@ Defined by this header: **man-end****************************************************************/ -#define PDCURSES 1 /* PDCurses-only routines */ -#define PDC_BUILD 3809 +#define PDCURSES 1 +#define PDC_BUILD 3810 #define PDC_VER_MAJOR 3 #define PDC_VER_MINOR 8 #define PDC_VERDOT "3.8" + #define CHTYPE_LONG 1 /* chtype >= 32 bits */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L @@ -46,7 +47,7 @@ Defined by this header: #include #include -#include /* Required by X/Open usage below */ +#include #ifdef PDC_WIDE # include @@ -128,7 +129,7 @@ enum /*---------------------------------------------------------------------- * - * Mouse Interface -- SYSVR4, with extensions + * Mouse Interface * */ @@ -360,6 +361,7 @@ typedef struct short line_color; /* color of line attributes - default -1 */ attr_t termattrs; /* attribute capabilities */ WINDOW *lastscr; /* the last screen image */ + FILE *dbfp; /* debug trace file pointer */ bool color_started; /* TRUE after start_color() */ bool dirty; /* redraw on napms() after init_color() */ } SCREEN; diff --git a/curspriv.h b/curspriv.h index 6f57e182..ff3c6c6c 100644 --- a/curspriv.h +++ b/curspriv.h @@ -42,7 +42,6 @@ typedef struct /* structure for ripped off lines */ #define _DWCHAR 0x17 /* Delete Word char (^W) */ #define _DLCHAR 0x15 /* Delete Line char (^U) */ -extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */ extern MOUSE_STATUS pdc_mouse_status; /*----------------------------------------------------------------------*/ @@ -96,7 +95,7 @@ size_t PDC_wcstombs(char *, const wchar_t *, size_t); #endif #ifdef PDCDEBUG -# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x +# define PDC_LOG(x) if (SP && SP->dbfp) PDC_debug x #else # define PDC_LOG(x) #endif diff --git a/pdcurses/debug.c b/pdcurses/debug.c index 13f45b7a..64448865 100644 --- a/pdcurses/debug.c +++ b/pdcurses/debug.c @@ -39,7 +39,6 @@ debug #include #include -FILE *pdc_dbfp = NULL; static bool want_fflush = FALSE; void PDC_debug(const char *fmt, ...) @@ -48,15 +47,15 @@ void PDC_debug(const char *fmt, ...) char hms[9]; time_t now; - if (!pdc_dbfp) + if (!SP || !SP->dbfp) return; time(&now); strftime(hms, 9, "%H:%M:%S", localtime(&now)); - fprintf(pdc_dbfp, "At: %8.8ld - %s ", (long) clock(), hms); + fprintf(SP->dbfp, "At: %8.8ld - %s ", (long) clock(), hms); va_start(args, fmt); - vfprintf(pdc_dbfp, fmt, args); + vfprintf(SP->dbfp, fmt, args); va_end(args); /* If you are crashing and losing debugging information, enable this @@ -64,7 +63,7 @@ void PDC_debug(const char *fmt, ...) impact performance. */ if (want_fflush) - fflush(pdc_dbfp); + fflush(SP->dbfp); /* If with PDC_TRACE_FLUSH enabled you are still losing logging in crashes, you may need to add a platform-dependent mechanism to @@ -74,12 +73,15 @@ void PDC_debug(const char *fmt, ...) void traceon(void) { - if (pdc_dbfp) - fclose(pdc_dbfp); + if (!SP) + return; + + if (SP->dbfp) + fclose(SP->dbfp); /* open debug log file append */ - pdc_dbfp = fopen("trace", "a"); - if (!pdc_dbfp) + SP->dbfp = fopen("trace", "a"); + if (!SP->dbfp) { fprintf(stderr, "PDC_debug(): Unable to open debug log file\n"); return; @@ -93,12 +95,12 @@ void traceon(void) void traceoff(void) { - if (!pdc_dbfp) + if (!SP || !SP->dbfp) return; PDC_LOG(("traceoff() - called\n")); - fclose(pdc_dbfp); - pdc_dbfp = NULL; + fclose(SP->dbfp); + SP->dbfp = NULL; want_fflush = FALSE; } diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c index 115e7c7e..7a0c1143 100644 --- a/pdcurses/initscr.c +++ b/pdcurses/initscr.c @@ -150,6 +150,7 @@ WINDOW *Xinitscr(int argc, char *argv[]) SP->delaytenths = 0; SP->line_color = -1; SP->lastscr = (WINDOW *)NULL; + SP->dbfp = NULL; SP->color_started = FALSE; SP->dirty = FALSE;