From 552badf29f3aa5e9b76d02716f93f37b94ba8353 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Feb 2008 21:13:05 +0000 Subject: * debug.c (ruby_set_debug_option): separated ruby_each_words(). * util.c (ruby_each_words): extracted from ruby_set_debug_option(). * ruby.c (proc_options): generalized enable/disable options. * ruby.c (ruby_init_gems): take enabled flag. [ruby-core:14840] * ruby.c (process_options): added --disable-rubyopt flag. * include/ruby/util.h (ruby_each_words): prototype. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- debug.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 7ca9e3aae5..be90698b82 100644 --- a/debug.c +++ b/debug.c @@ -11,6 +11,7 @@ #include "ruby/ruby.h" #include "ruby/encoding.h" +#include "ruby/util.h" #include "debug.h" #include "vm_core.h" @@ -121,31 +122,25 @@ ruby_debug_breakpoint(void) } #ifdef RUBY_DEBUG_ENV -#include - -void -ruby_set_debug_option(const char *str) +static void +set_debug_option(const char *str, int len, void *arg) { - const char *end; - int len; - - if (!str) return; - for (; *str; str = end) { - while (ISSPACE(*str) || *str == ',') str++; - if (!*str) break; - end = str; - while (*end && !ISSPACE(*end) && *end != ',') end++; - len = end - str; -#define SET_WHEN(name, var) \ +#define SET_WHEN(name, var) do { \ if (len == sizeof(name) - 1 && \ strncmp(str, name, len) == 0) { \ extern int ruby_##var; \ ruby_##var = 1; \ - continue; \ - } - SET_WHEN("gc_stress", gc_stress); - SET_WHEN("core", enable_coredump); - fprintf(stderr, "unexpected debug option: %.*s\n", len, str); - } + return; \ + } \ + } while (0) + SET_WHEN("gc_stress", gc_stress); + SET_WHEN("core", enable_coredump); + fprintf(stderr, "unexpected debug option: %.*s\n", len, str); +} + +void +ruby_set_debug_option(const char *str) +{ + ruby_each_words(str, set_debug_option, 0); } #endif -- cgit v1.2.3