[PATCH 2/2] time: in strptime(), make %z accept [+-]HH:MM tz [BZ #17887]
Vincent Bernat
Vincent.Bernat@exoscale.ch
Thu Sep 17 07:56:00 GMT 2015
❦ 16 septembre 2015 13:19 -0400, Mike Frysinger <vapier@gentoo.org> :
>> --- a/time/tst-strptime2.c
>> +++ b/time/tst-strptime2.c
>>
>> - snprintf (buf + i, ndigits + 1, "%04u", hhmm);
>> + snprintf (buf + i,
>> + (colon && ndigits >= 2) ? ndigits + 2 : ndigits + 1,
>> + "%02u%s%02u", hh, colon ? ":" : "", mm);
>
> i think the inlining of |colon| makes it hard to read. just use an if
> statement to do it:
> if (colon)
> snprintf (buf + i, ndigits + 2, "%02u:%02u", hh, mm);
> else
> snprintf (buf + i, ndigits + 1, "%04u", hhmm);
Yes, far better. Updated patch:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-time-in-strptime-make-z-accept-HH-MM-tz-BZ-17887.patch
Type: text/x-diff
Size: 3701 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150917/14a2446f/attachment.bin>
-------------- next part --------------
--
Vincent Bernat — Vincent.Bernat@exoscale.ch
❬❱ http://www.exoscale.ch
More information about the Libc-alpha
mailing list