Skip to content

Commit 97aa4d6

Browse files
committed
Merge branch 'maint'
2 parents 872d4ef + c6d1533 commit 97aa4d6

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

erts/etc/common/erlexec.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,15 @@ read_args_file(char *filename)
19521952

19531953
do {
19541954
errno = 0;
1955+
#ifdef __WIN32__
1956+
{
1957+
WCHAR *wfilename = utf8_to_utf16((unsigned char *)filename);
1958+
file = _wfopen(wfilename, L"r");
1959+
efree(wfilename);
1960+
}
1961+
#else
19551962
file = fopen(filename, "r");
1963+
#endif
19561964
} while (!file && errno == EINTR);
19571965
if (!file) {
19581966
#ifdef __WIN32__

erts/test/erlexec_SUITE.erl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
init_per_testcase/2, end_per_testcase/2]).
3434

3535
-export([args_file/1, evil_args_file/1, missing_args_file/1, env/1, args_file_env/1,
36+
unicode_args_file/1,
3637
otp_7461/1, otp_7461_remote/1, argument_separation/1, argument_with_option/1,
3738
zdbbl_dist_buf_busy_limit/1, long_path_env/1, argument_too_large/1]).
3839

@@ -43,7 +44,7 @@ suite() ->
4344
{timetrap, {minutes, 1}}].
4445

4546
all() ->
46-
[args_file, evil_args_file, missing_args_file, env, args_file_env,
47+
[args_file, evil_args_file, missing_args_file, env, args_file_env, unicode_args_file,
4748
otp_7461, argument_separation, argument_with_option, zdbbl_dist_buf_busy_limit,
4849
long_path_env, argument_too_large].
4950

@@ -321,6 +322,22 @@ missing_args_file(Config) when is_list(Config) ->
321322
exit({unexpected_args_output, Output, Error})
322323
end.
323324

325+
unicode_args_file(Config) when is_list(Config) ->
326+
%% Test that -args_file works with Unicode paths (e.g. Cyrillic).
327+
%% This is a regression test for a bug where fopen() on Windows
328+
%% could not open files with non-ASCII paths.
329+
PrivDir = proplists:get_value(priv_dir, Config),
330+
UnicodeDir = filename:join(PrivDir, "Артем"),
331+
ok = file:make_dir(UnicodeDir),
332+
AFN = filename:join(UnicodeDir, "args.txt"),
333+
write_file(AFN, "-MiscArg1 +\\#100 -extra +XtraArg1"),
334+
CmdLine = "-args_file " ++ AFN,
335+
{Emu, Misc, Extra} = emu_args(CmdLine),
336+
verify_args(["-#100"], Emu),
337+
verify_args(["-MiscArg1"], Misc),
338+
verify_args(["+XtraArg1"], Extra),
339+
ok.
340+
324341
env(Config) when is_list(Config) ->
325342
os:putenv("ERL_AFLAGS", "-MiscArg1 +#100 -extra +XtraArg1 +XtraArg2"),
326343
CmdLine = "+#200 -MiscArg2 -extra +XtraArg3 +XtraArg4",

0 commit comments

Comments
 (0)