Skip to content

readline: link to ncurses instead of termcap; drop termcap - #31018

Open
dragon-archer wants to merge 3 commits into
msys2:masterfrom
dragon-archer:fix-readline
Open

readline: link to ncurses instead of termcap; drop termcap#31018
dragon-archer wants to merge 3 commits into
msys2:masterfrom
dragon-archer:fix-readline

Conversation

@dragon-archer

Copy link
Copy Markdown
Collaborator

This aligns with MSYS-packages and Arch.

termcap is so old that cannot be built with current GCC without massive patching. The last user (readline) is gone now. Besides, MSYS2-packages and Arch all dropped it.

This aligns with MSYS-packages and Arch.
It's so old that cannot be built with current GCC without massive patching. The last user (readline) is gone now. Besides, MSYS2-packages and Arch all dropped it.
@lazka

lazka commented Aug 16, 2026

Copy link
Copy Markdown
Member

lgtm

@mmuetzel any objections?

@mmuetzel

Copy link
Copy Markdown
Collaborator

I'm currently away from a PC. Can't really test.
Does Octave CLI and GUI still work after this change (e.g., can you use the up and down arrow keys to traverse the history)?
I seem to recall that headline and gdb had compatibility issues at some point. Does it also still work as expected?

@dragon-archer

Copy link
Copy Markdown
Collaborator Author

I'm currently away from a PC. Can't really test. Does Octave CLI and GUI still work after this change (e.g., can you use the up and down arrow keys to traverse the history)? I seem to recall that headline and gdb had compatibility issues at some point. Does it also still work as expected?

Tested with octave, and octave-gui. Arrow keys all work correctly. I've tested gdb several times these days (to cleanup old issues), so I'm sure it works well. I'm not sure what you mean by "headline"?

BTW, it seemes like octave-gui.exe actually starts a CUI, just like octave.exe, instead of a pop-up GUI windows. Is that expected?

@lazka

lazka commented Aug 17, 2026

Copy link
Copy Markdown
Member

@mmuetzel we can wait for you to test too if you want

@mmuetzel

mmuetzel commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

I meant "readline". But autocorrect on my mobile thought it knew better...

octave-gui links to the Qt libraries (as opposed to octave-cli which doesn't). It doesn't start the GUI by default though.
octave mainly just dispatches to octave-gui in the configuration for MSYS2. (It might dispatch to octave-cli for different configurations.)
To actually test the GUI, you'd need to use the command line flag --gui (e.g., octave --gui).

I'll probably be able to run some tests myself by the end of the week.

Comment on lines +109 to +112
bash_cv_termcap_lib=libncurses \
CFLAGS="${CFLAGS} -DNCURSES_STATIC"

make SHLIB_LIBS=-lncursesw

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, there is a good reason for this. But why are you telling the configure script to prepare for a different library variant (libncurses) compared to the one that you link to (libncursesw)?

Wouldn't it be more consistent to use the same for the configuration and make command? I.e., bash_cv_termcap_lib=libncursesw.
The same for the shared library.

If I read the readline repository correctly, the generated pkg-config file (and potentially other things) will be wrong with the changes from here. It is likely referencing the ncurses module while it should be referencing the ncursesw module.
Afaics, the MINGW ncurses packages don't even install a ncurses.pc file. The ncurses package for the MSYS2 environment installs it in the ncurses-devel package.
That might be a different issue though.

Looking at the readline repository, setting bash_cv_termcap_lib=libncursesw might require additional changes so the correct termcap.h is being used. It currently has Windows-specific checks only for libncurses.

@mmuetzel mmuetzel Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To check if there is an issue with the generated pkg-config file: What does pkg-config --static --libs readline do with the package from here?

@mmuetzel mmuetzel Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back on a PC.

The pkg-config file is broken indeed:

$ pkg-config --libs readline
Package ncurses was not found in the pkg-config search path.
Perhaps you should add the directory containing `ncurses.pc'
to the PKG_CONFIG_PATH environment variable
Package 'ncurses', required by 'readline', not found

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the pkg-config is broken now, manually editting the Requires.private: ncurses to ncursesw can fix it. I'll look into lt later, and try whether this can be fixed in make, or maybe have to be done by sed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's easier to sed readline.pc, as the configure has several special handling for ncurses but not for ncursesw.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the reason why we copy ncursew into ncurse is that most "Unixy" applications doesn't care about wide character support, therefore many of them only use ncurses. OTOH, on Windows wide character is usually preferred. Considering ncursesw works well to emulate ncurses now, I think there's little reason for us to distribute a real ncurses in the near future, so the patch here shouldn't be a big problem.

@mmuetzel mmuetzel Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not describing the situation on posixy platforms entirely correctly. The difference between ncurses is not only single byte character width vs. wide character C types. More importantly for those platforms, it is the support for UTF-8 (that is present in ncursesw but not (completely) in ncurses).
If I recall correctly, the difference matters, e.g. in this case: If you are using an application that does not support UTF-8 (but expects a "single byte locale"), the highest bit is "discarded" with ncursesw (essentially limiting support to the ASCII character range). With ncurses (and the locale set correctly), you can use the whole range of characters in that locale.

I still don't think it is a good idea to use this "Frankenstein-configuration" where the ncursesw library is mixed with the headers of ncurses.

@dragon-archer dragon-archer Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then what do you think should we do? readline can't compile successfully with bash_cv_termcap_lib=libncursew, because many of its configure doesn't treat ncursew as almost similar to ncurse. And if you really heavily patch to it add this part, then what's the difference between the status quo?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then what do you think should we do?

What I wrote about 3 weeks ago:

Looking at the readline repository, setting bash_cv_termcap_lib=libncursesw might require additional changes so the correct termcap.h is being used. It currently has Windows-specific checks only for libncurses.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between the status quo?

There are still quite a few issues when it comes to supporting non-ASCII characters in packages distributed by MSYS2. I don't know if any (or how many) of these are caused because we "sell" them an ncurses library that is actually ncursesw.
Maybe, it would be better to be "honest" and actually distribute different versions for ncurses and ncursesw.
Maybe, doing that would cause a lot of other problems. Hard to tell without having any background about why the status quo is as it is.

In any case, we shouldn't rely on the current "happenstance" when updating build rules for existing packages imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants