Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2019-2021,2023 Thomas E. Dickey * |
| 3 | * Copyright 2001-2016,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | * copy of this software and associated documentation files (the * |
| 7 | * "Software"), to deal in the Software without restriction, including * |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | * copies of the Software, and to permit persons to whom the Software is * |
| 11 | * furnished to do so, subject to the following conditions: * |
| 12 | * * |
| 13 | * The above copyright notice and this permission notice shall be included * |
| 14 | * in all copies or substantial portions of the Software. * |
| 15 | * * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | * * |
| 24 | * Except as contained in this notice, the name(s) of the above copyright * |
| 25 | * holders shall not be used in advertising or otherwise to promote the * |
| 26 | * sale, use or other dealings in this Software without prior written * |
| 27 | * authorization. * |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Author: Thomas E. Dickey 1996-on * |
| 32 | * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * |
| 33 | * and: Eric S. Raymond <esr@snark.thyrsus.com> * |
| 34 | ****************************************************************************/ |
| 35 | |
| 36 | /* |
| 37 | * visbuf.c - Tracing/Debugging support routines |
| 38 | */ |
| 39 | |
| 40 | #define NEED_NCURSES_CH_T |
| 41 | #include <curses.priv.h> |
| 42 | |
| 43 | #include <tic.h> |
| 44 | #include <ctype.h> |
| 45 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 46 | MODULE_ID("$Id: visbuf.c,v 1.54 2023/05/27 20:13:10 tom Exp $") |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 47 | |
| 48 | #define NUM_VISBUFS 4 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | |
| 50 | #define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 51 | #define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * (size_t) MB_CUR_MAX) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 52 | |
| 53 | #ifdef TRACE |
| 54 | static const char d_quote[] = StringOf(D_QUOTE); |
| 55 | static const char l_brace[] = StringOf(L_BRACE); |
| 56 | static const char r_brace[] = StringOf(R_BRACE); |
| 57 | #endif |
| 58 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 59 | #if USE_STRING_HACKS && HAVE_SNPRINTF |
| 60 | #define VisChar(tp, chr, limit) _nc_vischar(tp, chr, limit) |
| 61 | #define LIMIT_ARG ,size_t limit |
| 62 | #else |
| 63 | #define VisChar(tp, chr, limit) _nc_vischar(tp, chr) |
| 64 | #define LIMIT_ARG /* nothing */ |
| 65 | #endif |
| 66 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 67 | static char * |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 68 | _nc_vischar(char *tp, unsigned c LIMIT_ARG) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | if (tp == NULL) { |
| 71 | return NULL; |
| 72 | } else if (c == '"' || c == '\\') { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 73 | *tp++ = '\\'; |
| 74 | *tp++ = (char) c; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 75 | } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 76 | *tp++ = (char) c; |
| 77 | } else if (c == '\n') { |
| 78 | *tp++ = '\\'; |
| 79 | *tp++ = 'n'; |
| 80 | } else if (c == '\r') { |
| 81 | *tp++ = '\\'; |
| 82 | *tp++ = 'r'; |
| 83 | } else if (c == '\b') { |
| 84 | *tp++ = '\\'; |
| 85 | *tp++ = 'b'; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 86 | } else if (c == '\t') { |
| 87 | *tp++ = '\\'; |
| 88 | *tp++ = 't'; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 89 | } else if (c == '\033') { |
| 90 | *tp++ = '\\'; |
| 91 | *tp++ = 'e'; |
| 92 | } else if (UChar(c) == 0x7f) { |
| 93 | *tp++ = '\\'; |
| 94 | *tp++ = '^'; |
| 95 | *tp++ = '?'; |
| 96 | } else if (is7bits(c) && iscntrl(UChar(c))) { |
| 97 | *tp++ = '\\'; |
| 98 | *tp++ = '^'; |
| 99 | *tp++ = (char) ('@' + c); |
| 100 | } else { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 101 | _nc_SPRINTF(tp, _nc_SLIMIT(limit) |
| 102 | "\\%03lo", (unsigned long) ChCharOf(c)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 103 | tp += strlen(tp); |
| 104 | } |
| 105 | *tp = 0; |
| 106 | return tp; |
| 107 | } |
| 108 | |
| 109 | static const char * |
| 110 | _nc_visbuf2n(int bufnum, const char *buf, int len) |
| 111 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 112 | const char *vbuf = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 113 | char *tp; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 114 | int count; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 115 | |
| 116 | if (buf == 0) |
| 117 | return ("(null)"); |
| 118 | if (buf == CANCELLED_STRING) |
| 119 | return ("(cancelled)"); |
| 120 | |
| 121 | if (len < 0) |
| 122 | len = (int) strlen(buf); |
| 123 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 124 | count = len; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 125 | #ifdef TRACE |
| 126 | vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len)); |
| 127 | #else |
| 128 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 129 | static char *mybuf[NUM_VISBUFS]; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 130 | int c; |
| 131 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 132 | if (bufnum < 0) { |
| 133 | for (c = 0; c < NUM_VISBUFS; ++c) { |
| 134 | FreeAndNull(mybuf[c]); |
| 135 | } |
| 136 | tp = 0; |
| 137 | } else { |
| 138 | mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]); |
| 139 | vbuf = tp = mybuf[bufnum]; |
| 140 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 141 | } |
| 142 | #endif |
| 143 | if (tp != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 144 | int c; |
| 145 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 146 | *tp++ = D_QUOTE; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 147 | while ((--count >= 0) && (c = *buf++) != '\0') { |
| 148 | tp = VisChar(tp, UChar(c), NormalLen(len)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 149 | } |
| 150 | *tp++ = D_QUOTE; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 151 | *tp = '\0'; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 152 | } else { |
| 153 | vbuf = ("(_nc_visbuf2n failed)"); |
| 154 | } |
| 155 | return (vbuf); |
| 156 | } |
| 157 | |
| 158 | NCURSES_EXPORT(const char *) |
| 159 | _nc_visbuf2(int bufnum, const char *buf) |
| 160 | { |
| 161 | return _nc_visbuf2n(bufnum, buf, -1); |
| 162 | } |
| 163 | |
| 164 | NCURSES_EXPORT(const char *) |
| 165 | _nc_visbuf(const char *buf) |
| 166 | { |
| 167 | return _nc_visbuf2(0, buf); |
| 168 | } |
| 169 | |
| 170 | NCURSES_EXPORT(const char *) |
| 171 | _nc_visbufn(const char *buf, int len) |
| 172 | { |
| 173 | return _nc_visbuf2n(0, buf, len); |
| 174 | } |
| 175 | |
| 176 | #ifdef TRACE |
| 177 | #if USE_WIDEC_SUPPORT |
| 178 | |
| 179 | #if defined(USE_TERMLIB) |
| 180 | #define _nc_wchstrlen _my_wchstrlen |
| 181 | static int |
| 182 | _nc_wchstrlen(const cchar_t *s) |
| 183 | { |
| 184 | int result = 0; |
| 185 | while (CharOf(s[result]) != L'\0') { |
| 186 | result++; |
| 187 | } |
| 188 | return result; |
| 189 | } |
| 190 | #endif |
| 191 | |
| 192 | static const char * |
| 193 | _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len) |
| 194 | { |
| 195 | const char *vbuf; |
| 196 | char *tp; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 197 | int count; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 198 | |
| 199 | if (buf == 0) |
| 200 | return ("(null)"); |
| 201 | |
| 202 | if (len < 0) |
| 203 | len = (int) wcslen(buf); |
| 204 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 205 | count = len; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 206 | #ifdef TRACE |
| 207 | vbuf = tp = _nc_trace_buf(bufnum, WideLen(len)); |
| 208 | #else |
| 209 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 210 | static char *mybuf[NUM_VISBUFS]; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 211 | mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]); |
| 212 | vbuf = tp = mybuf[bufnum]; |
| 213 | } |
| 214 | #endif |
| 215 | if (tp != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 216 | wchar_t c; |
| 217 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 218 | *tp++ = D_QUOTE; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 219 | while ((--count >= 0) && (c = *buf++) != '\0') { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 220 | char temp[CCHARW_MAX + 80]; |
| 221 | int j = wctomb(temp, c), k; |
| 222 | if (j <= 0) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 223 | _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) |
| 224 | "\\u%08X", (unsigned) c); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 225 | j = (int) strlen(temp); |
| 226 | } |
| 227 | for (k = 0; k < j; ++k) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 228 | tp = VisChar(tp, UChar(temp[k]), WideLen(len)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | *tp++ = D_QUOTE; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 232 | *tp = '\0'; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 233 | } else { |
| 234 | vbuf = ("(_nc_viswbuf2n failed)"); |
| 235 | } |
| 236 | return (vbuf); |
| 237 | } |
| 238 | |
| 239 | NCURSES_EXPORT(const char *) |
| 240 | _nc_viswbuf2(int bufnum, const wchar_t *buf) |
| 241 | { |
| 242 | return _nc_viswbuf2n(bufnum, buf, -1); |
| 243 | } |
| 244 | |
| 245 | NCURSES_EXPORT(const char *) |
| 246 | _nc_viswbuf(const wchar_t *buf) |
| 247 | { |
| 248 | return _nc_viswbuf2(0, buf); |
| 249 | } |
| 250 | |
| 251 | NCURSES_EXPORT(const char *) |
| 252 | _nc_viswbufn(const wchar_t *buf, int len) |
| 253 | { |
| 254 | return _nc_viswbuf2n(0, buf, len); |
| 255 | } |
| 256 | |
| 257 | /* this special case is used for wget_wstr() */ |
| 258 | NCURSES_EXPORT(const char *) |
| 259 | _nc_viswibuf(const wint_t *buf) |
| 260 | { |
| 261 | static wchar_t *mybuf; |
| 262 | static unsigned mylen; |
| 263 | unsigned n; |
| 264 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 265 | for (n = 0; buf[n] != 0; ++n) { |
| 266 | ; /* empty */ |
| 267 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 268 | if (mylen < ++n) { |
| 269 | mylen = n + 80; |
| 270 | if (mybuf != 0) |
| 271 | mybuf = typeRealloc(wchar_t, mylen, mybuf); |
| 272 | else |
| 273 | mybuf = typeMalloc(wchar_t, mylen); |
| 274 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 275 | if (mybuf != 0) { |
| 276 | for (n = 0; buf[n] != 0; ++n) { |
| 277 | mybuf[n] = (wchar_t) buf[n]; |
| 278 | } |
| 279 | mybuf[n] = L'\0'; |
| 280 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 281 | |
| 282 | return _nc_viswbuf2(0, mybuf); |
| 283 | } |
| 284 | #endif /* USE_WIDEC_SUPPORT */ |
| 285 | |
| 286 | /* use these functions for displaying parts of a line within a window */ |
| 287 | NCURSES_EXPORT(const char *) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 288 | _nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 289 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 290 | char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 291 | |
| 292 | if (result != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 293 | int first = 0; |
| 294 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 295 | #if USE_WIDEC_SUPPORT |
| 296 | if (len < 0) |
| 297 | len = _nc_wchstrlen(buf); |
| 298 | #endif /* USE_WIDEC_SUPPORT */ |
| 299 | |
| 300 | /* |
| 301 | * Display one or more strings followed by attributes. |
| 302 | */ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 303 | while (first < len) { |
| 304 | attr_t attr = AttrOf(buf[first]); |
| 305 | int last = len - 1; |
| 306 | int j; |
| 307 | |
| 308 | for (j = first + 1; j < len; ++j) { |
| 309 | if (!SameAttrOf(buf[j], buf[first])) { |
| 310 | last = j - 1; |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 315 | (void) _nc_trace_bufcat(bufnum, l_brace); |
| 316 | (void) _nc_trace_bufcat(bufnum, d_quote); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 317 | for (j = first; j <= last; ++j) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 318 | const char *found = _nc_altcharset_name(attr, (chtype) |
| 319 | CharOf(buf[j])); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 320 | if (found != 0) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 321 | (void) _nc_trace_bufcat(bufnum, found); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 322 | attr &= ~A_ALTCHARSET; |
| 323 | } else |
| 324 | #if USE_WIDEC_SUPPORT |
| 325 | if (!isWidecExt(buf[j])) { |
| 326 | PUTC_DATA; |
| 327 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 328 | for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { |
| 329 | int k; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 330 | char temp[80]; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 331 | |
| 332 | PUTC_ch = buf[j].chars[PUTC_i]; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 333 | if (PUTC_ch == L'\0') { |
| 334 | if (PUTC_i == 0) |
| 335 | (void) _nc_trace_bufcat(bufnum, "\\000"); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 336 | break; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 337 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 338 | PUTC_INIT; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 339 | PUTC_n = (int) wcrtomb(PUTC_buf, |
| 340 | buf[j].chars[PUTC_i], &PUT_st); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 341 | if (PUTC_n <= 0 || buf[j].chars[PUTC_i] > 255) { |
| 342 | _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) |
| 343 | "{%d:\\u%lx}", |
| 344 | _nc_wacs_width(buf[j].chars[PUTC_i]), |
| 345 | (unsigned long) buf[j].chars[PUTC_i]); |
| 346 | (void) _nc_trace_bufcat(bufnum, temp); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 347 | break; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 348 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 349 | for (k = 0; k < PUTC_n; k++) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 350 | VisChar(temp, UChar(PUTC_buf[k]), sizeof(temp)); |
| 351 | (void) _nc_trace_bufcat(bufnum, temp); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | } |
| 355 | #else |
| 356 | { |
| 357 | char temp[80]; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 358 | VisChar(temp, UChar(buf[j]), sizeof(temp)); |
| 359 | (void) _nc_trace_bufcat(bufnum, temp); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 360 | } |
| 361 | #endif /* USE_WIDEC_SUPPORT */ |
| 362 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 363 | (void) _nc_trace_bufcat(bufnum, d_quote); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 364 | if (attr != A_NORMAL) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 365 | (void) _nc_trace_bufcat(bufnum, " | "); |
| 366 | (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 367 | } |
| 368 | result = _nc_trace_bufcat(bufnum, r_brace); |
| 369 | first = last + 1; |
| 370 | } |
| 371 | } |
| 372 | return result; |
| 373 | } |
| 374 | |
| 375 | NCURSES_EXPORT(const char *) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 376 | _nc_viscbuf(const NCURSES_CH_T *buf, int len) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 377 | { |
| 378 | return _nc_viscbuf2(0, buf, len); |
| 379 | } |
| 380 | #endif /* TRACE */ |