commit:     3ef45fa46d5a45a3f19806cf62aba8532b4e401f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 30 10:35:55 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 10:35:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3ef45fa4

qlop: support -d 0 (or @0)

Allow setting the zero date, to basically have a quick way to list
everything, useful with -E, e.g. -Evd 0 to show the entire emerge
history.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 man/include/qlop.desc         |  2 +-
 man/include/qlop.optdesc.yaml |  2 +-
 man/qlop.1                    |  6 +++---
 qlop.c                        | 25 +++++++++++++++++--------
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/man/include/qlop.desc b/man/include/qlop.desc
index e39f689..0f7fa7c 100644
--- a/man/include/qlop.desc
+++ b/man/include/qlop.desc
@@ -19,7 +19,7 @@ in further on specific packages.
 .P
 After version \fB0.74\fR of portage-utils, \fIqlop\fR was changed
 considerably to be more consistent and more advanced.  Most notably,
-this has changed default date output and commmand line flags.  Instead
+this has changed default date output and command line flags.  Instead
 of reporting the time the operation finished, \fIqlop\fR now reports the
 time the operation started.  The behaviour of the old \fB-g\fR flag is
 best matched by the new \fB-t\fR flag.  Similar, the old \fB-t\fR flag

diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml
index c6e0833..fc268d6 100644
--- a/man/include/qlop.optdesc.yaml
+++ b/man/include/qlop.optdesc.yaml
@@ -16,7 +16,7 @@ date: |
     .IP YYYY-MM-DDThh:mm:ss
     As before, but hours, minutes and seconds added.  This is the same
     format qlop prints for timestamps.
-    .IP SSSSSSSSS
+    .IP "SSSSSSSSS or @SSSSSSSSS"
     Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch.
     .IP FORMAT|DATE
     Use \fIFORMAT\fR as input for \fBstrptime\fR(3) to parse \fIDATE\fR.

diff --git a/man/qlop.1 b/man/qlop.1
index 5aafa82..a175332 100644
--- a/man/qlop.1
+++ b/man/qlop.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qlop "1" "Nov 2020" "Gentoo Foundation" "qlop"
+.TH qlop "1" "Jan 2021" "Gentoo Foundation" "qlop"
 .SH NAME
 qlop \- emerge log analyzer
 .SH SYNOPSIS
@@ -27,7 +27,7 @@ in further on specific packages.
 .P
 After version \fB0.74\fR of portage-utils, \fIqlop\fR was changed
 considerably to be more consistent and more advanced.  Most notably,
-this has changed default date output and commmand line flags.  Instead
+this has changed default date output and command line flags.  Instead
 of reporting the time the operation finished, \fIqlop\fR now reports the
 time the operation started.  The behaviour of the old \fB-g\fR flag is
 best matched by the new \fB-t\fR flag.  Similar, the old \fB-t\fR flag
@@ -110,7 +110,7 @@ year, followed by month and day of month.
 .IP YYYY-MM-DDThh:mm:ss
 As before, but hours, minutes and seconds added.  This is the same
 format qlop prints for timestamps.
-.IP SSSSSSSSS
+.IP "SSSSSSSSS or @SSSSSSSSS"
 Seconds since 1970-01-01 00:00:00 +0000 (UTC), the UNIX epoch.
 .IP FORMAT|DATE
 Use \fIFORMAT\fR as input for \fBstrptime\fR(3) to parse \fIDATE\fR.

diff --git a/qlop.c b/qlop.c
index 5045d17..2d01689 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <[email protected]>
@@ -116,14 +116,17 @@ parse_date(const char *sdate, time_t *t)
        } else {
                /* Handle automatic formats:
                 * - "12315128"            -> %s
+                * - "@12315128"            -> %s
                 * - "2015-12-24"          -> %Y-%m-%d
                 * - "2019-03-28T13:52:31" -> %Y-%m-%dT%H:%M:%s"
                 * - human readable format (see below)
                 */
-               size_t len = strspn(sdate, "0123456789-:T");
+               size_t len = strspn(sdate, "0123456789-:T@");
                if (sdate[len] == '\0') {
                        const char *fmt;
-                       if (strchr(sdate, '-') == NULL) {
+                       if (sdate[0] == '@') {
+                               fmt = "@%s";
+                       } else if (strchr(sdate, '-') == NULL) {
                                fmt = "%s";
                        } else if ((s = strchr(sdate, 'T')) == NULL) {
                                fmt = "%Y-%m-%d";
@@ -1394,8 +1397,8 @@ int qlop_main(int argc, char **argv)
        DECLARE_ARRAY(atoms);
        int runningmode = 0;
 
-       start_time = 0;
-       end_time = LONG_MAX;
+       start_time = -1;
+       end_time = -1;
        m.do_time = 0;
        m.do_merge = 0;
        m.do_unmerge = 0;
@@ -1435,10 +1438,10 @@ int qlop_main(int argc, char **argv)
                        case 'l': m.show_lastmerge = 1; break;
                        case 'F': m.fmt = optarg;       break;
                        case 'd':
-                               if (start_time == 0) {
+                               if (start_time == -1) {
                                        if (!parse_date(optarg, &start_time))
                                                err("invalid date: %s", optarg);
-                               } else if (end_time == LONG_MAX) {
+                               } else if (end_time == -1) {
                                        if (!parse_date(optarg, &end_time))
                                                err("invalid date: %s", optarg);
                                } else
@@ -1539,7 +1542,7 @@ int qlop_main(int argc, char **argv)
        }
 
        /* handle -l / -d conflict */
-       if (start_time != 0 && m.show_lastmerge) {
+       if (start_time != -1 && m.show_lastmerge) {
                if (!m.show_emerge)
                        warn("-l and -d cannot be used together, dropping -l");
                m.show_lastmerge = 0;
@@ -1563,6 +1566,12 @@ int qlop_main(int argc, char **argv)
                        m.fmt = "%[CATEGORY]%[PN]";
        }
 
+       /* adjust time ranges when unset */
+       if (start_time == -1)
+               start_time = 0;
+       if (end_time == -1)
+               end_time = LONG_MAX;
+
        if (m.do_running) {
                array_t *new_atoms = NULL;
 

Reply via email to