[scc-dev] [PATCH 3/3] make/posix: Fix feature test macros

From: Roberto E. Vargas Caballero <k0ga_at_shike2.net>
Date: Mon, 10 Mar 2025 11:54:06 +0100

From: remph <lhr_at_disroot.org>

_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.
---
 src/cmd/scc-make/posix.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/cmd/scc-make/posix.c b/src/cmd/scc-make/posix.c
index 1b966f17..e9b94842 100644
--- a/src/cmd/scc-make/posix.c
+++ b/src/cmd/scc-make/posix.c
_at_@ -1,4 +1,5 @@
-#define _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
 
 #include <signal.h>
 #include <sys/stat.h>
_at_@ -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
-- 
2.46.1
--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Mon 10 Mar 2025 - 11:54:06 CET

This archive was generated by hypermail 2.3.0 : Mon 10 Mar 2025 - 12:00:02 CET