bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk with dates before 1970


From: Glaudiston Gomes da Silva
Subject: Re: [bug-gawk] gawk with dates before 1970
Date: Thu, 9 Apr 2015 15:25:33 -0300

I wrote the post asking for help in stackoverflow:
The context is that I need to format/manipulate dates before 1970. mktime seems to be fine, but strftime do not accept negative numbers.

For all others on stackoverflow post (and for me) it's seems to be a bug in gawk.

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
gawk: cmd. line:1: fatal: strftime: second argument less than 0 or too big for time_t


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 ?

Thanks.


reply via email to

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