NetBSD Problem Report #60844

From www@netbsd.org  Sat Oct  3 11:19:40 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 481031A923E
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  3 Oct 2026 11:19:40 +0000 (UTC)
Message-Id: <20261003111939.585351A923F@mollari.NetBSD.org>
Date: Sat,  3 Oct 2026 11:19:39 +0000 (UTC)
From: uwe@stderr.spb.ru
Reply-To: uwe@stderr.spb.ru
To: gnats-bugs@NetBSD.org
Subject: www/lynx with NetBSD curses fails to display utf-8
X-Send-Pr-Version: www-1.0
X-From4GNATS: "uwe@stderr.spb.ru via gnats" <gnats-admin@NetBSD.org>

>Number:         60844
>Category:       pkg
>Synopsis:       www/lynx with NetBSD curses fails to display utf-8
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 03 11:20:00 +0000 2026
>Last-Modified:  Sat Oct 03 11:25:02 +0000 2026
>Originator:     Valery Ushakov
>Release:        pkgsrc-2026Q3
>Organization:
>Environment:
NetBSD omena 11.0 NetBSD 11.0 (GENERIC) #0: Thu Jul 30 15:23:12 UTC 2026  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
I use lynx with utf-8 display charset (and utf-8 locale) and raw mode
OFF on NetBSD with netbsd curses.  When I open www.netbsd.org instead
of angle quotes, like:

  » Learn more

I get

  » Learn more

I.e. the two bytes of utf-8 representation of the quote are displayed
as two characters, not one.

If I open an HTML with cyrillic, I get all the characters split this
way:

  ÐивеÑ

instead of

  Привет

>How-To-Repeat:
Set RAW to OFF, set display charset to UTF-8, open www.netbsd.org.
In a typical 80x24 terminal you'll need to page down once.

>Fix:
I tracked it down to LYwaddnstr (in LYCurses.c) calling

  waddch(w, UCH(src[inx]));

in a loop, which obviously rips the utf-8 apart.

I'll attach a patch in a follow-up e-mail.

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/60844: www/lynx with NetBSD curses fails to display utf-8
Date: Sat, 3 Oct 2026 14:23:58 +0300

 --- a/src/LYCurses.c
 +++ b/src/LYCurses.c
 @@ -2287,19 +2287,31 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
  #endif
      LYGetYX(y0, x0);

 -    for (inx = 0; inx < len; ++inx) {
 -	/*
 -	 * Do tab-expansion relative to the base of the string (rather than
 -	 * the screen) so that tabs in a TEXTAREA will look right.
 -	 */
 -	if (src[inx] == '\t') {
 -	    LYGetYX(y, x);
 -	    while ((++x - x0) % 8)
 -		waddch(w, ' ');
 -	    waddch(w, ' ');
 -	} else {
 -	    waddch(w, UCH(src[inx]));
 +    /*
 +     * waddnstr(w, src, len), but do tab-expansion relative to the
 +     * base of the string (rather than the screen) so that tabs in a
 +     * TEXTAREA will look right.
 +     */
 +    const char *chunk = src;
 +    while (*chunk != '\0') {
 +	const char *tabp = strchr(chunk, '\t');
 +	if (tabp == NULL) {
 + 	    size_t toend = src + len - chunk;
 +	    waddnstr(w, chunk, toend);
 +	    break;
  	}
 +
 +	if (tabp != chunk) {
 + 	    size_t totab = tabp - chunk;
 +	    waddnstr(w, chunk, totab);
 +	}
 +
 +	LYGetYX(y, x);
 +	do {
 +	    waddch(w, ' ');
 +	} while ((++x - x0) % 8);
 +
 +	chunk = tabp + 1;
      }
  }

 ----8<--------8<--------8<----
 begin 644 LYwaddnstr.patch
 M+2TM(&$O<W)C+TQ90W5R<V5S+F,**RLK(&(O<W)C+TQ90W5R<V5S+F,*0$`@
 M+3(R.#<L,3D@*S(R.#<L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+"!T;V5N9"D["BL)("`@(&)R96%K.PH@"7T**PHK"6EF("AT86)P("$](&-H
 M=6YK*2!["BL@"2`@("!S:7IE7W0@=&]T86(@/2!T86)P("T@8VAU;FL["BL)
 M("`@('=A9&1N<W1R*'<L(&-H=6YK+"!T;W1A8BD["BL)?0HK"BL)3%E'9719
 M6"AY+"!X*3L**PED;R!["BL)("`@('=A9&1C:"AW+"`G("<I.PHK"7T@=VAI
 M;&4@*"@K*W@@+2!X,"D@)2`X*3L**PHK"6-H=6YK(#T@=&%B<"`K(#$["B`@
 *("`@?0H@?0H@"@``
 `
 end

 -uwe

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.