From ffa591d5e09389b01c50dd98333fce6b994a11a9 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 28 Apr 2023 12:28:06 -0700 Subject: [PATCH] Fix --help output for options without a short flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously --help printed the following: ``` -V --no-trace -� --trace-output -l --inst-limit ``` With the new change it is: ``` -V --no-trace --trace-output -l --inst-limit ``` --- c_emulator/riscv_sim.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c index 5a73896ba..84ee04d3f 100644 --- a/c_emulator/riscv_sim.c +++ b/c_emulator/riscv_sim.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -156,7 +157,10 @@ static void print_usage(const char *argv0, int ec) #endif struct option *opt = options; while (opt->name) { - fprintf(stdout, "\t -%c\t --%s\n", (char)opt->val, opt->name); + if (isprint(opt->val)) + fprintf(stdout, "\t -%c\t --%s\n", (char)opt->val, opt->name); + else + fprintf(stdout, "\t \t --%s\n", opt->name); opt++; } exit(ec);