]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/lib_traceatr.c
ncurses 5.7 - patch 20101225
[ncurses.git] / ncurses / trace / lib_traceatr.c
index 45a03cea05feb194988e2455077354e2244f03b5..0f2c681e7b8f007e4a150f342223da99667183ce 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
@@ -30,6 +30,7 @@
  *  Author: Thomas Dickey                           1996-on                 *
  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                                                 *
  ****************************************************************************/
 
 /*
  */
 
 #include <curses.priv.h>
-#include <term.h>              /* acs_chars */
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.63 2008/08/03 16:24:53 tom Exp $")
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+MODULE_ID("$Id: lib_traceatr.c,v 1.72 2010/12/19 00:51:35 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -128,11 +132,11 @@ _traceattr2(int bufnum, chtype newmode)
        for (n = 0; n < SIZEOF(names); n++) {
            if ((newmode & names[n].val) != 0) {
                if (result[1] != '\0')
-                   result = _nc_trace_bufcat(bufnum, "|");
+                   (void) _nc_trace_bufcat(bufnum, "|");
                result = _nc_trace_bufcat(bufnum, names[n].name);
 
                if (names[n].val == A_COLOR) {
-                   short pairnum = PAIR_NUMBER(newmode);
+                   short pairnum = (short) PairNumber(newmode);
 #ifdef USE_TERMLIB
                    /* pair_content lives in libncurses */
                    (void) sprintf(temp, "{%d}", pairnum);
@@ -186,6 +190,9 @@ _nc_altcharset_name(attr_t attr, chtype ch)
        unsigned int val;
        const char *name;
     } ALT_NAMES;
+#if NCURSES_SP_FUNCS
+    SCREEN *sp = CURRENT_SCREEN;
+#endif
     static const ALT_NAMES names[] =
     {
        {'l', "ACS_ULCORNER"},  /* upper left corner */
@@ -225,23 +232,26 @@ _nc_altcharset_name(attr_t attr, chtype ch)
 
     const char *result = 0;
 
+#if NCURSES_SP_FUNCS
+    (void) sp;
+#endif
     if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
        char *cp;
        char *found = 0;
-       const ALT_NAMES *sp;
+       const ALT_NAMES *strp;
 
        for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
-           if (ChCharOf(cp[1]) == ChCharOf(ch)) {
+           if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) {
                found = cp;
                /* don't exit from loop - there may be redefinitions */
            }
        }
 
        if (found != 0) {
-           ch = ChCharOf(*found);
-           for (sp = names; sp->val; sp++)
-               if (sp->val == ch) {
-                   result = sp->name;
+           ch = ChCharOf(UChar(*found));
+           for (strp = names; strp->val; strp++)
+               if (strp->val == ch) {
+                   result = strp->name;
                    break;
                }
        }
@@ -260,7 +270,9 @@ _tracechtype2(int bufnum, chtype ch)
        if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
            (void) _nc_trace_bufcat(bufnum, found);
        } else
-           (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int) ChCharOf(ch)));
+           (void) _nc_trace_bufcat(bufnum,
+                                   _nc_tracechar(CURRENT_SCREEN,
+                                                 (int) ChCharOf(ch)));
 
        if (ChAttrOf(ch) != A_NORMAL) {
            (void) _nc_trace_bufcat(bufnum, " | ");
@@ -313,14 +325,17 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
                (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_ch == L'\0') {
+                       if (PUTC_i == 0)
+                           (void) _nc_trace_bufcat(bufnum, "\\000");
                        break;
-                   PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+                   }
+                   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(SP,
+                                                   _nc_tracechar(CURRENT_SCREEN,
                                                                  UChar(ch->chars[PUTC_i])));
                        }
                        break;
@@ -329,7 +344,7 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
                        if (n)
                            (void) _nc_trace_bufcat(bufnum, ", ");
                        (void) _nc_trace_bufcat(bufnum,
-                                               _nc_tracechar(SP,
+                                               _nc_tracechar(CURRENT_SCREEN,
                                                              UChar(PUTC_buf[n])));
                    }
                }