From 67d10189823b4f28412dcb99c49d4f2e22046518 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 9 Feb 2016 08:32:20 +0000 Subject: [PATCH] ruby.c: available list from enum * ruby.c (feature_option, debug_option, dump_option): build available list in warning messages from enum lists. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ruby.c b/ruby.c index 26c204cd16..af785ec3cf 100644 --- a/ruby.c +++ b/ruby.c @@ -762,9 +762,12 @@ name_match_p(const char *name, const char *str, size_t len) return; \ } +#define LITERAL_NAME_ELEMENT(name) #name", " + static void feature_option(const char *str, int len, void *arg, const unsigned int enable) { + static const char list[] = EACH_FEATURES(LITERAL_NAME_ELEMENT); unsigned int *argp = arg; unsigned int mask = ~0U; #if AMBIGUOUS_FEATURE_NAMES @@ -799,7 +802,7 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable) #endif rb_warn("unknown argument for --%s: `%.*s'", enable ? "enable" : "disable", len, str); - rb_warn("features are [gems, did-you-mean, rubyopt, frozen-string-literal]."); + rb_warn("features are [%.*s].", (int)strlen(list) - 2, list); } static void @@ -817,18 +820,21 @@ disable_option(const char *str, int len, void *arg) static void debug_option(const char *str, int len, void *arg) { + static const char list[] = EACH_DEBUG_FEATURES(LITERAL_NAME_ELEMENT); #define SET_WHEN_DEBUG(bit) SET_WHEN(#bit, DEBUG_BIT(bit), str, len) EACH_DEBUG_FEATURES(SET_WHEN_DEBUG); rb_warn("unknown argument for --debug: `%.*s'", len, str); + rb_warn("debug features are [%.*s].", (int)strlen(list) - 2, list); } static void dump_option(const char *str, int len, void *arg) { + static const char list[] = EACH_DEBUG_FEATURES(LITERAL_NAME_ELEMENT); #define SET_WHEN_DUMP(bit) SET_WHEN(#bit, DUMP_BIT(bit), str, len) EACH_DUMPS(SET_WHEN_DUMP); 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].", (int)strlen(list) - 2, list); } static void