aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-21 02:44:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-21 02:44:23 +0000
commit255e98f502ba56973a821a0c65c9877de3154cc7 (patch)
treec2d11cf5ed0f619fd3694ae7972fde04d8f7e023 /debug.c
parentb471e39bd1b68e6f820fcdff5512789e56b779b0 (diff)
downloadruby-255e98f502ba56973a821a0c65c9877de3154cc7.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/debug.c b/debug.c
index 11a1aaddd6..01ac05b61d 100644
--- a/debug.c
+++ b/debug.c
@@ -121,8 +121,8 @@ UINT ruby_w32_codepage[2];
#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 len, void *arg)
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 len, void *arg)
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 len, void *arg)
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