Re: [PATCH] Portability of dash to legacy systems, such as AT&T Unix PC : 06-stdbool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 -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,

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux