Subject: Re: bug#64577: 29.0.92; configure on NetBSD forces unstable terminfo library

From: Eli Zaretskii <[email-masked]>
Date: Wed, 12 Jul 2023 15:11:02 +0300

> From: [email-masked]
> Date: Tue, 11 Jul 2023 20:37:19 +0000
> 
> 
> configure on NetBSD forces using the native libterminfo library, even
> when ncurses is available. When started with a TERM such xterm-256color,
> this results in abort() in tputs1 (TERM=xterm works).
> 
> Hacking configure to use ncurses when available provides stable
> operation on xterm-256color.
> 
> The current special configure logic originates from this issue:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6190 . This check is
> probably not a good idea today. Either NetBSD should do a) what the
> other BSDs do (= force ncurses) or b) what gnu* does (use what
> configure found, otherwise force ncurses).
> 
> My vote goes to b (possibly with a warning from configure if libterminfo
> is picked): keep it possible to build emacs without installing ncurses,
> but use ncurses for terminfo when available.

I'm not sure I understand.  The configure script first looks for a
library with tputs, and it tries tinfo, ncurses, terminfo, curses,
termcap, tinfow, ncursesw, in that order.  I understand that in your
case it finds ncurses, which is good, right?

After that, the configure script decides whether to use terminfo or
termcap.  It is here that for netbsd we decide to use termcap in
certain situations instead of terminfo.  In your case, since ncurses
was found, LIBS_TERMCAP should have been set to -lncurses, and this
code:

  netbsd)
    if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
      TERMINFO=no
      LIBS_TERMCAP="-ltermcap"
    fi

should have set TERMINFO=no, which disables linking against terminfo.

So I don't think I understand what is going on there.

As I don't have access to a netbsd system, could you please post the
config.log you get when configuring with a fresh tree of
emacs-29.0.92, and also show the "set -x" expansion of the relevant
parts of the configure script?  (Please compress those when posting if
they are larger than, say, 0.5MB.)  I would like to use those to
understand what happens on your system and why the configure script
decides to use terminfo.

Once we understand the exact reason, it will be easier to discuss
potential solutions.

Also, do you happen to know when terminfo on NetBSD started to be
buggy?  I would think that the change in bug#6190 did work at the
time, so at least back then NetBSD did have a workable terminfo.  When
did it start failing?

Thanks.