Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Add -h/--help options and end marker to demangler_options #1940

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions misc/demangler.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ enum options {
};

static struct option demangler_options[] = {
{ "simple", no_argument, 0, OPT_simple },
{ "full", no_argument, 0, OPT_full },
{ "no", no_argument, 0, OPT_no },
{ "verbose", no_argument, 0, 'v' },
{ "simple", no_argument, 0, OPT_simple }, { "full", no_argument, 0, OPT_full },
{ "no", no_argument, 0, OPT_no }, { "verbose", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' }, { 0 }
};

static const char demangler_usage[] =
Expand All @@ -32,6 +31,7 @@ static const char demangler_usage[] =
" --full Use libstdc++ demangler\n"
" --no Do not use demangler\n"
" -v, --verbose Be verbose\n"
" -h, --help Display this help and exit\n"
"\n";

struct demangler_opts {
Expand All @@ -46,7 +46,7 @@ static void parse_option(int argc, char **argv, struct demangler_opts *opts)
while (!done) {
int key, tmp;

key = getopt_long(argc, argv, "v", demangler_options, &tmp);
key = getopt_long(argc, argv, "vh", demangler_options, &tmp);
switch (key) {
case OPT_simple:
opts->mode = DEMANGLE_SIMPLE;
Expand All @@ -65,6 +65,10 @@ static void parse_option(int argc, char **argv, struct demangler_opts *opts)
dbg_domain[DBG_DEMANGLE]++;
break;

case 'h':
printf("%s", demangler_usage);
exit(0);

case -1:
done = true;
break;
Expand Down