summaryrefslogtreecommitdiff
path: root/lib/libcurses
diff options
context:
space:
mode:
authorblymn <blymn@NetBSD.org>2022-12-20 04:57:01 +0000
committerblymn <blymn@NetBSD.org>2022-12-20 04:57:01 +0000
commit57ca5fb00051d8ce7af23d30eef4c6448a8261ad (patch)
treed9a49fe5c65bdfd78fbcbbf46a6f9c727ad18dfb /lib/libcurses
parent0b9e9f8a61dee435a64da2cfa52b121e4c9207cd (diff)
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 (limited to 'lib/libcurses')
-rw-r--r--lib/libcurses/addbytes.c14
-rw-r--r--lib/libcurses/slk.c9
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
index f9678abb391..05a80406d0f 100644
--- a/lib/libcurses/addbytes.c
+++ b/lib/libcurses/addbytes.c
@@ -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 @@ _cursesi_waddbytes(WINDOW *win, const char *bytes, int count, attr_t attr,
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 @@ _cursesi_waddbytes(WINDOW *win, const char *bytes, int count, attr_t attr,
}
__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 --git a/lib/libcurses/slk.c b/lib/libcurses/slk.c
index 81bb1a567cc..8ad2298d094 100644
--- a/lib/libcurses/slk.c
+++ b/lib/libcurses/slk.c
@@ -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 @@ __slk_draw(SCREEN *screen, int labnum)
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 @@ __slk_draw(SCREEN *screen, int labnum)
(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;