summaryrefslogtreecommitdiff
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-12-16 21:06:07 +0200
committerArnold D. Robbins <arnold@skeeve.com>2010-12-16 21:06:07 +0200
commitd587d4e5a72d08926d36288663a92ca6efbe0a6b (patch)
treebc0ca68333c11f7c56d4c6894b1a725ff707e4c8 /builtin.c
parentedfb721ac785219e9b881d8ac3a841cef8270a79 (diff)
downloadgawk-d587d4e5a72d08926d36288663a92ca6efbe0a6b.tar.gz
Add PROCINFO["strftime"] as default strftime() format.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c19
1 files changed, 17 insertions, 2 deletions
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;