bug-coreutils
[Top][All Lists]
Advanced

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

more stdbool portability fixes for coreutils


From: Paul Eggert
Subject: more stdbool portability fixes for coreutils
Date: Tue, 13 Dec 2005 11:45:20 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed this to work around a buggy compiler that had _Bool but
its implementation of _Bool was quite broken.

2005-12-13  Paul Eggert  <address@hidden>

        * lib/stdbool_.h (_Bool): Resurrect the "#if address@hidden@" check, to
        work around compilers that have a (possibly-broken) _Bool but lack
        a working <stdbool.h>.
        * m4/stdbool.m4 (AC_HEADER_STDBOOL): Check for buggy compiler that
        has _Bool but mishandles _Bool |= _Bool.

Index: lib/stdbool_.h
===================================================================
RCS file: /fetish/cu/lib/stdbool_.h,v
retrieving revision 1.6
diff -p -u -r1.6 stdbool_.h
--- lib/stdbool_.h      26 Nov 2005 06:37:31 -0000      1.6
+++ lib/stdbool_.h      13 Dec 2005 19:38:38 -0000
@@ -59,10 +59,10 @@
 # include <OS.h> /* defines bool but not _Bool */
 #endif
 
-/* C++ and BeOS have a reliable _Bool.  Otherwise, since this file is
-   being compiled, the system <stdbool.h> is not reliable so assume
-   that the system _Bool is not reliable either.  Under that
-   assumption, it is tempting to write
+/* C++ and BeOS have a reliable bool (and _Bool, if it exists).
+   Otherwise, since this file is being compiled, the system
+   <stdbool.h> is not reliable so assume that the system _Bool is not
+   reliable either.  Under that assumption, it is tempting to write
 
       typedef enum { false, true } _Bool;
 
@@ -88,7 +88,9 @@
    existing definition of _Bool and use our own.  */
 
 #if defined __cplusplus || defined __BEOS__
+# if address@hidden@
 typedef bool _Bool;
+# endif
 #else
 # define _Bool signed char
 #endif
Index: m4/stdbool.m4
===================================================================
RCS file: /fetish/cu/m4/stdbool.m4,v
retrieving revision 1.7
diff -p -u -r1.7 stdbool.m4
--- m4/stdbool.m4       26 Nov 2005 06:37:52 -0000      1.7
+++ m4/stdbool.m4       13 Dec 2005 19:38:38 -0000
@@ -83,11 +83,15 @@ AC_DEFUN([AC_HEADER_STDBOOL],
           char digs[] = "0123456789";
           int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
          #endif
+         _Bool q = true;
+         _Bool *pq = &q;
        ],
        [
+         *pq |= q;
+         *pq |= ! q;
          /* Refer to every declared value, to avoid compiler optimizations.  */
          return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
-                 + !m + !n + !o + !p);
+                 + !m + !n + !o + !p + !q + !pq);
        ],
        [ac_cv_header_stdbool_h=yes],
        [ac_cv_header_stdbool_h=no])])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]