Skip to content

Commit

Permalink
Fix --help output for options without a short flag
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
arichardson committed Aug 3, 2023
1 parent be0962c commit ffa591d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion c_emulator/riscv_sim.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ffa591d

Please sign in to comment.