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: Hermann Peifer
Subject: Re: [bug-gawk] Problem with strftime
Date: Tue, 18 Oct 2011 17:01:32 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

Re-posting my earlier message... Hermann


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]