From e245856fd23b07c1cfa7a3d18921f054c14b2c43 Mon Sep 17 00:00:00 2001 From: lev105 <77709387+lev105@users.noreply.github.com> Date: Tue, 19 Jan 2021 21:02:00 -0700 Subject: [PATCH] Fix incompatibilities with the musl C library (#156) This makes ksh build on Alpine Linux which uses this C library. src/lib/libast/include/ast_std.h: - Define __DEFINED_FILE to hide FILE internals from the Korn shell's SFIO. src/lib/libast/features/wchar: - Include wchar.h before redefining iswalpha() to avoid mangling the C library's declaration. src/lib/libast/features/lib: - Test whether off64_t and off_t are actually distinct types before using the former. Fixes: #3 --- src/lib/libast/features/lib | 10 ++++++++++ src/lib/libast/features/wchar | 12 +++++++----- src/lib/libast/include/ast_std.h | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/lib/libast/features/lib b/src/lib/libast/features/lib index ca665ccb9..4c1e81d64 100644 --- a/src/lib/libast/features/lib +++ b/src/lib/libast/features/lib @@ -723,3 +723,13 @@ tst no64 -D_LARGEFILE64_SOURCE note{ largefile 64 broken }end execute{ echo "#undef _lib_statvfs64" echo "#undef _lib_truncate64" }end + +tst need64 -D_LARGEFILE64_SOURCE note{ off64_t necessary }end nocompile{ + #include + typedef off64_t __ast_off64_t__; + typedef off_t __ast_off_t__; + extern __ast_off64_t__ x; + __ast_off_t__ x; +}end fail{ + echo "#undef _typ_off64_t" +}end diff --git a/src/lib/libast/features/wchar b/src/lib/libast/features/wchar index 915399494..fc3db8161 100644 --- a/src/lib/libast/features/wchar +++ b/src/lib/libast/features/wchar @@ -16,11 +16,17 @@ lib towlower,towupper stdlib.h stdio.h wchar.h typ mbstate_t stdlib.h stdio.h wchar.h nxt wchar -cat{ +run{ +cat < #include #endif + + #if _hdr_wchar && defined(_nxt_wchar) + #include ${_nxt_wchar-_nxt_wchar} /* the native wchar.h */ + #endif +! }end if tst note{ requires native }end nocompile{ @@ -53,10 +59,6 @@ endif run{ cat <