Skip to content

libedit: Update to 20260512 and fix Cygwin build#6399

Open
lygstate wants to merge 1 commit into
msys2:masterfrom
lygstate:libedit-upgrade
Open

libedit: Update to 20260512 and fix Cygwin build#6399
lygstate wants to merge 1 commit into
msys2:masterfrom
lygstate:libedit-upgrade

Conversation

@lygstate

Copy link
Copy Markdown
Contributor
  • Bump snapshot to 20260512_3.1 (pkgrel 2).
  • Refactor patches with _patches and apply via prepare() loop.
  • Extend cygwin-build.patch with read.c sys/ioctl.h for CYGWIN.
  • Remove libedit-20191231-3.1.patch; wchar_t display types break Cygwin.

@lazka

lazka commented Jun 29, 2026

Copy link
Copy Markdown
Member

Remove libedit-20191231-3.1.patch; wchar_t display types break Cygwin.

Could you go into detail as to why? It was added in #2241 to fix openssh

@lygstate

Copy link
Copy Markdown
Contributor Author

The patch changes only el_display / el_vdisplay in el.h from wint_t ** to wchar_t **. That was a minimal workaround for #1697 / #2241: on Cygwin wchar_t is 16-bit (Windows ABI) while wint_t is 32-bit, and libedit treats the display buffers as wchar_t * in several places (e.g. terminal_overwrite(), casts in terminal.c). Passing a wint_t[] where wchar_t * is expected makes the prompt look truncated (sftp> -> s _).

The problem is that the patch never updated the helpers that allocate/free those buffers. terminal_alloc_buffer() and terminal_free_buffer() in terminal.c still use wint_t ** / wint_t ***, and refresh.c also mixes the two types. You noted this at merge time in #2241.

With GCC 15, -Wincompatible-pointer-types is a hard error, so the incomplete patch no longer builds. I reproduced this on 20260512 with only cygwin-build.patch + libedit-20191231-3.1.patch:

terminal.c:462:24: error: assignment to 'wchar_t **' from incompatible pointer type 'wint_t **'
terminal.c:481:30: error: passing argument 1 of 'terminal_free_buffer' from incompatible pointer type 'wchar_t ***' (expected 'wint_t ***')
refresh.c:1123:34: error: assignment to 'wint_t *' from incompatible pointer type 'wchar_t *'

The same failure happens on the current 20240808 snapshot with GCC 15.3.0, so this is not specific to the version bump; it is the toolchain catching the type mismatch that the one-line el.h hack papered over.

Without the patch, 20260512 builds cleanly with --enable-widec and cygwin-build.patch.

Open question: whether the original openssh/sftp prompt bug still reproduces without the patch on the new snapshot. I have not re-tested sftp interactively yet. If it does, we probably need either a fuller Cygwin patch (also switch terminal_alloc_buffer / terminal_free_buffer and the refresh.c sites to wchar_t, as you suggested in #2241) or an upstream fix for the wint_t/wchar_t mix on 16-bit wchar_t platforms.

@lazka

lazka commented Jun 29, 2026

Copy link
Copy Markdown
Member

I see, thanks for the details

- Bump snapshot to 20260512_3.1 (pkgrel 1).
- Refactor patches with _patches and apply via prepare() loop.
- Extend cygwin-build.patch with read.c sys/ioctl.h for __CYGWIN__.
- Add 0002-fixes-compiling-with-gcc-15-by-use-wchar_t.patch; replaces the
  incomplete libedit-20191231-3.1.patch from msys2#2241.

Reproduction (Cygwin, GCC 15.3.0, libedit 20260512):

Runtime (msys2#1697 / msys2#2241 openssh sftp prompt): on Cygwin, wchar_t is 2 bytes
and wint_t is 4 bytes. libedit stores display cells as wint_t but reads them
via (wchar_t *) casts. Small C test:

  wint_t display[] = { L's', L'f', L't', L'p', L'>', 0 };
  wcslen((wchar_t *)display);  /* prints len=1, shows 's' not 'sftp>' */

With wchar_t storage (what 0002 applies): wcslen returns 5, shows 'sftp>'.

Build: the old el.h-only patch fails on GCC 15 (-Wincompatible-pointer-types
is an error), e.g. refresh.c:108 and terminal.c:462/481. Without any wchar
patch the tree builds but drops the msys2#2241 openssh fix. With cygwin-build.patch
+ 0002 the tree builds and keeps the fix.

Compare patches on 20260512:

  libedit-20191231-3.1.patch (removed): el.h only; fails GCC 15 build.
  0002 (added): el.h + terminal.c alloc/free + refresh.c locals; builds on
  GCC 15 and matches what lazka noted was missing at msys2#2241 merge time.
@lygstate

Copy link
Copy Markdown
Contributor Author

I see, thanks for the details

fixed the issue.

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.

2 participants