From 5e2366ced5cf1a52bfe69955f705fa98a250f56d Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 24 Oct 2020 13:39:19 +0200 Subject: More robust way. --- stc/cfmt.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stc/cfmt.h b/stc/cfmt.h index 2b544051..6e4f4fcc 100644 --- a/stc/cfmt.h +++ b/stc/cfmt.h @@ -35,8 +35,9 @@ _cfmt_conv(int nargs, const char *fmt, ...); enum {_cfmt_bn=4, _cfmt_sn=64}; STC_INLINE const char* _cfmt_strftime(char* n, char buf[][_cfmt_sn], size_t maxsize, const char *fmt, const struct tm *timeptr) { if (*n >= _cfmt_bn) return fmt; - strftime(buf[*n], maxsize, fmt, timeptr); - return buf[(*n)++]; + int k = (*n)++; + strftime(buf[k], maxsize, fmt, timeptr); + return buf[k]; } #ifndef __cplusplus -- cgit v1.2.3