diff mbox series

P*rtability of dash to legacy systems, such as AT&T Unix PC : 06-stdbool

Message ID b88c1ef2-9217-4c54-afef-1c502fdb9f19@knaff.lu (mailing list archive)
State Under Review
Delegated to: Herbert Xu
Headers show
Series P*rtability of dash to legacy systems, such as AT&T Unix PC : 06-stdbool | expand

Commit Message

Alain Knaff Nov. 17, 2024, 9:40 a.m. UTC
Hi,

The 6th patch is dedicated to the stdbool.h header file. If it doesn't
exist, it cannot be simply dropped, as it contains definitions
absolutely needed by the application, which need to be replaced.

So:
 - a simple definition for the bool type is supplied
 - return of strchr() is explicitly compared with NULL rather than
 relying on an implicit conversion to boolean. Would cause a warning
 without this

Regards,

Alain
diff mbox series

Patch

diff -X ../exclude.txt -urN dash-0.5.12+05-sys-headers/configure.ac dash-0.5.12+06-stdbool/configure.ac
--- dash-0.5.12+05-sys-headers/configure.ac	2024-11-10 17:06:10.308390356 +0000
+++ dash-0.5.12+06-stdbool/configure.ac	2024-11-10 17:06:18.440583714 +0000
@@ -44,7 +44,7 @@ 
 dnl Checks for libraries.
 
 dnl Checks for header files.
-AC_CHECK_HEADERS(alloca.h paths.h pwd.h dirent.h \
+AC_CHECK_HEADERS(alloca.h paths.h pwd.h stdbool.h dirent.h \
 		getopt.h sys/resource.h termios.h sys/time.h)
 
 dnl Check for declarations
diff -X ../exclude.txt -urN dash-0.5.12+05-sys-headers/src/expand.c dash-0.5.12+06-stdbool/src/expand.c
--- dash-0.5.12+05-sys-headers/src/expand.c	2024-11-10 15:30:16.271361150 +0000
+++ dash-0.5.12+06-stdbool/src/expand.c	2024-10-20 21:03:17.122588883 +0000
@@ -73,7 +73,12 @@ 
 #include <glob.h>
 #endif
 #include <ctype.h>
+#ifdef HAVE_STDBOOL_H
 #include <stdbool.h>
+#else
+typedef int bool;
+const int false = 0;
+#endif
 
 /*
  * Routines to expand arguments to commands.  We have to deal with
@@ -1057,10 +1062,10 @@ 
 				if (c == (char)CTLESC)
 					c = *p++;
 
-				isifs = strchr(ifs, c);
+				isifs = strchr(ifs, c) != NULL;
 				isdefifs = false;
 				if (isifs)
-					isdefifs = strchr(defifs, c);
+					isdefifs = strchr(defifs, c) != NULL;
 
 				/* If only reading one more argument:
 				 * If we have exactly one field,