]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/lib_traceatr.c
ncurses 5.9 - patch 20111022
[ncurses.git] / ncurses / trace / lib_traceatr.c
index 50920f2405e8342c92efc254206501b8c37c1c6b..8abc1c6a9a45962c58abf939611e02714e4ffb79 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2011 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  */
 
 #include <curses.priv.h>
  */
 
 #include <curses.priv.h>
-#include <term.h>              /* acs_chars */
 
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.64 2009/02/28 21:10:20 tom Exp $")
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+MODULE_ID("$Id: lib_traceatr.c,v 1.76 2011/10/22 15:39:21 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -117,7 +120,7 @@ _traceattr2(int bufnum, chtype newmode)
     ;
     size_t n;
     char temp[80];
     ;
     size_t n;
     char temp[80];
-    char *result = _nc_trace_buf(bufnum, BUFSIZ);
+    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
     if (result != 0) {
        unsigned save_nc_tracing = _nc_tracing;
 
     if (result != 0) {
        unsigned save_nc_tracing = _nc_tracing;
@@ -129,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')
        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) {
                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);
 #ifdef USE_TERMLIB
                    /* pair_content lives in libncurses */
                    (void) sprintf(temp, "{%d}", pairnum);
@@ -173,6 +176,14 @@ _traceattr(attr_t newmode)
 }
 
 /* Trace 'int' return-values */
 }
 
 /* Trace 'int' return-values */
+NCURSES_EXPORT(int)
+_nc_retrace_int_attr_t(attr_t code)
+{
+    T((T_RETURN("%s"), _traceattr(code)));
+    return (int) code;
+}
+
+/* Trace 'attr_t' return-values */
 NCURSES_EXPORT(attr_t)
 _nc_retrace_attr_t(attr_t code)
 {
 NCURSES_EXPORT(attr_t)
 _nc_retrace_attr_t(attr_t code)
 {
@@ -187,6 +198,9 @@ _nc_altcharset_name(attr_t attr, chtype ch)
        unsigned int val;
        const char *name;
     } ALT_NAMES;
        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 */
     static const ALT_NAMES names[] =
     {
        {'l', "ACS_ULCORNER"},  /* upper left corner */
@@ -226,20 +240,23 @@ _nc_altcharset_name(attr_t attr, chtype ch)
 
     const char *result = 0;
 
 
     const char *result = 0;
 
-    if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
+#if NCURSES_SP_FUNCS
+    (void) sp;
+#endif
+    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) {
        char *cp;
        char *found = 0;
        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) {
                found = cp;
                /* don't exit from loop - there may be redefinitions */
            }
        }
 
        if (found != 0) {
-           ch = ChCharOf(*found);
+           ch = ChCharOf(UChar(*found));
            for (strp = names; strp->val; strp++)
                if (strp->val == ch) {
                    result = strp->name;
            for (strp = names; strp->val; strp++)
                if (strp->val == ch) {
                    result = strp->name;
@@ -254,15 +271,16 @@ NCURSES_EXPORT(char *)
 _tracechtype2(int bufnum, chtype ch)
 {
     const char *found;
 _tracechtype2(int bufnum, chtype ch)
 {
     const char *found;
-    char *result = _nc_trace_buf(bufnum, BUFSIZ);
+    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
     if (result != 0) {
        strcpy(result, l_brace);
        if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
            (void) _nc_trace_bufcat(bufnum, found);
        } else
 
     if (result != 0) {
        strcpy(result, l_brace);
        if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
            (void) _nc_trace_bufcat(bufnum, found);
        } else
-           (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN,
-                                   (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, " | ");
 
        if (ChAttrOf(ch) != A_NORMAL) {
            (void) _nc_trace_bufcat(bufnum, " | ");
@@ -293,7 +311,7 @@ _nc_retrace_chtype(chtype code)
 NCURSES_EXPORT(char *)
 _tracecchar_t2(int bufnum, const cchar_t *ch)
 {
 NCURSES_EXPORT(char *)
 _tracecchar_t2(int bufnum, const cchar_t *ch)
 {
-    char *result = _nc_trace_buf(bufnum, BUFSIZ);
+    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
     attr_t attr;
     const char *found;
 
     attr_t attr;
     const char *found;
 
@@ -315,9 +333,12 @@ _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];
                (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;
                        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 */
                    if (PUTC_n <= 0) {
                        if (PUTC_ch != L'\0') {
                            /* it could not be a multibyte sequence */