NetBSD Problem Report #53653

From www@NetBSD.org  Sun Oct  7 01:53:33 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 09F427A180
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  7 Oct 2018 01:53:33 +0000 (UTC)
Message-Id: <20181007015331.D18A17A279@mollari.NetBSD.org>
Date: Sun,  7 Oct 2018 01:53:31 +0000 (UTC)
From: uwe@NetBSD.org
Reply-To: uwe@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: Curses doesn't always show line drawing characters correctly on wsvt25
X-Send-Pr-Version: www-1.0

>Number:         53653
>Category:       lib
>Synopsis:       Curses doesn't always show line drawing characters correctly on wsvt25
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 07 01:55:00 +0000 2018
>Closed-Date:    
>Last-Modified:  Fri Oct 26 22:42:19 +0000 2018
>Originator:     Valery Ushakov
>Release:        NetBSD 8.99.25
>Organization:
>Environment:
>Description:
Use misc/dialog with TERM=wsvt25 and observe ASC ascii chars instead
of line-drawing chars shown in some boxes.  Works with TERM=xterm.  As
far as I can tell the problem is when colors are switched in the
middle of using line-drawing characters.  dialog tries to create faux
3d look by using colors, and when color is changed in the middle of
the line, the line after the color switch comes out in ASCII.

For the top border the following is emitted with wsvt25, cleaned up
and split for readability:

    \E[37m\E[47m\E(0lqqq\E[m\E(B
    \E[30m\E[47mk\E(B

Note that for the upper-right corner 'k' there's no preceding smacs
\E[(0 sequence, so I guess curses thinks it's still in ACS mode, while
it's not (it emitted rmacs \E(B before just before the color switch).

>How-To-Repeat:
On wscons run:

   TERM=wsvt25 dialog --msgbox "hello world" 10 40

cf.

  TERM=xterm dialog --msgbox "hello world" 10 40 # works

>Fix:

>Release-Note:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53653: Curses doesn't always show line drawing characters
 correctly on wsvt25
Date: Sun, 7 Oct 2018 05:05:05 +0300

 The code to draw the box is in dlg_draw_box2() in uitl.c and it
 basically does:

     waddch(win, borderchar | ACS_ULCORNER);
     waddch(win, borderchar | ACS_HLINE);
     ...
     /* this next one will be wrong */
     waddch(win, borderchar2 | ACS_URCORNER);

 where borderchar is a combination of optional A_BOLD and
 COLOR_PAIR()

 -uwe

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53653: Curses doesn't always show line drawing characters
 correctly on wsvt25
Date: Sun, 7 Oct 2018 05:21:14 +0300

 It's not the color, but turning off A_BOLD that seems to confuse it.
 The following standalone test case fails with TERM=wsvt25 and
 TERM=vt200 (but works with xterm and vt100).

 #include <curses.h>

 int
 main(void)
 {
     initscr();

     addch(ACS_HLINE);
     addch(ACS_HLINE | A_BOLD);
     addch(ACS_HLINE);
     addch(ACS_HLINE | A_BOLD);

     refresh();
     endwin();
     return 0;
 }

 -uwe

From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, uwe@NetBSD.org
Subject: Re: lib/53653: Curses doesn't always show line drawing characters
 correctly on wsvt25
Date: Mon, 8 Oct 2018 16:20:58 +0200

 Hi,

 >  It's not the color, but turning off A_BOLD that seems to confuse it.
 >  The following standalone test case fails with TERM=wsvt25 and
 >  TERM=vt200 (but works with xterm and vt100).

 This might be related to the attribute unset logic in refresh.c:

   https://nxr.netbsd.org/xref/src/lib/libcurses/refresh.c#1074

 where we test colour and other attributes when we disable bold (standout)
 and the logic to set this in setterm.c:

   https://nxr.netbsd.org/xref/src/lib/libcurses/setterm.c#223

 However, neither of these check ACS, so __unsetattr() is another possibility:

   https://nxr.netbsd.org/xref/src/lib/libcurses/refresh.c#1903

 For some reason, we think that ACS is still on but we have switched it off.
 However, I'm not sure why we see the difference between xterm/vt100 and
 wsvt25/vt200 here - I guess that we parse the terminfo incorrectly.

 Regards,

 Julian

From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, uwe@NetBSD.org
Subject: Re: lib/53653: Curses doesn't always show line drawing characters
 correctly on wsvt25
Date: Wed, 10 Oct 2018 21:45:53 +0200

 Hi,

 Looking at the output with tracing on, I see for the vt220 case:

   1539197247.063514: does_ctrl_o: Testing ^[[m^[(B for ^[(B$<4>

 when we check to see if turning off all attributes also turns off ACS.
 However, the terminfo entry for vt220 doesn't contain any delay for sgr0,
 whilst it does for rmacs:

   rmacs=\E(B$<4>, sgr0=\E[m\E(B

 so we think that sending sgr0 (i.e. when unsetting bold) didn't unset ACS
 mode, and thus we don't set ACS mode again.

 This might be a bug in the terminfo entry and it should really have a delay
 in both.  However, stripping the trailing delay from the end of rmacs when
 we check is probably a more sensible solution, so the appended patch does
 that.

 Regards,

 Julian

  - - - - - 8< - - - - - - - - - - - - - - - - - - - - - - - - - 8< - - - - - -
 --- src/lib/libcurses/setterm.c.orig	2018-10-10 20:24:25.000000000 +0100
 +++ src/lib/libcurses/setterm.c	2018-10-10 20:37:54.000000000 +0100
 @@ -348,8 +348,12 @@
  does_ctrl_o(const char *exit_cap, const char *acs_cap)
  {
  	const char *eptr = exit_cap, *aptr = acs_cap;
 +	char *dptr;
  	int l;

 +	dptr = strstr(aptr, "$<");
 +	if (dptr != NULL && dptr > aptr)
 +		*dptr = '\0';
  #ifdef DEBUG
  	__CTRACE(__CTRACE_INIT, "does_ctrl_o: Testing %s for %s\n", eptr, aptr);
  #endif
  - - - - - 8< - - - - - - - - - - - - - - - - - - - - - - - - - 8< - - - - - -

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, uwe@NetBSD.org
Cc: 
Subject: Re: lib/53653: Curses doesn't always show line drawing characters correctly on wsvt25
Date: Wed, 10 Oct 2018 16:30:32 -0400

 On Oct 10,  7:50pm, jdc@coris.org.uk (Julian Coleman) wrote:
 -- Subject: Re: lib/53653: Curses doesn't always show line drawing characters

 |  Hi,
 |  
 |  Looking at the output with tracing on, I see for the vt220 case:
 |  
 |    1539197247.063514: does_ctrl_o: Testing ^[[m^[(B for ^[(B$<4>
 |  
 |  when we check to see if turning off all attributes also turns off ACS.
 |  However, the terminfo entry for vt220 doesn't contain any delay for sgr0,
 |  whilst it does for rmacs:
 |  
 |    rmacs=\E(B$<4>, sgr0=\E[m\E(B
 |  
 |  so we think that sending sgr0 (i.e. when unsetting bold) didn't unset ACS
 |  mode, and thus we don't set ACS mode again.
 |  
 |  This might be a bug in the terminfo entry and it should really have a delay
 |  in both.  However, stripping the trailing delay from the end of rmacs when
 |  we check is probably a more sensible solution, so the appended patch does
 |  that.
 |  

 If trailing delays are illegal/undesired, then terminfo should warn and
 the entry should be fixed. I don't think that curses should be involved :-)

 christos

From: "Valeriy E. Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53653 CVS commit: src/lib/libcurses
Date: Fri, 26 Oct 2018 22:22:24 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Fri Oct 26 22:22:24 UTC 2018

 Modified Files:
 	src/lib/libcurses: setterm.c

 Log Message:
 Ignore terminfo padding specifications when checking whether
 exit_attribute_mode contains exit_alt_charset_mode.

 Fixes PR lib/53653.


 To generate a diff of this commit:
 cvs rdiff -u -r1.67 -r1.68 src/lib/libcurses/setterm.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Fri, 26 Oct 2018 22:33:52 +0000
State-Changed-Why:
Needs pullups after a bit more testing.


State-Changed-From-To: pending-pullups->needs-pullups
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Fri, 26 Oct 2018 22:42:19 +0000
State-Changed-Why:
Pullups have not been requested yet.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.