From 966c0c1dfa422ebe44ff73f650ffb87a1e0761da Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 18 Jul 2015 19:36:10 +0530 Subject: [PATCH] Add command line option to query valid values for --dump --- man/ruby.1 | 5 ++++- ruby.c | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/man/ruby.1 b/man/ruby.1 index 5f13a0f..6a369a1 100644 --- a/man/ruby.1 +++ b/man/ruby.1 @@ -413,8 +413,11 @@ DO NOT USE. .Pp Prints the specified target. .Ar target -can be one of; +can be one of: .Bl -hang -offset indent +.It Sy targets +valid target values +.Pp .It Sy insns disassembled instructions .Pp diff --git a/ruby.c b/ruby.c index 9167b68..b53640e 100644 --- a/ruby.c +++ b/ruby.c @@ -78,9 +78,12 @@ enum dump_flag_bits { dump_parsetree, dump_parsetree_with_comment, dump_insns, + dump_targets, dump_flag_count }; +static const char *valid_dump_targets = "version, copyright, usage, yydebug, syntax, parsetree, parsetree_with_comment, insns, targets"; + struct cmdline_options { int sflag, xflag; int do_loop, do_print; @@ -745,8 +748,9 @@ dump_option(const char *str, int len, void *arg) SET_WHEN_DUMP(parsetree); SET_WHEN_DUMP(parsetree_with_comment); SET_WHEN_DUMP(insns); + SET_WHEN_DUMP(targets); rb_warn("don't know how to dump `%.*s',", len, str); - rb_warn("but only [version, copyright, usage, yydebug, syntax, parsetree, parsetree_with_comment, insns]."); + rb_warn("but only [%s].\n", valid_dump_targets); } static void @@ -1347,6 +1351,10 @@ process_options(int argc, char **argv, struct cmdline_options *opt) if (opt->dump & DUMP_BIT(copyright)) { ruby_show_copyright(); } + if (opt->dump & DUMP_BIT(targets)) { + printf("%s\n", valid_dump_targets); + return Qtrue; + } if (!opt->e_script) { if (argc == 0) { /* no more args */ -- 2.4.6