From 882428883a2d4a6cd8583811c4e3e4bf0f0b52ee Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sat, 14 Mar 2026 14:54:53 +0000 Subject: [PATCH] Remember both -N and -F values if two were given (#67). --- src/include/options.h | 2 ++ src/main/options.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/include/options.h b/src/include/options.h index b1f0f3e..491851f 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -56,8 +56,10 @@ struct opts_s { /*@keep@*/ const char *program_name; /* name the program is running as */ /*@keep@*/ /*@null@*/ char *output; /* fd to write output to */ /*@keep@*/ /*@null@*/ char *name; /* display name, if any */ + /*@keep@*/ /*@null@*/ char *name1; /* first name, if two were given */ /*@keep@*/ /*@null@*/ char *default_bar_style; /* default bar style */ /*@keep@*/ /*@null@*/ char *format; /* output format, if any */ + /*@keep@*/ /*@null@*/ char *format1; /* first format, if two were given */ /*@keep@*/ /*@null@*/ char *pidfile; /* PID file, if any */ /*@keep@*/ /*@null@*/ char *store_and_forward_file; /* store and forward file, if any */ /*@keep@*/ /*@null@*/ char *extra_display; /* extra display specifier, if any */ diff --git a/src/main/options.c b/src/main/options.c index 1f52d51..43177a6 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -64,8 +64,12 @@ void opts_free( /*@only@ */ opts_t opts) */ if (NULL != opts->name) free(opts->name); + if (NULL != opts->name1) + free(opts->name1); if (NULL != opts->format) free(opts->format); + if (NULL != opts->format1) + free(opts->format1); if (NULL != opts->pidfile) free(opts->pidfile); if (NULL != opts->output) @@ -1017,7 +1021,7 @@ opts_t opts_parse(unsigned int argc, char **argv) opts->height_set_manually = opts->height == 0 ? false : true; break; case 'N': - /* TODO: preserve previous name for use with "-M both" */ + opts->name1 = opts->name; opts->name = pv_strdup(optarg); if (NULL == opts->name) { fprintf(stderr, "%s: -N: %s\n", opts->program_name, strerror(errno)); @@ -1092,7 +1096,7 @@ opts_t opts_parse(unsigned int argc, char **argv) } break; case 'F': - /* TODO: preserve previous format for use with "-M both" */ + opts->format1 = opts->format; opts->format = pv_strdup(optarg); if (NULL == opts->format) { fprintf(stderr, "%s: -F: %s\n", opts->program_name, strerror(errno));