aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-31 00:35:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-31 00:35:02 +0000
commit2009b8cabf04e0ea02fb49071f79218ecd47bfd6 (patch)
tree2c37a87d21e7022de7a4d5bb99417400b5b1f5a6 /debug.c
parent713700c41c0ac61b55ab4795b3c6407e66a30d5d (diff)
downloadruby-2009b8cabf04e0ea02fb49071f79218ecd47bfd6.tar.gz
RUBY_DEBUG codepage option [ci skip]
* debug.c (set_debug_option): add "codepage" option to force locale charmap on Windows. * localeinit.c (locale_charmap): use the codepage by debug env if given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/debug.c b/debug.c
index 8a5e69bbf5..e785af98f4 100644
--- a/debug.c
+++ b/debug.c
@@ -106,12 +106,16 @@ ruby_debug_breakpoint(void)
/* */
}
+#if defined _WIN32
+# if RUBY_MSVCRT_VERSION >= 80
+extern int ruby_w32_rtc_error;
+# endif
+UINT ruby_w32_codepage;
+#endif
+
static void
set_debug_option(const char *str, int len, void *arg)
{
-#if defined _WIN32 && RUBY_MSVCRT_VERSION >= 80
- extern int ruby_w32_rtc_error;
-#endif
#define SET_WHEN(name, var, val) do { \
if (len == sizeof(name) - 1 && \
strncmp(str, (name), len) == 0) { \
@@ -119,10 +123,25 @@ set_debug_option(const char *str, int len, void *arg)
return; \
} \
} while (0)
+#define NAME_MATCH_VALUE(name) \
+ ((size_t)len > sizeof(name) && \
+ strncmp(str, (name), sizeof(name)-1) == 0 && \
+ str[sizeof(name)-1] == '=' && \
+ (str += sizeof(name), len -= sizeof(name), 1))
+
SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr, Qtrue);
SET_WHEN("core", ruby_enable_coredump, 1);
-#if defined _WIN32 && RUBY_MSVCRT_VERSION >= 80
+#if defined _WIN32
+# if RUBY_MSVCRT_VERSION >= 80
SET_WHEN("rtc_error", ruby_w32_rtc_error, 1);
+# endif
+ if (NAME_MATCH_VALUE("codepage")) {
+ int ov;
+ size_t retlen;
+ ruby_w32_codepage =
+ ruby_scan_digits(str, len, 10, &retlen, &ov);
+ return;
+ }
#endif
fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
}