]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/visbuf.c
ncurses 6.2 - patch 20211016
[ncurses.git] / ncurses / trace / visbuf.c
index 13023aaa1a82426e9f2c45e1a730299d7ff623e3..aca8affc4fa1b11a27dbcb37873b6e3f1e4bd83d 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2014,2016 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2001-2016,2017 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            *
@@ -42,7 +43,7 @@
 #include <tic.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: visbuf.c,v 1.48 2016/09/05 00:43:08 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.53 2021/02/27 20:07:57 tom Exp $")
 
 #define NUM_VISBUFS 4
 
@@ -80,6 +81,9 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG)
     } else if (c == '\b') {
        *tp++ = '\\';
        *tp++ = 'b';
+    } else if (c == '\t') {
+       *tp++ = '\\';
+       *tp++ = 't';
     } else if (c == '\033') {
        *tp++ = '\\';
        *tp++ = 'e';
@@ -279,7 +283,7 @@ _nc_viswibuf(const wint_t *buf)
 
 /* 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)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len)
 {
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
@@ -334,9 +338,9 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
                                               buf[j].chars[PUTC_i], &PUT_st);
                        if (PUTC_n <= 0 || buf[j].chars[PUTC_i] > 255) {
                            _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
-                                       "{%d:\\u%x}",
-                                       wcwidth(buf[j].chars[PUTC_i]),
-                                       buf[j].chars[PUTC_i]);
+                                       "{%d:\\u%lx}",
+                                       _nc_wacs_width(buf[j].chars[PUTC_i]),
+                                       (unsigned long) buf[j].chars[PUTC_i]);
                            (void) _nc_trace_bufcat(bufnum, temp);
                            break;
                        }
@@ -367,7 +371,7 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viscbuf(const NCURSES_CH_T * buf, int len)
+_nc_viscbuf(const NCURSES_CH_T *buf, int len)
 {
     return _nc_viscbuf2(0, buf, len);
 }