Re: [PATCH v3] date.c: Support iso8601 timezone formats

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Also, I do not quite understand why the match_tz() logic needs to be that
> long.
>
> Wouldn't something like this patch (on top of yours) easier to follow?
>
>  date.c |   50 +++++++++++++++++++++-----------------------------
>  1 files changed, 21 insertions(+), 29 deletions(-)
>
> diff --git a/date.c b/date.c
> index f8722c1..6079b1a 100644
> --- a/date.c
> +++ b/date.c
> @@ -551,44 +551,36 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
>  
>  static int match_tz(const char *date, int *offp)
>  {
> +	int min;

Micronit; this should be "int min = 0", as parsing of "hh" form relies on
the if/elseif/else cascade to parse only the hour part and leaving min to
the original value.

>  	char *end;
> +	int hour = strtoul(date + 1, &end, 10);
> +	int n = end - (date + 1);
>  
> +	if (n == 4) {
> +		/* hhmm */
> +		min = hour % 100;
> +		hour = hour / 100;
> +	} else if (n != 2) {
> +		min = 99; /* random crap */
> +	} else if (*end == ':') {
> +		/* hh:mm? */
> +		min = strtoul(end + 1, &end, 10);
> +		if (end - (date + 1) != 5)
> +			min = 99; /* random crap */
>  	}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]