aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/trace
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/trace')
-rw-r--r--contrib/ncurses/ncurses/trace/README30
-rw-r--r--contrib/ncurses/ncurses/trace/lib_trace.c98
-rw-r--r--contrib/ncurses/ncurses/trace/lib_traceatr.c139
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c6
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracechr.c36
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracedmp.c41
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracemse.c42
-rw-r--r--contrib/ncurses/ncurses/trace/trace_buf.c71
-rw-r--r--contrib/ncurses/ncurses/trace/varargs.c64
-rw-r--r--contrib/ncurses/ncurses/trace/visbuf.c227
10 files changed, 532 insertions, 222 deletions
diff --git a/contrib/ncurses/ncurses/trace/README b/contrib/ncurses/ncurses/trace/README
index a627a537a3d1..e658feccb873 100644
--- a/contrib/ncurses/ncurses/trace/README
+++ b/contrib/ncurses/ncurses/trace/README
@@ -1,4 +1,32 @@
--- $Id: README,v 1.1 1998/11/08 00:11:01 tom Exp $
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998,2006 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 --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: README,v 1.2 2006/04/22 22:19:37 tom Exp $
+-------------------------------------------------------------------------------
The files in this directory (trace) support both the terminfo and ncurses
libraries. Most of the functions are linked in only when the libraries
diff --git a/contrib/ncurses/ncurses/trace/lib_trace.c b/contrib/ncurses/ncurses/trace/lib_trace.c
index 29eecc0a2764..7f7812217999 100644
--- a/contrib/ncurses/ncurses/trace/lib_trace.c
+++ b/contrib/ncurses/ncurses/trace/lib_trace.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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 *
@@ -29,10 +29,16 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* lib_trace.c - Tracing/Debugging routines
+ *
+ * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982.
+ * pcurses allowed one to enable/disable tracing using traceon() and traceoff()
+ * functions. ncurses provides a trace() function which allows one to
+ * selectively enable or disable several tracing features.
*/
#include <curses.priv.h>
@@ -40,32 +46,38 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_trace.c,v 1.48 2001/10/20 20:35:25 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.59 2006/08/19 12:05:25 tom Exp $")
-NCURSES_EXPORT_VAR(unsigned)
-_nc_tracing = 0; /* always define this */
+NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
#ifdef TRACE
-NCURSES_EXPORT_VAR(const char *)
-_nc_tputs_trace = "";
-NCURSES_EXPORT_VAR(long)
-_nc_outchars = 0;
+NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace = "";
+NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
- static FILE *tracefp; /* default to writing to stderr */
+static FILE *tracefp = 0; /* default to writing to stderr */
NCURSES_EXPORT(void)
-trace(const unsigned int tracelevel GCC_UNUSED)
+trace(const unsigned int tracelevel)
{
static bool been_here = FALSE;
- static char my_name[] = "trace";
+ static char my_name[PATH_MAX];
- if (!been_here && tracelevel) {
- been_here = TRUE;
+ if ((tracefp == 0) && tracelevel) {
+ const char *mode = been_here ? "ab" : "wb";
+
+ if (*my_name == '\0') {
+ if (getcwd(my_name, sizeof(my_name) - 10) == 0) {
+ perror("curses: Can't get working directory");
+ exit(EXIT_FAILURE);
+ }
+ strcat(my_name, "/trace");
+ }
+ been_here = TRUE;
_nc_tracing = tracelevel;
if (_nc_access(my_name, W_OK) < 0
- || (tracefp = fopen(my_name, "wb")) == 0) {
- perror("curses: Can't open 'trace' file: ");
+ || (tracefp = fopen(my_name, mode)) == 0) {
+ perror("curses: Can't open 'trace' file");
exit(EXIT_FAILURE);
}
/* Try to set line-buffered mode, or (failing that) unbuffered,
@@ -77,8 +89,16 @@ trace(const unsigned int tracelevel GCC_UNUSED)
#elif HAVE_SETBUF /* POSIX */
(void) setbuffer(tracefp, (char *) 0);
#endif
- _tracef("TRACING NCURSES version %s (tracelevel=%#x)",
- curses_version(), tracelevel);
+ _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;
+ }
+ _nc_tracing = tracelevel;
} else if (_nc_tracing != tracelevel) {
_nc_tracing = tracelevel;
_tracef("tracelevel=%#x", tracelevel);
@@ -94,7 +114,7 @@ _tracef(const char *fmt,...)
va_list ap;
bool before = FALSE;
bool after = FALSE;
- int doit = _nc_tracing;
+ unsigned doit = _nc_tracing;
int save_err = errno;
if (strlen(fmt) >= sizeof(Called) - 1) {
@@ -133,6 +153,14 @@ _tracef(const char *fmt,...)
errno = save_err;
}
+/* Trace 'bool' return-values */
+NCURSES_EXPORT(NCURSES_BOOL)
+_nc_retrace_bool(NCURSES_BOOL code)
+{
+ T((T_RETURN("%s"), code ? "TRUE" : "FALSE"));
+ return code;
+}
+
/* Trace 'int' return-values */
NCURSES_EXPORT(int)
_nc_retrace_int(int code)
@@ -141,6 +169,14 @@ _nc_retrace_int(int code)
return code;
}
+/* Trace 'unsigned' return-values */
+NCURSES_EXPORT(unsigned)
+_nc_retrace_unsigned(unsigned code)
+{
+ T((T_RETURN("%#x"), code));
+ return code;
+}
+
/* Trace 'char*' return-values */
NCURSES_EXPORT(char *)
_nc_retrace_ptr(char *code)
@@ -149,9 +185,33 @@ _nc_retrace_ptr(char *code)
return code;
}
+/* Trace 'const char*' return-values */
+NCURSES_EXPORT(const char *)
+_nc_retrace_cptr(const char *code)
+{
+ T((T_RETURN("%s"), _nc_visbuf(code)));
+ return code;
+}
+
+/* Trace 'NCURSES_CONST void*' return-values */
+NCURSES_EXPORT(NCURSES_CONST void *)
+_nc_retrace_cvoid_ptr(NCURSES_CONST void *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+/* Trace 'void*' return-values */
+NCURSES_EXPORT(void *)
+_nc_retrace_void_ptr(void *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
/* Trace 'SCREEN *' return-values */
NCURSES_EXPORT(SCREEN *)
-_nc_retrace_sp(SCREEN * code)
+_nc_retrace_sp(SCREEN *code)
{
T((T_RETURN("%p"), code));
return code;
diff --git a/contrib/ncurses/ncurses/trace/lib_traceatr.c b/contrib/ncurses/ncurses/trace/lib_traceatr.c
index 870624f3f514..ee6cf5f1f3d3 100644
--- a/contrib/ncurses/ncurses/trace/lib_traceatr.c
+++ b/contrib/ncurses/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas Dickey 1996-2001 *
+ * Author: Thomas Dickey 1996-on *
* and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -39,20 +39,40 @@
#include <curses.priv.h>
#include <term.h> /* acs_chars */
-MODULE_ID("$Id: lib_traceatr.c,v 1.42 2002/06/16 00:35:01 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.56 2006/12/02 21:18:28 tom Exp $")
-#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
+#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
#ifdef TRACE
static const char l_brace[] = {L_BRACE, 0};
static const char r_brace[] = {R_BRACE, 0};
+#ifndef USE_TERMLIB
+static char *
+color_of(int c)
+{
+ static char buffer[2][80];
+ static int sel;
+ static int last = -1;
+
+ if (c != last) {
+ last = c;
+ sel = !sel;
+ if (c == COLOR_DEFAULT)
+ strcpy(buffer[sel], "default");
+ else
+ sprintf(buffer[sel], "color%d", c);
+ }
+ return buffer[sel];
+}
+#endif /* !USE_TERMLIB */
+
NCURSES_EXPORT(char *)
-_traceattr2(int bufnum, attr_t newmode)
+_traceattr2(int bufnum, chtype newmode)
{
char *buf = _nc_trace_buf(bufnum, BUFSIZ);
- char *tmp = buf;
+ char temp[80];
static const struct {
unsigned int val;
const char *name;
@@ -73,7 +93,9 @@ _traceattr2(int bufnum, attr_t newmode)
{ A_COLOR, "A_COLOR" },
/* *INDENT-ON* */
- },
+ }
+#ifndef USE_TERMLIB
+ ,
colors[] =
{
/* *INDENT-OFF* */
@@ -87,44 +109,51 @@ _traceattr2(int bufnum, attr_t newmode)
{ COLOR_WHITE, "COLOR_WHITE" },
/* *INDENT-ON* */
- };
+ }
+#endif /* !USE_TERMLIB */
+ ;
size_t n;
unsigned save_nc_tracing = _nc_tracing;
_nc_tracing = 0;
- strcpy(tmp++, l_brace);
+ strcpy(buf, l_brace);
for (n = 0; n < SIZEOF(names); n++) {
if ((newmode & names[n].val) != 0) {
if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, names[n].name);
- tmp += strlen(tmp);
+ buf = _nc_trace_bufcat(bufnum, "|");
+ buf = _nc_trace_bufcat(bufnum, names[n].name);
if (names[n].val == A_COLOR) {
short pairnum = PAIR_NUMBER(newmode);
+#ifdef USE_TERMLIB
+ /* pair_content lives in libncurses */
+ (void) sprintf(temp, "{%d}", pairnum);
+#else
short fg, bg;
- if (pair_content(pairnum, &fg, &bg) == OK)
- (void) sprintf(tmp,
+ if (pair_content(pairnum, &fg, &bg) == OK) {
+ (void) sprintf(temp,
"{%d = {%s, %s}}",
pairnum,
COLOR_OF(fg),
- COLOR_OF(bg)
- );
- else
- (void) sprintf(tmp, "{%d}", pairnum);
+ COLOR_OF(bg));
+ } else {
+ (void) sprintf(temp, "{%d}", pairnum);
+ }
+#endif
+ buf = _nc_trace_bufcat(bufnum, temp);
}
}
}
if (ChAttrOf(newmode) == A_NORMAL) {
if (buf[1] != '\0')
- strcat(tmp, "|");
- strcat(tmp, "A_NORMAL");
+ (void) _nc_trace_bufcat(bufnum, "|");
+ (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
}
_nc_tracing = save_nc_tracing;
- return (strcat(buf, r_brace));
+ return (_nc_trace_bufcat(bufnum, r_brace));
}
NCURSES_EXPORT(char *)
@@ -146,7 +175,7 @@ _nc_altcharset_name(attr_t attr, chtype ch)
{
const char *result = 0;
- if (attr & A_ALTCHARSET) {
+ if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
char *cp;
char *found = 0;
static const struct {
@@ -214,20 +243,21 @@ _nc_altcharset_name(attr_t attr, chtype ch)
NCURSES_EXPORT(char *)
_tracechtype2(int bufnum, chtype ch)
{
- char *buf = _nc_trace_buf(bufnum, BUFSIZ);
const char *found;
- strcpy(buf, l_brace);
+ strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace);
if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
- (void) strcat(buf, found);
+ (void) _nc_trace_bufcat(bufnum, found);
} else
- (void) strcat(buf, _tracechar(ChCharOf(ch)));
+ (void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));
- if (ChAttrOf(ch) != A_NORMAL)
- (void) sprintf(buf + strlen(buf), " | %s",
+ if (ChAttrOf(ch) != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum,
_traceattr2(bufnum + 20, ChAttrOf(ch)));
+ }
- return (strcat(buf, r_brace));
+ return (_nc_trace_bufcat(bufnum, r_brace));
}
NCURSES_EXPORT(char *)
@@ -237,8 +267,8 @@ _tracechtype (chtype ch)
}
/* Trace 'chtype' return-values */
-NCURSES_EXPORT(attr_t)
-_nc_retrace_chtype (attr_t code)
+NCURSES_EXPORT(chtype)
+_nc_retrace_chtype (chtype code)
{
T((T_RETURN("%s"), _tracechtype(code)));
return code;
@@ -255,38 +285,45 @@ _tracecchar_t2 (int bufnum, const cchar_t *ch)
strcpy(buf, l_brace);
if (ch != 0) {
attr = AttrOfD(ch);
- if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) {
- (void) strcat(buf, found);
+ if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
- } else if (!isnac(CHDEREF(ch))) {
+ } else if (isWidecExt(CHDEREF(ch))) {
+ (void) _nc_trace_bufcat(bufnum, "{NAC}");
+ attr &= ~A_CHARTEXT;
+ } else {
PUTC_DATA;
int n;
- memset (&PUT_st, '\0', sizeof (PUT_st));
- PUTC_i = 0;
- (void) strcat(buf, "{ ");
- do {
- PUTC_ch = PUTC_i < CCHARW_MAX ? ch->chars[PUTC_i] : L'\0';
- PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+ PUTC_INIT;
+ (void) _nc_trace_bufcat(bufnum, "{ ");
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ PUTC_ch = ch->chars[PUTC_i];
if (PUTC_ch == L'\0')
- --PUTC_n;
- if (PUTC_n <= 0)
break;
+ PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+ if (PUTC_n <= 0) {
+ if (PUTC_ch != L'\0') {
+ /* it could not be a multibyte sequence */
+ (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i])));
+ }
+ break;
+ }
for (n = 0; n < PUTC_n; n++) {
if (n)
- (void) strcat(buf, ", ");
- (void) strcat(buf, _tracechar(UChar(PUTC_buf[n])));
+ (void) _nc_trace_bufcat(bufnum, ", ");
+ (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n])));
}
- ++PUTC_i;
- } while (PUTC_ch != L'\0');
- (void) strcat(buf, " }");
+ }
+ (void) _nc_trace_bufcat(bufnum, " }");
+ }
+ if (attr != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
}
- if (attr != A_NORMAL)
- (void) sprintf(buf + strlen(buf), " | %s",
- _traceattr2(bufnum + 20, attr));
}
- return (strcat(buf, r_brace));
+ return (_nc_trace_bufcat(bufnum, r_brace));
}
NCURSES_EXPORT(char *)
diff --git a/contrib/ncurses/ncurses/trace/lib_tracebits.c b/contrib/ncurses/ncurses/trace/lib_tracebits.c
index e681862649af..d9defd0cc9d6 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracebits.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracebits.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 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 *
@@ -29,12 +29,13 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_tracebits.c,v 1.12 2002/05/25 14:35:07 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.13 2006/12/10 01:33:00 tom Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -106,6 +107,7 @@ _nc_trace_ttymode(TTY * tty)
}, oflags[] =
{
{OPOST, "OPOST"},
+ {OFLAGS_TABS, "XTABS"},
{0, NULL}
#define ALLOUT (OPOST)
}, cflags[] =
diff --git a/contrib/ncurses/ncurses/trace/lib_tracechr.c b/contrib/ncurses/ncurses/trace/lib_tracechr.c
index 2f33391b5505..34a2bb616f29 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracechr.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracechr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -36,19 +37,36 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracechr.c,v 1.9 2002/05/25 23:34:19 tom Exp $")
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_tracechr.c,v 1.12 2005/04/16 16:55:46 tom Exp $")
#ifdef TRACE
NCURSES_EXPORT(char *)
_tracechar(int ch)
{
- static char crep[40];
- (void) sprintf(crep, "'%.30s' = %#03o",
- ((ch > KEY_MIN || ch < 0)
- ? keyname(ch)
- : unctrl(ch)),
- ch);
- return (crep);
+ static char result[40];
+ NCURSES_CONST char *name;
+
+ if (ch > KEY_MIN || ch < 0) {
+ name = keyname(ch);
+ if (name == 0 || *name == '\0')
+ name = "NULL";
+ (void) sprintf(result, "'%.30s' = %#03o", name, ch);
+ } else if (!is8bits(ch) || !isprint(UChar(ch))) {
+ /*
+ * workaround for glibc bug:
+ * sprintf changes the result from unctrl() to an empty string if it
+ * does not correspond to a valid multibyte sequence.
+ */
+ (void) sprintf(result, "%#03o", ch);
+ } else {
+ name = unctrl((chtype) ch);
+ if (name == 0 || *name == 0)
+ name = "null"; /* shouldn't happen */
+ (void) sprintf(result, "'%.30s' = %#03o", name, ch);
+ }
+ return (result);
}
#else
empty_module(_nc_lib_tracechr)
diff --git a/contrib/ncurses/ncurses/trace/lib_tracedmp.c b/contrib/ncurses/ncurses/trace/lib_tracedmp.c
index 8f8753640e0c..41739a92527c 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracedmp.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracedmp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996-2001 *
+ * Author: Thomas E. Dickey 1996-on *
* and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -39,7 +39,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_tracedmp.c,v 1.22 2001/11/03 15:45:35 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.27 2006/10/14 20:43:31 tom Exp $")
#ifdef TRACE
NCURSES_EXPORT(void)
@@ -53,9 +53,13 @@ _tracedump(const char *name, WINDOW *win)
/* compute narrowest possible display width */
for (width = i = 0; i <= win->_maxy; ++i) {
n = 0;
- for (j = 0; j <= win->_maxx; ++j)
- if (CharOf(win->_line[i].text[j]) != L(' '))
+ for (j = 0; j <= win->_maxx; ++j) {
+ if (CharOf(win->_line[i].text[j]) != L(' ')
+ || AttrOf(win->_line[i].text[j]) != A_NORMAL
+ || GetPair(win->_line[i].text[j]) != 0) {
n = j;
+ }
+ }
if (n > width)
width = n;
@@ -64,7 +68,7 @@ _tracedump(const char *name, WINDOW *win)
++width;
if (++width + 1 > (int) used) {
used = 2 * (width + 1);
- buf = _nc_doalloc(buf, used);
+ buf = typeRealloc(char, used, buf);
}
for (n = 0; n <= win->_maxy; ++n) {
@@ -89,24 +93,34 @@ _tracedump(const char *name, WINDOW *win)
: '?';
}
ep[j] = '\0';
- _tracef("%s[%2d] %3d%3d ='%s'",
+ _tracef("%s[%2d] %3ld%3ld ='%s'",
name, n,
- win->_line[n].firstchar,
- win->_line[n].lastchar,
+ (long) win->_line[n].firstchar,
+ (long) win->_line[n].lastchar,
ep);
/* dump A_COLOR part, will screw up if there are more than 96 */
havecolors = FALSE;
for (j = 0; j < width; ++j)
- if (AttrOf(win->_line[n].text[j]) & A_COLOR) {
+ if (GetPair(win->_line[n].text[j]) != 0) {
havecolors = TRUE;
break;
}
if (havecolors) {
ep = buf;
- for (j = 0; j < width; ++j)
- ep[j] = UChar(CharOf(win->_line[n].text[j]) >>
- NCURSES_ATTR_SHIFT) + ' ';
+ for (j = 0; j < width; ++j) {
+ int pair = GetPair(win->_line[n].text[j]);
+ if (pair >= 52)
+ ep[j] = '?';
+ else if (pair >= 36)
+ ep[j] = pair + 'A';
+ else if (pair >= 10)
+ ep[j] = pair + 'a';
+ else if (pair >= 1)
+ ep[j] = pair + '0';
+ else
+ ep[j] = ' ';
+ }
ep[j] = '\0';
_tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
"colors", n, 8, " ", buf);
@@ -135,6 +149,7 @@ _tracedump(const char *name, WINDOW *win)
}
#if NO_LEAKS
free(buf);
+ buf = 0;
used = 0;
#endif
}
diff --git a/contrib/ncurses/ncurses/trace/lib_tracemse.c b/contrib/ncurses/ncurses/trace/lib_tracemse.c
index f4a100b6eb43..98290a1efb0e 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracemse.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracemse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2005 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -37,48 +38,81 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracemse.c,v 1.10 2002/01/12 22:32:25 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.12 2005/06/11 19:53:50 tom Exp $")
#ifdef TRACE
NCURSES_EXPORT(char *)
_tracemouse(MEVENT const *ep)
{
- static char buf[80];
+ /*
+ * hmm - format is no longer than 80 columns, there are 5 numbers that
+ * could at most have 10 digits, and the mask contains no more than 32 bits
+ * with each bit representing less than 15 characters. Usually the whole
+ * string is less than 80 columns, but this buffer size is an absolute
+ * limit.
+ */
+ static char buf[80 + (5 * 10) + (32 * 15)];
(void) sprintf(buf, "id %2d at (%2d, %2d, %2d) state %4lx = {",
- ep->id, ep->x, ep->y, ep->z, ep->bstate);
+ ep->id,
+ ep->x,
+ ep->y,
+ ep->z,
+ (unsigned long) ep->bstate);
#define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(buf, s), ", ")
+
SHOW(BUTTON1_RELEASED, "release-1");
SHOW(BUTTON1_PRESSED, "press-1");
SHOW(BUTTON1_CLICKED, "click-1");
SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
+#if NCURSES_MOUSE_VERSION == 1
SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
+#endif
+
SHOW(BUTTON2_RELEASED, "release-2");
SHOW(BUTTON2_PRESSED, "press-2");
SHOW(BUTTON2_CLICKED, "click-2");
SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
+#if NCURSES_MOUSE_VERSION == 1
SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
+#endif
+
SHOW(BUTTON3_RELEASED, "release-3");
SHOW(BUTTON3_PRESSED, "press-3");
SHOW(BUTTON3_CLICKED, "click-3");
SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
+#if NCURSES_MOUSE_VERSION == 1
SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
+#endif
+
SHOW(BUTTON4_RELEASED, "release-4");
SHOW(BUTTON4_PRESSED, "press-4");
SHOW(BUTTON4_CLICKED, "click-4");
SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
+#if NCURSES_MOUSE_VERSION == 1
SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
+#endif
+
+#if NCURSES_MOUSE_VERSION == 2
+ SHOW(BUTTON5_RELEASED, "release-5");
+ SHOW(BUTTON5_PRESSED, "press-5");
+ SHOW(BUTTON5_CLICKED, "click-5");
+ SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
+ SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
+#endif
+
SHOW(BUTTON_CTRL, "ctrl");
SHOW(BUTTON_SHIFT, "shift");
SHOW(BUTTON_ALT, "alt");
SHOW(ALL_MOUSE_EVENTS, "all-events");
SHOW(REPORT_MOUSE_POSITION, "position");
+
#undef SHOW
if (buf[strlen(buf) - 1] == ' ')
diff --git a/contrib/ncurses/ncurses/trace/trace_buf.c b/contrib/ncurses/ncurses/trace/trace_buf.c
index 15748d423d9e..85b4fbe682e8 100644
--- a/contrib/ncurses/ncurses/trace/trace_buf.c
+++ b/contrib/ncurses/ncurses/trace/trace_buf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2003 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,21 +35,40 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_buf.c,v 1.10 2001/04/21 21:19:18 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.12 2003/03/15 21:21:36 tom Exp $")
typedef struct {
char *text;
size_t size;
} LIST;
-NCURSES_EXPORT(char *)
-_nc_trace_buf(int bufnum, size_t want)
+static char *
+_nc_trace_alloc(int bufnum, size_t want)
{
+ char *result = 0;
static LIST *list;
static size_t have;
+ if (bufnum >= 0) {
+ if ((size_t) (bufnum + 1) > have) {
+ size_t need = (bufnum + 1) * 2;
+ if ((list = typeRealloc(LIST, need, list)) == 0)
+ return (0);
+ while (need > have)
+ list[have++].text = 0;
+ }
+
+ if (list[bufnum].text == 0
+ || want > list[bufnum].size) {
+ if ((list[bufnum].text = typeRealloc(char, want, list[bufnum].text))
+ != 0)
+ list[bufnum].size = want;
+ }
+
+ result = list[bufnum].text;
+ }
#if NO_LEAKS
- if (bufnum < 0) {
+ else {
if (have) {
while (have--) {
if (list[have].text != 0)
@@ -57,26 +76,34 @@ _nc_trace_buf(int bufnum, size_t want)
}
free(list);
}
- return 0;
}
#endif
+ return result;
+}
- if ((size_t) (bufnum + 1) > have) {
- size_t need = (bufnum + 1) * 2;
- if ((list = typeRealloc(LIST, need, list)) == 0)
- return (0);
- while (need > have)
- list[have++].text = 0;
- }
+/*
+ * (re)Allocate a buffer big enough for the caller's wants.
+ */
+NCURSES_EXPORT(char *)
+_nc_trace_buf(int bufnum, size_t want)
+{
+ char *result = _nc_trace_alloc(bufnum, want);
+ if (result != 0)
+ *result = '\0';
+ return result;
+}
- if (list[bufnum].text == 0
- || want > list[bufnum].size) {
- if ((list[bufnum].text = typeRealloc(char, want, list[bufnum].text))
- != 0)
- list[bufnum].size = want;
- }
+/*
+ * Append a new string to an existing buffer.
+ */
+NCURSES_EXPORT(char *)
+_nc_trace_bufcat(int bufnum, const char *value)
+{
+ char *buffer = _nc_trace_alloc(bufnum, 0);
+ size_t have = strlen(buffer);
+
+ buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
+ (void) strcpy(buffer + have, value);
- if (list[bufnum].text != 0)
- *(list[bufnum].text) = '\0';
- return list[bufnum].text;
+ return buffer;
}
diff --git a/contrib/ncurses/ncurses/trace/varargs.c b/contrib/ncurses/ncurses/trace/varargs.c
index 7bcb7b55d42c..aee2010546a4 100644
--- a/contrib/ncurses/ncurses/trace/varargs.c
+++ b/contrib/ncurses/ncurses/trace/varargs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2002,2003 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,17 +34,19 @@
#include <ctype.h>
-MODULE_ID("$Id: varargs.c,v 1.2 2002/06/01 16:16:00 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.4 2003/05/24 21:10:28 tom Exp $")
#ifdef TRACE
+#define MAX_PARMS 10
+
typedef enum {
atUnknown = 0, atInteger, atFloat, atPoint, atString
} ARGTYPE;
#define VA_INT(type) ival = va_arg(ap, type)
#define VA_FLT(type) fval = va_arg(ap, type)
-#define VA_PTR(type) pval = (void *)va_arg(ap, type)
+#define VA_PTR(type) pval = (char *)va_arg(ap, type)
#define VA_STR(type) sval = va_arg(ap, type)
/*
@@ -58,6 +60,8 @@ _nc_varargs(const char *fmt, va_list ap)
static size_t result_len;
char buffer[BUFSIZ];
+ const char *param;
+ int n;
if (fmt == 0 || *fmt == '\0')
return dummy;
@@ -75,14 +79,16 @@ _nc_varargs(const char *fmt, va_list ap)
int done = FALSE;
int ival = 0;
int type = 0;
+ ARGTYPE parm[MAX_PARMS];
+ int parms = 0;
ARGTYPE used = atUnknown;
while (*++fmt != '\0' && !done) {
if (*fmt == '*') {
VA_INT(int);
- used = atInteger;
- break;
+ if (parms < MAX_PARMS)
+ parm[parms++] = atInteger;
} else if (isalpha(UChar(*fmt))) {
done = TRUE;
switch (*fmt) {
@@ -135,30 +141,34 @@ _nc_varargs(const char *fmt, va_list ap)
} else if (*fmt == '%') {
done = TRUE;
}
- if (used != atUnknown) {
- const char *param = buffer;
- switch (used) {
- case atInteger:
- sprintf(buffer, "%d", ival);
- break;
- case atFloat:
- sprintf(buffer, "%f", fval);
- break;
- case atPoint:
- sprintf(buffer, "%p", pval);
- break;
- case atString:
- param = _nc_visbuf2(1, sval);
- break;
- default:
- strcpy(buffer, "?");
- break;
+ if (used != atUnknown && parms < MAX_PARMS) {
+ parm[parms++] = used;
+ for (n = 0; n < parms; ++n) {
+ used = parm[n];
+ param = buffer;
+ switch (used) {
+ case atInteger:
+ sprintf(buffer, "%d", ival);
+ break;
+ case atFloat:
+ sprintf(buffer, "%f", fval);
+ break;
+ case atPoint:
+ sprintf(buffer, "%p", pval);
+ break;
+ case atString:
+ param = _nc_visbuf2(1, sval);
+ break;
+ default:
+ strcpy(buffer, "?");
+ break;
+ }
+ result_len += strlen(param) + 2;
+ result_buf = typeRealloc(char, result_len, result_buf);
+ sprintf(result_buf + strlen(result_buf), ", %s", param);
}
- result_len += strlen(param) + 2;
- result_buf = typeRealloc(char, result_len, result_buf);
- sprintf(result_buf + strlen(result_buf), ",%s", param);
- used = atUnknown;
}
+ used = atUnknown;
}
} else {
fmt++;
diff --git a/contrib/ncurses/ncurses/trace/visbuf.c b/contrib/ncurses/ncurses/trace/visbuf.c
index 5f2460f3ed2c..0540ee6d8184 100644
--- a/contrib/ncurses/ncurses/trace/visbuf.c
+++ b/contrib/ncurses/ncurses/trace/visbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2001 Free Software Foundation, Inc. *
+ * Copyright (c) 2001-2005,2006 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 *
@@ -27,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey 1996-2001 *
+ * Author: Thomas E. Dickey 1996-on *
* and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -36,12 +36,17 @@
* visbuf.c - Tracing/Debugging support routines
*/
+#define NEED_NCURSES_CH_T
#include <curses.priv.h>
#include <tic.h>
#include <ctype.h>
-MODULE_ID("$Id: visbuf.c,v 1.3 2001/11/10 23:47:51 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.21 2006/12/02 21:20:28 tom Exp $")
+
+static const char d_quote[] = {D_QUOTE, 0};
+static const char l_brace[] = {L_BRACE, 0};
+static const char r_brace[] = {R_BRACE, 0};
static char *
_nc_vischar(char *tp, unsigned c)
@@ -68,14 +73,15 @@ _nc_vischar(char *tp, unsigned c)
*tp++ = '^';
*tp++ = '@' + c;
} else {
- sprintf(tp, "\\%03lo", ChCharOf(c));
+ sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c));
tp += strlen(tp);
}
+ *tp = 0;
return tp;
}
-NCURSES_EXPORT(const char *)
-_nc_visbuf2(int bufnum, const char *buf)
+static const char *
+_nc_visbuf2n(int bufnum, const char *buf, int len)
{
char *vbuf;
char *tp;
@@ -86,17 +92,20 @@ _nc_visbuf2(int bufnum, const char *buf)
if (buf == CANCELLED_STRING)
return ("(cancelled)");
+ if (len < 0)
+ len = strlen(buf);
+
#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
+ tp = vbuf = _nc_trace_buf(bufnum, (unsigned) (len * 4) + 5);
#else
{
static char *mybuf[2];
- mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], (strlen(buf) * 4) + 5);
+ mybuf[bufnum] = typeRealloc(char, (unsigned) (len * 4) + 5, mybuf[bufnum]);
tp = vbuf = mybuf[bufnum];
}
#endif
*tp++ = D_QUOTE;
- while ((c = *buf++) != '\0') {
+ while ((--len >= 0) && (c = *buf++) != '\0') {
tp = _nc_vischar(tp, UChar(c));
}
*tp++ = D_QUOTE;
@@ -105,35 +114,72 @@ _nc_visbuf2(int bufnum, const char *buf)
}
NCURSES_EXPORT(const char *)
+_nc_visbuf2(int bufnum, const char *buf)
+{
+ return _nc_visbuf2n(bufnum, buf, -1);
+}
+
+NCURSES_EXPORT(const char *)
_nc_visbuf(const char *buf)
{
return _nc_visbuf2(0, buf);
}
-#if USE_WIDEC_SUPPORT
-#ifdef TRACE
NCURSES_EXPORT(const char *)
-_nc_viswbuf2(int bufnum, const wchar_t * buf)
+_nc_visbufn(const char *buf, int len)
+{
+ return _nc_visbuf2n(0, buf, len);
+}
+
+#ifdef TRACE
+#if USE_WIDEC_SUPPORT
+
+#if defined(USE_TERMLIB)
+#define _nc_wchstrlen _my_wchstrlen
+static int
+_nc_wchstrlen(const cchar_t *s)
+{
+ int result = 0;
+ while (CharOf(s[result]) != L'\0') {
+ result++;
+ }
+ return result;
+}
+#endif
+
+static const char *
+_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
char *vbuf;
char *tp;
- int c;
+ wchar_t c;
if (buf == 0)
return ("(null)");
+ if (len < 0)
+ len = wcslen(buf);
+
#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, (wcslen(buf) * 4) + 5);
+ tp = vbuf = _nc_trace_buf(bufnum, (unsigned) (len * 4) + 5);
#else
{
static char *mybuf[2];
- mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], (wcslen(buf) * 4) + 5);
+ mybuf[bufnum] = typeRealloc(char, (unsigned) (len * 4) + 5, mybuf[bufnum]);
tp = vbuf = mybuf[bufnum];
}
#endif
*tp++ = D_QUOTE;
- while ((c = *buf++) != '\0') {
- tp = _nc_vischar(tp, ChCharOf(c));
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ char temp[CCHARW_MAX + 80];
+ int j = wctomb(temp, c), k;
+ if (j <= 0) {
+ sprintf(temp, "\\u%08X", (wint_t) c);
+ j = strlen(temp);
+ }
+ for (k = 0; k < j; ++k) {
+ tp = _nc_vischar(tp, UChar(temp[k]));
+ }
}
*tp++ = D_QUOTE;
*tp++ = '\0';
@@ -141,92 +187,125 @@ _nc_viswbuf2(int bufnum, const wchar_t * buf)
}
NCURSES_EXPORT(const char *)
-_nc_viswbuf(const wchar_t * buf)
+_nc_viswbuf2(int bufnum, const wchar_t *buf)
+{
+ return _nc_viswbuf2n(bufnum, buf, -1);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viswbuf(const wchar_t *buf)
{
return _nc_viswbuf2(0, buf);
}
NCURSES_EXPORT(const char *)
-_nc_viscbuf2(int bufnum, const cchar_t * buf, int len)
+_nc_viswbufn(const wchar_t *buf, int len)
+{
+ return _nc_viswbuf2n(0, buf, len);
+}
+
+/* this special case is used for wget_wstr() */
+NCURSES_EXPORT(const char *)
+_nc_viswibuf(const wint_t *buf)
+{
+ static wchar_t *mybuf;
+ static unsigned mylen;
+ unsigned n;
+
+ for (n = 0; buf[n] != 0; ++n) ;
+ if (mylen < ++n) {
+ mylen = n + 80;
+ if (mybuf != 0)
+ mybuf = typeRealloc(wchar_t, mylen, mybuf);
+ else
+ mybuf = typeMalloc(wchar_t, mylen);
+ }
+ for (n = 0; buf[n] != 0; ++n)
+ mybuf[n] = (wchar_t) buf[n];
+
+ return _nc_viswbuf2(0, mybuf);
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+/* use these functions for displaying parts of a line within a window */
+NCURSES_EXPORT(const char *)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
{
- size_t have = BUFSIZ;
- char *result = _nc_trace_buf(bufnum, have);
- char *tp = result;
- int n;
- bool same = TRUE;
- attr_t attr = A_NORMAL;
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
+ int first;
const char *found;
+#if USE_WIDEC_SUPPORT
if (len < 0)
len = _nc_wchstrlen(buf);
-
- for (n = 1; n < len; n++) {
- if (AttrOf(buf[n]) != AttrOf(buf[0])) {
- same = FALSE;
- break;
- }
- }
+#endif /* USE_WIDEC_SUPPORT */
/*
- * If the rendition is the same for the whole string, display it as a
- * quoted string, followed by the rendition. Otherwise, use the more
- * detailed trace function that displays each character separately.
+ * Display one or more strings followed by attributes.
*/
- if (same) {
- *tp++ = D_QUOTE;
- while (len-- > 0) {
- if ((found = _nc_altcharset_name(attr, CharOfD(buf))) != 0) {
- (void) strcpy(tp, found);
- tp += strlen(tp);
+ first = 0;
+ while (first < len) {
+ attr_t attr = AttrOf(buf[first]);
+ int last = len - 1;
+ int j;
+
+ for (j = first + 1; j < len; ++j) {
+ if (!SameAttrOf(buf[j], buf[first])) {
+ last = j - 1;
+ break;
+ }
+ }
+
+ result = _nc_trace_bufcat(bufnum, l_brace);
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ for (j = first; j <= last; ++j) {
+ if ((found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]))) != 0) {
+ result = _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
- } else if (!isnac(CHDEREF(buf))) {
+ } else
+#if USE_WIDEC_SUPPORT
+ if (!isWidecExt(buf[j])) {
PUTC_DATA;
- memset(&PUT_st, '\0', sizeof(PUT_st));
- PUTC_i = 0;
- do {
- PUTC_ch = PUTC_i < CCHARW_MAX ? buf->chars[PUTC_i] : L'\0';
- PUTC_n = wcrtomb(PUTC_buf, buf->chars[PUTC_i], &PUT_st);
+ PUTC_INIT;
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ int k;
+
+ PUTC_ch = buf[j].chars[PUTC_i];
if (PUTC_ch == L'\0')
- --PUTC_n;
+ break;
+ PUTC_n = wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
if (PUTC_n <= 0)
break;
- for (n = 0; n < PUTC_n; n++) {
- tp = _nc_vischar(tp, UChar(PUTC_buf[n]));
+ for (k = 0; k < PUTC_n; k++) {
+ char temp[80];
+ _nc_vischar(temp, UChar(PUTC_buf[k]));
+ result = _nc_trace_bufcat(bufnum, temp);
}
- ++PUTC_i;
- } while (PUTC_ch != L'\0');
+ }
}
- buf++;
- }
- *tp++ = D_QUOTE;
- *tp++ = '\0';
- if (attr != A_NORMAL)
- (void) sprintf(tp, " | %s",
- _traceattr2(bufnum + 20, attr));
- } else {
- *tp++ = L_BRACE;
- while (len-- > 0) {
- char *temp = _tracecchar_t2(bufnum + 20, buf++);
- size_t used = (tp - result);
- size_t want = strlen(temp) + 5 + used;
- if (want > have) {
- result = _nc_trace_buf(bufnum, have = want);
- tp = result + used;
+#else
+ {
+ char temp[80];
+ _nc_vischar(temp, UChar(buf[j]));
+ result = _nc_trace_bufcat(bufnum, temp);
}
- (void) strcpy(tp, temp);
- tp += strlen(tp);
+#endif /* USE_WIDEC_SUPPORT */
+ }
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ if (attr != A_NORMAL) {
+ result = _nc_trace_bufcat(bufnum, " | ");
+ result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
}
- *tp++ = R_BRACE;
- *tp++ = '\0';
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ first = last + 1;
}
return result;
}
NCURSES_EXPORT(const char *)
-_nc_viscbuf(const cchar_t * buf, int len)
+_nc_viscbuf(const NCURSES_CH_T * buf, int len)
{
return _nc_viscbuf2(0, buf, len);
}
#endif /* TRACE */
-#endif /* USE_WIDEC_SUPPORT */