diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-09-01 11:57:53 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-09-01 11:57:53 (EDT) |
commit | 8f1be1d0db978b5da2fb9a84f9228397af5b5f6f (patch) | |
tree | a1421daa51b7daa93ddb729eb61eb5f3832ad8d0 | |
parent | 469814149f1e2434740d6edd4944d150f368f464 (diff) | |
download | atsign-8f1be1d0db978b5da2fb9a84f9228397af5b5f6f.zip atsign-8f1be1d0db978b5da2fb9a84f9228397af5b5f6f.tar.gz atsign-8f1be1d0db978b5da2fb9a84f9228397af5b5f6f.tar.bz2 |
main: Skip empty formats
This was previously done in _datetime_strftime() but in a way that would
overflow the array if an empty format was at the end. Moving this logic
into the caller is safer and makes a little more sense.
-rw-r--r-- | src/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -94,18 +94,27 @@ _list_formats(void) puts("Time formats:"); i = 0; while (datetime_strftime_time(tm, &out, &buf_sz, &buf, &i) > 0) { + if (out[0] == '\0') { + continue; + } printf(" * %s\n", out); } puts("Date formats:"); i = 0; while (datetime_strftime_date(tm, &out, &buf_sz, &buf, &i) > 0) { + if (out[0] == '\0') { + continue; + } printf(" * %s\n", out); } puts("Additional formats:"); i = 0; while (datetime_strftime_misc(tm, &out, &buf_sz, &buf, &i) > 0) { + if (out[0] == '\0') { + continue; + } printf(" * %s\n", out); } } |