changeset 9951:03b212920228

Work around preprocessors that don't handle UINTMAX_MAX. * lib/memchr2.c (memchr2): Avoid embedded #if. Reported by Alain Guibert, fix suggested by Bruno Haible. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Mon, 21 Apr 2008 09:57:07 -0600
parents c2d7cd5bb587
children 08dc00159dba
files ChangeLog lib/memchr2.c
diffstat 2 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-21  Eric Blake  <ebb9@byu.net>
+
+	Work around preprocessors that don't handle UINTMAX_MAX.
+	* lib/memchr2.c (memchr2): Avoid embedded #if.
+	Reported by Alain Guibert, fix suggested by Bruno Haible.
+
 2008-04-21  Simon Josefsson  <simon@josefsson.org>
 
 	* doc/posix-functions/strftime.texi (strftime): Explain better
@@ -120,7 +126,7 @@
 	Reported by Daniel Bergström <daniel@octocode.com>.
 
 2007-12-25  KJK::Hyperion  <hackbunny@reactos.com>
-            Bruno Haible  <bruno@clisp.org>
+	    Bruno Haible  <bruno@clisp.org>
 
 	* lib/localename.c (gl_locale_name_canonicalize) [WIN32_NATIVE]: New
 	function.
--- a/lib/memchr2.c
+++ b/lib/memchr2.c
@@ -83,18 +83,19 @@
   charmask2 = c2 | (c2 << 8);
   charmask1 |= charmask1 << 16;
   charmask2 |= charmask2 << 16;
-#if 0xffffffffU < UINTMAX_MAX
-  magic_bits |= magic_bits << 32;
-  charmask1 |= charmask1 << 32;
-  charmask2 |= charmask2 << 32;
-  if (8 < sizeof longword1)
-    for (i = 64; i < sizeof longword1 * 8; i *= 2)
-      {
-	magic_bits |= magic_bits << i;
-	charmask1 |= charmask1 << i;
-	charmask2 |= charmask2 << i;
-      }
-#endif
+  if (0xffffffffU < UINTMAX_MAX)
+    {
+      magic_bits |= magic_bits << 32;
+      charmask1 |= charmask1 << 32;
+      charmask2 |= charmask2 << 32;
+      if (8 < sizeof longword1)
+	for (i = 64; i < sizeof longword1 * 8; i *= 2)
+	  {
+	    magic_bits |= magic_bits << i;
+	    charmask1 |= charmask1 << i;
+	    charmask2 |= charmask2 << i;
+	  }
+    }
   magic_bits = (UINTMAX_MAX >> 1) & (magic_bits | 1);
 
   /* Instead of the traditional loop which tests each character,