NetBSD Problem Report #58444

From www@netbsd.org  Fri Jul 19 13:50:48 2024
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) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7441B1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 19 Jul 2024 13:50:48 +0000 (UTC)
Message-Id: <20240719135046.EF7421A923A@mollari.NetBSD.org>
Date: Fri, 19 Jul 2024 13:50:46 +0000 (UTC)
From: uwe@stderr.spb.ru
Reply-To: uwe@stderr.spb.ru
To: gnats-bugs@NetBSD.org
Subject: curses: wbkg regression
X-Send-Pr-Version: www-1.0

>Number:         58444
>Category:       bin
>Synopsis:       curses: wbkg regression
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 19 13:55:00 +0000 2024
>Originator:     Valery Ushakov
>Release:        NetBSD 10
>Organization:
>Environment:
NetBSD snips 10.0_STABLE NetBSD 10.0_STABLE (GENERIC) #0: Mon Jul  8 16:08:11 MSK 2024  uwe@majava:/home/uwe/work/netbsd/cvs/src-release-10/sys/arch/macppc/compile/GENERIC macppc
>Description:
lib/libcurses/background.c
revision 1.31
date: 2022-05-03 10:25:34 +0300;  author: blymn;  state: Exp;  lines: +15 -13;  commitid: pj0Gxm3JnXF80ACD;
[...]
 * Fix bug introduced when wbkgrndset was fixed, we cannot blindly
   replace any instance of the old background character with the new one
   because some of those characters were put there by the application
   leading to display corruption.  So flag characters as background when
   they are erased and only update the flagged characters when setting
   the background.

I think this change is incorrect.  This is not how I read the XCurses
spec and this is not what ncurses does.  Consider:

    mvaddstr(5, 0, "hel lo");
    bkgd('~');
    mvaddstr(6, 0, "HEL LO");

which renders as

   |~~~~~~~~...
   |hel~lo~~...
   |HEL~LO~~...
   |~~~~~~~~...

with ncurses, but as 

   |~~~~~~~~...
   |hel lo~~...
   |HEL LO~~...
   |~~~~~~~~...

on NetBSD.

The first bug is that the background character in "hel lo"  is not
replaced, the second is that the space in "HEL LO" is not rendered
as the background character.

X/Open Curses, Issue 7 says:

  3.4.4 Rendition of Characters Placed into a Window

  When the application adds or inserts characters into a window, the
  effect is as follows:
  [...]

  If the character is the <space> character, then the window receives:

  * The background character

  * The color that the application specifies; or the window color, if
    the application does not specify a color


So the whole idea of distinguihing a "real" background character vs.
a character explicitly added by the application that happens to be
background character is self-contradictory.

>How-To-Repeat:
#include <curses.h>
#include <unistd.h>

int
main()
{
    initscr();

    mvaddstr(5, 0, "hel lo");

    refresh();
    sleep(1);

    bkgd('~');
    mvaddstr(6, 0, "HEL LO");

    refresh();
    sleep(2);

    endwin();
    return 0;
}

>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.