From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 28180@debbugs.gnu.org
Subject: bug#28180: [w32] Unicode characters in subprocess (git) arguments changed to space
Date: Mon, 28 Aug 2017 10:42:14 -0400 [thread overview]
Message-ID: <CAM-tV--3p_JKL5d+65BvMR2pMS97wfH9-ZVNW3DR2tPf4AObJQ@mail.gmail.com> (raw)
In-Reply-To: <83y3qbabzw.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
On Tue, Aug 22, 2017 at 10:54 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> As to the "other places", the only problem I'm aware of is that the
> encoding of the command-line arguments, when they arrive at w32proc.c,
> is not known in advance, so this must be somehow fixed/changed,
> otherwise we will be unable to re-encode them in UTF-16. I believe
> the comment in w32.c does mention that.
Just to understand the issue better, I applied the attached diff to
use CreateProcessW. It seemed to work, but only when I start emacs
from mingw's msys shell. When running from cmd.exe it still translates
to space.
Furthermore, when I run an unpatched Emacs from the msys shell, the
output of the test I posted above is different:
(call-process "git" nil '(t t) nil
"-c" "alias.x=!x() { printf '%s' \"$1\" | od -tx1; }; x"
"x" "(好)")
0000000 28 c3 a5 c2 a5 c2 bd 29
0000010
Do you have any idea what setting could cause this?
[-- Attachment #2: CreateProcessW.diff --]
[-- Type: text/plain, Size: 2433 bytes --]
diff --git c/src/process.c i/src/process.c
index e7ee99a..2c17b5a 100644
--- c/src/process.c
+++ i/src/process.c
@@ -1881,8 +1881,7 @@ usage: (make-process &rest ARGS) */)
if (STRING_MULTIBYTE (arg))
{
if (NILP (arg_encoding))
- arg_encoding = (complement_process_encoding_system
- (XPROCESS (proc)->encode_coding_system));
+ arg_encoding = Qutf_8;
arg = code_convert_string_norecord (arg, arg_encoding, 1);
}
tem = Fcons (arg, tem);
diff --git c/src/w32proc.c i/src/w32proc.c
index 76af55f..86aaee2 100644
--- c/src/w32proc.c
+++ i/src/w32proc.c
@@ -1204,14 +1204,13 @@ static BOOL
create_child (char *exe, char *cmdline, char *env, int is_gui_app,
pid_t * pPid, child_process *cp)
{
- STARTUPINFO start;
+ STARTUPINFOW start;
SECURITY_ATTRIBUTES sec_attrs;
#if 0
SECURITY_DESCRIPTOR sec_desc;
#endif
DWORD flags;
char dir[ MAX_PATH ];
- char *p;
const char *ext;
if (cp == NULL) emacs_abort ();
@@ -1242,14 +1241,8 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */;
sec_attrs.bInheritHandle = FALSE;
- filename_to_ansi (process_dir, dir);
- /* Can't use unixtodos_filename here, since that needs its file name
- argument encoded in UTF-8. OTOH, process_dir, which _is_ in
- UTF-8, points, to the directory computed by our caller, and we
- don't want to modify that, either. */
- for (p = dir; *p; p = CharNextA (p))
- if (*p == '/')
- *p = '\\';
+ strcpy (dir, process_dir);
+ unixtodos_filename (dir);
/* CreateProcess handles batch files as exe specially. This special
handling fails when both the batch file and arguments are quoted.
@@ -1265,8 +1258,13 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
: CREATE_NEW_CONSOLE);
if (NILP (Vw32_start_process_inherit_error_mode))
flags |= CREATE_DEFAULT_ERROR_MODE;
- if (!CreateProcessA (exe, cmdline, &sec_attrs, NULL, TRUE,
- flags, env, dir, &start, &cp->procinfo))
+
+ wchar_t exeW[MAX_PATH], cmdlineW[MAX_PATH], dirW[MAX_PATH];
+ filename_to_utf16 (exe, exeW);
+ filename_to_utf16 (cmdline, cmdlineW);
+ filename_to_utf16 (dir, dirW);
+ if (!CreateProcessW (exeW, cmdlineW, &sec_attrs, NULL, TRUE,
+ flags, env, dirW, &start, &cp->procinfo))
goto EH_Fail;
cp->pid = (int) cp->procinfo.dwProcessId;
next prev parent reply other threads:[~2017-08-28 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 2:35 bug#28180: [w32] Unicode characters in subprocess (git) arguments changed to space npostavs
2017-08-22 14:54 ` Eli Zaretskii
2017-08-28 14:42 ` Noam Postavsky [this message]
2017-08-28 17:15 ` Eli Zaretskii
2017-08-29 22:06 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM-tV--3p_JKL5d+65BvMR2pMS97wfH9-ZVNW3DR2tPf4AObJQ@mail.gmail.com \
--to=npostavs@users.sourceforge.net \
--cc=28180@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).