Subject: Re: bug#69598: 29.2; colour support based on $TERM value not terminfo database

From: Eli Zaretskii <[email-masked]>
Date: Thu, 07 Mar 2024 21:26:32 +0200

> From: [email-masked]
> cc: [email-masked], [email-masked]
> Comments: In-reply-to Eli Zaretskii <[email-masked]>
>    message dated "Thu, 07 Mar 2024 19:47:05 +0200."
> Date: Thu, 07 Mar 2024 18:31:20 +0000
> 
> Eli Zaretskii writes:
> > So I guess you will need to step with a debugger through the code in
> > term.c which discovers and initializes the color-related capabilities,
> 
> If there's something you would like me to look for then I can but
> I am highly sceptical of the idea that it is isolated to something
> unique about my computers here.

I think there might be a misunderstanding.  What meant was to see what
happens in the function init_tty in this part of it:

  #ifdef TERMINFO
	{
	  const char *fg = tigetstr ("setf24");
	  const char *bg = tigetstr ("setb24");
	  /* Non-standard support for 24-bit colors. */
	  if (fg && bg
	      && fg != (char *) (intptr_t) -1
	      && bg != (char *) (intptr_t) -1)
	    {
	      tty->TS_set_foreground = fg;
	      tty->TS_set_background = bg;
	      tty->TN_max_colors = 16777216;
	    }
	  /* Standard support for 24-bit colors.  */
	  else if (tigetflag ("RGB") > 0)
	    {
	      /* If the used Terminfo library supports only 16-bit
		 signed values, tgetnum("Co") and tigetnum("colors")
		 could return 32767.  */
	      tty->TN_max_colors = 16777216;
	    }
	  /* Fall back to xterm+direct (semicolon version) if Tc is set
	     (de-facto standard introduced by tmux) or if	requested by
	     the COLORTERM environment variable.  */
	  else if ((tigetflag ("Tc") > 0)
		   || ((bg = getenv ("COLORTERM")) != NULL
		       && strcasecmp (bg, "truecolor") == 0))
	    {
	      tty->TS_set_foreground = "\033[%?%p1%{8}%<%t3%p1%d%e38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m";
	      tty->TS_set_background = "\033[%?%p1%{8}%<%t4%p1%d%e48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m";
	      tty->TN_max_colors = 16777216;
	    }
	}
  #endif

By contrast, it sounds like you are only talking about a terminfo
entry that redirects to another entry.

> Did you confirm presence of the bug with the transcript I provided?

No, I cannot try that on the systems to which I have access.  Maybe
someone else could, preferably someone who knows more than I do about
terminfo.