Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Win32: Unicode arguments (outgoing)
author
Karsten Blees
<blees@dcon.de>
Sun, 16 Jan 2011 17:27:53 +0000
(18:27 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 16 Jun 2014 17:56:47 +0000
(10:56 -0700)
Convert command line arguments from UTF-8 to UTF-16 when creating other
processes.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5901dc6
)
diff --git
a/compat/mingw.c
b/compat/mingw.c
index 1140a131bfa4e1cc004cef162ad749df985ca0d9..8a7b0476c22aaeada292944b3206a00f6d64ee16 100644
(file)
--- a/
compat/mingw.c
+++ b/
compat/mingw.c
@@
-831,9
+831,10
@@
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
const char *dir,
int prepend_cmd, int fhin, int fhout, int fherr)
{
const char *dir,
int prepend_cmd, int fhin, int fhout, int fherr)
{
- STARTUPINFO si;
+ STARTUPINFO
W
si;
PROCESS_INFORMATION pi;
struct strbuf envblk, args;
PROCESS_INFORMATION pi;
struct strbuf envblk, args;
+ wchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs;
unsigned flags;
BOOL ret;
unsigned flags;
BOOL ret;
@@
-869,6
+870,11
@@
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
si.hStdOutput = winansi_get_osfhandle(fhout);
si.hStdError = winansi_get_osfhandle(fherr);
si.hStdOutput = winansi_get_osfhandle(fhout);
si.hStdError = winansi_get_osfhandle(fherr);
+ if (xutftowcs_path(wcmd, cmd) < 0)
+ return -1;
+ if (dir && xutftowcs_path(wdir, dir) < 0)
+ return -1;
+
/* concatenate argv, quoting args as we go */
strbuf_init(&args, 0);
if (prepend_cmd) {
/* concatenate argv, quoting args as we go */
strbuf_init(&args, 0);
if (prepend_cmd) {
@@
-886,6
+892,10
@@
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
free(quoted);
}
free(quoted);
}
+ wargs = xmalloc((2 * args.len + 1) * sizeof(wchar_t));
+ xutftowcs(wargs, args.buf, 2 * args.len + 1);
+ strbuf_release(&args);
+
if (env) {
int count = 0;
char **e, **sorted_env;
if (env) {
int count = 0;
char **e, **sorted_env;
@@
-907,12
+917,12
@@
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
}
memset(&pi, 0, sizeof(pi));
}
memset(&pi, 0, sizeof(pi));
- ret = CreateProcess
(cmd, args.buf
, NULL, NULL, TRUE, flags,
- env ? envblk.buf : NULL, dir, &si, &pi);
+ ret = CreateProcess
W(wcmd, wargs
, NULL, NULL, TRUE, flags,
+ env ? envblk.buf : NULL, dir
? wdir : NULL
, &si, &pi);
if (env)
strbuf_release(&envblk);
if (env)
strbuf_release(&envblk);
-
strbuf_release(&
args);
+
free(w
args);
if (!ret) {
errno = ENOENT;
if (!ret) {
errno = ENOENT;