[PATCH 2/2] time: in strptime(), make %z accept [+-]HH:MM tz [BZ #17887]

Mike Frysinger vapier@gentoo.org
Wed Sep 16 17:19:00 GMT 2015


On 16 Sep 2015 10:47, Vincent Bernat wrote:
> --- a/time/strptime_l.c
> +++ b/time/strptime_l.c
>
> +		if (*rp == ':' && n == 2 && isdigit(*(rp + 1)))

needs a space: isdigit (...)

> --- 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);
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150916/8c21f50d/attachment.sig>


More information about the Libc-alpha mailing list