logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: d2b4c0cd845f1a5e47af06b48b239bbfb902c66e
parent cee0a0eb1efee02b89202bcc294c8afca3538915
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 11 Feb 2025 05:07:48 +0100

cmd/date: increase readability of %% handling

Diffstat:

Mcmd/date.c23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/cmd/date.c b/cmd/date.c @@ -42,18 +42,19 @@ date_strftime(char *restrict buf, static char fmt_buf[100] = ""; size_t fmt_bufi = 0; - fmt_buf[0] = '\0'; - - if(fmt[i] == '%') fmt_buf[fmt_bufi++] = fmt[i++]; - - if(fmt[i] == '%') // handle '%%' + if(fmt[i] == '%') { - *buf = '%'; - buf++; - buflen--; - printed++; - i++; - continue; + fmt_buf[fmt_bufi++] = fmt[i++]; + + if(fmt[i] == '%') // handle '%%' + { + *buf = '%'; + buf++; + buflen--; + printed++; + i++; + continue; + } } for(; fmt[i] != '%' && i < fmtlen;)