diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-16 22:59:17 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-04-16 22:59:17 +0300 |
commit | 2e7a100d802bd835f61b03544343267d2cfc5f4f (patch) | |
tree | 5381b7edd3a465ce8dc0e180c2ec540208061c52 | |
parent | e934ad609d3639152324a4211857d87f228cf938 (diff) | |
download | egawk-2e7a100d802bd835f61b03544343267d2cfc5f4f.tar.gz egawk-2e7a100d802bd835f61b03544343267d2cfc5f4f.tar.bz2 egawk-2e7a100d802bd835f61b03544343267d2cfc5f4f.zip |
Return "" from strftime if bad time_t value instead of fatal.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | builtin.c | 16 |
2 files changed, 15 insertions, 5 deletions
@@ -1,3 +1,7 @@ +2015-04-16 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_strftime): For bad time_t values, return "". + 2015-04-16 Andrew J. Schorr <aschorr@telemetry-investments.com> * node.c (r_force_number): If strtod sets errno, then force the @@ -1917,15 +1917,21 @@ do_strftime(int nargs) clock_val = get_number_d(t2); fclock = (time_t) clock_val; /* - * 4/2015: Protect against negative value being assigned + * Protect against negative value being assigned * to unsigned time_t. */ - if (clock_val < 0 && fclock > 0) - fatal(_("strftime: second argument less than 0 or too big for time_t")); + if (clock_val < 0 && fclock > 0) { + if (do_lint) + lintwarn(_("strftime: second argument less than 0 or too big for time_t")); + return make_string("", 0); + } /* And check that the value is in range */ - if (clock_val < time_t_min || clock_val > time_t_max) - fatal(_("strftime: second argument out of range for time_t")); + if (clock_val < time_t_min || clock_val > time_t_max) { + if (do_lint) + lintwarn(_("strftime: second argument out of range for time_t")); + return make_string("", 0); + } DEREF(t2); } |