]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/lib_trace.c
ncurses 5.0
[ncurses.git] / ncurses / trace / lib_trace.c
similarity index 92%
rename from ncurses/lib_trace.c
rename to ncurses/trace/lib_trace.c
index a9accd56fc844926189afc53dffcf6f51aebb9a0..aa4b887111a7cd7ac2c3b94d4acb270c19e55a51 100644 (file)
  *     lib_trace.c - Tracing/Debugging routines
  */
 
-#ifndef TRACE
-#define TRACE                  /* turn on internal defs for this module */
-#endif
-
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.25 1998/02/11 12:13:55 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.30 1998/10/03 23:41:42 tom Exp $")
 
 #include <ctype.h>
 #if HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 
-unsigned _nc_tracing = 0;
+unsigned _nc_tracing = 0;      /* always define this */
+
+#ifdef TRACE
 const char *_nc_tputs_trace = "";
 long _nc_outchars;
-int _nc_optimize_enable = OPTIMIZE_ALL;
 
 static FILE *  tracefp;        /* default to writing to stderr */
+#endif
 
-void trace(const unsigned int tracelevel)
+void trace(const unsigned int tracelevel GCC_UNUSED)
 {
+#ifdef TRACE
 static bool    been_here = FALSE;
+static char    my_name[] = "trace";
 
        _nc_tracing = tracelevel;
        if (! been_here && tracelevel) {
                been_here = TRUE;
 
-               if ((tracefp = fopen("trace", "w")) == 0) {
+               if (_nc_access(my_name, W_OK) < 0
+                || (tracefp = fopen(my_name, "w")) == 0) {
                        perror("curses: Can't open 'trace' file: ");
                        exit(EXIT_FAILURE);
                }
@@ -79,6 +81,7 @@ static bool   been_here = FALSE;
                _tracef("TRACING NCURSES version %s (%d)",
                        NCURSES_VERSION, NCURSES_VERSION_PATCH);
        }
+#endif
 }
 
 const char *_nc_visbuf2(int bufnum, const char *buf)
@@ -90,6 +93,8 @@ int c;
 
        if (buf == 0)
            return("(null)");
+       if (buf == CANCELLED_STRING)
+           return("(cancelled)");
 
        tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
        *tp++ = '"';
@@ -123,6 +128,7 @@ const char *_nc_visbuf(const char *buf)
        return _nc_visbuf2(0, buf);
 }
 
+#ifdef TRACE
 void
 _tracef(const char *fmt, ...)
 {
@@ -191,3 +197,4 @@ WINDOW *_nc_retrace_win(WINDOW *code)
        T((T_RETURN("%p"), code));
        return code;
 }
+#endif /* TRACE */