bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] strptime: silence gcc warnings


From: Eric Blake
Subject: Re: [PATCH 2/2] strptime: silence gcc warnings
Date: Thu, 12 Jan 2012 08:40:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

On 01/11/2012 08:31 PM, Bruno Haible wrote:
> Eric Blake wrote:
>> @@ -683,7 +684,9 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt 
>> LOCALE_PARAM)
>>                ++rp;
>>              if (*rp != '+' && *rp != '-')
>>                return NULL;
>> +#if defined _LIBC || HAVE_TM_GMTOFF
>>              neg = *rp++ == '-';
>> +#endif
>>              n = 0;
>>              while (n < 4 && *rp >= '0' && *rp <= '9')
>>                {
> 
> Here you need to pull the side effect of the statement outside the #if.

Phooey, you're right.  Consider it fixed by this:

From 16f49939147b27628041daa5cf01e9f7ada6a44d Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 12 Jan 2012 08:39:07 -0700
Subject: [PATCH] strptime: fix regression on mingw

The previous change lost the side effect of skipping past a
time-zone offset sign.  Instead, fix things to rely on the
fact that _GL_UNUSED can be applied to any variable, even if
some compilation paths use it, to silence gcc on the paths
where it is not used.

* lib/strptime.c (__strptime_internal) [!_LIBC && !HAVE_TM_GMTOFF]:
Fix regression.  Reported by Bruno Haible.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog      |    6 ++++++
 lib/strptime.c |    6 +-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80b5702..dabbd8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-12  Eric Blake  <address@hidden>
+
+       strptime: fix regression on mingw
+       * lib/strptime.c (__strptime_internal) [!_LIBC && !HAVE_TM_GMTOFF]:
+       Fix regression.  Reported by Bruno Haible.
+
 2012-01-11  Reuben Thomas  <address@hidden>
            Bruno Haible  <address@hidden>

diff --git a/lib/strptime.c b/lib/strptime.c
index 0d4c3a4..6a0139e 100644
--- a/lib/strptime.c
+++ b/lib/strptime.c
@@ -674,9 +674,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt
LOCALE_PARAM)
              specify hours.  If fours digits are used, minutes are
              also specified.  */
           {
-#if defined _LIBC || HAVE_TM_GMTOFF
-            bool neg;
-#endif
+            bool neg _GL_UNUSED;
             int n;

             val = 0;
@@ -684,9 +682,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt
LOCALE_PARAM)
               ++rp;
             if (*rp != '+' && *rp != '-')
               return NULL;
-#if defined _LIBC || HAVE_TM_GMTOFF
             neg = *rp++ == '-';
-#endif
             n = 0;
             while (n < 4 && *rp >= '0' && *rp <= '9')
               {
-- 
1.7.7.5



-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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