aboutsummaryrefslogtreecommitdiff
path: root/ncurses/trace
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-02-07 08:36:41 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-02-07 08:36:41 +0000
commitf0179cb6083cc92e5947ae56e6a0a5c5328aead0 (patch)
treebcee0ba9c2149b71f0bfc036df1e61e3105bf980 /ncurses/trace
parentcea297eb34d2361e79529034397465068ae34ecd (diff)
downloadsrc-f0179cb6083cc92e5947ae56e6a0a5c5328aead0.tar.gz
src-f0179cb6083cc92e5947ae56e6a0a5c5328aead0.zip
Vendor import ncurses 6.1-20200118vendor/ncurses/6.1-20200118
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=357645 svn path=/vendor/ncurses/6.1-20200118/; revision=357646; tag=vendor/ncurses/6.1-20200118
Diffstat (limited to 'ncurses/trace')
-rw-r--r--ncurses/trace/lib_trace.c165
-rw-r--r--ncurses/trace/lib_traceatr.c181
-rw-r--r--ncurses/trace/lib_tracebits.c115
-rw-r--r--ncurses/trace/lib_tracedmp.c8
-rw-r--r--ncurses/trace/lib_tracemse.c16
-rw-r--r--ncurses/trace/trace_xnames.c10
-rw-r--r--ncurses/trace/visbuf.c39
7 files changed, 320 insertions, 214 deletions
diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c
index cec01de517f8..7e2ca854e656 100644
--- a/ncurses/trace/lib_trace.c
+++ b/ncurses/trace/lib_trace.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2018,2019 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 *
@@ -47,7 +47,7 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_trace.c,v 1.82 2013/07/06 19:42:09 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.94 2019/12/07 22:32:36 tom Exp $")
NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
@@ -85,60 +85,83 @@ 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
-#define TraceLevel _nc_globals.trace_level
+#define MyFP _nc_globals.trace_fp
+#define MyFD _nc_globals.trace_fd
+#define MyInit _nc_globals.trace_opened
+#define MyPath _nc_globals.trace_fname
+#define MyLevel _nc_globals.trace_level
+#define MyNested _nc_globals.nested_tracef
+#endif /* TRACE */
-NCURSES_EXPORT(void)
-trace(const unsigned int tracelevel)
+NCURSES_EXPORT(unsigned)
+curses_trace(unsigned tracelevel)
{
- if ((TraceFP == 0) && tracelevel) {
- const char *mode = _nc_globals.init_trace ? "ab" : "wb";
-
- if (TracePath[0] == '\0') {
- size_t size = sizeof(TracePath) - 12;
- if (getcwd(TracePath, size) == 0) {
- perror("curses: Can't get working directory");
- exit(EXIT_FAILURE);
+ unsigned result;
+#if defined(TRACE)
+ result = _nc_tracing;
+ if ((MyFP == 0) && tracelevel) {
+ MyInit = TRUE;
+ if (MyFD >= 0) {
+ MyFP = fdopen(MyFD, BIN_W);
+ } else {
+ if (MyPath[0] == '\0') {
+ size_t size = sizeof(MyPath) - 12;
+ if (getcwd(MyPath, size) == 0) {
+ perror("curses: Can't get working directory");
+ exit(EXIT_FAILURE);
+ }
+ MyPath[size] = '\0';
+ assert(strlen(MyPath) <= size);
+ _nc_STRCAT(MyPath, "/trace", sizeof(MyPath));
+ if (_nc_is_dir_path(MyPath)) {
+ _nc_STRCAT(MyPath, ".log", sizeof(MyPath));
+ }
}
- TracePath[size] = '\0';
- assert(strlen(TracePath) <= size);
- _nc_STRCAT(TracePath, "/trace", sizeof(TracePath));
- if (_nc_is_dir_path(TracePath)) {
- _nc_STRCAT(TracePath, ".log", sizeof(TracePath));
+ if (_nc_access(MyPath, W_OK) < 0
+ || (MyFD = open(MyPath, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0
+ || (MyFP = fdopen(MyFD, BIN_W)) == 0) {
+ ; /* EMPTY */
}
}
-
- _nc_globals.init_trace = TRUE;
_nc_tracing = tracelevel;
- if (_nc_access(TracePath, W_OK) < 0
- || (TraceFP = fopen(TracePath, mode)) == 0) {
- perror("curses: Can't open 'trace' file");
- exit(EXIT_FAILURE);
- }
/* Try to set line-buffered mode, or (failing that) unbuffered,
* so that the trace-output gets flushed automatically at the
* end of each line. This is useful in case the program dies.
*/
+ if (MyFP != 0) {
#if HAVE_SETVBUF /* ANSI */
- (void) setvbuf(TraceFP, (char *) 0, _IOLBF, (size_t) 0);
+ (void) setvbuf(MyFP, (char *) 0, _IOLBF, (size_t) 0);
#elif HAVE_SETBUF /* POSIX */
- (void) setbuffer(TraceFP, (char *) 0);
+ (void) setbuffer(MyFP, (char *) 0);
#endif
+ }
_tracef("TRACING NCURSES version %s.%d (tracelevel=%#x)",
NCURSES_VERSION,
NCURSES_VERSION_PATCH,
tracelevel);
} else if (tracelevel == 0) {
- if (TraceFP != 0) {
- fclose(TraceFP);
- TraceFP = 0;
+ if (MyFP != 0) {
+ MyFD = dup(MyFD); /* allow reopen of same file */
+ fclose(MyFP);
+ MyFP = 0;
}
_nc_tracing = tracelevel;
} else if (_nc_tracing != tracelevel) {
_nc_tracing = tracelevel;
_tracef("tracelevel=%#x", tracelevel);
}
+#else
+ (void) tracelevel;
+ result = 0;
+#endif
+ return result;
+}
+
+#if defined(TRACE)
+NCURSES_EXPORT(void)
+trace(const unsigned int tracelevel)
+{
+ curses_trace(tracelevel);
}
static void
@@ -151,16 +174,23 @@ _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 && !MyInit && _nc_tracing >= DEBUG_LEVEL(1))
+ fp = stderr;
+#endif
if (strlen(fmt) >= sizeof(Called) - 1) {
if (!strncmp(fmt, Called, sizeof(Called) - 1)) {
before = TRUE;
- TraceLevel++;
+ MyLevel++;
} else if (!strncmp(fmt, Return, sizeof(Return) - 1)) {
after = TRUE;
}
if (before || after) {
- if ((TraceLevel <= 1)
+ if ((MyLevel <= 1)
|| (doit & TRACE_ICALLS) != 0)
doit &= (TRACE_CALLS | TRACE_CCALLS);
else
@@ -168,9 +198,7 @@ _nc_va_tracef(const char *fmt, va_list ap)
}
}
- if (doit != 0) {
- if (TraceFP == 0)
- TraceFP = stderr;
+ if (doit != 0 && fp != 0) {
#ifdef USE_PTHREADS
/*
* TRACE_ICALLS is "really" needed to show normal use with threaded
@@ -184,30 +212,30 @@ _nc_va_tracef(const char *fmt, va_list ap)
# if USE_WEAK_SYMBOLS
if ((pthread_self))
# endif
-#ifdef __MINGW32__
- fprintf(TraceFP, "%#lx:", (long) (intptr_t) pthread_self().p);
+#ifdef _WIN32
+ fprintf(fp, "%#lx:", (long) (intptr_t) pthread_self().p);
#else
- fprintf(TraceFP, "%#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 < TraceLevel; n++)
- fputs("+ ", TraceFP);
+ for (n = 1; n < MyLevel; n++)
+ fputs("+ ", fp);
}
- vfprintf(TraceFP, fmt, ap);
- fputc('\n', TraceFP);
- fflush(TraceFP);
+ vfprintf(fp, fmt, ap);
+ fputc('\n', fp);
+ fflush(fp);
}
- if (after && TraceLevel)
- TraceLevel--;
+ if (after && MyLevel)
+ MyLevel--;
errno = save_err;
}
NCURSES_EXPORT(void)
-_tracef(const char *fmt,...)
+_tracef(const char *fmt, ...)
{
va_list ap;
@@ -296,6 +324,39 @@ _nc_retrace_win(WINDOW *code)
return code;
}
+NCURSES_EXPORT(char *)
+_nc_fmt_funcptr(char *target, const char *source, size_t size)
+{
+ size_t n;
+ char *dst = target;
+ bool leading = TRUE;
+
+ union {
+ int value;
+ char bytes[sizeof(int)];
+ } byteorder;
+
+ byteorder.value = 0x1234;
+
+ *dst++ = '0';
+ *dst++ = 'x';
+
+ for (n = 0; n < size; ++n) {
+ unsigned ch = ((byteorder.bytes[0] == 0x34)
+ ? UChar(source[size - n - 1])
+ : UChar(source[n]));
+ if (ch != 0 || (n + 1) >= size)
+ leading = FALSE;
+ if (!leading) {
+ _nc_SPRINTF(dst, _nc_SLIMIT(TR_FUNC_LEN - (dst - target))
+ "%02x", ch & 0xff);
+ dst += 2;
+ }
+ }
+ *dst = '\0';
+ return target;
+}
+
#if USE_REENTRANT
/*
* Check if the given trace-mask is enabled.
@@ -310,13 +371,13 @@ _nc_use_tracef(unsigned mask)
bool result = FALSE;
_nc_lock_global(tst_tracef);
- if (!_nc_globals.nested_tracef++) {
+ if (!MyNested++) {
if ((result = (_nc_tracing & (mask))) != 0
&& _nc_try_global(tracef) == 0) {
/* we will call _nc_locked_tracef(), no nesting so far */
} else {
/* we will not call _nc_locked_tracef() */
- _nc_globals.nested_tracef = 0;
+ MyNested = 0;
}
} else {
/* we may call _nc_locked_tracef(), but with nested_tracef > 0 */
@@ -331,7 +392,7 @@ _nc_use_tracef(unsigned mask)
* the tracef mutex.
*/
NCURSES_EXPORT(void)
-_nc_locked_tracef(const char *fmt,...)
+_nc_locked_tracef(const char *fmt, ...)
{
va_list ap;
@@ -339,7 +400,7 @@ _nc_locked_tracef(const char *fmt,...)
_nc_va_tracef(fmt, ap);
va_end(ap);
- if (--(_nc_globals.nested_tracef) == 0) {
+ if (--(MyNested) == 0) {
_nc_unlock_global(tracef);
}
}
diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c
index 5fb0df95f4fd..31312c233e6e 100644
--- a/ncurses/trace/lib_traceatr.c
+++ b/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2018,2019 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 *
@@ -43,7 +43,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_traceatr.c,v 1.81 2014/02/01 22:09:27 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.93 2019/05/04 20:46:24 tom Exp $")
#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
@@ -67,7 +67,7 @@ color_of(int c)
if (c != my_cached) {
my_cached = c;
my_select = !my_select;
- if (c == COLOR_DEFAULT)
+ if (isDefaultColor(c))
_nc_STRCPY(my_buffer[my_select], "default",
COLOR_BUF_SIZE(my_select));
else
@@ -85,53 +85,48 @@ color_of(int c)
NCURSES_EXPORT(char *)
_traceattr2(int bufnum, chtype newmode)
{
+#define DATA(name) { name, { #name } }
static const struct {
unsigned int val;
- const char *name;
+ const char name[14];
} names[] =
{
- /* *INDENT-OFF* */
- { A_STANDOUT, "A_STANDOUT" },
- { A_UNDERLINE, "A_UNDERLINE" },
- { A_REVERSE, "A_REVERSE" },
- { A_BLINK, "A_BLINK" },
- { A_DIM, "A_DIM" },
- { A_BOLD, "A_BOLD" },
- { A_ALTCHARSET, "A_ALTCHARSET" },
- { A_INVIS, "A_INVIS" },
- { A_PROTECT, "A_PROTECT" },
- { A_CHARTEXT, "A_CHARTEXT" },
- { A_NORMAL, "A_NORMAL" },
- { A_COLOR, "A_COLOR" },
+ DATA(A_STANDOUT),
+ DATA(A_UNDERLINE),
+ DATA(A_REVERSE),
+ DATA(A_BLINK),
+ DATA(A_DIM),
+ DATA(A_BOLD),
+ DATA(A_ALTCHARSET),
+ DATA(A_INVIS),
+ DATA(A_PROTECT),
+ DATA(A_CHARTEXT),
+ DATA(A_NORMAL),
+ DATA(A_COLOR),
#if USE_ITALIC
- { A_ITALIC, "A_ITALIC" },
+ DATA(A_ITALIC),
#endif
- /* *INDENT-ON* */
-
}
#ifndef USE_TERMLIB
,
colors[] =
{
- /* *INDENT-OFF* */
- { COLOR_BLACK, "COLOR_BLACK" },
- { COLOR_RED, "COLOR_RED" },
- { COLOR_GREEN, "COLOR_GREEN" },
- { COLOR_YELLOW, "COLOR_YELLOW" },
- { COLOR_BLUE, "COLOR_BLUE" },
- { COLOR_MAGENTA, "COLOR_MAGENTA" },
- { COLOR_CYAN, "COLOR_CYAN" },
- { COLOR_WHITE, "COLOR_WHITE" },
- /* *INDENT-ON* */
-
+ DATA(COLOR_BLACK),
+ DATA(COLOR_RED),
+ DATA(COLOR_GREEN),
+ DATA(COLOR_YELLOW),
+ DATA(COLOR_BLUE),
+ DATA(COLOR_MAGENTA),
+ DATA(COLOR_CYAN),
+ DATA(COLOR_WHITE),
}
#endif /* !USE_TERMLIB */
;
- size_t n;
- char temp[80];
+#undef DATA
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
if (result != 0) {
+ size_t n;
unsigned save_nc_tracing = _nc_tracing;
_nc_tracing = 0;
@@ -139,12 +134,14 @@ _traceattr2(int bufnum, chtype newmode)
_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
for (n = 0; n < SIZEOF(names); n++) {
+
if ((newmode & names[n].val) != 0) {
if (result[1] != '\0')
(void) _nc_trace_bufcat(bufnum, "|");
result = _nc_trace_bufcat(bufnum, names[n].name);
if (names[n].val == A_COLOR) {
+ char temp[80];
short pairnum = (short) PairNumber(newmode);
#ifdef USE_TERMLIB
/* pair_content lives in libncurses */
@@ -205,49 +202,50 @@ _nc_retrace_attr_t(attr_t code)
const char *
_nc_altcharset_name(attr_t attr, chtype ch)
{
+#define DATA(code, name) { code, { #name } }
typedef struct {
unsigned int val;
- const char *name;
+ const char name[13];
} ALT_NAMES;
#if NCURSES_SP_FUNCS
SCREEN *sp = CURRENT_SCREEN;
#endif
static const ALT_NAMES names[] =
{
- {'l', "ACS_ULCORNER"}, /* upper left corner */
- {'m', "ACS_LLCORNER"}, /* lower left corner */
- {'k', "ACS_URCORNER"}, /* upper right corner */
- {'j', "ACS_LRCORNER"}, /* lower right corner */
- {'t', "ACS_LTEE"}, /* tee pointing right */
- {'u', "ACS_RTEE"}, /* tee pointing left */
- {'v', "ACS_BTEE"}, /* tee pointing up */
- {'w', "ACS_TTEE"}, /* tee pointing down */
- {'q', "ACS_HLINE"}, /* horizontal line */
- {'x', "ACS_VLINE"}, /* vertical line */
- {'n', "ACS_PLUS"}, /* large plus or crossover */
- {'o', "ACS_S1"}, /* scan line 1 */
- {'s', "ACS_S9"}, /* scan line 9 */
- {'`', "ACS_DIAMOND"}, /* diamond */
- {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
- {'f', "ACS_DEGREE"}, /* degree symbol */
- {'g', "ACS_PLMINUS"}, /* plus/minus */
- {'~', "ACS_BULLET"}, /* bullet */
- {',', "ACS_LARROW"}, /* arrow pointing left */
- {'+', "ACS_RARROW"}, /* arrow pointing right */
- {'.', "ACS_DARROW"}, /* arrow pointing down */
- {'-', "ACS_UARROW"}, /* arrow pointing up */
- {'h', "ACS_BOARD"}, /* board of squares */
- {'i', "ACS_LANTERN"}, /* lantern symbol */
- {'0', "ACS_BLOCK"}, /* solid square block */
- {'p', "ACS_S3"}, /* scan line 3 */
- {'r', "ACS_S7"}, /* scan line 7 */
- {'y', "ACS_LEQUAL"}, /* less/equal */
- {'z', "ACS_GEQUAL"}, /* greater/equal */
- {'{', "ACS_PI"}, /* Pi */
- {'|', "ACS_NEQUAL"}, /* not equal */
- {'}', "ACS_STERLING"}, /* UK pound sign */
- {'\0', (char *) 0}
+ DATA('l', ACS_ULCORNER), /* upper left corner */
+ DATA('m', ACS_LLCORNER), /* lower left corner */
+ DATA('k', ACS_URCORNER), /* upper right corner */
+ DATA('j', ACS_LRCORNER), /* lower right corner */
+ DATA('t', ACS_LTEE), /* tee pointing right */
+ DATA('u', ACS_RTEE), /* tee pointing left */
+ DATA('v', ACS_BTEE), /* tee pointing up */
+ DATA('w', ACS_TTEE), /* tee pointing down */
+ DATA('q', ACS_HLINE), /* horizontal line */
+ DATA('x', ACS_VLINE), /* vertical line */
+ DATA('n', ACS_PLUS), /* large plus or crossover */
+ DATA('o', ACS_S1), /* scan line 1 */
+ DATA('s', ACS_S9), /* scan line 9 */
+ DATA('`', ACS_DIAMOND), /* diamond */
+ DATA('a', ACS_CKBOARD), /* checker board (stipple) */
+ DATA('f', ACS_DEGREE), /* degree symbol */
+ DATA('g', ACS_PLMINUS), /* plus/minus */
+ DATA('~', ACS_BULLET), /* bullet */
+ DATA(',', ACS_LARROW), /* arrow pointing left */
+ DATA('+', ACS_RARROW), /* arrow pointing right */
+ DATA('.', ACS_DARROW), /* arrow pointing down */
+ DATA('-', ACS_UARROW), /* arrow pointing up */
+ DATA('h', ACS_BOARD), /* board of squares */
+ DATA('i', ACS_LANTERN), /* lantern symbol */
+ DATA('0', ACS_BLOCK), /* solid square block */
+ DATA('p', ACS_S3), /* scan line 3 */
+ DATA('r', ACS_S7), /* scan line 7 */
+ DATA('y', ACS_LEQUAL), /* less/equal */
+ DATA('z', ACS_GEQUAL), /* greater/equal */
+ DATA('{', ACS_PI), /* Pi */
+ DATA('|', ACS_NEQUAL), /* not equal */
+ DATA('}', ACS_STERLING), /* UK pound sign */
};
+#undef DATA
const char *result = 0;
@@ -257,7 +255,6 @@ _nc_altcharset_name(attr_t attr, chtype ch)
if (SP_PARM != 0 && (attr & A_ALTCHARSET) && (acs_chars != 0)) {
char *cp;
char *found = 0;
- const ALT_NAMES *strp;
for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) {
@@ -267,12 +264,15 @@ _nc_altcharset_name(attr_t attr, chtype ch)
}
if (found != 0) {
+ size_t n;
+
ch = ChCharOf(UChar(*found));
- for (strp = names; strp->val; strp++)
- if (strp->val == ch) {
- result = strp->name;
+ for (n = 0; n < SIZEOF(names); ++n) {
+ if (names[n].val == ch) {
+ result = names[n].name;
break;
}
+ }
}
}
return result;
@@ -281,22 +281,25 @@ _nc_altcharset_name(attr_t attr, chtype ch)
NCURSES_EXPORT(char *)
_tracechtype2(int bufnum, chtype ch)
{
- const char *found;
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
if (result != 0) {
+ const char *found;
+ attr_t attr = ChAttrOf(ch);
+
_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
- if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
+ if ((found = _nc_altcharset_name(attr, ch)) != 0) {
(void) _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
} else
(void) _nc_trace_bufcat(bufnum,
_nc_tracechar(CURRENT_SCREEN,
(int) ChCharOf(ch)));
- if (ChAttrOf(ch) != A_NORMAL) {
+ if (attr != A_NORMAL) {
(void) _nc_trace_bufcat(bufnum, " | ");
(void) _nc_trace_bufcat(bufnum,
- _traceattr2(bufnum + 20, ChAttrOf(ch)));
+ _traceattr2(bufnum + 20, attr));
}
result = _nc_trace_bufcat(bufnum, r_brace);
@@ -323,13 +326,13 @@ NCURSES_EXPORT(char *)
_tracecchar_t2(int bufnum, const cchar_t *ch)
{
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- attr_t attr;
- const char *found;
if (result != 0) {
_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
if (ch != 0) {
- attr = AttrOfD(ch);
+ const char *found;
+ attr_t attr = AttrOfD(ch);
+
if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
(void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
@@ -340,7 +343,6 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
PUTC_DATA;
int n;
- PUTC_INIT;
(void) _nc_trace_bufcat(bufnum, "{ ");
for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
PUTC_ch = ch->chars[PUTC_i];
@@ -349,6 +351,7 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
(void) _nc_trace_bufcat(bufnum, "\\000");
break;
}
+ PUTC_INIT;
PUTC_n = (int) wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
if (PUTC_n <= 0) {
if (PUTC_ch != L'\0') {
@@ -358,6 +361,14 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
UChar(ch->chars[PUTC_i])));
}
break;
+ } else if (ch->chars[PUTC_i] > 255) {
+ char temp[80];
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "{%d:\\u%lx}",
+ _nc_wacs_width(ch->chars[PUTC_i]),
+ (unsigned long) ch->chars[PUTC_i]);
+ (void) _nc_trace_bufcat(bufnum, temp);
+ break;
}
for (n = 0; n < PUTC_n; n++) {
if (n)
@@ -373,6 +384,18 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
(void) _nc_trace_bufcat(bufnum, " | ");
(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
}
+#if NCURSES_EXT_COLORS
+ /*
+ * Just in case the extended color is different from the chtype
+ * value, trace both.
+ */
+ if (ch->ext_color != PairNumber(attr)) {
+ char temp[80];
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr));
+ (void) _nc_trace_bufcat(bufnum, temp);
+ }
+#endif
}
result = _nc_trace_bufcat(bufnum, r_brace);
diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c
index 7d8325a828f4..43b29a9496e0 100644
--- a/ncurses/trace/lib_tracebits.c
+++ b/ncurses/trace/lib_tracebits.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2015,2019 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 *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracebits.c,v 1.23 2012/06/09 19:55:46 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.27 2019/02/16 22:12:08 tom Exp $")
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
@@ -73,7 +73,7 @@ MODULE_ID("$Id: lib_tracebits.c,v 1.23 2012/06/09 19:55:46 tom Exp $")
typedef struct {
unsigned int val;
- const char *name;
+ const char name[8];
} BITNAMES;
#define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size)
@@ -85,7 +85,7 @@ lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned int v
_nc_STRCAT(buf, label, TRACE_BUF_SIZE(0));
_nc_STRCAT(buf, ": {", TRACE_BUF_SIZE(0));
- for (sp = table; sp->name; sp++)
+ for (sp = table; sp->name[0]; sp++)
if (sp->val != 0
&& (val & sp->val) == sp->val) {
_nc_STRCAT(buf, sp->name, TRACE_BUF_SIZE(0));
@@ -103,56 +103,59 @@ _nc_trace_ttymode(TTY * tty)
char *buf;
#ifdef TERMIOS
+#define DATA(name) { name, { #name } }
+#define DATA2(name,name2) { name, { #name2 } }
+#define DATAX() { 0, { "" } }
static const BITNAMES iflags[] =
{
- {BRKINT, "BRKINT"},
- {IGNBRK, "IGNBRK"},
- {IGNPAR, "IGNPAR"},
- {PARMRK, "PARMRK"},
- {INPCK, "INPCK"},
- {ISTRIP, "ISTRIP"},
- {INLCR, "INLCR"},
- {IGNCR, "IGNC"},
- {ICRNL, "ICRNL"},
- {IXON, "IXON"},
- {IXOFF, "IXOFF"},
- {0, NULL}
+ DATA(BRKINT),
+ DATA(IGNBRK),
+ DATA(IGNPAR),
+ DATA(PARMRK),
+ DATA(INPCK),
+ DATA(ISTRIP),
+ DATA(INLCR),
+ DATA(IGNCR),
+ DATA(ICRNL),
+ DATA(IXON),
+ DATA(IXOFF),
+ DATAX()
#define ALLIN (BRKINT|IGNBRK|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF)
}, oflags[] =
{
- {OPOST, "OPOST"},
- {OFLAGS_TABS, "XTABS"},
- {ONLCR, "ONLCR"},
- {OCRNL, "OCRNL"},
- {ONOCR, "ONOCR"},
- {ONLRET, "ONLRET"},
- {0, NULL}
-#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET)
+ DATA(OPOST),
+ DATA2(OFLAGS_TABS, XTABS),
+ DATA(ONLCR),
+ DATA(OCRNL),
+ DATA(ONOCR),
+ DATA(ONLRET),
+ DATAX()
+#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET|OFLAGS_TABS)
}, cflags[] =
{
- {CLOCAL, "CLOCAL"},
- {CREAD, "CREAD"},
- {CSTOPB, "CSTOPB"},
+ DATA(CLOCAL),
+ DATA(CREAD),
+ DATA(CSTOPB),
#if !defined(CS5) || !defined(CS8)
- {CSIZE, "CSIZE"},
+ DATA(CSIZE),
#endif
- {HUPCL, "HUPCL"},
- {PARENB, "PARENB"},
- {PARODD | PARENB, "PARODD"}, /* concession to readability */
- {0, NULL}
+ DATA(HUPCL),
+ DATA(PARENB),
+ DATA2(PARODD | PARENB, PARODD),
+ DATAX()
#define ALLCTRL (CLOCAL|CREAD|CSIZE|CSTOPB|HUPCL|PARENB|PARODD)
}, lflags[] =
{
- {ECHO, "ECHO"},
- {ECHOE | ECHO, "ECHOE"}, /* concession to readability */
- {ECHOK | ECHO, "ECHOK"}, /* concession to readability */
- {ECHONL, "ECHONL"},
- {ICANON, "ICANON"},
- {ISIG, "ISIG"},
- {NOFLSH, "NOFLSH"},
- {TOSTOP, "TOSTOP"},
- {IEXTEN, "IEXTEN"},
- {0, NULL}
+ DATA(ECHO),
+ DATA2(ECHOE | ECHO, ECHOE),
+ DATA2(ECHOK | ECHO, ECHOK),
+ DATA(ECHONL),
+ DATA(ICANON),
+ DATA(ISIG),
+ DATA(NOFLSH),
+ DATA(TOSTOP),
+ DATA(IEXTEN),
+ DATAX()
#define ALLLOCAL (ECHO|ECHONL|ICANON|ISIG|NOFLSH|TOSTOP|IEXTEN)
};
@@ -175,11 +178,11 @@ _nc_trace_ttymode(TTY * tty)
#if defined(CS5) && defined(CS8)
{
- static struct {
+ static const struct {
int value;
- const char *name;
+ const char name[5];
} csizes[] = {
-#define CS_DATA(name) { name, #name " " }
+#define CS_DATA(name) { name, { #name " " } }
CS_DATA(CS5),
#ifdef CS6
CS_DATA(CS6),
@@ -228,17 +231,17 @@ _nc_trace_ttymode(TTY * tty)
static const BITNAMES cflags[] =
{
- {CBREAK, "CBREAK"},
- {CRMOD, "CRMOD"},
- {ECHO, "ECHO"},
- {EVENP, "EVENP"},
- {LCASE, "LCASE"},
- {LLITOUT, "LLITOUT"},
- {ODDP, "ODDP"},
- {RAW, "RAW"},
- {TANDEM, "TANDEM"},
- {XTABS, "XTABS"},
- {0, NULL}
+ DATA(CBREAK),
+ DATA(CRMOD),
+ DATA(ECHO),
+ DATA(EVENP),
+ DATA(LCASE),
+ DATA(LLITOUT),
+ DATA(ODDP),
+ DATA(RAW),
+ DATA(TANDEM),
+ DATA(XTABS),
+ DATAX()
#define ALLCTRL (CBREAK|CRMOD|ECHO|EVENP|LCASE|LLITOUT|ODDP|RAW|TANDEM|XTABS)
};
diff --git a/ncurses/trace/lib_tracedmp.c b/ncurses/trace/lib_tracedmp.c
index 0fda15b252e6..c8b7b05c2035 100644
--- a/ncurses/trace/lib_tracedmp.c
+++ b/ncurses/trace/lib_tracedmp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2016 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 *
@@ -39,7 +39,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_tracedmp.c,v 1.34 2012/10/27 20:54:42 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.35 2016/05/28 23:30:01 tom Exp $")
#ifdef TRACE
@@ -76,7 +76,7 @@ _tracedump(const char *name, WINDOW *win)
for (n = 0; n <= win->_maxy; ++n) {
char *ep = my_buffer;
- bool haveattrs, havecolors;
+ bool havecolors;
/*
* Dump A_CHARTEXT part. It is more important to make the grid line up
@@ -156,8 +156,8 @@ _tracedump(const char *name, WINDOW *win)
for (i = 0; i < 4; ++i) {
const char *hex = " 123456789ABCDEF";
attr_t mask = (attr_t) (0xf << ((i + 4) * 4));
+ bool haveattrs = FALSE;
- haveattrs = FALSE;
for (j = 0; j < width; ++j)
if (AttrOf(win->_line[n].text[j]) & mask) {
haveattrs = TRUE;
diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c
index 51ffa2ef7634..c62b71a0658b 100644
--- a/ncurses/trace/lib_tracemse.c
+++ b/ncurses/trace/lib_tracemse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2014 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 *
@@ -38,19 +38,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracemse.c,v 1.21 2012/12/15 23:51:19 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.22 2014/10/10 09:06:26 tom Exp $")
#ifdef TRACE
#define my_buffer sp->tracemse_buf
-static char *
-_trace_mmask_t(SCREEN *sp, mmask_t code)
+NCURSES_EXPORT(char *)
+_nc_trace_mmask_t(SCREEN *sp, mmask_t code)
{
#define SHOW(m, s) \
if ((code & m) == m) { \
- _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \
+ size_t n = strlen(my_buffer); \
+ if (n && (my_buffer[n-1] != '{')) \
_nc_STRCAT(my_buffer, ", ", sizeof(my_buffer)); \
+ _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \
}
SHOW(BUTTON1_RELEASED, "release-1");
@@ -125,7 +127,7 @@ _nc_tracemouse(SCREEN *sp, MEVENT const *ep)
ep->z,
(unsigned long) ep->bstate);
- (void) _trace_mmask_t(sp, ep->bstate);
+ (void) _nc_trace_mmask_t(sp, ep->bstate);
_nc_STRCAT(my_buffer, "}", sizeof(my_buffer));
result = (my_buffer);
}
@@ -137,7 +139,7 @@ _nc_retrace_mmask_t(SCREEN *sp, mmask_t code)
{
if (sp != 0) {
*my_buffer = '\0';
- T((T_RETURN("{%s}"), _trace_mmask_t(sp, code)));
+ T((T_RETURN("{%s}"), _nc_trace_mmask_t(sp, code)));
} else {
T((T_RETURN("{?}")));
}
diff --git a/ncurses/trace/trace_xnames.c b/ncurses/trace/trace_xnames.c
index 38a48730ccdc..8d0eefb9d4f0 100644
--- a/ncurses/trace/trace_xnames.c
+++ b/ncurses/trace/trace_xnames.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1999-2000,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2010,2016 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 *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_xnames.c,v 1.6 2010/01/23 17:59:27 tom Exp $")
+MODULE_ID("$Id: trace_xnames.c,v 1.7 2016/05/28 23:30:01 tom Exp $")
NCURSES_EXPORT(void)
_nc_trace_xnames(TERMTYPE *tp GCC_UNUSED)
@@ -43,8 +43,9 @@ _nc_trace_xnames(TERMTYPE *tp GCC_UNUSED)
#ifdef TRACE
#if NCURSES_XNAMES
int limit = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
- int n, m;
+
if (limit) {
+ int n;
int begin_num = tp->ext_Booleans;
int begin_str = tp->ext_Booleans + tp->ext_Numbers;
@@ -53,7 +54,10 @@ _nc_trace_xnames(TERMTYPE *tp GCC_UNUSED)
limit,
tp->ext_Booleans, tp->ext_Numbers, tp->ext_Strings,
tp->num_Booleans, tp->num_Numbers, tp->num_Strings);
+
for (n = 0; n < limit; n++) {
+ int m;
+
if ((m = n - begin_str) >= 0) {
_tracef("[%d] %s = %s", n,
tp->ext_Names[n],
diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c
index effa84352b7d..4f78139f3fcc 100644
--- a/ncurses/trace/visbuf.c
+++ b/ncurses/trace/visbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001-2012,2014 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2017,2019 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 *
@@ -42,12 +42,12 @@
#include <tic.h>
#include <ctype.h>
-MODULE_ID("$Id: visbuf.c,v 1.43 2014/02/23 01:21:08 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.51 2019/05/04 20:31:31 tom Exp $")
#define NUM_VISBUFS 4
#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4)
-#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX)
+#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * (size_t) MB_CUR_MAX)
#ifdef TRACE
static const char d_quote[] = StringOf(D_QUOTE);
@@ -69,7 +69,7 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG)
if (c == '"' || c == '\\') {
*tp++ = '\\';
*tp++ = (char) c;
- } else if (is7bits((int)c) && (isgraph((int)c) || c == ' ')) {
+ } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) {
*tp++ = (char) c;
} else if (c == '\n') {
*tp++ = '\\';
@@ -80,6 +80,9 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG)
} else if (c == '\b') {
*tp++ = '\\';
*tp++ = 'b';
+ } else if (c == '\t') {
+ *tp++ = '\\';
+ *tp++ = 't';
} else if (c == '\033') {
*tp++ = '\\';
*tp++ = 'e';
@@ -105,7 +108,6 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
{
const char *vbuf = 0;
char *tp;
- int c;
int count;
if (buf == 0)
@@ -122,6 +124,8 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
#else
{
static char *mybuf[NUM_VISBUFS];
+ int c;
+
if (bufnum < 0) {
for (c = 0; c < NUM_VISBUFS; ++c) {
FreeAndNull(mybuf[c]);
@@ -134,6 +138,8 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
}
#endif
if (tp != 0) {
+ int c;
+
*tp++ = D_QUOTE;
while ((--count >= 0) && (c = *buf++) != '\0') {
tp = VisChar(tp, UChar(c), NormalLen(len));
@@ -185,7 +191,6 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
const char *vbuf;
char *tp;
- wchar_t c;
int count;
if (buf == 0)
@@ -205,6 +210,8 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
}
#endif
if (tp != 0) {
+ wchar_t c;
+
*tp++ = D_QUOTE;
while ((--count >= 0) && (c = *buf++) != '\0') {
char temp[CCHARW_MAX + 80];
@@ -278,10 +285,10 @@ NCURSES_EXPORT(const char *)
_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
{
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- int first;
- const char *found;
if (result != 0) {
+ int first = 0;
+
#if USE_WIDEC_SUPPORT
if (len < 0)
len = _nc_wchstrlen(buf);
@@ -290,7 +297,6 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
/*
* Display one or more strings followed by attributes.
*/
- first = 0;
while (first < len) {
attr_t attr = AttrOf(buf[first]);
int last = len - 1;
@@ -306,7 +312,8 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
(void) _nc_trace_bufcat(bufnum, l_brace);
(void) _nc_trace_bufcat(bufnum, d_quote);
for (j = first; j <= last; ++j) {
- found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
+ const char *found = _nc_altcharset_name(attr, (chtype)
+ CharOf(buf[j]));
if (found != 0) {
(void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
@@ -315,9 +322,9 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
if (!isWidecExt(buf[j])) {
PUTC_DATA;
- PUTC_INIT;
for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
int k;
+ char temp[80];
PUTC_ch = buf[j].chars[PUTC_i];
if (PUTC_ch == L'\0') {
@@ -325,12 +332,18 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
(void) _nc_trace_bufcat(bufnum, "\\000");
break;
}
+ PUTC_INIT;
PUTC_n = (int) wcrtomb(PUTC_buf,
buf[j].chars[PUTC_i], &PUT_st);
- if (PUTC_n <= 0)
+ if (PUTC_n <= 0 || buf[j].chars[PUTC_i] > 255) {
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "{%d:\\u%lx}",
+ _nc_wacs_width(buf[j].chars[PUTC_i]),
+ (unsigned long) buf[j].chars[PUTC_i]);
+ (void) _nc_trace_bufcat(bufnum, temp);
break;
+ }
for (k = 0; k < PUTC_n; k++) {
- char temp[80];
VisChar(temp, UChar(PUTC_buf[k]), sizeof(temp));
(void) _nc_trace_bufcat(bufnum, temp);
}