[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/23] test/gdc.c: Fix bug when `-t` option used.
From: |
G. Branden Robinson |
Subject: |
[PATCH 09/23] test/gdc.c: Fix bug when `-t` option used. |
Date: |
Sat, 22 Jun 2024 12:48:31 -0500 |
Stop writing the contents of the buffer populated by `ctime()` below the
clock display when the `-t` option is used; it always showed the date as
1 January 1970 (possibly 31 December 1969 for time zones east of GMT).
---
test/gdc.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/test/gdc.c b/test/gdc.c
index 7243c104b..4c474b174 100644
--- a/test/gdc.c
+++ b/test/gdc.c
@@ -60,6 +60,7 @@ static long older[6], next[6], newer[6], mask;
static int sigtermed = 0;
static bool redirected = FALSE;
static bool hascolor = FALSE;
+static bool hascustomtime = FALSE;
static void
sighndl(int signo)
@@ -247,6 +248,7 @@ main(int argc, char *argv[])
smooth = TRUE;
break;
case 't':
+ hascustomtime = TRUE;
starts = parse_time(optarg);
break;
case OPTS_VERSION:
@@ -399,14 +401,16 @@ main(int argc, char *argv[])
}
}
- /* this depends on the detailed format of ctime(3) */
- _nc_STRNCPY(buf, ctime(&now), (size_t) 30);
- {
- char *d2 = buf + 10;
- char *s2 = buf + 19;
- while ((*d2++ = *s2++) != '\0') ;
+ if (!hascustomtime) {
+ /* this depends on the detailed format of ctime(3) */
+ _nc_STRNCPY(buf, ctime(&now), (size_t) 30);
+ {
+ char *d2 = buf + 10;
+ char *s2 = buf + 19;
+ while ((*d2++ = *s2++) != '\0') ;
+ }
+ MvAddStr(16, 30, buf);
}
- MvAddStr(16, 30, buf);
move(6, 0);
drawbox(FALSE);
--
2.30.2
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 09/23] test/gdc.c: Fix bug when `-t` option used.,
G. Branden Robinson <=