From 77ab60a149c77f1797a25a43c613dcdb8ad6ce07 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 27 Jan 2021 15:03:06 +0000 Subject: [PATCH] iffe: revert removal, add different fix (re: 308696ec) Commit 308696ec caused the build to fail on macOS Catalina. src/cmd/INIT/iffe.sh: - Fix a blatantly unportable practice of passing multiple "|"-separated 'case' patterns through a variable. This was a way of grepping for some headers including stdio.h, but it only works this way on ksh93 and possibly the original Bourne shell, and not on *any* other shell (not even pdksh or mksh) -- and the fact that it works on ksh93 is arguably a bug. Fix by eliminating the "noext" variable (which is init'ed once and never changes) and using the pattern in the relevant 'case' statement directly. src/cmd/builtin/features/pty: - No matter what I try, including causes the build to fail on Gentoo Linux (i386) with mysterious "invalid identifier: off64_t" errors -- this is probably some AST preprocessor hackery gone awry, but I've no idea where to even begin with that. This works around the problem by using AST sfio instead, which is built and functional by the time this feature test is run. - Remove explicit extern declaration for ptsname(2) that was never used because it depended on an npt_ptsname feature test that doesn't exist (or no longer exists). - Add missing , , and for open(2), ptsname(2) and close(2), respectively. src/lib/libast/features/float, src/lib/libast/features/sfio, src/lib/libast/features/stdio: - Re-include . Fixes: https://github.com/ksh93/ksh/issues/164 (I hope) --- src/cmd/INIT/iffe.sh | 5 +++-- src/cmd/builtin/features/pty | 19 ++++++++----------- src/lib/libast/features/float | 5 +++++ src/lib/libast/features/sfio | 1 + src/lib/libast/features/stdio | 1 + 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/cmd/INIT/iffe.sh b/src/cmd/INIT/iffe.sh index bfd29ab83..6eaaacc2e 100644 --- a/src/cmd/INIT/iffe.sh +++ b/src/cmd/INIT/iffe.sh @@ -1327,7 +1327,6 @@ std='#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) #define _NIL_(x) ((x)0)' tst= ext="#include " -noext='*[<"][Ss][Tt][Dd][Ii][Oo].[Hh][">]*|**|**|*/[*][*]/*' # loop on op [ arg [ ... ] ] [ : op [ arg [ ... ] ] ] @@ -3376,7 +3375,9 @@ int x; esac case $src in ?*) case $src in - $noext) EXT= ;; + *[\<\"][Ss][Tt][Dd][Ii][Oo].[Hh][\"\>]* | *\* | *\* | */[*]\[*]/*) + EXT= + ;; *) EXT="$tst $ext" ;; diff --git a/src/cmd/builtin/features/pty b/src/cmd/builtin/features/pty index f912d3ead..b617013de 100755 --- a/src/cmd/builtin/features/pty +++ b/src/cmd/builtin/features/pty @@ -14,17 +14,14 @@ lib grantpt,unlockpt,posix_openpt stdlib.h lib cfmakeraw termios.h tst - output{ + #include + #include + #if _lib_ptsname + #include + #endif + #include #include #include - #if _lib_ptsname && _npt_ptsname - _BEGIN_EXTERNS_ - #if _STD_ - extern char* ptsname(int); - #else - extern char* ptsname(); - #endif - #endif - _END_EXTERNS_ int main() { int i; @@ -39,7 +36,7 @@ tst - output{ { if (ptsname(fd)) { - printf("#define _pty_clone\t\"%s\"\n", ptc[i]); + sfprintf(sfstdout, "#define _pty_clone\t\"%s\"\n", ptc[i]); close(fd); break; } @@ -49,7 +46,7 @@ tst - output{ for (i = 0;; i++) if(i >= (sizeof(pty) / sizeof(pty[0]) - 1) || stat(pty[i], &statb)>=0) { - printf("#define _pty_first\t\"%s\"\n", pty[i]); + sfprintf(sfstdout, "#define _pty_first\t\"%s\"\n", pty[i]); break; } return 0; diff --git a/src/lib/libast/features/float b/src/lib/libast/features/float index 0f357eec9..781f76e0f 100644 --- a/src/lib/libast/features/float +++ b/src/lib/libast/features/float @@ -245,6 +245,7 @@ macro{ tst - note{ missing floating point limits }end output{ #include "FEATURE/common" + #include #if _hdr_float #include #endif @@ -899,6 +900,7 @@ tst - note{ missing floating point limits }end output{ tst - note{ double exponent bitfoolery }end output{ #include "FEATURE/common" + #include typedef union _dbl_exp_u { unsigned _ast_int4_t e[sizeof(double) / 4]; @@ -934,6 +936,7 @@ tst - note{ double exponent bitfoolery }end output{ tst - note{ long double exponent bitfoolery }end output{ #include "FEATURE/common" + #include typedef union _ast_fltmax_exp_u { unsigned _ast_int4_t e[sizeof(_ast_fltmax_t) / 4]; @@ -968,6 +971,7 @@ tst - note{ long double exponent bitfoolery }end output{ }end tst - -DN=1 - -DN=2 note{ _ast_fltmax_t maximum integral type }end output{ + #include int main() { @@ -992,6 +996,7 @@ tst - -DSCAN=1 - -lm -DSTRTO=1 - -DMAC=1 - -DDIV=1 - -DEXP=1 - -DADD=1 - -DMPY=1 #define _FP_MODE_VARIABLE 1 #endif #include "FEATURE/common" + #include #include #include #include diff --git a/src/lib/libast/features/sfio b/src/lib/libast/features/sfio index 3ec8d1de9..2d240545f 100644 --- a/src/lib/libast/features/sfio +++ b/src/lib/libast/features/sfio @@ -7,6 +7,7 @@ key signed typ struct.sf_hdtr sys/socket.h tst - note{ number of bits in pointer }end output{ + #include int main() { diff --git a/src/lib/libast/features/stdio b/src/lib/libast/features/stdio index 0e5c3b79d..508879f3b 100644 --- a/src/lib/libast/features/stdio +++ b/src/lib/libast/features/stdio @@ -204,6 +204,7 @@ cat{ #endif }end output{ + #include #ifndef FILENAME_MAX #ifndef NAME_MAX #ifndef _POSIX_NAME_MAX