diff options
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r-- | usr.bin/awk/run.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index dcd959aa52d..f6b141c695c 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.67 2020/08/11 16:57:05 millert Exp $ */ +/* $OpenBSD: run.c,v 1.68 2020/08/28 16:29:16 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -1594,7 +1594,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis FILE *fp; int status = 0; time_t tv; - struct tm *tm; + struct tm *tm, tmbuf; t = ptoi(a[0]); x = execute(a[1]); @@ -1749,6 +1749,26 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis else u = fflush(fp); break; + case FMKTIME: + memset(&tmbuf, 0, sizeof(tmbuf)); + tm = &tmbuf; + t = sscanf(getsval(x), "%d %d %d %d %d %d %d", + &tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, + &tm->tm_min, &tm->tm_sec, &tm->tm_isdst); + switch (t) { + case 6: + tm->tm_isdst = -1; /* let mktime figure it out */ + /* FALLTHROUGH */ + case 7: + tm->tm_year -= 1900; + tm->tm_mon--; + u = mktime(tm); + break; + default: + u = -1; + break; + } + break; case FSYSTIME: u = time((time_t *) 0); break; |