From d587d4e5a72d08926d36288663a92ca6efbe0a6b Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 16 Dec 2010 21:06:07 +0200 Subject: Add PROCINFO["strftime"] as default strftime() format. --- builtin.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 268656bc..fc3a327d 100644 --- a/builtin.c +++ b/builtin.c @@ -802,17 +802,32 @@ do_strftime(int nargs) char *bufp; size_t buflen, bufsize; char buf[BUFSIZ]; - static const char def_format[] = "%a %b %e %H:%M:%S %Z %Y"; const char *format; int formatlen; int do_gmt; + NODE *val = NULL; + NODE *sub = NULL; /* set defaults first */ - format = def_format; /* traditional date format */ + format = def_strftime_format; /* traditional date format */ formatlen = strlen(format); (void) time(& fclock); /* current time of day */ do_gmt = FALSE; + if (PROCINFO_node != NULL) { + sub = make_string("strftime", 8); + val = in_array(PROCINFO_node, sub); + unref(sub); + + if (val != NULL) { + if (do_lint && (val->flags & STRING) == 0) + lintwarn(_("strftime: format value in PROCINFO[\"strftime\"] has numeric type")); + val = force_string(val); + format = val->stptr; + formatlen = val->stlen; + } + } + t1 = t2 = t3 = NULL; if (nargs > 0) { /* have args */ NODE *tmp; -- cgit v1.2.3