Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Jun 2025 13:09:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 287358] [ncurses][patch] Cannot handle termcap-style 'tputs("50")' on freebsd-current and 14.2-RELEASE due to wrong definition in lib/ncurses/tinfo/ncurses_cfg.h
Message-ID:  <bug-287358-227@https.bugs.freebsd.org/bugzilla/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287358

            Bug ID: 287358
           Summary: [ncurses][patch] Cannot handle termcap-style
                    'tputs("50")' on freebsd-current and 14.2-RELEASE due
                    to wrong definition in lib/ncurses/tinfo/ncurses_cfg.h
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: CQG00620@nifty.ne.jp
 Attachment #261063 text/plain
         mime type:

Created attachment 261063
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=261063&action=edit
git diff for lib/ncurses/tinfo/ncurses_cfg.h

On freebsd-current and 14.2-RELEASE, ports/games/nethack34 remains garbage
characters on the tty interface.  The x11 interface has not affected.

games/nethack{32,33}* and japanese/nethack34 has the same problem.  
games/nethack36 has not affected.  The other nethack variants has not tested.


* How to repeat (e.g. games/nethack34, Ranger-elf-male)

| 
| 
|                                            -------------
|                                            |..{....d...|
|                                ------    ##............|
|                                +....|    # |..........@|
|                                |.....##### |...........|
|                                |....|      -.-----------
|                                |....|
|                                |<...|
|                                |....|
|                                ------
| 
| Nabe the Tenderfoot          St:15 Dx:10 Co:12 In:15 Wi:13 Ch:8  Chaotic
| Dlvl:1  $:16 HP:14(14) Pw:3(3) AC:7  Exp:1

When I hit 'f' to shoot allows, the screen becomes corrupted:

| You shoot 3 elven arrows.
| 
|                                            -------------
|                                            |..{....d...|           .
|                                ------    ##............|
|                                +....|    # |.......d.)))))))..50
|                                |.....##### |...........|
|                                |....|      -.-----------
|                                |....|
|                                |<...|
|                                |....|
|                                ------
| 
| Nabe the Tenderfoot          St:15 Dx:10 Co:12 In:15 Wi:13 Ch:8  Chaotic
| Dlvl:1  $:16 HP:14(14) Pw:3(3) AC:7  Exp:1

Then if I hit '^R' to redraw the screen, it becomes normally:

| 
| 
|                                            -------------
|                                            |..{........|
|                                ------    ##............|
|                                +....|    # |..)....d..@|
|                                |.....##### |...........|
|                                |....|      -.-----------
|                                |....|
|                                |<...|
|                                |....|
|                                ------
| 
| Nabe the Tenderfoot          St:15 Dx:10 Co:12 In:15 Wi:13 Ch:8  Chaotic
| Dlvl:1  $:16 HP:14(14) Pw:3(3) AC:7  Exp:1


 * Workaround

If I build games/nethack34 with not system ncurses but devel/ncurses,
the problem has gone.


 * How to fix

It is caused by the code in tty_delay_output()@nethack-3.4.3/win/tty/termcap.c
like this:

> tputs("50", 1, xputc);

Described in BUGS section in curs_termcap(3X), it is interpreted as
busy-wait for 50 msec by termcap.

On ncurses these interpretation is enabled with adding '--enable-bsdpad'
argument to the configure script.  devel/ncurses has built with the option.

In June, 2024, ncurses-6.5 is imported to the FreeBSD main branch and
stable/14 branch.

And then committed "ncurses: reinstantiate bsd specific code" to the both
branch:

https://cgit.freebsd.org/src/commit/lib/ncurses/tinfo/ncurses_cfg.h?id=e402155e1ad7ec92a1fbd1712ce86c2ca43e1823
> diff --git a/lib/ncurses/tinfo/ncurses_cfg.h b/lib/ncurses/tinfo/ncurses_cfg.h
> index ced59c68e93c..33890f300310 100644
> --- a/lib/ncurses/tinfo/ncurses_cfg.h
> +++ b/lib/ncurses/tinfo/ncurses_cfg.h
> @@ -60,6 +60,9 @@
>  #define HAVE_LONG_FILE_NAMES 1
>  #define MIXEDCASE_FILENAMES 1
>  #define STDC_HEADERS 1
> +#define USE_GETCAP 1
> +#define USE_BSD_TPUTS 1
> +#define HAVE_BSD_CGETENT 1
>  #define HAVE_SYS_TYPES_H 1
>  #define HAVE_SYS_STAT_H 1
>  #define HAVE_STDLIB_H 1

Unfortunately, on ncurses-6.5 '--enable-bsdpad' defines not USE_BSD_TPUTS
but BSD_TPUTS.  The other two defines seems correct.

After apply the attached patch and rebuild the system, games/nethack34
(and others) works correctly in the tty interface.  The patch has tested
on freebsd-current and 14.2-RELEASE.

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-287358-227>