X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;ds=sidebyside;f=ncurses%2Ftrace%2Flib_trace.c;fp=ncurses%2Ftrace%2Flib_trace.c;h=4567054a9fd30120b47309d576e258d41033c9d1;hb=5461fc336d03fbfea6b85ac21c6d49c528f6752d;hp=140d8e54e198f3137d169cc671f6960924f569a4;hpb=62ca6190a9a8ddccb2c4d5ca7b2ef9f88432da65;p=ncurses.git diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c index 140d8e54..4567054a 100644 --- a/ncurses/trace/lib_trace.c +++ b/ncurses/trace/lib_trace.c @@ -47,7 +47,7 @@ #include -MODULE_ID("$Id: lib_trace.c,v 1.84 2016/11/27 02:35:17 tom Exp $") +MODULE_ID("$Id: lib_trace.c,v 1.85 2016/12/31 13:50:06 tom Exp $") NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */ @@ -156,6 +156,13 @@ _nc_va_tracef(const char *fmt, va_list ap) bool after = FALSE; unsigned doit = _nc_tracing; int save_err = errno; + FILE *fp = MyFP; + +#ifdef TRACE + /* verbose-trace in the command-line utilities relies on this */ + if (fp == 0 && _nc_tracing >= DEBUG_LEVEL(1)) + fp = stderr; +#endif if (strlen(fmt) >= sizeof(Called) - 1) { if (!strncmp(fmt, Called, sizeof(Called) - 1)) { @@ -173,7 +180,7 @@ _nc_va_tracef(const char *fmt, va_list ap) } } - if (doit != 0 && MyFP != 0) { + if (doit != 0 && fp != 0) { #ifdef USE_PTHREADS /* * TRACE_ICALLS is "really" needed to show normal use with threaded @@ -188,19 +195,19 @@ _nc_va_tracef(const char *fmt, va_list ap) if ((pthread_self)) # endif #ifdef __MINGW32__ - fprintf(MyFP, "%#lx:", (long) (intptr_t) pthread_self().p); + fprintf(fp, "%#lx:", (long) (intptr_t) pthread_self().p); #else - fprintf(MyFP, "%#lx:", (long) (intptr_t) pthread_self()); + fprintf(fp, "%#lx:", (long) (intptr_t) pthread_self()); #endif #endif if (before || after) { int n; for (n = 1; n < MyLevel; n++) - fputs("+ ", MyFP); + fputs("+ ", fp); } - vfprintf(MyFP, fmt, ap); - fputc('\n', MyFP); - fflush(MyFP); + vfprintf(fp, fmt, ap); + fputc('\n', fp); + fflush(fp); } if (after && MyLevel)