_tracecchar_t2(int bufnum, const cchar_t *ch) { char *result = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; if (result != 0) { strcpy(result, l_brace); if (ch != 0) { attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { 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]; if (PUTC_ch == L'\0') { if (PUTC_i == 0) result = _nc_trace_bufcat(bufnum, "\\000"); 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, _nc_tracechar(CURRENT_SCREEN, UChar(ch->chars[PUTC_i]))); } break; } for (n = 0; n < PUTC_n; n++) { if (n) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(PUTC_buf[n]))); } } (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
_tracecchar_t2 (int bufnum, const cchar_t *ch) { char *buf = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; strcpy(buf, l_brace); if (ch != 0) { attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; PUTC_INIT; (void) _nc_trace_bufcat(bufnum, "{ "); do { PUTC_ch = PUTC_i < CCHARW_MAX ? ch->chars[PUTC_i] : L'\0'; PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); if (PUTC_ch == L'\0') --PUTC_n; 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) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n]))); } ++PUTC_i; } while (PUTC_ch != L'\0'); (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } } return (_nc_trace_bufcat(bufnum, r_brace)); }
_tracecchar_t2(int bufnum, const cchar_t *ch) { char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); if (result != 0) { _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); if (ch != 0) { 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; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; (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') { if (PUTC_i == 0) (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') { /* it could not be a multibyte sequence */ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, 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}", wcwidth(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) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(PUTC_buf[n]))); } } (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (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); } return result; }
static void encode_cell(char *target, CARG_CH_T source, CARG_CH_T previous) { #if NCURSES_WIDECHAR size_t n; *target = '\0'; if (previous->attr != source->attr) { encode_attr(target, source->attr, previous->attr); } target += strlen(target); #if NCURSES_EXT_COLORS if (previous->ext_color != source->ext_color) { sprintf(target, "%c%cC%d%c", MARKER, L_CURL, source->ext_color, R_CURL); } #endif for (n = 0; n < SIZEOF(source->chars); ++n) { unsigned uch = (unsigned) source->chars[n]; if (uch == 0) continue; if (n) { *target++ = MARKER; *target++ = APPEND; } *target++ = MARKER; if (uch > 0xffff) { sprintf(target, "U%08x", uch); } else if (uch > 0xff) { sprintf(target, "u%04x", uch); } else if (uch < 32 || uch >= 127) { sprintf(target, "%03o", uch & 0xff); } else { switch (uch) { case ' ': strcpy(target, "s"); break; case MARKER: *target++ = MARKER; *target = '\0'; break; default: sprintf(--target, "%c", uch); break; } } target += strlen(target); } #else chtype ch = CharOfD(source); *target = '\0'; if (AttrOfD(previous) != AttrOfD(source)) { encode_attr(target, AttrOfD(source), AttrOfD(previous)); } target += strlen(target); *target++ = MARKER; if (ch < 32 || ch >= 127) { sprintf(target, "%03o", UChar(ch)); } else { switch (ch) { case ' ': strcpy(target, "s"); break; case MARKER: *target++ = MARKER; *target = '\0'; break; default: sprintf(--target, "%c", UChar(ch)); break; } } #endif }