|
From: | Glaudiston Gomes da Silva |
Subject: | Re: [bug-gawk] gawk with dates before 1970 |
Date: | Fri, 10 Apr 2015 06:42:36 -0300 |
hum... wait, thats really matter? if a variable is unsigned, all works, else if signed, it will not be negative.
If you are insecure about it, we can add different validation type like: if (clock_val < 0 && fclock > 0)
$ diff builtin.c.orig builtin.c
1916,1917d1915
< if (clock_val < 0)
< fatal(_("strftime: second argument less than 0 or too big for time_t"));
1918a1917,1918
> if (clock_val < 0 && fclock > 0)
> fatal(_("strftime: second argument less than 0 or too big for time_t"));
anyway, in last case, we have other options, like add a "#ifndef linux" for this block.2015-04-10 4:31 GMT-03:00 Eli Zaretskii <address@hidden>:> From: Glaudiston Gomes da Silva <address@hidden>
> Date: Thu, 9 Apr 2015 15:25:33 -0300
>
> So I looked in source file and commented out the 2 lines that test if is
> negative and make it fatal.
> 1701,1702c1701,1702
> glaudiston:/sources/gawk-4.1.1c$ diff builtin.c.orig builtin.c
> 1916,1917c1916,1917
> < if (clock_val < 0)
> < fatal(_("strftime: second argument less than 0 or too big for time_t"));
> ---
> > //if (clock_val < 0)
> > // fatal(_("strftime: second argument less than 0 or too big for time_t"));
>
> And it worked like magic:
> glaudiston:/sources/gawk-4.1.1c$ ./gawk 'BEGIN{t=mktime("1960 01 01 00 00 00");
> print t; print strftime("%Y-%m-%d", t) }'
> -315608400
> 1960-01-01
>
> 3 questions:
> 1) Why do exists this 2 lines?
> 2) Can my change break anything else?
> 3) If is not a dangerous change, there is any reason to do not add this to the
> next main release code ?
You cannot just delete those lines, because some systems have time_t
as an unsigned data type.
[Prev in Thread] | Current Thread | [Next in Thread] |