bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Problem with strftime


From: Aharon Robbins
Subject: Re: [bug-gawk] Problem with strftime
Date: Fri, 21 Oct 2011 15:05:33 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi. The problem is defining "reasonable" negative values. I don't want
to uglify the code and in any case whatever heuristic I use will be
wrong for someone.

Perhaps it's reasonable to allow it to be negative by one day, to allow
for time zone differences, but that's it.

Unless someone complains bitterly, I'm going to leave it as is.

Thanks,

Arnold

> On 18/10/2011 14:26, Hermann Peifer wrote:
> > On 18/10/2011 11:35, Aharon Robbins wrote:
> >>
> >> Here's a fix:
> >>
> >> diff --git a/builtin.c b/builtin.c
> >> index 072fd8f..bae02f4 100644
> >> --- a/builtin.c
> >> +++ b/builtin.c
> >> @@ -1673,6 +1673,8 @@ do_strftime(int nargs)
> >> if (do_lint&& (t2->flags& (NUMCUR|NUMBER)) == 0)
> >> lintwarn(_("strftime: received non-numeric second argument"));
> >> fclock = (time_t) force_number(t2);
> >> + if (fclock< 0)
> >> + fatal(_("strftime: second argument less than 0 or too big for
> >> time_t"));
> >> DEREF(t2);
> >> }
> >>
> >>
> >>
> >
> > Thanks. I am not sure if this is intended: before the fix, the behaviour
> > for (reasonable) negative values was:
> >
> > $ echo -1 | TZ=UTC gawk '{print strftime("%Y-%m-%d",$1)}'
> > 1969-12-31
> >
> > $ echo -9999999999 | TZ=UTC gawk '{print strftime("%Y-%m-%d",$1)}'
> > 1653-02-10
> >
> > ...and now it is:
> >
> > $ echo -1 | TZ=UTC ./gawk '{print strftime("%Y-%m-%d",$1)}'
> > gawk: cmd. line:1: (FILENAME=- FNR=1) fatal: strftime: second argument
> > less than 0 or too big for time_t
> >
> >
> > Hermann



reply via email to

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