diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-06 03:45:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-06 03:45:02 +0000 |
commit | 4529948edd67b88722ca39edbceb7da9042a0869 () | |
tree | bb0dd7035f385e633be1943f56097724083688b7 | |
parent | df05ad53fbc0ab1802367e5c410b39542ac57bc2 (diff) |
debug.c: parse locale and filesystem codepages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | debug.c | 25 | ||||
-rw-r--r-- | localeinit.c | 6 |
2 files changed, 21 insertions, 10 deletions
@@ -117,7 +117,7 @@ extern int ruby_w32_rtc_error; #endif #if defined _WIN32 || defined __CYGWIN__ #include <windows.h> -UINT ruby_w32_codepage; #endif static void @@ -131,7 +131,7 @@ set_debug_option(const char *str, int len, void *arg) } \ } 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)) @@ -144,14 +144,25 @@ set_debug_option(const char *str, int len, void *arg) # endif #endif #if defined _WIN32 || defined __CYGWIN__ - { int ov; size_t retlen; unsigned long n; - if (NAME_MATCH_VALUE("codepage") && - (n = ruby_scan_digits(str, len, 10, &retlen, &ov), - (size_t)len == retlen && !ov)) { - ruby_w32_codepage = (UINT)n; } return; } @@ -22,7 +22,7 @@ #define SIZEOF_CP_NAME ((sizeof(UINT) * 8 / 3) + 4) #define CP_FORMAT(buf, codepage) snprintf(buf, sizeof(buf), "CP%u", (codepage)) -extern UINT ruby_w32_codepage; #endif #ifndef NO_LOCALE_CHARMAP @@ -45,7 +45,7 @@ locale_charmap(VALUE (*conv)(const char *)) codeset = nl_langinfo_codeset(); # endif if (!codeset) { - UINT codepage = ruby_w32_codepage; if (!codepage) codepage = GetConsoleCP(); if (!codepage) codepage = GetACP(); CP_FORMAT(cp, codepage); @@ -122,7 +122,7 @@ Init_enc_set_filesystem_encoding(void) idx = ENCINDEX_US_ASCII; #elif defined _WIN32 char cp[SIZEOF_CP_NAME]; - const UINT codepage = ruby_w32_codepage ? ruby_w32_codepage : AreFileApisANSI() ? GetACP() : GetOEMCP(); CP_FORMAT(cp, codepage); idx = rb_enc_find_index(cp); |