bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] strerror_r: fix on newer cygwin


From: Bruno Haible
Subject: Re: [PATCH] strerror_r: fix on newer cygwin
Date: Thu, 19 May 2011 22:02:31 +0200
User-agent: KMail/1.9.9

Eric Blake wrote:
> --- a/lib/strerror_r.c
> +++ b/lib/strerror_r.c
> @@ -34,7 +34,11 @@
>  # endif
> 
> 
> -#if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__)
> +#if (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__) && 
> HAVE___XPG_STRERROR_R /* glibc >= 2.3.4, cygwin >= 1.7.9 */
> +
> +# define USE_XPG_STRERROR_R 1
> +
> +#elif HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__)
> 
>  /* The system's strerror_r function is OK, except that its third argument
>     is 'int', not 'size_t', or its return type is wrong.  */
> @@ -43,10 +47,6 @@
> 
>  # define USE_SYSTEM_STRERROR_R 1
> 
> -#elif (__GLIBC__ >= 2 || defined __UCLIBC__) && HAVE___XPG_STRERROR_R /* 
> glibc >= 2.3.4 */
> -
> -# define USE_XPG_STRERROR_R 1
> -
>  #else /* (__GLIBC__ >= 2 || defined __UCLIBC__ ? !HAVE___XPG_STRERROR_R : 
> !HAVE_DECL_STRERROR_R) */
> 
>  /* Use the system's strerror().  */

For consistency, I prefer to have the same order of #ifs in the function as
at the top of the file, so I'm applying this:


2011-05-19  Bruno Haible  <address@hidden>

        strerror_r: Reorder #if blocks.
        * lib/strerror_r.c (strerror_r): Reorder conditionals in the function
        for consistency with the previous commit.

--- lib/strerror_r.c.orig       Thu May 19 21:59:21 2011
+++ lib/strerror_r.c    Thu May 19 21:56:04 2011
@@ -419,7 +419,17 @@
   {
     int ret;
 
-#if USE_SYSTEM_STRERROR_R
+#if USE_XPG_STRERROR_R
+
+    {
+      extern int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
+
+      ret = __xpg_strerror_r (errnum, buf, buflen);
+      if (ret < 0)
+        ret = errno;
+    }
+
+#elif USE_SYSTEM_STRERROR_R
 
     if (buflen > INT_MAX)
       buflen = INT_MAX;
@@ -495,16 +505,6 @@
           }
       }
 
-#elif USE_XPG_STRERROR_R
-
-    {
-      extern int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
-
-      ret = __xpg_strerror_r (errnum, buf, buflen);
-      if (ret < 0)
-        ret = errno;
-    }
-
 #else /* USE_SYSTEM_STRERROR */
 
     /* Try to do what strerror (errnum) does, but without clobbering the

-- 
In memoriam Anne Boleyn <http://en.wikipedia.org/wiki/Anne_Boleyn>



reply via email to

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