From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D60B115808B for ; Wed, 23 Feb 2022 11:57:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EEF93E0972; Wed, 23 Feb 2022 11:57:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BA2ACE0972 for ; Wed, 23 Feb 2022 11:57:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B5E3F343078 for ; Wed, 23 Feb 2022 11:57:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D8FC22EC for ; Wed, 23 Feb 2022 11:57:08 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1645617355.b59cdb9849c6528922664fcc1c07537ac71e05b1.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: b59cdb9849c6528922664fcc1c07537ac71e05b1 X-VCS-Branch: master Date: Wed, 23 Feb 2022 11:57:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 12d02619-b92d-4a89-a5ad-de0cd35ef010 X-Archives-Hash: 3413c33c22afdb1f6cbf1792a24e7705 commit: b59cdb9849c6528922664fcc1c07537ac71e05b1 Author: Fabian Groffen gentoo org> AuthorDate: Wed Feb 23 11:55:55 2022 +0000 Commit: Fabian Groffen gentoo 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 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 {