Remember both -N and -F values if two were given (#67).

This commit is contained in:
Andrew Wood
2026-03-14 14:54:53 +00:00
parent c2bbb8eef1
commit 882428883a
2 changed files with 8 additions and 2 deletions
+2
View File
@@ -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 */
+6 -2
View File
@@ -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));