summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-29 07:53:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-29 07:53:17 +0000
commit33ea2646b98adb49ae2e1781753bf22d33729ac0 (patch)
tree5cdaf18f6980ec1fbe5f794bf01976395b07edb5 /win32/win32.c
parent544d28c300b5a8084693968cb88b75443def8ab2 (diff)
win32.c: use UTF-8 for argv
* ruby.c (ruby_set_argv): convert argv from UTF-8. * win32/win32.c (rb_w32_sysinit, cmdglob, w32_cmdvector): convert wide char command line to UTF-8 argv, and glob in UTF-8 so that metacharacters would match multibyte characters. [ruby-dev:48752] [Bug #10555] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 301c152..949e918 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -108,6 +108,7 @@ int rb_w32_wait_events(HANDLE *events, int num, DWORD timeout);
static int rb_w32_open_osfhandle(intptr_t osfhandle, int flags);
static int wstati64(const WCHAR *path, struct stati64 *st);
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
+int ruby_brace_glob_with_enc(const char *str, int flags, ruby_glob_func *func, VALUE arg, rb_encoding *enc);
#define RUBY_CRITICAL(expr) do { expr; } while (0)
@@ -743,7 +744,7 @@ socklist_delete(SOCKET *sockp, int *flagp)
return ret;
}
-static int w32_cmdvector(const WCHAR *, char ***, UINT);
+static int w32_cmdvector(const WCHAR *, char ***, UINT, rb_encoding *);
//
// Initialization stuff
//
@@ -767,7 +768,7 @@ rb_w32_sysinit(int *argc, char ***argv)
//
// subvert cmd.exe's feeble attempt at command line parsing
//
- *argc = w32_cmdvector(GetCommandLineW(), argv, CP_ACP);
+ *argc = w32_cmdvector(GetCommandLineW(), argv, CP_UTF8, rb_utf8_encoding());
//
// Now set up the correct time stuff
@@ -1486,7 +1487,7 @@ insert(const char *path, VALUE vinfo, void *enc)
/* License: Artistic or GPL */
static NtCmdLineElement **
-cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail, UINT cp)
+cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail, UINT cp, rb_encoding *enc)
{
char buffer[MAXPATHLEN], *buf = buffer;
NtCmdLineElement **last = tail;
@@ -1498,7 +1499,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail, UINT cp)
strlcpy(buf, patt->str, patt->len + 1);
buf[patt->len] = '\0';
translate_char(buf, '\\', '/', cp);
- status = ruby_brace_glob(buf, 0, insert, (VALUE)&tail);
+ status = ruby_brace_glob_with_enc(buf, 0, insert, (VALUE)&tail, enc);
if (buf != buffer)
free(buf);
@@ -1574,7 +1575,7 @@ skipspace(WCHAR *ptr)
/* License: Artistic or GPL */
static int
-w32_cmdvector(const WCHAR *cmd, char ***vec, UINT cp)
+w32_cmdvector(const WCHAR *cmd, char ***vec, UINT cp, rb_encoding *enc)
{
int globbing, len;
int elements, strsz, done;
@@ -1742,7 +1743,7 @@ w32_cmdvector(const WCHAR *cmd, char ***vec, UINT cp)
curr->str = rb_w32_wstr_to_mbstr(cp, base, len, &curr->len);
curr->flags |= NTMALLOC;
- if (globbing && (tail = cmdglob(curr, cmdtail, cp))) {
+ if (globbing && (tail = cmdglob(curr, cmdtail, cp, enc))) {
cmdtail = tail;
}
else {