From 255383a8cd049f9c90fa234ba7d586be2bcde8d7 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 17 Mar 2022 00:00:00 -0500 Subject: [PATCH] top: do not add an extra line when rewritting a rcfile When the configuration file is first written, there is just the normal single newline which ends that rcfile. However, when any existing rcfile was rewritten, there was one extra newline '\n' character added at the end. This will happen just once. The file does NOT continue to grow with the extra blank lines always being added. Anyway, this patch will put an end to such a practice. [ along the way i fixed an unrelated whitespace oops ] Signed-off-by: Jim Warner --- top/top.c | 2 +- top/top.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/top/top.c b/top/top.c index 0bda1d01..83baab77 100644 --- a/top/top.c +++ b/top/top.c @@ -5079,7 +5079,7 @@ static void write_rcfile (void) { fprintf(fp, Osel_delim_2_txt); } - if (Inspect.raw) + if (Inspect.raw && strcmp(Inspect.raw, "\n")) fputs(Inspect.raw, fp); fclose(fp); diff --git a/top/top.h b/top/top.h index 79e72f5f..1c05a7a7 100644 --- a/top/top.h +++ b/top/top.h @@ -509,7 +509,7 @@ typedef struct WIN_t { #define RCF_PLUS_H "\\]^_`abcdefghij" #define RCF_PLUS_J "klmnopqrstuvwxyz" // this next guy must never, ever change - // ( we transition from'char' to 'int' ) + // ( transitioned from 'char' to 'int' ) #define RCF_XFORMED_ID 'k' // this next guy is incremented when columns change // ( to prevent older top versions from accessing )