ruby-changes:47014
From: nobu <ko1@a...>
Date: Wed, 21 Jun 2017 11:44:28 +0900 (JST)
Subject: [ruby-changes:47014] nobu:r59129 (trunk): ruby.c: debug options in command line
nobu 2017-06-21 11:44:23 +0900 (Wed, 21 Jun 2017) New Revision: 59129 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59129 Log: ruby.c: debug options in command line * ruby.c (debug_option): parse options in --debug command line option same as RUBY_DEBUG env. available only in the trunk. Modified files: trunk/debug.c trunk/ruby.c Index: ruby.c =================================================================== --- ruby.c (revision 59128) +++ ruby.c (revision 59129) @@ -856,12 +856,16 @@ disable_option(const char *str, int len, https://github.com/ruby/ruby/blob/trunk/ruby.c#L856 feature_option(str, len, arg, 0U); } +RUBY_EXTERN const int ruby_patchlevel; +int ruby_env_debug_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, ;); + if (ruby_patchlevel < 0 && ruby_env_debug_option(str, len, 0)) return; rb_warn("unknown argument for --debug: `%.*s'", len, str); rb_warn("debug features are [%.*s].", (int)strlen(list), list); } Index: debug.c =================================================================== --- debug.c (revision 59128) +++ debug.c (revision 59129) @@ -121,8 +121,8 @@ UINT ruby_w32_codepage[2]; https://github.com/ruby/ruby/blob/trunk/debug.c#L121 #endif extern int ruby_rgengc_debug; -static void -set_debug_option(const char *str, int len, void *arg) +int +ruby_env_debug_option(const char *str, int len, void *arg) { int ov; size_t retlen; @@ -131,7 +131,7 @@ set_debug_option(const char *str, int le https://github.com/ruby/ruby/blob/trunk/debug.c#L131 if (len == sizeof(name) - 1 && \ strncmp(str, (name), len) == 0) { \ (var) = (val); \ - return; \ + return 1; \ } \ } while (0) #define NAME_MATCH_VALUE(name) \ @@ -168,7 +168,7 @@ set_debug_option(const char *str, int le https://github.com/ruby/ruby/blob/trunk/debug.c#L168 if (NAME_MATCH_VALUE("rgengc")) { if (!len) ruby_rgengc_debug = 1; else SET_UINT_LIST("rgengc", &ruby_rgengc_debug, 1); - return; + return 1; } #if defined _WIN32 # if RUBY_MSVCRT_VERSION >= 80 @@ -179,10 +179,18 @@ set_debug_option(const char *str, int le https://github.com/ruby/ruby/blob/trunk/debug.c#L179 if (NAME_MATCH_VALUE("codepage")) { if (!len) fprintf(stderr, "missing codepage argument"); else SET_UINT_LIST("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage)); - return; + return 1; } #endif - fprintf(stderr, "unexpected debug option: %.*s\n", len, str); + return 0; +} + +static void +set_debug_option(const char *str, int len, void *arg) +{ + if (!ruby_env_debug_option(str, len, arg)) { + fprintf(stderr, "unexpected debug option: %.*s\n", len, str); + } } void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/