From: Nathanael P Wilson Date: Mon, 28 Nov 2022 20:30:06 +0000 (-0800) Subject: Fix extra space when no TZ printed X-Git-Tag: v12.7.2~43^2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f00d5980a06dd4909b404fb187bf0815adf20fb;p=sysstat Fix extra space when no TZ printed --- diff --git a/sadf_misc.c b/sadf_misc.c index cda8e99..e9a3f23 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -832,11 +832,18 @@ char *print_dbppc_timestamp(int fmt, struct file_header *file_hdr, char *cur_dat else { strcpy(temp2, temp1); } - snprintf(pre, sizeof(pre), "%s%s %s", temp2, cur_time, - strlen(cur_date) ? (PRINT_LOCAL_TIME(flags) ? my_tz - : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname - : "UTC")) - : ""); + + if (strlen(cur_date) && (!PRINT_TRUE_TIME(flags) || (PRINT_TRUE_TIME(flags) && strlen(file_hdr->sa_tzname)))) { + snprintf(pre, sizeof(pre), "%s%s %s", temp2, cur_time, + PRINT_LOCAL_TIME(flags) ? my_tz + : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname + : "UTC")); + } else { + snprintf(pre, sizeof(pre), "%s%s", temp2, cur_time); + } + + + pre[sizeof(pre) - 1] = '\0'; if (DISPLAY_HORIZONTALLY(flags)) {