NetBSD Problem Report #58034

From wiz@exadelic.gatalith.at  Wed Mar 13 09:49:31 2024
Return-Path: <wiz@exadelic.gatalith.at>
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))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 36CB01A9245
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 13 Mar 2024 09:49:31 +0000 (UTC)
Message-Id: <20240313094856.477132EBBADD@exadelic.gatalith.at>
Date: Wed, 13 Mar 2024 10:48:56 +0100 (CET)
From: Thomas Klausner <wiz@NetBSD.org>
Reply-To: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Subject: terminfo: tmux-direct different from ncurses version
X-Send-Pr-Version: 3.95

>Number:         58034
>Category:       lib
>Synopsis:       terminfo: tmux-direct different from ncurses version
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 13 09:50:00 +0000 2024
>Last-Modified:  Wed Mar 13 11:35:00 +0000 2024
>Originator:     Thomas Klausner
>Release:        NetBSD 10.99.10
>Organization:

>Environment:


Architecture: x86_64
Machine: amd64
>Description:
On NetBSD 10.99.10, the tmux-direct entry only has 8 colors instead
of the 16 million it should have.
>How-To-Repeat:
$ infocmp -1x tmux-direct
...
        colors#8,
...
        pairs#64,
...

The definition from the terminfo file is:
tmux-direct|tmux with direct-color indexing,
        use=kitty+setal, use=xterm+direct, use=tmux,

"kitty+setal" does not set colors:
$ infocmp -1x kitty+setal
# Reconstructed from /usr/share/misc/terminfo.cdb
kitty+setal|set underline colors (nonstandard),
        setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,

"xterm+direct" does:
$ infocmp -1x xterm+direct
# Reconstructed from /usr/share/misc/terminfo.cdb
...
        colors#16777216,
...
        pairs#65536,
...

And since it's the second entry in the definition, this should win,
but it doesn't.

To complete the picture, "tmux" defines colors too:
$ infocmp -1x tmux
# Reconstructed from /usr/share/misc/terminfo.cdb
...
        colors#8,
...
        pairs#64,
...

The behaviour seems to work for simple case:
--- terminfotest ---
minfirst|TermInfo Test,
       use=min, use=max,
maxfirst|TermInfo Test,
       use=max, use=min,

max|any number > INT16_MAX,
       colors#16777216,

min|any num < INT16_MAX,
       colors#8,
--- end of terminfotest ---

> tic -x terminfotest
> infocmp -1x -A /home/wiz/terminfotest.cdb minfirst
# Reconstructed from /home/wiz/terminfotest.cdb
minfirst|TermInfo Test,
        colors#8,
> infocmp -1x -A /home/wiz/terminfotest.cdb maxfirst
# Reconstructed from /home/wiz/terminfotest.cdb
maxfirst|TermInfo Test,
        colors#16777216,


but breaks down when I add a third entry:
--- terminfotest2 ---
kitty+setal|set underline colors (nonstandard),
        setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,

minfirst|TermInfo Test,
# if the second number is >32767, it disappears!
       use=min, use=max,
maxfirst|TermInfo Test,
# putting the bigger one first makes "promotion" happen.
       use=max, use=min,

max|any number > INT16_MAX,
       colors#16777216,

min|any num < INT16_MAX,
       colors#8,

kittymin|kitty+min,
        use=kitty+setal, use=min, use=max
kittymax|kitty+max,
        use=kitty+setal, use=max, use=min
--- end of terminfotest2 ---

> tic -x terminfotest2

> infocmp -1x -A /home/wiz/terminfotest2.cdb kittymin
# Reconstructed from /home/wiz/terminfotest2.cdb
kittymin|kitty+min,
        colors#8,
        setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,
> infocmp -1x -A /home/wiz/terminfotest2.cdb kittymax
# Reconstructed from /home/wiz/terminfotest2.cdb
kittymax|kitty+max,
        colors#8,
        setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,

>Fix:
Yes, please.

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/58034: terminfo: tmux-direct different from ncurses version
Date: Wed, 13 Mar 2024 17:41:57 +0700

     Date:        Wed, 13 Mar 2024 09:50:00 +0000 (UTC)
     From:        Thomas Klausner <wiz@NetBSD.org>
     Message-ID:  <20240313095000.86C5C1A9247@mollari.NetBSD.org>

   | And since it's the second entry in the definition, this should win,

 It has been a long time, but my memory of termcap, and so probably
 terminfo, is that that is backwards.

 That's what allows 'continuation' (tc=) to work, define
 whatever makes this entry first, then add everything from
 another entry, and the specific entries (coming first) are
 used in preference to later ones which belong to the other,
 similar, terminal.

From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: lib/58034: terminfo: tmux-direct different from ncurses version
Date: Wed, 13 Mar 2024 11:55:41 +0100

 On Wed, Mar 13, 2024 at 10:45:02AM +0000, Robert Elz wrote:
 >    | And since it's the second entry in the definition, this should win,
 >  
 >  It has been a long time, but my memory of termcap, and so probably
 >  terminfo, is that that is backwards.
 >  
 >  That's what allows 'continuation' (tc=) to work, define
 >  whatever makes this entry first, then add everything from
 >  another entry, and the specific entries (coming first) are
 >  used in preference to later ones which belong to the other,
 >  similar, terminal.

 Perhaps the syntax for 'use' is different.

 Anyway, the behaviour is inconsistent in itself (because it changes
 when kitty+setal is added compared to before), and different to what
 ncurses' terminfo does.
  Thomas

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/58034: terminfo: tmux-direct different from ncurses version
Date: Wed, 13 Mar 2024 14:34:26 +0300

 On Wed, Mar 13, 2024 at 10:45:02 +0000, Robert Elz wrote:
 > Date: Wed, 13 Mar 2024 10:45:02 +0000 (UTC)
 > From: Robert Elz <kre@munnari.OZ.AU>
 > Subject: Re: lib/58034: terminfo: tmux-direct different from ncurses version
 > Newsgroups: gmane.os.netbsd.bugs
 > To: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 >  netbsd-bugs@netbsd.org, Thomas Klausner <wiz@NetBSD.org>
 > Reply-To: gnats-bugs@netbsd.org
 > 
 > The following reply was made to PR lib/58034; it has been noted by GNATS.
 > 
 > From: Robert Elz <kre@munnari.OZ.AU>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: lib/58034: terminfo: tmux-direct different from ncurses version
 > Date: Wed, 13 Mar 2024 17:41:57 +0700
 > 
 >      Date:        Wed, 13 Mar 2024 09:50:00 +0000 (UTC)
 >      From:        Thomas Klausner <wiz@NetBSD.org>
 >      Message-ID:  <20240313095000.86C5C1A9247@mollari.NetBSD.org>
 >  
 >    | And since it's the second entry in the definition, this should win,
 >  
 >  It has been a long time, but my memory of termcap, and so probably
 >  terminfo, is that that is backwards.
 >  
 >  That's what allows 'continuation' (tc=) to work, define
 >  whatever makes this entry first, then add everything from
 >  another entry, and the specific entries (coming first) are
 >  used in preference to later ones which belong to the other,
 >  similar, terminal.

 Right, but the "second" above is a bit misleading, as we naturally
 tend to infer "first" as its target, while in fact it's "third" (the
 use=tmux entry that comes later and defines 8 colors).

 A.1.16 Similar Terminals

   If there are two similar terminals, one can be defined as being just
   like the other with certain exceptions. The string capability use can
   be given with the name of the similar terminal. The capabilities given
   before use override those in the terminal type invoked by use. A
   capability can be canceled by placing capability-name@ prior to the
   appearance of the string capability use.

 In the thread that led to this PR martin@ pointed out this was broken
 in usr.bin/tic/tic.c revision 1.33

 date: 2020-03-27 16:11:57 +0100;  author: christos;  state: Exp;  lines: +21 -17;  commitid: 2Q6C4aNTDvrFf32C;

 -uwe

>Unformatted:

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.