Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Backout change to addnstr that broke other app...



details:   https://anonhg.NetBSD.org/src/rev/67ea79879497
branches:  trunk
changeset: 372683:67ea79879497
user:      blymn <blymn%NetBSD.org@localhost>
date:      Tue Dec 20 04:57:01 2022 +0000

description:
Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.

diffstat:

 lib/libcurses/addbytes.c |  14 +++++---------
 lib/libcurses/slk.c      |   9 ++++++---
 2 files changed, 11 insertions(+), 12 deletions(-)

diffs (85 lines):

diff -r a70700b42bad -r 67ea79879497 lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c  Tue Dec 20 04:10:11 2022 +0000
+++ b/lib/libcurses/addbytes.c  Tue Dec 20 04:57:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addbytes.c,v 1.67 2022/12/12 21:14:15 blymn Exp $      */
+/*     $NetBSD: addbytes.c,v 1.68 2022/12/20 04:57:01 blymn Exp $      */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.67 2022/12/12 21:14:15 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.68 2022/12/20 04:57:01 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -118,7 +118,7 @@
        int             *py = &win->cury, *px = &win->curx, err;
        __LINE          *lp;
 #ifdef HAVE_WCHAR
-       int             n, width;
+       int             n;
        cchar_t         cc;
        wchar_t         wc;
        mbstate_t       st;
@@ -170,18 +170,14 @@
                }
 
                __CTRACE(__CTRACE_INPUT,
-                   "ADDBYTES WIDE(0x%x [%s], %x) at (%d, %d), ate %d bytes\n",
+                   "ADDBYTES WIDE(0x%04x [%s], %x) at (%d, %d), ate %d bytes\n",
                    (unsigned)wc, unctrl((unsigned)wc), attr, *py, *px, n);
                cc.vals[0] = wc;
                cc.elements = 1;
                cc.attributes = attr;
                err = _cursesi_addwchar(win, &lp, py, px, &cc, char_interp);
                bytes += n;
-
-               width = wcwidth(wc);
-               if (width < 0)
-                       width = 1;
-               count -= width;
+               count -= n;
 #endif
        }
 
diff -r a70700b42bad -r 67ea79879497 lib/libcurses/slk.c
--- a/lib/libcurses/slk.c       Tue Dec 20 04:10:11 2022 +0000
+++ b/lib/libcurses/slk.c       Tue Dec 20 04:57:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $   */
+/*     $NetBSD: slk.c,v 1.21 2022/12/20 04:57:01 blymn Exp $   */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 #include <limits.h>
 #ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: slk.c,v 1.21 2022/12/20 04:57:01 blymn Exp $");
 #endif                         /* not lint */
 
 #include <limits.h>
@@ -819,6 +819,9 @@
        wchar_t wc[2];
 #endif
 
+       __CTRACE(__CTRACE_INPUT, "__slk_draw: screen %p, label %d\n", screen,
+           labnum);
+
        if (screen->slk_hidden)
                return OK;
 
@@ -834,7 +837,7 @@
                    (screen->slk_window->flags & __SCROLLOK) ||
                    ((l->x + screen->slk_label_len) < screen->slk_window->maxx)) {
                        retval = mvwaddnstr(screen->slk_window, 0, l->x,
-                           l->label, screen->slk_label_len);
+                           l->label, strlen(l->label));
                } else {
                        lcnt = 0;
                        tx = 0;



Home | Main Index | Thread Index | Old Index