diff options
author | lns <matzeton@googlemail.com> | 2018-06-09 18:15:47 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2018-06-09 18:15:47 +0200 |
commit | 531e07c02848deec10eb1c9057c6d6b3d444ad73 (patch) | |
tree | 8bb375f11bf0c4d9bafa78e82aab04709d70a1f1 /src/options.c | |
parent | ef10351f70c3d41e536c024b71d811bad6e98884 (diff) |
POTD skeleton #100.
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/options.c b/src/options.c index f06cbb1..7b83909 100644 --- a/src/options.c +++ b/src/options.c @@ -188,7 +188,8 @@ static void usage(const char *arg0, int print_copyright) { int i, has_default; size_t off; - char spaces[16]; + char spaces[6]; + char spaces_long[28]; char buf_arg[64]; char buf_shorthelp[BUFSIZ]; char buf_help[BUFSIZ]; @@ -205,13 +206,15 @@ static void usage(const char *arg0, int print_copyright) memset(spaces, ' ', sizeof spaces); spaces[sizeof spaces - 1] = 0; + memset(spaces_long, ' ', sizeof spaces_long); + spaces_long[sizeof spaces_long - 1] = 0; for (i = 0; i < OPT_MAX; ++i) { snprintf(buf_arg, sizeof buf_arg, "--%s", options[i].arg_name); memset(buf_shorthelp, 0, sizeof buf_shorthelp); if (options[i].short_help) - snprint_multilined_ljust(&spaces[sizeof spaces / 2], + snprint_multilined_ljust(spaces, options[i].short_help, buf_shorthelp, sizeof buf_shorthelp); @@ -219,7 +222,7 @@ static void usage(const char *arg0, int print_copyright) memset(buf_help, 0, sizeof buf_help); off = 0; if (options[i].help) - off = snprint_multilined_ljust(spaces, options[i].help, + off = snprint_multilined_ljust(spaces_long, options[i].help, buf_help, sizeof buf_help); has_default = 0; @@ -248,10 +251,10 @@ static void usage(const char *arg0, int print_copyright) break; } if (has_default) - snprint_multilined_ljust(spaces, value, - buf_help + off, sizeof buf_help - off); + snprint_multilined_ljust(&spaces_long[sizeof spaces_long / 2], + value, buf_help + off, sizeof buf_help - off); - fprintf(stderr, "%16s %s\n" + fprintf(stderr, "%16s %s" "%s\n", buf_arg, buf_shorthelp, buf_help); } |