commit f507bae3a0e45b6f9eeadecb3065afaea1a6d6bc
parent dee0c6f0c90f7d64fd45cb6e3c48321f4beaf81d
Author: remph <lhr@disroot.org>
Date: Sat, 22 Feb 2025 13:14:54 +0100
make/posix: Fix feature test macros
_POSIX_C_SOURCE must be defined with a value that signals what
version of POSIX has to be exposed, and just defining it without
any value is equivalent to define it with 0 that is not a valid
version number.
In the same way, posix.c was using S_IFDIR that is XSI, and
to increase the portability it was changed to S_ISDIR that
is defined in the base specification.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/cmd/scc-make/posix.c b/src/cmd/scc-make/posix.c
@@ -1,4 +1,5 @@
-#define _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
#include <signal.h>
#include <sys/stat.h>
@@ -18,7 +19,7 @@ is_dir(char *fname)
if (stat(fname, &st) < 0)
return 0;
- return (st.st_mode & S_IFMT) == S_IFDIR;
+ return S_ISDIR(st.st_mode);
}
void