[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] gawk with dates before 1970
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] gawk with dates before 1970 |
Date: |
Mon, 13 Apr 2015 23:33:42 -0400 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Apr 13, 2015 at 11:06:39PM -0400, Andrew J. Schorr wrote:
> On Mon, Apr 13, 2015 at 04:30:03PM +0300, Aharon Robbins wrote:
> > > You cannot just delete those lines, because some systems have time_t
> > > as an unsigned data type.
> >
> > The actual variable used is a long, in order to be able to
> > test for < 0. But removing them doesn't seem to cause any
> > problems.
>
> I may be confused, but I think Eli's point was that time_t could be unsigned,
> so when the code says:
>
> time_t fclock;
> long clock_val;
>
> clock_val = <value of 2nd argument>
> fclock = (time_t) clock_val;
>
> the value could be changed. In that case, strftime would give an unexpected
> result. In general, we're stuffing a double-precision or MPFR value
> into a time_t. Should we check after the conversion that we haven't
> mutilated the value? Either of those assignments could alter the value...
For example, using installed gawk with the old check in place:
bash-4.2$ /bin/gawk 'BEGIN {print strftime("%F-%T", 1e300)}'
gawk: cmd. line:1: fatal: strftime: second argument less than 0 or too big for
time_t
With the new code in the master branch:
bash-4.2$ ./gawk 'BEGIN {print strftime("%F-%T", 1e300)}'
gawk: cmd. line:1: fatal error: internal error
Aborted (core dumped)
In the debugger, I see:
(gdb) print fclock
$1 = -9223372036854775808
This behavior seems a bit unattractive. :-)
Regards,
Andy
- Re: [bug-gawk] gawk with dates before 1970, Glaudiston Gomes da Silva, 2015/04/09
- Re: [bug-gawk] gawk with dates before 1970, Eli Zaretskii, 2015/04/10
- Re: [bug-gawk] gawk with dates before 1970, Aharon Robbins, 2015/04/13
- Re: [bug-gawk] gawk with dates before 1970, Andrew J. Schorr, 2015/04/13
- Re: [bug-gawk] gawk with dates before 1970,
Andrew J. Schorr <=
- Re: [bug-gawk] gawk with dates before 1970, Glaudiston Gomes da Silva, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Andrew J. Schorr, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Aharon Robbins, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Eli Zaretskii, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Aharon Robbins, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Eli Zaretskii, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Andrew J. Schorr, 2015/04/14
- Re: [bug-gawk] gawk with dates before 1970, Aharon Robbins, 2015/04/16
- Re: [bug-gawk] gawk with dates before 1970, Andrew J. Schorr, 2015/04/16
- Re: [bug-gawk] gawk with dates before 1970, Aharon Robbins, 2015/04/16