commit: b59cdb9849c6528922664fcc1c07537ac71e05b1 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Wed Feb 23 11:55:55 2022 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Wed Feb 23 11:55:55 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b59cdb98
qlop: fix date parsing of epochs on musl %s isn't a valid modifier in POSIX for strptime, so parse the number manually and produce a time out of that. Bug: https://bugs.gentoo.org/833942 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qlop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qlop.c b/qlop.c index addb4b3..16bf69f 100644 --- a/qlop.c +++ b/qlop.c @@ -126,18 +126,18 @@ parse_date(const char *sdate, time_t *t) */ size_t len = strspn(sdate, "0123456789-:T@"); if (sdate[len] == '\0') { - const char *fmt; if (sdate[0] == '@') { - fmt = "@%s"; + time_t d = (time_t)strtoll(&sdate[1], (char **)&s, 10); + localtime_r(&d, &tm); } else if (strchr(sdate, '-') == NULL) { - fmt = "%s"; + time_t d = (time_t)strtoll(sdate, (char **)&s, 10); + localtime_r(&d, &tm); } else if ((s = strchr(sdate, 'T')) == NULL) { - fmt = "%Y-%m-%d"; + s = strptime(sdate, "%Y-%m-%d", &tm); } else { - fmt = "%Y-%m-%dT%H:%M:%S"; + s = strptime(sdate, "%Y-%m-%dT%H:%M:%S", &tm); } - s = strptime(sdate, fmt, &tm); if (s == NULL || s[0] != '\0') return false; } else {