aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2018-01-16 09:57:54 +0100
committerHans Bolinder <[email protected]>2018-01-16 09:57:54 +0100
commitd0b12578d697e627a61b758c9ba2c2d183ae4631 (patch)
treefbeadcf128fc5a86c76283a79372380dc7536b45
parentf359cffc2590848c9ea4ff366d550c1351569479 (diff)
parenta5a0d49a3e9e76ed893920698f7ddbd97601d671 (diff)
downloadotp-d0b12578d697e627a61b758c9ba2c2d183ae4631.tar.gz
otp-d0b12578d697e627a61b758c9ba2c2d183ae4631.tar.bz2
otp-d0b12578d697e627a61b758c9ba2c2d183ae4631.zip
Merge branch 'maint'
* maint: stdlib: Handle Unicode when formatting stacktraces
-rw-r--r--erts/emulator/test/code_SUITE.erl9
-rw-r--r--lib/stdlib/src/lib.erl6
2 files changed, 10 insertions, 5 deletions
diff --git a/erts/emulator/test/code_SUITE.erl b/erts/emulator/test/code_SUITE.erl
index fcef070f08..661a2ee6c9 100644
--- a/erts/emulator/test/code_SUITE.erl
+++ b/erts/emulator/test/code_SUITE.erl
@@ -951,9 +951,14 @@ erl_544(Config) when is_list(Config) ->
receive Go -> ok end,
Res2 = process_info(Tester, current_stacktrace),
io:format("~p~n", [Res2]),
- {current_stacktrace,
- [{Mod, wait, 2, Info2}|_]} = Res2,
+ {current_stacktrace, Stack} = Res2,
+ [{Mod, wait, 2, Info2}|_] = Stack,
File = proplists:get_value(file, Info2),
+ StackFun = fun(_, _, _) -> false end,
+ FormatFun = fun (Term, _) -> io_lib:format("~tp", [Term]) end,
+ Formated =
+ lib:format_stacktrace(1, Stack, StackFun, FormatFun),
+ true = is_list(Formated),
ok
after
ok = file:set_cwd(CWD)
diff --git a/lib/stdlib/src/lib.erl b/lib/stdlib/src/lib.erl
index a7980cc294..51e0c3f77e 100644
--- a/lib/stdlib/src/lib.erl
+++ b/lib/stdlib/src/lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2017. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2018. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -551,7 +551,7 @@ format_stacktrace1(S0, Stack0, PF, SF, Enc) ->
format_stacktrace2(S, Stack, 1, PF, Enc).
format_stacktrace2(S, [{M,F,A,L}|Fs], N, PF, Enc) when is_integer(A) ->
- [io_lib:fwrite(<<"~s~s ~ts ~s">>,
+ [io_lib:fwrite(<<"~s~s ~ts ~ts">>,
[sep(N, S), origin(N, M, F, A),
mfa_to_string(M, F, A, Enc),
location(L)])
@@ -573,7 +573,7 @@ location(L) ->
Line = proplists:get_value(line, L),
if
File =/= undefined, Line =/= undefined ->
- io_lib:format("(~s, line ~w)", [File, Line]);
+ io_lib:format("(~ts, line ~w)", [File, Line]);
true ->
""
end.