aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/test/ct_verbosity_SUITE.erl2
-rw-r--r--lib/debugger/src/dbg_wx_trace.erl2
-rw-r--r--lib/debugger/src/dbg_wx_trace_win.erl2
-rw-r--r--lib/debugger/src/dbg_wx_win.erl2
-rw-r--r--lib/dialyzer/test/race_SUITE_data/results/extract_translations4
-rw-r--r--lib/kernel/doc/src/file.xml67
-rw-r--r--lib/kernel/test/file_SUITE.erl40
-rw-r--r--lib/reltool/examples/display_args5
-rw-r--r--lib/reltool/src/reltool.erl4
-rw-r--r--lib/reltool/src/reltool_app_win.erl12
-rw-r--r--lib/reltool/src/reltool_fgraph_win.erl4
-rw-r--r--lib/reltool/src/reltool_mod_win.erl75
-rw-r--r--lib/reltool/src/reltool_server.erl94
-rw-r--r--lib/reltool/src/reltool_sys_win.erl28
-rw-r--r--lib/reltool/src/reltool_target.erl24
-rw-r--r--lib/reltool/src/reltool_utils.erl41
-rw-r--r--lib/reltool/test/reltool_server_SUITE.erl165
-rw-r--r--lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl1
-rw-r--r--lib/reltool/test/reltool_server_SUITE_data/unicode/ua-1.0/ebin/ua.app7
-rw-r--r--lib/sasl/src/release_handler.erl15
-rw-r--r--lib/sasl/src/release_handler_1.erl8
-rw-r--r--lib/sasl/src/systools_lib.erl15
-rw-r--r--lib/sasl/src/systools_make.erl75
-rw-r--r--lib/sasl/src/systools_rc.erl14
-rw-r--r--lib/sasl/src/systools_relup.erl36
-rw-r--r--lib/sasl/test/systools_SUITE.erl72
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/ebin/ua.app9
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/src/ua1.erl2
-rw-r--r--lib/ssl/doc/src/ssl.xml11
-rw-r--r--lib/ssl/doc/src/ssl_app.xml7
-rw-r--r--lib/ssl/src/ssl_connection.erl2
-rw-r--r--lib/ssl/test/ssl_packet_SUITE.erl50
-rw-r--r--lib/ssl/test/ssl_test_lib.erl77
-rw-r--r--lib/stdlib/doc/src/filelib.xml5
-rw-r--r--lib/stdlib/doc/src/io.xml12
-rw-r--r--lib/stdlib/doc/src/io_lib.xml14
-rw-r--r--lib/stdlib/src/binary.erl2
-rw-r--r--lib/stdlib/src/erl_pp.erl18
-rw-r--r--lib/stdlib/src/io.erl7
-rw-r--r--lib/stdlib/src/io_lib.erl48
-rw-r--r--lib/stdlib/src/io_lib_pretty.erl55
-rw-r--r--lib/stdlib/src/shell.erl27
-rw-r--r--lib/stdlib/test/epp_SUITE.erl33
-rw-r--r--lib/stdlib/test/erl_pp_SUITE.erl40
-rw-r--r--lib/stdlib/test/escript_SUITE.erl2
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode12
-rw-r--r--lib/stdlib/test/io_SUITE.erl101
-rw-r--r--lib/stdlib/test/io_proto_SUITE.erl6
-rw-r--r--lib/stdlib/test/shell_SUITE.erl32
49 files changed, 907 insertions, 469 deletions
diff --git a/lib/common_test/test/ct_verbosity_SUITE.erl b/lib/common_test/test/ct_verbosity_SUITE.erl
index 198d4c44b5..ff4c05ce3a 100644
--- a/lib/common_test/test/ct_verbosity_SUITE.erl
+++ b/lib/common_test/test/ct_verbosity_SUITE.erl
@@ -59,7 +59,7 @@ init_per_testcase(TestCase, Config) ->
end_per_testcase(TestCase, Config) ->
ct_test_support:end_per_testcase(TestCase, Config).
-suite() -> [{timetrap,{seconds,30}},
+suite() -> [{timetrap,{minutes,2}},
{ct_hooks,[ts_install_cth]}].
all() ->
diff --git a/lib/debugger/src/dbg_wx_trace.erl b/lib/debugger/src/dbg_wx_trace.erl
index bd92cb4b42..eaea01822c 100644
--- a/lib/debugger/src/dbg_wx_trace.erl
+++ b/lib/debugger/src/dbg_wx_trace.erl
@@ -687,7 +687,7 @@ meta_cmd({trace_output, Str}, State) ->
%% Reply on a user command
meta_cmd({eval_rsp, Res}, State) ->
- Str = io_lib:print(Res),
+ Str = io_lib_pretty:print(Res,[{encoding,unicode}]),
dbg_wx_trace_win:eval_output(State#state.win, [$<,Str,10], normal),
State.
diff --git a/lib/debugger/src/dbg_wx_trace_win.erl b/lib/debugger/src/dbg_wx_trace_win.erl
index 8b206ccd78..e54ce3913f 100644
--- a/lib/debugger/src/dbg_wx_trace_win.erl
+++ b/lib/debugger/src/dbg_wx_trace_win.erl
@@ -853,7 +853,7 @@ handle_event(#wx{id=?EVAL_ENTRY, event=#wxCommand{type=command_text_enter}},
handle_event(#wx{event=#wxList{type=command_list_item_selected, itemIndex=Row}},Wi) ->
Bs = get(bindings),
{Var,Val} = lists:nth(Row+1, Bs),
- Str = io_lib:format("< ~s = ~p~n", [Var, Val]),
+ Str = io_lib:format("< ~s = ~lp~n", [Var, Val]),
eval_output(Wi, Str, bold),
ignore;
handle_event(#wx{event=#wxList{type=command_list_item_activated, itemIndex=Row}},_Wi) ->
diff --git a/lib/debugger/src/dbg_wx_win.erl b/lib/debugger/src/dbg_wx_win.erl
index 3cb6edd953..eceacd7c88 100644
--- a/lib/debugger/src/dbg_wx_win.erl
+++ b/lib/debugger/src/dbg_wx_win.erl
@@ -254,7 +254,7 @@ notify(Win,Message) ->
entry(Parent, Title, Prompt, {Type, Value}) ->
Ted = wxTextEntryDialog:new(Parent, to_string(Prompt),
[{caption, to_string(Title)},
- {value, to_string("~999999tp",Value)}]),
+ {value, to_string("~999999tp",[Value])}]),
case wxDialog:showModal(Ted) of
?wxID_OK ->
diff --git a/lib/dialyzer/test/race_SUITE_data/results/extract_translations b/lib/dialyzer/test/race_SUITE_data/results/extract_translations
index 62aa1aa511..295404bfed 100644
--- a/lib/dialyzer/test/race_SUITE_data/results/extract_translations
+++ b/lib/dialyzer/test/race_SUITE_data/results/extract_translations
@@ -1,5 +1,5 @@
-extract_translations.erl:140: The call ets:insert('files',{atom() | binary() | [atom() | [any()] | char()]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('files',File::atom() | binary() | [atom() | [any()] | char()]) call in extract_translations.erl on line 135
+extract_translations.erl:140: The call ets:insert('files',{atom() | [atom() | [any()] | char()]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('files',File::atom() | [atom() | [any()] | char()]) call in extract_translations.erl on line 135
extract_translations.erl:146: The call ets:insert('translations',{_,[]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('translations',Str::any()) call in extract_translations.erl on line 126
-extract_translations.erl:152: The call ets:insert('files',{atom() | binary() | [atom() | [any()] | char()]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('files',File::atom() | binary() | [atom() | [any()] | char()]) call in extract_translations.erl on line 148
+extract_translations.erl:152: The call ets:insert('files',{atom() | [atom() | [any()] | char()]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('files',File::atom() | [atom() | [any()] | char()]) call in extract_translations.erl on line 148
extract_translations.erl:154: The call ets:insert('translations',{_,[]}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup('translations',Str::any()) call in extract_translations.erl on line 126
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 75fa32f702..66ecba1bf2 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -60,14 +60,6 @@
converted, why the Unicode mode for file names is not default on
systems having completely transparent file naming.</p>
- <note>
- <p>As of R14B01, the most basic file handling modules
- (<c>file</c>, <c>prim_file</c>, <c>filelib</c> and
- <c>filename</c>) accept raw file names, but the rest of OTP is not
- guaranteed to handle them, why Unicode file naming on systems
- where it is not default is still considered experimental.</p>
- </note>
-
<p>Raw file names is a new feature in OTP R14B01, which allows the
user to supply completely uninterpreted file names to the
underlying OS/filesystem. They are supplied as binaries, where it
@@ -512,7 +504,8 @@
<name name="list_dir" arity="1"/>
<fsummary>List files in a directory</fsummary>
<desc>
- <p>Lists all the files in a directory. Returns
+ <p>Lists all files in a directory, <b>except</b> files
+ with "raw" names. Returns
<c>{ok, <anno>Filenames</anno>}</c> if successful.
Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>.
<c><anno>Filenames</anno></c> is a list of
@@ -539,6 +532,31 @@
</desc>
</func>
<func>
+ <name name="list_dir_all" arity="1"/>
+ <fsummary>List all files in a directory</fsummary>
+ <desc>
+ <p>Lists all the files in a directory, including files with
+ "raw" names.
+ Returns <c>{ok, <anno>Filenames</anno>}</c> if successful.
+ Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>.
+ <c><anno>Filenames</anno></c> is a list of
+ the names of all the files in the directory. The names are
+ not sorted.</p>
+ <p>Typical error reasons are:</p>
+ <taglist>
+ <tag><c>eacces</c></tag>
+ <item>
+ <p>Missing search or write permissions for <c><anno>Dir</anno></c>
+ or one of its parent directories.</p>
+ </item>
+ <tag><c>enoent</c></tag>
+ <item>
+ <p>The directory does not exist.</p>
+ </item>
+ </taglist>
+ </desc>
+ </func>
+ <func>
<name name="make_dir" arity="1"/>
<fsummary>Make a directory</fsummary>
<desc>
@@ -1423,10 +1441,41 @@
<fsummary>See what a link is pointing to</fsummary>
<desc>
<p>This function returns <c>{ok, <anno>Filename</anno>}</c> if
+ <c><anno>Name</anno></c> refers to a symbolic link that is
+ not a "raw" file name, or <c>{error, <anno>Reason</anno>}</c>
+ otherwise.
+ On platforms that do not support symbolic links, the return
+ value will be <c>{error,enotsup}</c>.</p>
+ <p>Typical error reasons:</p>
+ <taglist>
+ <tag><c>einval</c></tag>
+ <item>
+ <p><c><anno>Name</anno></c> does not refer to a symbolic link
+ or the name of the file that it refers to does not conform
+ to the expected encoding.</p>
+ </item>
+ <tag><c>enoent</c></tag>
+ <item>
+ <p>The file does not exist.</p>
+ </item>
+ <tag><c>enotsup</c></tag>
+ <item>
+ <p>Symbolic links are not supported on this platform.</p>
+ </item>
+ </taglist>
+ </desc>
+ </func>
+ <func>
+ <name name="read_link_all" arity="1"/>
+ <fsummary>See what a link is pointing to</fsummary>
+ <desc>
+ <p>This function returns <c>{ok, <anno>Filename</anno>}</c> if
<c><anno>Name</anno></c> refers to a symbolic link or
<c>{error, <anno>Reason</anno>}</c> otherwise.
On platforms that do not support symbolic links, the return
value will be <c>{error,enotsup}</c>.</p>
+ <p>Note that <c><anno>Filename</anno></c> can be either a list
+ or a binary.</p>
<p>Typical error reasons:</p>
<taglist>
<tag><c>einval</c></tag>
diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl
index f8887db34e..c604e7073f 100644
--- a/lib/kernel/test/file_SUITE.erl
+++ b/lib/kernel/test/file_SUITE.erl
@@ -45,7 +45,8 @@
init_per_testcase/2, end_per_testcase/2,
read_write_file/1, names/1]).
-export([cur_dir_0/1, cur_dir_1/1, make_del_dir/1,
- list_dir/1,list_dir_error/1, untranslatable_names/1,
+ list_dir/1,list_dir_error/1,
+ untranslatable_names/1, untranslatable_names_error/1,
pos1/1, pos2/1]).
-export([close/1, consult1/1, path_consult/1, delete/1]).
-export([ eval1/1, path_eval/1, script1/1, path_script/1,
@@ -117,7 +118,8 @@ all() ->
groups() ->
[{dirs, [], [make_del_dir, cur_dir_0, cur_dir_1,
- list_dir, list_dir_error, untranslatable_names]},
+ list_dir, list_dir_error, untranslatable_names,
+ untranslatable_names_error]},
{files, [],
[{group, open}, {group, pos}, {group, file_info},
{group, consult}, {group, eval}, {group, script},
@@ -598,6 +600,40 @@ untranslatable_names_1(Config) ->
end,
ok.
+untranslatable_names_error(Config) ->
+ case no_untranslatable_names() of
+ true ->
+ {skip,"Not a problem on this OS"};
+ false ->
+ untranslatable_names_error_1(Config)
+ end.
+
+untranslatable_names_error_1(Config) ->
+ {ok,OldCwd} = file:get_cwd(),
+ PrivDir = ?config(priv_dir, Config),
+ Dir = filename:join(PrivDir, "untranslatable_names_error"),
+ ok = file:make_dir(Dir),
+ Node = start_node(untranslatable_names, "+fnue"),
+ try
+ ok = file:set_cwd(Dir),
+ [ok = file:write_file(F, F) || {_,F} <- untranslatable_names()],
+
+ ExpectedListDir0 = [unicode:characters_to_list(N, utf8) ||
+ {utf8,N} <- untranslatable_names()],
+ ExpectedListDir = lists:sort(ExpectedListDir0),
+ io:format("ExpectedListDir: ~p\n", [ExpectedListDir]),
+ {error,{no_translation,BadFile}} =
+ rpc:call(Node, file, list_dir, [Dir]),
+ true = lists:keymember(BadFile, 2, untranslatable_names())
+
+ after
+ catch test_server:stop_node(Node),
+ file:set_cwd(OldCwd),
+ [file:delete(F) || {_,F} <- untranslatable_names()],
+ file:del_dir(Dir)
+ end,
+ ok.
+
untranslatable_names() ->
[{utf8,<<"abc">>},
{utf8,<<"def">>},
diff --git a/lib/reltool/examples/display_args b/lib/reltool/examples/display_args
index bf0994ab7c..a8882f7bda 100644
--- a/lib/reltool/examples/display_args
+++ b/lib/reltool/examples/display_args
@@ -1,8 +1,9 @@
#!/usr/bin/env escript
%% -*- erlang -*-
-%%! -smp disable
+%%! -emuarg emuvalue
main(Args) ->
+ {ok,[Emuvalue]} = init:get_argument(emuarg),
io:format("Root dir: ~s\n", [code:root_dir()]),
io:format("Script args: ~p\n", [Args]),
- io:format("Smp: ~p\n", [erlang:system_info(smp_support)]).
+ io:format("Emuarg: ~p\n", [Emuvalue]).
diff --git a/lib/reltool/src/reltool.erl b/lib/reltool/src/reltool.erl
index 2bdf222aa0..8ab2c2399e 100644
--- a/lib/reltool/src/reltool.erl
+++ b/lib/reltool/src/reltool.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -120,7 +120,7 @@ apply_fun(Pid, false, Fun) ->
apply_fun(Pid, true, Fun) ->
case get_status(Pid) of
{ok, Warnings} ->
- [io:format("~p: ~s\n", [?APPLICATION, W]) || W <- Warnings],
+ [io:format("~w: ~ts\n", [?APPLICATION, W]) || W <- Warnings],
apply_fun(Pid, false, Fun);
{error, _Reason} = Error ->
stop(Pid),
diff --git a/lib/reltool/src/reltool_app_win.erl b/lib/reltool/src/reltool_app_win.erl
index 6cd0d2f90b..81ab1687fb 100644
--- a/lib/reltool/src/reltool_app_win.erl
+++ b/lib/reltool/src/reltool_app_win.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -173,7 +173,7 @@ loop(#state{xref_pid = Xref, common = C, app = App} = S) ->
S#state.mod_wins)},
?MODULE:loop(S2);
Msg ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Msg]),
?MODULE:loop(S)
end.
@@ -181,7 +181,7 @@ loop(#state{xref_pid = Xref, common = C, app = App} = S) ->
exit_warning({'EXIT', _Pid, shutdown}) ->
ok;
exit_warning({'EXIT', _Pid, _Reason} = Msg) ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Msg]).
create_window(#state{app = App} = S) ->
@@ -627,7 +627,7 @@ handle_event(#state{sys = Sys, app = App} = S, Wx) ->
Items = reltool_utils:get_items(ListCtrl),
handle_mod_button(S, Items, Action);
_ ->
- error_logger:format("~p~p got unexpected app event from "
+ error_logger:format("~w~w got unexpected app event from "
"wx:\n\t~p\n",
[?MODULE, self(), Wx]),
S
@@ -674,8 +674,8 @@ move_mod(App, {_ItemNo, ModStr}, Action) ->
blacklist_del ->
undefined;
_ ->
- error_logger:format("~p~p got unexpected mod "
- "button event: ~p\n\t ~p\n",
+ error_logger:format("~w~w got unexpected mod "
+ "button event: ~w\n\t ~p\n",
[?MODULE, self(), ModName, Action]),
M#mod.incl_cond
end,
diff --git a/lib/reltool/src/reltool_fgraph_win.erl b/lib/reltool/src/reltool_fgraph_win.erl
index b0deb1bab2..66bc2b5ab3 100644
--- a/lib/reltool/src/reltool_fgraph_win.erl
+++ b/lib/reltool/src/reltool_fgraph_win.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -525,7 +525,7 @@ loop(S, G) ->
exit(Reason);
Other ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Other]),
loop(S, G)
end.
diff --git a/lib/reltool/src/reltool_mod_win.erl b/lib/reltool/src/reltool_mod_win.erl
index 899423bb6d..b0193a2ae4 100644
--- a/lib/reltool/src/reltool_mod_win.erl
+++ b/lib/reltool/src/reltool_mod_win.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -130,7 +130,7 @@ do_init(Parent, WxEnv, Xref, RelPid, C, ModName) ->
loop(#state{xref_pid = Xref, common = C, mod = Mod} = S) ->
receive
Msg ->
- %% io:format("~s~p -> ~p\n", [S#state.name, self(), Msg]),
+ %% io:format("~ts~w -> ~p\n", [S#state.name, self(), Msg]),
case Msg of
{system, From, SysMsg} ->
Dbg = C#common.sys_debug,
@@ -170,7 +170,7 @@ loop(#state{xref_pid = Xref, common = C, mod = Mod} = S) ->
S2 = handle_event(S, Wx),
?MODULE:loop(S2);
_ ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Msg]),
?MODULE:loop(S)
end
@@ -335,23 +335,37 @@ find_regular_bin(App, Mod) ->
SrcDir = filename:join([ActiveDir, "src"]),
ModStr = atom_to_list(Mod#mod.name),
Base = "^" ++ ModStr ++ "\\.erl$",
- Find = fun(F, _Acc) -> throw(file:read_file(F)) end,
+ Find = fun(F, _Acc) -> throw({file:read_file(F),epp:read_encoding(F)}) end,
case catch filelib:fold_files(SrcDir, Base, true, Find, {error, enoent}) of
- {ok, Bin} ->
- Bin;
+ {{ok, Bin},Encoding0} ->
+ Encoding =
+ case Encoding0 of
+ none -> epp:default_encoding();
+ _ -> Encoding0
+ end,
+ unicode:characters_to_binary(Bin,Encoding,utf8);
{error, enoent} ->
%% Reconstructing the source code from debug info if possible
BeamFile = filename:join([ActiveDir, "ebin", ModStr ++ ".beam"]),
- case beam_lib:chunks(BeamFile, [abstract_code]) of
- {ok,{_,[{abstract_code,{_,AC}}]}} ->
- IoList = erl_prettypr:format(erl_syntax:form_list(AC)),
- list_to_binary(IoList);
- _ ->
- list_to_binary(["%% Bad luck, cannot find any "
- "debug info in the file \"", BeamFile])
+ case source_from_beam(BeamFile) of
+ {ok,Source} ->
+ Source;
+ error ->
+ unicode:characters_to_binary(
+ ["%% Bad luck, cannot find any "
+ "debug info in the file \"", BeamFile])
end
end.
+source_from_beam(Beam) ->
+ case beam_lib:chunks(Beam, [abstract_code]) of
+ {ok,{_,[{abstract_code,{_,AC}}]}} ->
+ IoList = [erl_pp:form(F,[{encoding,utf8}]) || F <- AC],
+ {ok,unicode:characters_to_binary(IoList)};
+ _ ->
+ error
+ end.
+
find_escript_bin(#app{active_dir = ActiveDir}, Mod) ->
NotFound = false,
ModName = Mod#mod.name,
@@ -366,16 +380,10 @@ find_escript_bin(#app{active_dir = ActiveDir}, Mod) ->
case beam_lib:version(Bin) of
{ok,{M, _}} when M =:= ModName;
FullName =:= "." ->
- case beam_lib:chunks(Bin,
- [abstract_code]) of
- {ok,{_,[{abstract_code,{_,AC}}]}} ->
- Form =
- erl_syntax:form_list(AC),
- IoList =
- erl_prettypr:format(Form),
- {obj,
- list_to_binary(IoList)};
- _ ->
+ case source_from_beam(Bin) of
+ {ok,Source} ->
+ {obj,Source};
+ error ->
Acc
end;
_ ->
@@ -396,12 +404,9 @@ find_escript_bin(#app{active_dir = ActiveDir}, Mod) ->
case filename:split(FullName) of
[_AppName, "ebin", F]
when F =:= ObjFile, Acc =:= NotFound ->
- case beam_lib:chunks(GetBin(),
- [abstract_code]) of
- {ok,{_,[{abstract_code,{_,AC}}]}} ->
- Form = erl_syntax:form_list(AC),
- IoList = erl_prettypr:format(Form),
- {obj, list_to_binary(IoList)};
+ case source_from_beam(GetBin()) of
+ {ok,Source} ->
+ {obj,Source};
_ ->
Acc
end;
@@ -420,13 +425,15 @@ find_escript_bin(#app{active_dir = ActiveDir}, Mod) ->
{ok, {obj, Bin}} ->
Bin;
_ ->
- list_to_binary(["%% Bad luck, cannot find the "
- "code in the escript ", Escript, "."])
+ unicode:characters_to_binary(
+ ["%% Bad luck, cannot find the "
+ "code in the escript ", Escript, "."])
end
catch
throw:Reason when is_list(Reason) ->
- list_to_binary(["%% Bad luck, cannot find the code "
- "in the escript ", Escript, ": ", Reason])
+ unicode:characters_to_binary(
+ ["%% Bad luck, cannot find the code "
+ "in the escript ", Escript, ": ", Reason])
end.
create_config_page(S) ->
@@ -478,7 +485,7 @@ handle_event(#state{xref_pid = Xref} = S, Wx) ->
wxWindow:setFocus(ObjRef),
S;
_ ->
- error_logger:format("~p~p got unexpected mod event from "
+ error_logger:format("~w~w got unexpected mod event from "
"wx:\n\t~p\n",
[?MODULE, self(), Wx]),
S
diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl
index c56e29152d..5e25f22a6f 100644
--- a/lib/reltool/src/reltool_server.erl
+++ b/lib/reltool/src/reltool_server.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -399,12 +399,12 @@ loop(#state{sys = Sys} = S) ->
{'EXIT', Pid, Reason} when Pid =:= S#state.parent_pid ->
exit(Reason);
{call, ReplyTo, Ref, Msg} when is_pid(ReplyTo), is_reference(Ref) ->
- error_logger:format("~p~p got unexpected call:\n\t~p\n",
+ error_logger:format("~w~w got unexpected call:\n\t~p\n",
[?MODULE, self(), Msg]),
reltool_utils:reply(ReplyTo, Ref, {error, {invalid_call, Msg}}),
?MODULE:loop(S);
Msg ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Msg]),
?MODULE:loop(S)
end.
@@ -422,7 +422,7 @@ do_set_apps(#state{sys = Sys} = S, ChangedApps) ->
%% 2) removing #app records if no configurable fields are set
%% 3) keeping #app records that are not changed
app_update_config([#app{name=Name,is_escript={inlined,Escript}}|_],_SysApps) ->
- reltool_utils:throw_error("Application ~p is inlined in ~p. Can not change "
+ reltool_utils:throw_error("Application ~w is inlined in ~w. Can not change "
"configuration for an inlined application.",
[Name,Escript]);
app_update_config([Config|Configs],SysApps) ->
@@ -580,8 +580,8 @@ apps_in_rel(#rel{name = RelName, rel_apps = RelApps}, Apps) ->
IA;
false ->
reltool_utils:throw_error(
- "Release ~p uses non existing "
- "application ~p",
+ "Release ~tp uses non existing "
+ "application ~w",
[RelName,RA#rel_app.name])
end;
IA ->
@@ -602,7 +602,7 @@ more_apps_in_rels([{RelName, AppName} = RA | RelApps], Apps, Acc) ->
more_apps_in_rels(RelApps, Apps, Acc2);
false ->
reltool_utils:throw_error(
- "Release ~p uses non existing application ~p",
+ "Release ~tp uses non existing application ~w",
[RelName,AppName])
end
end;
@@ -640,7 +640,7 @@ app_init_is_included(#state{app_tab = AppTab, mod_tab = ModTab, sys=Sys},
{undefined, false, false, Status};
{exclude, [RelName | _]} -> % App is included in at least one rel
reltool_utils:throw_error(
- "Application ~p is used in release ~p and cannot be excluded",
+ "Application ~w is used in release ~tp and cannot be excluded",
[AppName,RelName]);
{derived, []} ->
{undefined, undefined, undefined, Status};
@@ -665,7 +665,7 @@ app_init_is_included(#state{app_tab = AppTab, mod_tab = ModTab, sys=Sys},
Status3.
mod_init_is_included(ModTab, M, ModCond, AppCond, Default, Status) ->
- %% print(M#mod.name, hipe, "incl_cond -> ~p\n", [AppCond]),
+ %% print(M#mod.name, hipe, "incl_cond -> ~w\n", [AppCond]),
IsIncl =
case AppCond of
include ->
@@ -677,7 +677,7 @@ mod_init_is_included(ModTab, M, ModCond, AppCond, Default, Status) ->
derived ->
undefined;
undefined ->
- %% print(M#mod.name, hipe, "mod_cond -> ~p\n",
+ %% print(M#mod.name, hipe, "mod_cond -> ~w\n",
%% [ModCond]),
case ModCond of
all -> true;
@@ -711,23 +711,23 @@ mod_init_is_included(ModTab, M, ModCond, AppCond, Default, Status) ->
{false,_} ->
ets:insert(ModTab, M2),
reltool_utils:add_warning(
- "Module ~p exists in applications ~p and ~p. "
- "Using module from application ~p.",
+ "Module ~w exists in applications ~w and ~w. "
+ "Using module from application ~w.",
[M#mod.name, Existing#mod.app_name,
M#mod.app_name, M#mod.app_name],
Status);
{_,false} ->
%% Don't insert in ModTab - using Existing
reltool_utils:add_warning(
- "Module ~p exists in applications ~p and ~p. "
- "Using module from application ~p.",
+ "Module ~w exists in applications ~w and ~w. "
+ "Using module from application ~w.",
[M#mod.name, Existing#mod.app_name,
M#mod.app_name,Existing#mod.app_name],
Status);
{_,_} ->
reltool_utils:throw_error(
- "Module ~p potentially included by two different "
- "applications: ~p and ~p.",
+ "Module ~w potentially included by two different "
+ "applications: ~w and ~w.",
[M#mod.name,Existing#mod.app_name,M#mod.app_name])
end;
[] ->
@@ -735,7 +735,7 @@ mod_init_is_included(ModTab, M, ModCond, AppCond, Default, Status) ->
Status
end,
- %% print(M#mod.name, hipe, "~p -> ~p\n", [M2, IsIncl]),
+ %% print(M#mod.name, hipe, "~p -> ~w\n", [M2, IsIncl]),
{M2,Status2}.
false_to_undefined(Bool) ->
@@ -888,7 +888,7 @@ mod_recap_dependencies(S, A, [#mod{name = ModName}=M1 | Mods], Acc, IsIncl) ->
case ets:lookup(S#state.mod_tab, ModName) of
[M2] when M2#mod.app_name=:=A#app.name ->
ModStatus = do_get_status(M2),
- %% print(M2#mod.name, hipe, "status -> ~p\n", [ModStatus]),
+ %% print(M2#mod.name, hipe, "status -> ~w\n", [ModStatus]),
{IsIncl2, M3} =
case M2#mod.is_included of
true ->
@@ -910,8 +910,8 @@ mod_recap_dependencies(S, A, [#mod{name = ModName}=M1 | Mods], Acc, IsIncl) ->
%% A module is potensially included by multiple
%% applications. This is not allowed!
reltool_utils:throw_error(
- "Module ~p potentially included by two different applications: "
- "~p and ~p", [ModName,A#app.name, " and ", M2#mod.app_name, "."])
+ "Module ~w potentially included by two different applications: "
+ "~w and ~w.", [ModName,A#app.name, M2#mod.app_name])
end;
mod_recap_dependencies(_S, _A, [], Acc, IsIncl) ->
{lists:reverse(Acc), IsIncl}.
@@ -939,7 +939,7 @@ verify_config(#state{app_tab=AppTab, sys=#sys{boot_rel = BootRel, rels = Rels}},
Rels);
false ->
reltool_utils:throw_error(
- "Release ~p is mandatory (used as boot_rel)",[BootRel])
+ "Release ~tp is mandatory (used as boot_rel)",[BootRel])
end.
check_app(AppTab, {RelName, AppName}, Status) ->
@@ -949,7 +949,7 @@ check_app(AppTab, {RelName, AppName}, Status) ->
Status;
_ ->
reltool_utils:throw_error(
- "Release ~p uses non included application ~p",[RelName,AppName])
+ "Release ~tp uses non included application ~w",[RelName,AppName])
end.
check_rel(RelName, RelApps, Status) ->
@@ -960,8 +960,8 @@ check_rel(RelName, RelApps, Status) ->
Acc;
false ->
reltool_utils:throw_error(
- "Mandatory application ~p is not included in "
- "release ~p", [AppName,RelName])
+ "Mandatory application ~w is not included in "
+ "release ~tp", [AppName,RelName])
end
end,
Mandatory = [kernel, stdlib],
@@ -1015,8 +1015,8 @@ refresh_app(#app{name = AppName,
lists:foldl(
fun(M,S) ->
reltool_utils:add_warning(
- "Module ~p duplicated in app file for "
- "application ~p.", [M, AppName], S)
+ "Module ~w duplicated in app file for "
+ "application ~w.", [M, AppName], S)
end,
Status3,
DuplicatedMods)
@@ -1074,18 +1074,18 @@ read_app_info(AppFileOrBin, AppFile, AppName, DefaultVsn, Status) ->
parse_app_info(AppFile, Info, AI, Status);
{ok, _BadApp} ->
{missing_app_info(DefaultVsn),
- reltool_utils:add_warning("~p: Illegal contents in app file ~p, "
+ reltool_utils:add_warning("~w: Illegal contents in app file ~tp, "
"application tuple with arity 3 expected.",
[AppName,AppFile],
Status)};
{error, Text} when Text =:= EnoentText ->
{missing_app_info(DefaultVsn),
- reltool_utils:add_warning("~p: Missing app file ~p.",
+ reltool_utils:add_warning("~w: Missing app file ~tp.",
[AppName,AppFile],
Status)};
{error, Text} ->
{missing_app_info(DefaultVsn),
- reltool_utils:add_warning("~p: Cannot parse app file ~p (~p).",
+ reltool_utils:add_warning("~w: Cannot parse app file ~tp (~tp).",
[AppName,AppFile,Text],
Status)}
end.
@@ -1122,7 +1122,7 @@ parse_app_info(File, [{Key, Val} | KeyVals], AI, Status) ->
Status);
_ ->
Status2 =
- reltool_utils:add_warning("Unexpected item ~p in app file ~p.",
+ reltool_utils:add_warning("Unexpected item ~p in app file ~tp.",
[Key,File],
Status),
parse_app_info(File, KeyVals, AI, Status2)
@@ -1212,7 +1212,7 @@ wait_for_processto_die(Ref, Pid, File) ->
{'DOWN', Ref, _Type, _Object, _Info} ->
ok
after timer:seconds(30) ->
- error_logger:error_msg("~p(~p): Waiting for process ~p to die ~p\n",
+ error_logger:error_msg("~w(~w): Waiting for process ~w to die ~tp\n",
[?MODULE, ?LINE, Pid, File]),
wait_for_processto_die(Ref, Pid, File)
end.
@@ -1223,7 +1223,7 @@ add_missing_mods(AppName, EbinMods, AppModNames) ->
[missing_mod(ModName, AppName) || ModName <- MissingModNames].
missing_mod(ModName, AppName) ->
- %% io:format("Missing: ~p -> ~p\n", [AppName, ModName]),
+ %% io:format("Missing: ~w -> ~w\n", [AppName, ModName]),
#mod{name = ModName,
app_name = AppName,
incl_cond = undefined,
@@ -1323,7 +1323,7 @@ read_config(OldSys, Filename) when is_list(Filename) ->
{ok, Content} ->
reltool_utils:throw_error("Illegal file content: ~p",[Content]);
{error, Reason} ->
- reltool_utils:throw_error("Illegal config file ~p: ~s",
+ reltool_utils:throw_error("Illegal config file ~tp: ~ts",
[Filename,file:format_error(Reason)])
end;
read_config(OldSys, {sys, KeyVals}) ->
@@ -1341,7 +1341,7 @@ read_config(OldSys, {sys, KeyVals}) ->
NewSys2;
false ->
reltool_utils:throw_error(
- "Release ~p is mandatory (used as boot_rel)",
+ "Release ~tp is mandatory (used as boot_rel)",
[NewSys2#sys.boot_rel])
end;
read_config(_OldSys, BadConfig) ->
@@ -1510,7 +1510,7 @@ decode(#app{} = App, [{Key, Val} | KeyVals]) ->
active_dir = Dir,
sorted_dirs = [Dir]};
false ->
- reltool_utils:throw_error("Illegal lib dir for ~p: ~p",
+ reltool_utils:throw_error("Illegal lib dir for ~w: ~p",
[App#app.name, Val])
end;
SelectVsn when SelectVsn=:=vsn; SelectVsn=:=lib_dir ->
@@ -1642,7 +1642,7 @@ patch_erts_version(RootDir, Apps, Status) ->
end;
false ->
reltool_utils:throw_error(
- "erts cannot be found in the root directory ~p", [RootDir])
+ "erts cannot be found in the root directory ~tp", [RootDir])
end.
libs_to_dirs(RootDir, LibDirs) ->
@@ -1669,10 +1669,10 @@ libs_to_dirs(RootDir, LibDirs) ->
lists:prefix("erts", F)],
app_dirs2(AllLibDirs, [ErtsFiles]);
[Duplicate | _] ->
- reltool_utils:throw_error("Duplicate library: ~p",[Duplicate])
+ reltool_utils:throw_error("Duplicate library: ~tp",[Duplicate])
end;
{error, Reason} ->
- reltool_utils:throw_error("Missing root library ~p: ~s",
+ reltool_utils:throw_error("Missing root library ~tp: ~ts",
[RootDir,file:format_error(Reason)])
end.
@@ -1697,7 +1697,7 @@ app_dirs2([Lib | Libs], Acc) ->
Files2 = lists:zf(Filter, Files),
app_dirs2(Libs, [Files2 | Acc]);
{error, Reason} ->
- reltool_utils:throw_error("Illegal library ~p: ~s",
+ reltool_utils:throw_error("Illegal library ~tp: ~ts",
[Lib, file:format_error(Reason)])
end;
app_dirs2([], Acc) ->
@@ -1756,7 +1756,7 @@ escripts_to_apps([Escript | Escripts], Apps, Status) ->
{ok, AF} ->
AF;
{error, Reason1} ->
- reltool_utils:throw_error("Illegal escript ~p: ~p",
+ reltool_utils:throw_error("Illegal escript ~tp: ~p",
[Escript,Reason1])
end,
@@ -1838,7 +1838,7 @@ escripts_to_apps([Escript | Escripts], Apps, Status) ->
Status2),
escripts_to_apps(Escripts, Apps2, Status3);
{error, Reason2} ->
- reltool_utils:throw_error("Illegal escript ~p: ~p",
+ reltool_utils:throw_error("Illegal escript ~tp: ~p",
[Escript,Reason2])
end;
escripts_to_apps([], Apps, Status) ->
@@ -1901,7 +1901,7 @@ init_escript_app(AppName, EscriptAppName, Dir, Info, Mods, Apps, Status) ->
case lists:keymember(AppName, #app.name, Apps) of
true ->
reltool_utils:throw_error(
- "~p: Application name clash. Escript ~p contains application ~p.",
+ "~w: Application name clash. Escript ~tp contains application ~tp.",
[AppName,Dir,AppName]);
false ->
{App2, Status}
@@ -1986,7 +1986,7 @@ ensure_app_info(#app{is_escript = IsEscript, active_dir = Dir, info = Info},
%% Escript or application which is inlined in an escript
{Info, Dir, Status};
ensure_app_info(#app{name = Name, sorted_dirs = []}, _Status) ->
- reltool_utils:throw_error("~p: : Missing application directory.",[Name]);
+ reltool_utils:throw_error("~w: : Missing application directory.",[Name]);
ensure_app_info(#app{name = Name,
vsn = Vsn,
use_selected_vsn = UseSelectedVsn,
@@ -2011,8 +2011,8 @@ ensure_app_info(#app{name = Name,
Status2;
[BadVsn | _] ->
reltool_utils:throw_error(
- "~p: Application version clash. "
- "Multiple directories contains version ~p.",
+ "~w: Application version clash. "
+ "Multiple directories contains version ~tp.",
[Name,BadVsn])
end,
FirstInfo = hd(AllInfo),
@@ -2034,8 +2034,8 @@ ensure_app_info(#app{name = Name,
{Info, VsnDir, Status3};
false ->
reltool_utils:throw_error(
- "~p: No application directory contains "
- "selected version ~p", [Name,Vsn])
+ "~w: No application directory contains "
+ "selected version ~tp", [Name,Vsn])
end
end;
true ->
diff --git a/lib/reltool/src/reltool_sys_win.erl b/lib/reltool/src/reltool_sys_win.erl
index 8e182d02ed..b5d54e6d3e 100644
--- a/lib/reltool/src/reltool_sys_win.erl
+++ b/lib/reltool/src/reltool_sys_win.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -181,7 +181,7 @@ do_init([{safe_config, Safe}, {parent, Parent} | Options]) ->
end.
restart_server_safe_config(true,Parent,Reason) ->
- io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
+ io:format("~w(~w): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
proc_lib:init_ack(Parent, {error,Reason});
restart_server_safe_config(false,Parent,Reason) ->
wx:new(),
@@ -198,7 +198,7 @@ restart_server_safe_config(false,Parent,Reason) ->
?wxID_OK ->
do_init([{safe_config,true},{parent,Parent},?safe_config]);
?wxID_CANCEL ->
- io:format("~p(~p): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
+ io:format("~w(~w): <ERROR> ~p\n", [?MODULE, ?LINE, Reason]),
proc_lib:init_ack(Parent,{error,Reason})
end.
@@ -211,7 +211,7 @@ exit_dialog(Warnings) ->
?wxID_OK ->
ok;
?wxID_CANCEL ->
- io:format("~p(~p): <ERROR> ~s\n", [?MODULE, ?LINE, Details]),
+ io:format("~w(~w): <ERROR> ~ts\n", [?MODULE, ?LINE, Details]),
exit(Details)
end.
@@ -249,7 +249,7 @@ loop(S) ->
WWs2 = lists:delete(ObjRef, WWs),
?MODULE:loop(S#state{warning_wins = WWs2});
false ->
- error_logger:format("~p~p got unexpected "
+ error_logger:format("~w~w got unexpected "
"message:\n\t~p\n",
[?MODULE, self(), Msg]),
?MODULE:loop(S)
@@ -291,7 +291,7 @@ loop(S) ->
S#state.app_wins),
?MODULE:loop(S#state{fgraph_wins = FWs, app_wins = AWs});
Msg ->
- error_logger:format("~p~p got unexpected message:\n\t~p\n",
+ error_logger:format("~w~w got unexpected message:\n\t~p\n",
[?MODULE, self(), Msg]),
?MODULE:loop(S)
end.
@@ -315,7 +315,7 @@ handle_child_exit({'EXIT', Pid, _Reason} = Exit, FWs, AWs) ->
msg_warning({'EXIT', _Pid, shutdown}, Type) when Type =/= unknown ->
ok;
msg_warning(Exit, Type) ->
- error_logger:format("~p~p got unexpected message (~p):\n\t~p\n",
+ error_logger:format("~w~w got unexpected message (~w):\n\t~p\n",
[?MODULE, self(), Type, Exit]).
create_window(S) ->
@@ -1161,7 +1161,7 @@ handle_system_event(#state{sys = Sys} = S,
Sys2 = Sys#sys{incl_cond = AppCond},
do_set_sys(S#state{sys = Sys2});
handle_system_event(S, Event, ObjRef, UserData) ->
- error_logger:format("~p~p got unexpected wx sys event to ~p "
+ error_logger:format("~w~w got unexpected wx sys event to ~p "
"with user data: ~p\n\t ~p\n",
[?MODULE, self(), ObjRef, UserData, Event]),
S.
@@ -1177,13 +1177,13 @@ handle_source_event(S,
_UserData) ->
case wxTreeCtrl:getItemData(ObjRef, Item) of
#root_data{dir = _Dir} ->
- %% io:format("Root dialog: ~p\n", [Dir]),
+ %% io:format("Root dialog: ~tp\n", [Dir]),
S;
#lib_data{dir = _Dir} ->
- %% io:format("Lib dialog: ~p\n", [Dir]),
+ %% io:format("Lib dialog: ~tp\n", [Dir]),
S;
#escript_data{file = _File} ->
- %% io:format("Escript dialog: ~p\n", [File]),
+ %% io:format("Escript dialog: ~tp\n", [File]),
S;
#app_data{name = Name} ->
do_open_app(S, Name);
@@ -1203,7 +1203,7 @@ handle_source_event(S,
#escript_data{file = File} ->
wx:batch(fun() -> escript_popup(S, File, Tree, Item) end);
#app_data{name = Name} ->
- io:format("App menu: ~p\n", [Name]),
+ io:format("App menu: ~tp\n", [Name]),
S;
undefined ->
S
@@ -1223,7 +1223,7 @@ handle_app_event(S,
Items = reltool_utils:get_items(ListCtrl),
handle_app_button(S, Items, Action);
handle_app_event(S, Event, ObjRef, UserData) ->
- error_logger:format("~p~p got unexpected wx app event to "
+ error_logger:format("~w~w got unexpected wx app event to "
"~p with user data: ~p\n\t ~p\n",
[?MODULE, self(), ObjRef, UserData, Event]),
S.
@@ -1267,7 +1267,7 @@ move_app(S, {_ItemNo, AppBase}, Action) ->
blacklist_del ->
undefined;
_ ->
- error_logger:format("~p~p got unexpected app "
+ error_logger:format("~w~w got unexpected app "
"button event: ~p ~p\n",
[?MODULE, self(), Action, AppBase]),
OldApp#app.incl_cond
diff --git a/lib/reltool/src/reltool_target.erl b/lib/reltool/src/reltool_target.erl
index 1f4ce7226a..f7a5932b7b 100644
--- a/lib/reltool/src/reltool_target.erl
+++ b/lib/reltool/src/reltool_target.erl
@@ -296,7 +296,7 @@ do_gen_rel(#rel{name = RelName, vsn = RelVsn, rel_apps = RelApps},
{ErtsName, Erts#app.vsn},
[strip_rel_info(App, RelApps) || App <- MergedApps]};
false ->
- reltool_utils:throw_error("Mandatory application ~p is "
+ reltool_utils:throw_error("Mandatory application ~w is "
"not included",
[ErtsName])
end.
@@ -383,8 +383,8 @@ merge_app(RelName,
[] ->
App#app{app_type = Type2, info = Info#app_info{incl_apps = InclApps}};
BadIncl ->
- reltool_utils:throw_error("~p: These applications are "
- "used by release ~s but are "
+ reltool_utils:throw_error("~w: These applications are "
+ "used by release ~ts but are "
"missing as included_applications "
"in the app file: ~p",
[Name, RelName, BadIncl])
@@ -865,7 +865,7 @@ strip_sys_files(Relocatable, SysFiles, Apps, ExclRegexps) ->
case File of
"erts" ->
reltool_utils:throw_error("This system is not installed. "
- "The directory ~s is missing.",
+ "The directory ~ts is missing.",
[Erts#app.label]);
_ when File =:= Erts#app.label ->
replace_dyn_erl(Relocatable, Spec);
@@ -987,7 +987,7 @@ check_sys(Mandatory, SysFiles) ->
do_check_sys(Prefix, Specs) ->
case lookup_spec(Prefix, Specs) of
[] ->
- reltool_utils:throw_error("Mandatory system directory ~s "
+ reltool_utils:throw_error("Mandatory system directory ~ts "
"is not included",
[Prefix]);
_ ->
@@ -1008,8 +1008,8 @@ lookup_spec(Prefix, Specs) ->
safe_lookup_spec(Prefix, Specs) ->
case lookup_spec(Prefix, Specs) of
[] ->
- %% io:format("lookup fail ~s:\n\t~p\n", [Prefix, Specs]),
- reltool_utils:throw_error("Mandatory system file ~s is "
+ %% io:format("lookup fail ~ts:\n\t~p\n", [Prefix, Specs]),
+ reltool_utils:throw_error("Mandatory system file ~ts is "
"not included", [Prefix]);
Match ->
Match
@@ -1053,7 +1053,7 @@ spec_lib_files(#sys{root_dir = RootDir,
check_apps([Mandatory | Names], Apps) ->
case lists:keymember(Mandatory, #app.name, Apps) of
false ->
- reltool_utils:throw_error("Mandatory application ~p is "
+ reltool_utils:throw_error("Mandatory application ~w is "
"not included in ~p",
[Mandatory, Apps]);
true ->
@@ -1144,13 +1144,13 @@ spec_dir(Dir) ->
Base,
[spec_dir(filename:join([Dir, F])) || F <- Files]};
error ->
- reltool_utils:throw_error("list dir ~s failed", [Dir])
+ reltool_utils:throw_error("list dir ~ts failed", [Dir])
end;
{ok, #file_info{type = regular}} ->
%% Plain file
{copy_file, Base};
_ ->
- reltool_utils:throw_error("read file info ~s failed", [Dir])
+ reltool_utils:throw_error("read file info ~ts failed", [Dir])
end.
spec_mod(Mod, DebugInfo) ->
@@ -1284,7 +1284,7 @@ do_eval_spec({archive, Archive, Options, Files},
{ok, _} ->
ok;
{error, Reason} ->
- reltool_utils:throw_error("create archive ~s failed: ~p",
+ reltool_utils:throw_error("create archive ~ts failed: ~p",
[ArchiveFile, Reason])
end;
do_eval_spec({copy_file, File}, _OrigSourceDir, SourceDir, TargetDir) ->
@@ -1473,7 +1473,7 @@ do_install(RelName, TargetDir) ->
ok = release_handler:create_RELEASES(TargetDir2, RelFile),
ok;
_ ->
- reltool_utils:throw_error("~s: Illegal data file syntax", [DataFile])
+ reltool_utils:throw_error("~ts: Illegal data file syntax",[DataFile])
end.
nativename(Dir) ->
diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl
index 6149d6ef06..edccb889b1 100644
--- a/lib/reltool/src/reltool_utils.erl
+++ b/lib/reltool/src/reltool_utils.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -106,7 +106,7 @@ normalize_dir([], Path) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
prim_consult(Bin) when is_binary(Bin) ->
- case erl_scan:string(binary_to_list(Bin)) of
+ case erl_scan:string(unicode:characters_to_list(Bin,encoding(Bin))) of
{ok, Tokens, _EndLine} ->
prim_parse(Tokens, []);
{error, {_ErrorLine, Module, Reason}, _EndLine} ->
@@ -120,6 +120,14 @@ prim_consult(FullName) when is_list(FullName) ->
{error, file:format_error(enoent)}
end.
+encoding(Bin) when is_binary(Bin) ->
+ case epp:read_encoding_from_binary(Bin) of
+ none ->
+ epp:default_encoding();
+ E ->
+ E
+ end.
+
prim_parse(Tokens, Acc) ->
case lists:splitwith(fun(T) -> element(1,T) =/= dot end, Tokens) of
{[], []} ->
@@ -423,7 +431,7 @@ scroll_size(ObjRef) ->
safe_keysearch(Key, Pos, List, Mod, Line) ->
case lists:keysearch(Key, Pos, List) of
false ->
- io:format("~p(~p): lists:keysearch(~p, ~p, ~p) -> false\n",
+ io:format("~w(~w): lists:keysearch(~p, ~w, ~p) -> false\n",
[Mod, Line, Key, Pos, List]),
erlang:error({Mod, Line, lists, keysearch, [Key, Pos, List]});
{value, Val} ->
@@ -455,7 +463,7 @@ create_dir(Dir) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("create dir ~s: ~s", [Dir, Text])
+ throw_error("create dir ~ts: ~ts", [Dir, Text])
end.
list_dir(Dir) ->
@@ -464,7 +472,7 @@ list_dir(Dir) ->
Files;
error ->
Text = file:format_error(enoent),
- throw_error("list dir ~s: ~s", [Dir, Text])
+ throw_error("list dir ~ts: ~ts", [Dir, Text])
end.
read_file_info(File) ->
@@ -473,7 +481,7 @@ read_file_info(File) ->
Info;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("read file info ~s: ~s", [File, Text])
+ throw_error("read file info ~ts: ~ts", [File, Text])
end.
write_file_info(File, Info) ->
@@ -482,7 +490,7 @@ write_file_info(File, Info) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("write file info ~s: ~s", [File, Text])
+ throw_error("write file info ~ts: ~ts", [File, Text])
end.
read_file(File) ->
@@ -491,7 +499,7 @@ read_file(File) ->
Bin;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("read file ~s: ~s", [File, Text])
+ throw_error("read file ~ts: ~ts", [File, Text])
end.
write_file(File, IoList) ->
@@ -500,7 +508,7 @@ write_file(File, IoList) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("write file ~s: ~s", [File, Text])
+ throw_error("write file ~ts: ~ts", [File, Text])
end.
recursive_delete(Dir) ->
@@ -516,7 +524,7 @@ recursive_delete(Dir) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("delete file ~s: ~s\n", [Dir, Text])
+ throw_error("delete file ~ts: ~ts\n", [Dir, Text])
end;
false ->
delete(Dir, regular)
@@ -530,7 +538,7 @@ delete(File, Type) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("delete file ~s: ~s\n", [File, Text])
+ throw_error("delete file ~ts: ~ts\n", [File, Text])
end.
do_delete(File, regular) ->
@@ -569,11 +577,11 @@ copy_file(From, To) ->
ok;
{error, Reason} ->
Text = file:format_error(Reason),
- throw_error("copy file ~s -> ~s: ~s\n", [From, To, Text])
+ throw_error("copy file ~ts -> ~ts: ~ts\n", [From, To, Text])
end;
error ->
Text = file:format_error(enoent),
- throw_error("copy file ~s -> ~s: ~s\n", [From, To, Text])
+ throw_error("copy file ~ts -> ~ts: ~ts\n", [From, To, Text])
end.
throw_error(Format, Args) ->
@@ -586,13 +594,10 @@ decode_regexps(Key, {add, Regexps}, Old) when is_list(Regexps) ->
decode_regexps(_Key, {del, Regexps}, Old) when is_list(Regexps) ->
[Re || Re <- Old, not lists:member(Re#regexp.source, Regexps)];
decode_regexps(Key, Regexps, _Old) when is_list(Regexps) ->
- do_decode_regexps(Key, Regexps, []);
-decode_regexps(Key, Regexps, _Old) when is_list(Regexps) ->
- Text = lists:flatten(io_lib:format("~p", [{Key, Regexps}])),
- throw({error, "Illegal option: " ++ Text}).
+ do_decode_regexps(Key, Regexps, []).
do_decode_regexps(Key, [Regexp | Regexps], Acc) ->
- case catch re:compile(Regexp, []) of
+ case catch re:compile(Regexp, [unicode]) of
{ok, MP} ->
do_decode_regexps(Key,
Regexps,
diff --git a/lib/reltool/test/reltool_server_SUITE.erl b/lib/reltool/test/reltool_server_SUITE.erl
index 8d71865508..23338d9ecd 100644
--- a/lib/reltool/test/reltool_server_SUITE.erl
+++ b/lib/reltool/test/reltool_server_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -42,6 +43,11 @@ end_per_suite(Config) ->
reltool_test_lib:end_per_suite(Config).
init_per_testcase(Func,Config) ->
+ Node = full_node_name(?NODE_NAME),
+ case net_adm:ping(Node) of
+ pong -> stop_node(Node);
+ pang -> ok
+ end,
reltool_test_lib:init_per_testcase(Func,Config).
end_per_testcase(Func,Config) ->
reltool_test_lib:end_per_testcase(Func,Config).
@@ -60,6 +66,7 @@ all() ->
create_script,
create_script_sort,
create_target,
+ create_target_unicode,
create_embedded,
create_standalone,
create_standalone_beam,
@@ -750,6 +757,72 @@ create_target(_Config) ->
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Generate target system
+
+create_target_unicode(Config) ->
+ DataDir = ?config(data_dir,Config),
+
+ %% If file name translation mode is unicode, then use unicode
+ %% characters release name (which will be used as file name for
+ %% .rel, .script and .boot)
+ RelNamePrefix =
+ case file:native_name_encoding() of
+ utf8 ->
+ "Unicode test αβ";
+ latin1 ->
+ "Unicode test"
+ end,
+
+ %% Configure the server
+ RelName1 = RelNamePrefix,
+ RelName2 = RelNamePrefix ++ " with SASL",
+ RelVsn = "1.0",
+ Sys =
+ {sys,
+ [
+ {root_dir, code:root_dir()},
+ {lib_dirs, [filename:join(DataDir,"unicode")]},
+ {app_file, all},
+ {incl_cond,exclude},
+ {boot_rel, RelName2},
+ {rel, RelName1, RelVsn, [stdlib, kernel, ua]},
+ {rel, RelName2, RelVsn, [sasl, stdlib, kernel, ua]},
+ {app, kernel, [{incl_cond, include}]},
+ {app, stdlib, [{incl_cond, include}]},
+ {app, sasl, [{incl_cond, include}]},
+ {app, ua, [{incl_cond, include}]}
+ ]},
+
+ %% Generate target file
+ TargetDir = filename:join([?WORK_DIR, "target_unicode"]),
+ ?m(ok, reltool_utils:recursive_delete(TargetDir)),
+ ?m(ok, file:make_dir(TargetDir)),
+ ?log("SPEC: ~p\n", [reltool:get_target_spec([{config, Sys}])]),
+ ok = ?m(ok, reltool:create_target([{config, Sys}], TargetDir)),
+
+ %% Start a node
+ Erl = filename:join([TargetDir, "bin", "erl"]),
+ {ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl)),
+
+
+ %% The ua application has a unicode string as description - check
+ %% that it is translated correctly.
+ wait_for_app(Node,ua,50),
+ Apps = rpc:call(Node,application,which_applications,[]),
+ ?m({ua,"Application for testing unicode in reltool - αβ","1.0"},
+ lists:keyfind(ua,1,Apps)),
+
+ %% Check that the release name is correct (really only
+ %% insteresting if file name translation mode is utf8)
+ [{RelName,_,_,_}] =
+ ?msym([{_,_,_,_}],rpc:call(Node,release_handler,which_releases,[])),
+ ?m(true,lists:prefix(RelNamePrefix,RelName)),
+
+ ?msym(ok, stop_node(Node)),
+
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Generate embedded target system
create_embedded(_Config) ->
@@ -810,11 +883,11 @@ create_standalone(_Config) ->
?msym(ok, stop_node(Node)),
%% Execute escript
- Expected = iolist_to_binary(["Root dir: ", RootDir, "\n"
- "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
- "Smp: false\n",
- "ExitCode:0"]),
- io:format("Expected: ~s\n", [Expected]),
+ Expected = s2b(["Root dir: ", RootDir, "\n"
+ "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
+ "Emuarg: [\"emuvalue\"]\n",
+ "ExitCode:0"]),
+ io:format("Expected: ~ts\n", [Expected]),
?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")),
ok.
@@ -857,10 +930,11 @@ create_standalone_beam(Config) ->
?msym(ok, stop_node(Node)),
%% Execute escript
- Expected = iolist_to_binary(["Root dir: ", RootDir, "\n"
- "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
- "ExitCode:0"]),
- io:format("Expected: ~s\n", [Expected]),
+ Expected = s2b(["Module: mymod\n"
+ "Root dir: ", RootDir, "\n"
+ "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
+ "ExitCode:0"]),
+ io:format("Expected: ~ts\n", [Expected]),
?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")),
ok.
@@ -909,10 +983,11 @@ create_standalone_app(Config) ->
?msym(ok, stop_node(Node)),
%% Execute escript
- Expected = iolist_to_binary(["Root dir: ", RootDir, "\n"
- "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
- "ExitCode:0"]),
- io:format("Expected: ~s\n", [Expected]),
+ Expected = s2b(["Module: mymod\n"
+ "Root dir: ", RootDir, "\n"
+ "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
+ "ExitCode:0"]),
+ io:format("Expected: ~ts\n", [Expected]),
?m(Expected, run(BinDir, EscriptName, "-arg1 arg2 arg3")),
ok.
@@ -995,19 +1070,20 @@ create_multiple_standalone(Config) ->
?msym(ok, stop_node(Node)),
%% Execute escript1
- Expected1 = iolist_to_binary(["Root dir: ", RootDir, "\n"
- "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
- "Smp: false\n",
- "ExitCode:0"]),
- io:format("Expected1: ~s\n", [Expected1]),
+ Expected1 = s2b(["Root dir: ", RootDir, "\n"
+ "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
+ "Emuarg: [\"emuvalue\"]\n",
+ "ExitCode:0"]),
+ io:format("Expected1: ~ts\n", [Expected1]),
?m(Expected1, run(BinDir, EscriptName1, "-arg1 arg2 arg3")),
%% Execute escript2
- Expected2 = iolist_to_binary(["Root dir: ", RootDir, "\n"
- "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
- "ExitCode:0"]),
- io:format("Expected2: ~s\n", [Expected2]),
+ Expected2 = s2b(["Module: mymod\n"
+ "Root dir: ", RootDir, "\n"
+ "Script args: [\"-arg1\",\"arg2\",\"arg3\"]\n",
+ "ExitCode:0"]),
+ io:format("Expected2: ~ts\n", [Expected2]),
?m(Expected2, run(BinDir, EscriptName2, "-arg1 arg2 arg3")),
ok.
@@ -1094,6 +1170,7 @@ create_slim(Config) ->
"-sasl", "releases_dir", EscapedQuote++TargetRelDir++EscapedQuote],
{ok, Node} = ?msym({ok, _}, start_node(?NODE_NAME, Erl, Args)),
?msym(RootDir, rpc:call(Node, code, root_dir, [])),
+ wait_for_app(Node,sasl,50),
?msym([{RelName,RelVsn,_,permanent}],
rpc:call(Node,release_handler,which_releases,[])),
?msym(ok, stop_node(Node)),
@@ -2420,7 +2497,7 @@ start_node(Name, ErlPath) ->
start_node(Name, ErlPath, Args0) ->
FullName = full_node_name(Name),
Args = mk_node_args(Name, Args0),
- io:format("Starting node ~p: ~s~n",
+ io:format("Starting node ~p: ~ts~n",
[FullName, lists:flatten([[X," "] || X <- [ErlPath|Args]])]),
%io:format("open_port({spawn_executable, ~p}, [{args,~p}])~n",[ErlPath,Args]),
case open_port({spawn_executable, ErlPath}, [{args,Args}]) of
@@ -2436,9 +2513,19 @@ start_node(Name, ErlPath, Args0) ->
end.
stop_node(Node) ->
- monitor_node(Node, true),
- spawn(Node, fun () -> halt() end),
- receive {nodedown, Node} -> ok end.
+ rpc:call(Node,erlang,halt,[]),
+ wait_for_node_down(Node,50).
+
+wait_for_node_down(Node,0) ->
+ test_server:fail({cant_terminate_node,Node});
+wait_for_node_down(Node,N) ->
+ case net_adm:ping(Node) of
+ pong ->
+ timer:sleep(1000),
+ wait_for_node_down(Node,N-1);
+ pang ->
+ ok
+ end.
mk_node_args(Name, Args) ->
Pa = filename:dirname(code:which(?MODULE)),
@@ -2485,6 +2572,22 @@ wait_for_process(Node, Name, N) when is_integer(N), N > 0 ->
ok
end.
+wait_for_app(_Node, Name, 0) ->
+ {error, Name};
+wait_for_app(Node, Name, N) when is_integer(N), N > 0 ->
+ case rpc:call(Node,application,which_applications,[]) of
+ {badrpc,Reason} ->
+ test_server:fail({failed_to_get_applications,Reason});
+ Apps ->
+ case lists:member(Name,Apps) of
+ false ->
+ timer:sleep(1000),
+ wait_for_app(Node, Name, N-1);
+ true ->
+ ok
+ end
+ end.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Run escript
@@ -2513,7 +2616,7 @@ do_run(Dir, Cmd) ->
Res = get_data(Port, []),
receive
{Port,{exit_status,ExitCode}} ->
- iolist_to_binary([Res,"ExitCode:"++integer_to_list(ExitCode)])
+ s2b([Res,"ExitCode:"++integer_to_list(ExitCode)])
end.
get_data(Port, SoFar) ->
@@ -2537,3 +2640,9 @@ expected_output([], _) ->
[];
expected_output(Bin, _) when is_binary(Bin) ->
Bin.
+
+%% Convert the given list to a binary with the same encoding as the
+%% file name translation mode
+s2b(List) ->
+ Enc = file:native_name_encoding(),
+ unicode:characters_to_binary(List,Enc,Enc).
diff --git a/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl
index b6c71c666d..c315f926d3 100644
--- a/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl
+++ b/lib/reltool/test/reltool_server_SUITE_data/escript/someapp-1.0/src/mymod.erl
@@ -22,5 +22,6 @@
%%%-----------------------------------------------------------------
%%% escript main function
main(Args) ->
+ io:format("Module: ~w\n", [?MODULE]),
io:format("Root dir: ~s\n", [code:root_dir()]),
io:format("Script args: ~p\n", [Args]).
diff --git a/lib/reltool/test/reltool_server_SUITE_data/unicode/ua-1.0/ebin/ua.app b/lib/reltool/test/reltool_server_SUITE_data/unicode/ua-1.0/ebin/ua.app
new file mode 100644
index 0000000000..6f571b7179
--- /dev/null
+++ b/lib/reltool/test/reltool_server_SUITE_data/unicode/ua-1.0/ebin/ua.app
@@ -0,0 +1,7 @@
+% -*- coding: utf-8 -*-
+{application, ua,
+ [{description, "Application for testing unicode in reltool - αβ"},
+ {vsn, "1.0"},
+ {modules,[]},
+ {registered, []},
+ {applications, [kernel, stdlib]}]}.
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl
index 1ff3eb96eb..c1b715b970 100644
--- a/lib/sasl/src/release_handler.erl
+++ b/lib/sasl/src/release_handler.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -41,7 +41,8 @@
%% Internal exports, a client release_handler may call this functions.
-export([do_write_release/3, do_copy_file/2, do_copy_files/2,
do_copy_files/1, do_rename_files/1, do_remove_files/1,
- remove_file/1, do_write_file/2, do_ensure_RELEASES/1]).
+ remove_file/1, do_write_file/2, do_write_file/3,
+ do_ensure_RELEASES/1]).
-record(state, {unpurged = [],
root,
@@ -254,7 +255,7 @@ check_timeout(_Else) -> false.
new_emulator_upgrade(Vsn, Opts) ->
Result = call({install_release, Vsn, reboot, Opts}),
error_logger:info_msg(
- "~p:install_release(~p,~p) completed after node restart "
+ "~w:install_release(~p,~p) completed after node restart "
"with new emulator version~nResult: ~p~n",[?MODULE,Vsn,Opts,Result]),
Result.
@@ -1128,7 +1129,7 @@ new_emulator_make_hybrid_config(CurrentVsn,ToVsn,TmpVsn,RelDir,Masters) ->
{ok,[FC]} ->
FC;
{error,Error1} ->
- io:format("Warning: ~p can not read ~p: ~p~n",
+ io:format("Warning: ~w can not read ~p: ~p~n",
[?MODULE,FromFile,Error1]),
[]
end,
@@ -1138,7 +1139,7 @@ new_emulator_make_hybrid_config(CurrentVsn,ToVsn,TmpVsn,RelDir,Masters) ->
{ok,[ToConfig]} ->
[lists:keyfind(App,1,ToConfig) || App <- [kernel,stdlib,sasl]];
{error,Error2} ->
- io:format("Warning: ~p can not read ~p: ~p~n",
+ io:format("Warning: ~w can not read ~p: ~p~n",
[?MODULE,ToFile,Error2]),
[false,false,false]
end,
@@ -1597,7 +1598,9 @@ remove_file(File) ->
end.
do_write_file(File, Str) ->
- case file:open(File, [write]) of
+ do_write_file(File, Str, []).
+do_write_file(File, Str, FileOpts) ->
+ case file:open(File, [write | FileOpts]) of
{ok, Fd} ->
io:put_chars(Fd, Str),
file:close(Fd),
diff --git a/lib/sasl/src/release_handler_1.erl b/lib/sasl/src/release_handler_1.erl
index 93d12cf609..b37ae2f944 100644
--- a/lib/sasl/src/release_handler_1.erl
+++ b/lib/sasl/src/release_handler_1.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -624,7 +624,7 @@ get_proc_state(Proc) ->
maybe_supervisor_which_children(suspended, Name, Pid) ->
error_logger:error_msg("release_handler: a which_children call"
- " to ~p (~p) was avoided. This supervisor"
+ " to ~p (~w) was avoided. This supervisor"
" is suspended and should likely be upgraded"
" differently. Exiting ...~n", [Name, Pid]),
error(suspended_supervisor);
@@ -635,7 +635,7 @@ maybe_supervisor_which_children(State, Name, Pid) ->
Res;
Other ->
error_logger:error_msg("release_handler: ~p~nerror during"
- " a which_children call to ~p (~p)."
+ " a which_children call to ~p (~w)."
" [State: ~p] Exiting ... ~n",
[Other, Name, Pid, State]),
error(which_children_failed)
@@ -647,7 +647,7 @@ maybe_get_dynamic_mods(Name, Pid) ->
Res;
Other ->
error_logger:error_msg("release_handler: ~p~nerror during a"
- " get_modules call to ~p (~p),"
+ " get_modules call to ~p (~w),"
" there may be an error in it's"
" childspec. Exiting ...~n",
[Other, Name, Pid]),
diff --git a/lib/sasl/src/systools_lib.erl b/lib/sasl/src/systools_lib.erl
index 1b6ea125d9..6618baa2aa 100644
--- a/lib/sasl/src/systools_lib.erl
+++ b/lib/sasl/src/systools_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -42,7 +42,11 @@ file_term2binary(FileIn, FileOut) ->
%%______________________________________________________________________
%% read_term(File) -> {ok, Term} | Error
-
+%%
+%% This is really an own implementation of file:consult/1, except it
+%% returns one term and not a list of terms. Keeping the function
+%% instead of using file:consult - for backwards compatibility with
+%% error reasons.
read_term(File) ->
case file:open(File, [read]) of
{ok, Stream} ->
@@ -54,6 +58,7 @@ read_term(File) ->
end.
read_term_from_stream(Stream, File) ->
+ _ = epp:set_encoding(Stream),
R = io:request(Stream, {get_until,'',erl_scan,tokens,[1]}),
case R of
{ok,Toks,_EndLine} ->
@@ -176,11 +181,11 @@ add_dirs(RegName, Dirs, Root) ->
regexp_match(RegName, D0, Root) ->
case file:list_dir(D0) of
{ok, Files} when length(Files) > 0 ->
- case re:compile(RegName) of
+ case re:compile(RegName,[unicode]) of
{ok, MP} ->
FR = fun(F) ->
- case re:run(F, MP) of
- {match,[{0,N}]} when N == length(F) ->
+ case re:run(F, MP, [{capture,first,list}]) of
+ {match,[F]} -> % All of F matches
DirF = join(D0, F, Root),
case dir_p(DirF) of
true ->
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl
index 9b2e2c809b..193dbb64bf 100644
--- a/lib/sasl/src/systools_make.erl
+++ b/lib/sasl/src/systools_make.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -156,10 +156,10 @@ return(ok,Warnings,Flags) ->
_ ->
case member(warnings_as_errors,Flags) of
true ->
- io:format("~s",[format_warning(Warnings, true)]),
+ io:format("~ts",[format_warning(Warnings, true)]),
error;
false ->
- io:format("~s",[format_warning(Warnings)]),
+ io:format("~ts",[format_warning(Warnings)]),
ok
end
end;
@@ -168,7 +168,7 @@ return({error,Mod,Error},_,Flags) ->
true ->
{error,Mod,Error};
_ ->
- io:format("~s",[Mod:format_error(Error)]),
+ io:format("~ts",[Mod:format_error(Error)]),
error
end.
@@ -1970,17 +1970,11 @@ is_app_type(_) -> false.
% check if a term is a string.
-string_p([H|T]) when is_integer(H), H >= $ , H < 255 ->
- string_p(T);
-string_p([$\n|T]) -> string_p(T);
-string_p([$\r|T]) -> string_p(T);
-string_p([$\t|T]) -> string_p(T);
-string_p([$\v|T]) -> string_p(T);
-string_p([$\b|T]) -> string_p(T);
-string_p([$\f|T]) -> string_p(T);
-string_p([$\e|T]) -> string_p(T);
-string_p([]) -> true;
-string_p(_) -> false.
+string_p(S) ->
+ case unicode:characters_to_list(S) of
+ S -> true;
+ _ -> false
+ end.
% check if a term is a list of two tuples with the first
% element as an atom.
@@ -2203,31 +2197,31 @@ format_error({illegal_applications,Names}) ->
io_lib:format("Illegal applications in the release file: ~p~n",
[Names]);
format_error({missing_mandatory_app,Name}) ->
- io_lib:format("Mandatory application ~p must be specified in the release file~n",
+ io_lib:format("Mandatory application ~w must be specified in the release file~n",
[Name]);
format_error({mandatory_app,Name,Type}) ->
- io_lib:format("Mandatory application ~p must be of type 'permanent' in the release file. Is '~p'.~n",
+ io_lib:format("Mandatory application ~w must be of type 'permanent' in the release file. Is '~p'.~n",
[Name,Type]);
format_error({duplicate_register,Dups}) ->
- io_lib:format("Duplicated register names: ~n~s",
+ io_lib:format("Duplicated register names: ~n~ts",
[map(fun({{Reg,App1,_,_},{Reg,App2,_,_}}) ->
- io_lib:format("\t~p registered in ~p and ~p~n",
+ io_lib:format("\t~w registered in ~w and ~w~n",
[Reg,App1,App2])
end, Dups)]);
format_error({undefined_applications,Apps}) ->
io_lib:format("Undefined applications: ~p~n",[Apps]);
format_error({duplicate_modules,Dups}) ->
- io_lib:format("Duplicated modules: ~n~s",
+ io_lib:format("Duplicated modules: ~n~ts",
[map(fun({{Mod,_,App1,_,_},{Mod,_,App2,_,_}}) ->
- io_lib:format("\t~p specified in ~p and ~p~n",
+ io_lib:format("\t~w specified in ~w and ~w~n",
[Mod,App1,App2])
end, Dups)]);
format_error({included_and_used, Dups}) ->
io_lib:format("Applications both used and included: ~p~n",[Dups]);
format_error({duplicate_include, Dups}) ->
- io_lib:format("Duplicated application included: ~n~s",
+ io_lib:format("Duplicated application included: ~n~ts",
[map(fun({{Name,App1,_,_},{Name,App2,_,_}}) ->
- io_lib:format("\t~p included in ~p and ~p~n",
+ io_lib:format("\t~w included in ~w and ~w~n",
[Name,App1,App2])
end, Dups)]);
format_error({modules,ModErrs}) ->
@@ -2238,11 +2232,11 @@ format_error({not_found,File}) ->
io_lib:format("File not found: ~p~n",[File]);
format_error({parse,File,{Line,Mod,What}}) ->
Str = Mod:format_error(What),
- io_lib:format("~s:~p: ~s\n",[File, Line, Str]);
+ io_lib:format("~ts:~w: ~ts\n",[File, Line, Str]);
format_error({read,File}) ->
io_lib:format("Cannot read ~p~n",[File]);
format_error({open,File,Error}) ->
- io_lib:format("Cannot open ~p - ~s~n",
+ io_lib:format("Cannot open ~p - ~ts~n",
[File,file:format_error(Error)]);
format_error({tar_error,What}) ->
form_tar_err(What);
@@ -2258,24 +2252,21 @@ format_errors(ListOfErrors) ->
form_err({bad_application_name,{Name,Found}}) ->
io_lib:format("~p: Mismatched application id: ~p~n",[Name,Found]);
form_err({error_reading, {Name, What}}) ->
- io_lib:format("~p: ~s~n",[Name,form_reading(What)]);
+ io_lib:format("~p: ~ts~n",[Name,form_reading(What)]);
form_err({module_not_found,App,Mod}) ->
- io_lib:format("~p: Module (~p) not found~n",[App,Mod]);
-form_err({{vsn_diff,File},{Mod,Vsn,App,_,_}}) ->
- io_lib:format("~p: Module (~p) version (~p) differs in file ~p~n",
- [App,Mod,Vsn,File]);
+ io_lib:format("~w: Module (~w) not found~n",[App,Mod]);
form_err({error_add_appl, {Name, {tar_error, What}}}) ->
- io_lib:format("~p: ~s~n",[Name,form_tar_err(What)]);
+ io_lib:format("~p: ~ts~n",[Name,form_tar_err(What)]);
form_err(E) ->
io_lib:format("~p~n",[E]).
form_reading({not_found,File}) ->
io_lib:format("File not found: ~p~n",[File]);
form_reading({application_vsn, {Name,Vsn}}) ->
- io_lib:format("Application ~s with version ~p not found~n",[Name, Vsn]);
+ io_lib:format("Application ~ts with version ~p not found~n",[Name, Vsn]);
form_reading({parse,File,{Line,Mod,What}}) ->
Str = Mod:format_error(What),
- io_lib:format("~s:~p: ~s\n",[File, Line, Str]);
+ io_lib:format("~ts:~w: ~ts\n",[File, Line, Str]);
form_reading({read,File}) ->
io_lib:format("Cannot read ~p~n",[File]);
form_reading({{bad_param, P},_}) ->
@@ -2291,15 +2282,15 @@ form_reading({no_valid_version, {{_, SVsn}, {_, File, FVsn}}}) ->
io_lib:format("No valid version (~p) of .app file found. Found file ~p with version ~p~n",
[SVsn, File, FVsn]);
form_reading({parse_error, {File, Line, Error}}) ->
- io_lib:format("Parse error in file: ~p. Line: ~p Error: ~p; ~n", [File, Line, Error]);
+ io_lib:format("Parse error in file: ~p. Line: ~w Error: ~p; ~n", [File, Line, Error]);
form_reading(W) ->
io_lib:format("~p~n",[W]).
form_tar_err({open, File, Error}) ->
- io_lib:format("Cannot open tar file ~s - ~p~n",
+ io_lib:format("Cannot open tar file ~ts - ~ts~n",
[File, erl_tar:format_error(Error)]);
form_tar_err({add, File, Error}) ->
- io_lib:format("Cannot add file ~s to tar file - ~s~n",
+ io_lib:format("Cannot add file ~ts to tar file - ~ts~n",
[File, erl_tar:format_error(Error)]).
%% Format warning
@@ -2317,23 +2308,23 @@ format_warning(Warnings, Werror) ->
map(fun({warning,W}) -> form_warn(Prefix, W) end, Warnings).
form_warn(Prefix, {source_not_found,{Mod,_,App,_,_}}) ->
- io_lib:format("~s~p: Source code not found: ~p.erl~n",
+ io_lib:format("~ts~w: Source code not found: ~w.erl~n",
[Prefix,App,Mod]);
form_warn(Prefix, {{parse_error, File},{_,_,App,_,_}}) ->
- io_lib:format("~s~p: Parse error: ~p~n",
+ io_lib:format("~ts~w: Parse error: ~p~n",
[Prefix,App,File]);
form_warn(Prefix, {obj_out_of_date,{Mod,_,App,_,_}}) ->
- io_lib:format("~s~p: Object code (~p) out of date~n",
+ io_lib:format("~ts~w: Object code (~w) out of date~n",
[Prefix,App,Mod]);
form_warn(Prefix, {exref_undef, Undef}) ->
F = fun({M,F,A}) ->
- io_lib:format("~sUndefined function ~p:~p/~p~n",
+ io_lib:format("~tsUndefined function ~w:~w/~w~n",
[Prefix,M,F,A])
end,
map(F, Undef);
form_warn(Prefix, missing_sasl) ->
- io_lib:format("~s: Missing application sasl. "
+ io_lib:format("~ts: Missing application sasl. "
"Can not upgrade with this release~n",
[Prefix]);
form_warn(Prefix, What) ->
- io_lib:format("~s ~p~n", [Prefix,What]).
+ io_lib:format("~ts ~p~n", [Prefix,What]).
diff --git a/lib/sasl/src/systools_rc.erl b/lib/sasl/src/systools_rc.erl
index cf5cca7cb3..54c327410d 100644
--- a/lib/sasl/src/systools_rc.erl
+++ b/lib/sasl/src/systools_rc.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -904,7 +904,7 @@ format_error({bad_op_before_point_of_no_return, Instruction}) ->
io_lib:format("Bad instruction ~p~nbefore point_of_no_return~n",
[Instruction]);
format_error({no_object_code, Mod}) ->
- io_lib:format("No load_object_code found for module: ~p~n", [Mod]);
+ io_lib:format("No load_object_code found for module: ~w~n", [Mod]);
format_error({suspended_not_resumed, Mods}) ->
io_lib:format("Suspended but not resumed: ~p~n", [Mods]);
format_error({resumed_not_suspended, Mods}) ->
@@ -916,19 +916,19 @@ format_error({start_not_stop, Mods}) ->
format_error({stop_not_start, Mods}) ->
io_lib:format("Stopped but not started: ~p~n", [Mods]);
format_error({no_such_application, App}) ->
- io_lib:format("Started undefined application: ~p~n", [App]);
+ io_lib:format("Started undefined application: ~w~n", [App]);
format_error({removed_application_present, App}) ->
- io_lib:format("Removed application present: ~p~n", [App]);
+ io_lib:format("Removed application present: ~w~n", [App]);
format_error(dup_mnesia_backup) ->
io_lib:format("Duplicate mnesia_backup~n", []);
format_error(bad_mnesia_backup) ->
io_lib:format("mnesia_backup in bad position~n", []);
format_error({conflicting_versions, Lib, V1, V2}) ->
- io_lib:format("Conflicting versions for ~p, ~p and ~p~n", [Lib, V1, V2]);
+ io_lib:format("Conflicting versions for ~w, ~ts and ~ts~n", [Lib, V1, V2]);
format_error({no_appl_vsn, Appl}) ->
- io_lib:format("No version specified for application: ~p~n", [Appl]);
+ io_lib:format("No version specified for application: ~w~n", [Appl]);
format_error({no_such_module, Mod}) ->
- io_lib:format("No such module: ~p~n", [Mod]);
+ io_lib:format("No such module: ~w~n", [Mod]);
format_error(too_many_point_of_no_return) ->
io_lib:format("Too many point_of_no_return~n", []);
diff --git a/lib/sasl/src/systools_relup.erl b/lib/sasl/src/systools_relup.erl
index 7048184426..716dc2b5ff 100644
--- a/lib/sasl/src/systools_relup.erl
+++ b/lib/sasl/src/systools_relup.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -494,21 +494,18 @@ get_script_from_appup(Mode, TopApp, BaseVsn, Ws, RUs) ->
throw({error, ?MODULE, {no_relup, FName, TopApp, BaseVsn}})
end.
-appup_search_for_version(BaseVsn, VsnRUs) ->
- appup_search_for_version(BaseVsn, length(BaseVsn), VsnRUs).
-
-appup_search_for_version(BaseVsn,_,[{BaseVsn,RU}|_]) ->
+appup_search_for_version(BaseVsn,[{BaseVsn,RU}|_]) ->
{ok,RU};
-appup_search_for_version(BaseVsn,Size,[{Vsn,RU}|VsnRUs]) when is_binary(Vsn) ->
- case re:run(BaseVsn,Vsn,[unicode,{capture,first,index}]) of
- {match,[{0,Size}]} ->
+appup_search_for_version(BaseVsn,[{Vsn,RU}|VsnRUs]) when is_binary(Vsn) ->
+ case re:run(BaseVsn,Vsn,[unicode,{capture,first,list}]) of
+ {match,[BaseVsn]} ->
{ok, RU};
_ ->
- appup_search_for_version(BaseVsn,Size,VsnRUs)
+ appup_search_for_version(BaseVsn,VsnRUs)
end;
-appup_search_for_version(BaseVsn,Size,[_|VsnRUs]) ->
- appup_search_for_version(BaseVsn,Size,VsnRUs);
-appup_search_for_version(_,_,[]) ->
+appup_search_for_version(BaseVsn,[_|VsnRUs]) ->
+ appup_search_for_version(BaseVsn,VsnRUs);
+appup_search_for_version(_,[]) ->
error.
@@ -603,14 +600,15 @@ print_error(Other) ->
format_error({file_problem, {"relup", _Posix}}) ->
io_lib:format("Could not open file relup~n", []);
format_error({file_problem, {File, What}}) ->
- io_lib:format("Could not ~p file ~p~n", [get_reason(What), File]);
+ io_lib:format("Could not ~w file ~ts~n", [get_reason(What), File]);
format_error({no_relup, File, App, Vsn}) ->
- io_lib:format("No release upgrade script entry for ~p-~s to ~p-~s "
- "in file ~p~n",
+ io_lib:format("No release upgrade script entry for ~w-~ts to ~w-~ts "
+ "in file ~ts~n",
[App#application.name, App#application.vsn,
App#application.name, Vsn, File]);
format_error({missing_sasl,Release}) ->
- io_lib:format("No sasl application in release ~p, ~p. Can not be upgraded.",
+ io_lib:format("No sasl application in release ~ts, ~ts. "
+ "Can not be upgraded.",
[Release#release.name, Release#release.vsn]);
format_error(Error) ->
io:format("~p~n", [Error]).
@@ -629,16 +627,16 @@ print_warning(W, Opts) ->
"*WARNING* "
end,
S = format_warning(Prefix, W),
- io:format("~s", [S]).
+ io:format("~ts", [S]).
format_warning(W) ->
format_warning("*WARNING* ", W).
format_warning(Prefix, {erts_vsn_changed, {Rel1, Rel2}}) ->
- io_lib:format("~sThe ERTS version changed between ~p and ~p~n",
+ io_lib:format("~tsThe ERTS version changed between ~p and ~p~n",
[Prefix, Rel1, Rel2]);
format_warning(Prefix, What) ->
- io_lib:format("~s~p~n",[Prefix, What]).
+ io_lib:format("~ts~p~n",[Prefix, What]).
get_reason({error, {open, _, _}}) -> open;
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl
index 878d582e6b..367cab1d77 100644
--- a/lib/sasl/test/systools_SUITE.erl
+++ b/lib/sasl/test/systools_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2012. All Rights Reserved.
+%% Copyright Ericsson AB 2012-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -40,7 +40,8 @@
-export([all/0,suite/0,groups/0,init_per_group/2,end_per_group/2]).
--export([script_options/1, normal_script/1, no_mod_vsn_script/1,
+-export([script_options/1, normal_script/1, unicode_script/1,
+ unicode_script/2, no_mod_vsn_script/1,
wildcard_script/1, variable_script/1, no_sasl_script/1,
abnormal_script/1, src_tests_script/1, crazy_script/1,
included_script/1, included_override_script/1,
@@ -75,7 +76,7 @@ all() ->
groups() ->
[{script, [],
- [script_options, normal_script, no_mod_vsn_script,
+ [script_options, normal_script, unicode_script, no_mod_vsn_script,
wildcard_script, variable_script, abnormal_script,
no_sasl_script, src_tests_script, crazy_script,
included_script, included_override_script,
@@ -250,6 +251,62 @@ normal_script(Config) when is_list(Config) ->
ok.
+%% make_script: Test make_script with unicode .app file
+unicode_script(Config) when is_list(Config) ->
+ UnicodeStr = [945,946], % alhpa beta in greek letters
+
+ {LatestDir, LatestName} = create_script({unicode,UnicodeStr},Config),
+
+ DataDir = filename:absname(?copydir),
+ UnicodeApp = fname([DataDir, "d_unicode", "lib", "ua-1.0"]),
+ TarFile = fname(?privdir, "unicode_app.tgz"),
+ {ok, Tar} = erl_tar:open(TarFile, [write, compressed]),
+ ok = erl_tar:add(Tar, UnicodeApp, "ua-1.0", [compressed]),
+ ok = erl_tar:close(Tar),
+
+ UnicodeLibDir = fname([DataDir, "d_unicode", UnicodeStr]),
+ P1 = fname([UnicodeLibDir, "ua-1.0", "ebin"]),
+
+ %% Need to do this on a separate node to make sure it has unicode
+ %% filename mode (+fnu*)
+ {ok,HostStr} = inet:gethostname(),
+ Host = list_to_atom(HostStr),
+ {ok,Node} = ct_slave:start(Host,unicode_script_node,[{erl_flags,"+fnui"}]),
+
+ ok = rpc:call(Node,erl_tar,extract,
+ [TarFile, [{cwd,UnicodeLibDir},compressed]]),
+
+ true = rpc:call(Node,code,add_patha,[P1]),
+
+ ok = rpc:call(Node,file,set_cwd,[LatestDir]),
+
+ ok = rpc:call(Node,systools,make_script,[filename:basename(LatestName),
+ [local]]),
+
+ {ok, Script} = rpc:call(Node,file,consult,[LatestName++".script"]),
+
+ %% For debug purpose - print script to log
+ io:format("~tp~n",[Script]),
+
+ %% check that script contains unicode strings in
+ %% 1. release version (set in ?MODULE:do_create_script)
+ [{script,{"Test release",UnicodeStr},Instr}] = Script,
+
+ %% 2. application description (set in ua.app in data dir)
+ [AppInfo] = [X || {apply,{application,load,[{application,ua,X}]}} <- Instr],
+ {description,UnicodeStr} = lists:keyfind(description,1,AppInfo),
+
+ %% 3. path (directory name where unicode_app.tgz is extracted)
+ true = lists:member({path,[P1]},Instr),
+
+ ok.
+
+unicode_script(cleanup,Config) ->
+ _ = ct_slave:stop(unicode_script_node),
+ file:delete(fname(?privdir, "unicode_app.tgz")),
+ ok.
+
+
%% make_script:
%% Modules specified without version in .app file (db-3.1).
%% Note that this is now the normal way - i.e. systools now ignores
@@ -2090,15 +2147,20 @@ create_script(current_all_future_erts,Config) ->
do_create_script(current_all_future_erts,Config,"99.99",Apps);
create_script(current_all_future_sasl,Config) ->
Apps = [{kernel,current},{stdlib,current},{sasl,"9.9"},{db,"2.1"},{fe,"3.1"}],
- do_create_script(current_all_future_sasl,Config,current,Apps).
+ do_create_script(current_all_future_sasl,Config,current,Apps);
+create_script({unicode,RelVsn},Config) ->
+ Apps = core_apps(current) ++ [{ua,"1.0"}],
+ do_create_script(unicode,RelVsn,Config,current,Apps).
do_create_script(Id,Config,ErtsVsn,AppVsns) ->
+ do_create_script(Id,string:to_upper(atom_to_list(Id)),Config,ErtsVsn,AppVsns).
+do_create_script(Id,RelVsn,Config,ErtsVsn,AppVsns) ->
PrivDir = ?privdir,
Name = fname(PrivDir, Id),
{ok,Fd} = file:open(Name++".rel",write),
RelfileContent =
- {release,{"Test release", string:to_upper(atom_to_list(Id))},
+ {release,{"Test release", RelVsn},
{erts,erts_vsn(ErtsVsn)},
app_vsns(AppVsns)},
io:format(Fd,"~p.~n",[RelfileContent]),
diff --git a/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/ebin/ua.app b/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/ebin/ua.app
new file mode 100644
index 0000000000..3d38a3dde4
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/ebin/ua.app
@@ -0,0 +1,9 @@
+%% -*- coding: utf-8 -*-
+{application, ua,
+ [{description, "αβ"},
+ {vsn, "1.0"},
+ {modules, [ua1]},
+ {registered, []},
+ {applications, []},
+ {env, []},
+ {start, {ua1, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/src/ua1.erl b/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/src/ua1.erl
new file mode 100644
index 0000000000..e988e80f3d
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_unicode/lib/ua-1.0/src/ua1.erl
@@ -0,0 +1,2 @@
+-module(ua1).
+-vsn("1.0").
diff --git a/lib/ssl/doc/src/ssl.xml b/lib/ssl/doc/src/ssl.xml
index ab468c8d6b..6979fb5b5e 100644
--- a/lib/ssl/doc/src/ssl.xml
+++ b/lib/ssl/doc/src/ssl.xml
@@ -278,11 +278,18 @@ fun(OtpCert :: #'OTPCertificate'{}, Event :: {bad_cert, Reason :: atom()} |
<p> {bad_cert, cert_expired}, {bad_cert, invalid_issuer}, {bad_cert, invalid_signature}, {bad_cert, unknown_ca},{bad_cert, selfsigned_peer}, {bad_cert, name_not_permitted}, {bad_cert, missing_basic_constraint}, {bad_cert, invalid_key_usage}</p>
</item>
+ <tag>{versions, [protocol()]}</tag>
+ <item>TLS protocol versions that will be supported by started clients and servers.
+ This option overrides the application environment option <c>protocol_version</c>. If the
+ environment option is not set it defaults to all versions supported by the SSL application. See also
+ <seealso marker="ssl:ssl_app">ssl(6)</seealso>
+ </item>
+
<tag>{hibernate_after, integer()|undefined}</tag>
- <item>When an integer-value is specified, the <code>ssl_connection</code>
+ <item>When an integer-value is specified, the <c>ssl_connection</c>
will go into hibernation after the specified number of milliseconds
of inactivity, thus reducing its memory footprint. When
- <code>undefined</code> is specified (this is the default), the process
+ <c>undefined</c> is specified (this is the default), the process
will never go into hibernation.
</item>
</taglist>
diff --git a/lib/ssl/doc/src/ssl_app.xml b/lib/ssl/doc/src/ssl_app.xml
index 84ad483617..0ee5b23e47 100644
--- a/lib/ssl/doc/src/ssl_app.xml
+++ b/lib/ssl/doc/src/ssl_app.xml
@@ -41,8 +41,9 @@
<section>
<title>ENVIRONMENT</title>
<p>The following application environment configuration parameters
- are defined for the SSL application. Refer to application(3) for
- more information about configuration parameters.
+ are defined for the SSL application. See <seealso
+ marker="kernel:application">application(3)</seealso>for more
+ information about configuration parameters.
</p>
<p>Note that the environment parameters can be set on the command line,
for instance,</p>
@@ -87,7 +88,7 @@
<section>
<title>SEE ALSO</title>
- <p>application(3)</p>
+ <p><seealso marker="kernel:application">application(3)</seealso></p>
</section>
</appref>
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 52b765f191..8f4fd88d42 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -987,7 +987,7 @@ handle_info({ErrorTag, Socket, econnaborted}, StateName,
#state{socket = Socket, transport_cb = Transport,
start_or_recv_from = StartFrom, role = Role,
error_tag = ErrorTag} = State) when StateName =/= connection ->
- alert_user(Transport, Socket, StartFrom, ?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE), Role),
+ alert_user(Transport, Socket, StartFrom, ?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), Role),
{stop, normal, State};
handle_info({ErrorTag, Socket, Reason}, StateName, #state{socket = Socket,
diff --git a/lib/ssl/test/ssl_packet_SUITE.erl b/lib/ssl/test/ssl_packet_SUITE.erl
index 158c40e372..4116bb39d1 100644
--- a/lib/ssl/test/ssl_packet_SUITE.erl
+++ b/lib/ssl/test/ssl_packet_SUITE.erl
@@ -55,6 +55,13 @@ all() ->
{group, 'sslv3'}
].
+groups() ->
+ [{'tlsv1.2', [], packet_tests()},
+ {'tlsv1.1', [], packet_tests()},
+ {'tlsv1', [], packet_tests()},
+ {'sslv3', [], packet_tests()}
+ ].
+
packet_tests() ->
active_packet_tests() ++ active_once_packet_tests() ++ passive_packet_tests() ++
[packet_send_to_large,
@@ -133,7 +140,6 @@ init_per_suite(Config) ->
try crypto:start() of
ok ->
application:start(public_key),
- ssl:start(),
Result =
(catch make_certs:all(?config(data_dir, Config),
?config(priv_dir, Config))),
@@ -184,7 +190,7 @@ packet_raw_passive_many_small() ->
packet_raw_passive_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, raw}",
- packet(Config, Data, send, passive_recv_packet, ?MANY, raw, false).
+ packet(Config, Data, send, passive_raw, ?MANY, raw, false).
%%--------------------------------------------------------------------
@@ -193,14 +199,14 @@ packet_raw_passive_some_big() ->
packet_raw_passive_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send, passive_recv_packet, ?SOME, raw, false).
+ packet(Config, Data, send, passive_raw, ?SOME, raw, false).
%%--------------------------------------------------------------------
packet_0_passive_many_small() ->
[{doc,"Test packet option {packet, 0} in passive mode."}].
packet_0_passive_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 0}, equivalent to packet raw.",
- packet(Config, Data, send, passive_recv_packet, ?MANY, 0, false).
+ packet(Config, Data, send, passive_raw, ?MANY, 0, false).
%%--------------------------------------------------------------------
packet_0_passive_some_big() ->
@@ -208,7 +214,7 @@ packet_0_passive_some_big() ->
packet_0_passive_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send, passive_recv_packet, ?SOME, 0, false).
+ packet(Config, Data, send, passive_raw, ?SOME, 0, false).
%%--------------------------------------------------------------------
packet_1_passive_many_small() ->
@@ -296,7 +302,7 @@ packet_1_active_once_many_small() ->
packet_1_active_once_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 1}",
- packet(Config, Data, send_raw, active_once_raw, ?MANY, 1, once).
+ packet(Config, Data, send, active_once_packet, ?MANY, 1, once).
%%--------------------------------------------------------------------
packet_1_active_once_some_big() ->
@@ -304,7 +310,7 @@ packet_1_active_once_some_big() ->
packet_1_active_once_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(255, "1")),
- packet(Config, Data, send_raw, active_once_raw, ?SOME, 1, once).
+ packet(Config, Data, send, active_once_packet, ?SOME, 1, once).
%%--------------------------------------------------------------------
@@ -313,7 +319,7 @@ packet_2_active_once_many_small() ->
packet_2_active_once_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 2}",
- packet(Config, Data, send_raw, active_once_raw, ?MANY, 2, once).
+ packet(Config, Data, send, active_once_packet, ?MANY, 2, once).
%%--------------------------------------------------------------------
packet_2_active_once_some_big() ->
@@ -321,7 +327,7 @@ packet_2_active_once_some_big() ->
packet_2_active_once_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_once_raw, ?SOME, 2, once).
+ packet(Config, Data, send, active_once_raw, ?SOME, 2, once).
%%--------------------------------------------------------------------
packet_4_active_once_many_small() ->
@@ -329,7 +335,7 @@ packet_4_active_once_many_small() ->
packet_4_active_once_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 4}",
- packet(Config, Data, send_raw, active_once_raw, ?MANY, 4, once).
+ packet(Config, Data, send, active_once_packet, ?MANY, 4, once).
%%--------------------------------------------------------------------
packet_4_active_once_some_big() ->
@@ -337,7 +343,7 @@ packet_4_active_once_some_big() ->
packet_4_active_once_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_once_raw, ?SOME, 4, once).
+ packet(Config, Data, send, active_once_packet, ?SOME, 4, once).
%%--------------------------------------------------------------------
packet_raw_active_many_small() ->
@@ -345,7 +351,7 @@ packet_raw_active_many_small() ->
packet_raw_active_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, raw}",
- packet(Config, Data, send_raw, active_raw, ?MANY, raw, active).
+ packet(Config, Data, send_raw, active_raw, ?MANY, raw, true).
%%--------------------------------------------------------------------
packet_raw_active_some_big() ->
@@ -353,7 +359,7 @@ packet_raw_active_some_big() ->
packet_raw_active_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_raw, ?SOME, raw, active).
+ packet(Config, Data, send_raw, active_raw, ?SOME, raw, true).
%%--------------------------------------------------------------------
packet_0_active_many_small() ->
@@ -361,7 +367,7 @@ packet_0_active_many_small() ->
packet_0_active_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 0}",
- packet(Config, Data, send_raw, active_raw, ?MANY, 0, active).
+ packet(Config, Data, send_raw, active_raw, ?MANY, 0, true).
%%--------------------------------------------------------------------
packet_0_active_some_big() ->
@@ -369,7 +375,7 @@ packet_0_active_some_big() ->
packet_0_active_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_raw, ?SOME, 0, active).
+ packet(Config, Data, send, active_raw, ?SOME, 0, true).
%%--------------------------------------------------------------------
packet_1_active_many_small() ->
@@ -377,7 +383,7 @@ packet_1_active_many_small() ->
packet_1_active_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 1}",
- packet(Config, Data, send_raw, active_raw, ?MANY, 1, active).
+ packet(Config, Data, send, active_packet, ?MANY, 1, true).
%%--------------------------------------------------------------------
packet_1_active_some_big() ->
@@ -385,7 +391,7 @@ packet_1_active_some_big() ->
packet_1_active_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(255, "1")),
- packet(Config, Data, send_raw, active_raw, ?SOME, 1, active).
+ packet(Config, Data, send, active_packet, ?SOME, 1, true).
%%--------------------------------------------------------------------
packet_2_active_many_small() ->
@@ -393,7 +399,7 @@ packet_2_active_many_small() ->
packet_2_active_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 2}",
- packet(Config, Data, send_raw, active_raw, ?MANY, 2, active).
+ packet(Config, Data, send, active_packet, ?MANY, 2, true).
%%--------------------------------------------------------------------
packet_2_active_some_big() ->
@@ -401,7 +407,7 @@ packet_2_active_some_big() ->
packet_2_active_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_raw, ?SOME, 2, active).
+ packet(Config, Data, send, active_packet, ?SOME, 2, true).
%%--------------------------------------------------------------------
packet_4_active_many_small() ->
@@ -409,7 +415,7 @@ packet_4_active_many_small() ->
packet_4_active_many_small(Config) when is_list(Config) ->
Data = "Packet option is {packet, 4}",
- packet(Config, Data, send_raw, active_raw, ?MANY, 4, active).
+ packet(Config, Data, send, active_packet, ?MANY, 4, true).
%%--------------------------------------------------------------------
packet_4_active_some_big() ->
@@ -417,7 +423,7 @@ packet_4_active_some_big() ->
packet_4_active_some_big(Config) when is_list(Config) ->
Data = lists:append(lists:duplicate(100, "1234567890")),
- packet(Config, Data, send_raw, active_raw, ?SOME, 4, active).
+ packet(Config, Data, send, active_packet, ?SOME, 4, true).
%%--------------------------------------------------------------------
packet_send_to_large() ->
@@ -1879,7 +1885,7 @@ packet(Config, Data, Send, Recv, Quantity, Packet, Active) ->
Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0},
{from, self()},
{mfa, {?MODULE, Send ,[Data, Quantity]}},
- {options, ServerOpts}]),
+ {options, [{packet, Packet} | ServerOpts]}]),
Port = ssl_test_lib:inet_port(Server),
Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port},
{host, Hostname},
diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl
index d58541df52..76b302b1cb 100644
--- a/lib/ssl/test/ssl_test_lib.erl
+++ b/lib/ssl/test/ssl_test_lib.erl
@@ -203,67 +203,6 @@ close(Pid) ->
ct:print("Pid: ~p down due to:~p ~n", [Pid, Reason])
end.
-
-check_result(Server, {error, SReason} = ServerMsg, Client, {error, closed} = ClientMsg) ->
- receive
- {Server, {error, SReason}} ->
- receive
- {Client, ClientMsg} ->
- ok;
- Unexpected ->
- Reason = {{expected, {Client, ClientMsg}},
- {got, Unexpected}},
- ct:fail(Reason)
- end;
- {Client, ClientMsg} ->
- receive
- {Server, {error, {SReason, _}}} ->
- ok;
- Unexpected ->
- Reason = {{expected, {Server,{error, {SReason, 'term()'}}},
- {got, Unexpected}}},
- ct:fail(Reason)
- end;
- {Port, {data,Debug}} when is_port(Port) ->
- io:format("openssl ~s~n",[Debug]),
- check_result(Server, ServerMsg, Client, ClientMsg);
-
- Unexpected ->
- Reason = {{expected, {Client, ClientMsg}},
- {expected, {Server, {error, {SReason, 'term()'}}}, {got, Unexpected}}},
- ct:fail(Reason)
- end;
-
-check_result(Server, {error, closed} = ServerMsg, Client, {error, CReson} = ClientMsg) ->
- receive
- {Server, ServerMsg} ->
- receive
- {Client, {error, {CReson, _}}} ->
- ok;
- Unexpected ->
- Reason = {{expected, {Client, {error, {CReson, 'term()'}}},
- {got, Unexpected}}},
- ct:fail(Reason)
- end;
- {Client, {error, {CReson, _}}} ->
- receive
- {Server, ServerMsg} ->
- ok;
- Unexpected ->
- Reason = {{expected, {Server, ServerMsg}},
- {got, Unexpected}},
- ct:fail(Reason)
- end;
- {Port, {data,Debug}} when is_port(Port) ->
- io:format("openssl ~s~n",[Debug]),
- check_result(Server, ServerMsg, Client, ClientMsg);
-
- Unexpected ->
- Reason = {{expected, {Client, {error, {CReson, 'term()'}}},
- {expected, {Server, ServerMsg}}, {got, Unexpected}}},
- ct:fail(Reason)
- end;
-
check_result(Server, ServerMsg, Client, ClientMsg) ->
receive
{Server, ServerMsg} ->
@@ -294,22 +233,6 @@ check_result(Server, ServerMsg, Client, ClientMsg) ->
ct:fail(Reason)
end.
-check_result(Pid, {error, Reason} = Err) when Reason == ecertfile;
- Reason == ecacertfile;
- Reason == ekeyfile;
- Reason == edhfile ->
- receive
- {Pid, {error, {Reason, Str}}} when is_list(Str) ->
- ok;
- {Port, {data,Debug}} when is_port(Port) ->
- io:format("openssl ~s~n",[Debug]),
- check_result(Pid, Err);
- Unexpected ->
- Reason = {{expected, {Pid, {error, {Reason, "'appropriate error string'"}}}},
- {got, Unexpected}},
- ct:fail(Reason)
- end;
-
check_result(Pid, Msg) ->
receive
{Pid, Msg} ->
diff --git a/lib/stdlib/doc/src/filelib.xml b/lib/stdlib/doc/src/filelib.xml
index ac67596f3c..bd780b2b2f 100644
--- a/lib/stdlib/doc/src/filelib.xml
+++ b/lib/stdlib/doc/src/filelib.xml
@@ -36,8 +36,9 @@
<description>
<p>This module contains utilities on a higher level than the <c>file</c>
module.</p>
- <p>The module supports Unicode file names, so that it will match against regular expressions given in Unicode and that it will find and process raw file names (i.e. files named in a way that does not confirm to the expected encoding).</p>
- <p>If the VM operates in Unicode file naming mode on a machine with transparent file naming, the <c>fun()</c> provided to <c>fold_files/5</c> needs to be prepared to handle binary file names.</p>
+ <p>This module does not support "raw" file names (i.e. files whose names
+ do not comply with the expected encoding). Such files will be ignored
+ by the functions in this module.</p>
<p>For more information about raw file names, see the <seealso marker="kernel:file">file</seealso> module.</p>
</description>
diff --git a/lib/stdlib/doc/src/io.xml b/lib/stdlib/doc/src/io.xml
index 63f814ad2e..90f24c4cbc 100644
--- a/lib/stdlib/doc/src/io.xml
+++ b/lib/stdlib/doc/src/io.xml
@@ -211,6 +211,18 @@
</desc>
</func>
<func>
+ <name name="printable_range" arity="0"/>
+ <fsummary>Get user requested printable character range</fsummary>
+ <desc>
+ <p>Return the user requested range of printable Unicode characters.</p>
+ <p>The user can request a range of characters that are to be considered printable in heuristic detection of strings by the shell and by the formatting functions. This is done by supplying <c>+pc &lt;range&gt;</c> when starting Erlang.</p>
+ <p>Currently the only valid values for <c>&lt;range&gt;</c> are <c>latin1</c> and <c>unicode</c>. <c>latin1</c> means that only code points below 256 (with the exception of control characters etc) will be considered printable. <c>unicode</c> means that all printable characters in all unicode character ranges are considered printable by the io functions.</p>
+ <p>By default, Erlang is started so that only the <c>latin1</c> range of characters will indicate that a list of integers is a string.</p>
+ <p>The simplest way to utilize the setting is to call <seealso marker="io_lib#printable_list/1">io_lib:printable_list/1</seealso>, which will use the return value of this function to decide if a list is a string of printable characters or not.</p>
+ <note><p>In the future, this function may return more values and ranges. It is recommended to use the io_lib:printable_list/1 function to avoid compatibility problems.</p></note>
+ </desc>
+ </func>
+ <func>
<name name="setopts" arity="1"/>
<name name="setopts" arity="2"/>
<fsummary>Set options</fsummary>
diff --git a/lib/stdlib/doc/src/io_lib.xml b/lib/stdlib/doc/src/io_lib.xml
index 001d34a7c2..3dac259477 100644
--- a/lib/stdlib/doc/src/io_lib.xml
+++ b/lib/stdlib/doc/src/io_lib.xml
@@ -301,7 +301,11 @@
<fsummary>Test for a list of printable characters</fsummary>
<desc>
<p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of
- printable Unicode characters, otherwise it returns <c>false</c>.</p>
+ printable characters, otherwise it returns <c>false</c>.</p>
+ <p>What is a printable character in this case is determined by the
+ <c>+pc</c> start up flag to the Erlang VM. See
+ <seealso marker="io#printable_range/0">io:printable_range/0</seealso>
+ and <seealso marker="erts:erl#erl">erl(1)</seealso>.</p>
</desc>
</func>
<func>
@@ -312,6 +316,14 @@
printable ISO-latin-1 characters, otherwise it returns <c>false</c>.</p>
</desc>
</func>
+ <func>
+ <name name="printable_unicode_list" arity="1"/>
+ <fsummary>Test for a list of printable Unicode characters</fsummary>
+ <desc>
+ <p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of
+ printable Unicode characters, otherwise it returns <c>false</c>.</p>
+ </desc>
+ </func>
</funcs>
</erlref>
diff --git a/lib/stdlib/src/binary.erl b/lib/stdlib/src/binary.erl
index de18b6cd54..1fb241fd1d 100644
--- a/lib/stdlib/src/binary.erl
+++ b/lib/stdlib/src/binary.erl
@@ -58,7 +58,7 @@ bin_to_list(_, _) ->
-spec bin_to_list(Subject, Pos, Len) -> [byte()] when
Subject :: binary(),
Pos :: non_neg_integer(),
- Len :: non_neg_integer().
+ Len :: integer().
bin_to_list(_, _, _) ->
erlang:nif_error(undef).
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index 06dae51cc9..7c7566e4ec 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -42,7 +42,7 @@
| {encoding, latin1 | unicode | utf8}).
-type(options() :: hook_function() | [option()]).
--record(pp, {string_fun, char_fun, term_fun}).
+-record(pp, {string_fun, char_fun}).
-record(options, {hook, encoding, opts}).
@@ -182,13 +182,11 @@ state(_Hook) ->
state() ->
#pp{string_fun = fun io_lib:write_string_as_latin1/1,
- char_fun = fun io_lib:write_char_as_latin1/1,
- term_fun = fun(T) -> io_lib:format("~p", [T]) end}.
+ char_fun = fun io_lib:write_char_as_latin1/1}.
unicode_state() ->
#pp{string_fun = fun io_lib:write_string/1,
- char_fun = fun io_lib:write_char/1,
- term_fun = fun(T) -> io_lib:format("~tp", [T]) end}.
+ char_fun = fun io_lib:write_char/1}.
encoding(Options) ->
case proplists:get_value(encoding, Options, epp:default_encoding()) of
@@ -204,10 +202,10 @@ lform({function,Line,Name,Arity,Clauses}, Opts, _State) ->
lform({rule,Line,Name,Arity,Clauses}, Opts, _State) ->
lrule({rule,Line,Name,Arity,Clauses}, Opts);
%% These are specials to make it easier for the compiler.
-lform({error,E}, _Opts, State) ->
- leaf((State#pp.term_fun)({error,E})++"\n");
-lform({warning,W}, _Opts, State) ->
- leaf((State#pp.term_fun)({warning,W})++"\n");
+lform({error,E}, _Opts, _State) ->
+ leaf(format("~p\n", [{error,E}]));
+lform({warning,W}, _Opts, _State) ->
+ leaf(format("~p\n", [{warning,W}]));
lform({eof,_Line}, _Opts, _State) ->
$\n.
@@ -233,7 +231,7 @@ lattribute(import, Name, _Opts, _State) when is_list(Name) ->
lattribute(import, {From,Falist}, _Opts, _State) ->
attr("import",[{var,0,pname(From)},falist(Falist)]);
lattribute(file, {Name,Line}, _Opts, State) ->
- attr("file", [{var,0,(State#pp.term_fun)(Name)},{integer,0,Line}]);
+ attr("file", [{var,0,(State#pp.string_fun)(Name)},{integer,0,Line}]);
lattribute(record, {Name,Is}, Opts, _State) ->
Nl = leaf(format("-record(~w,", [Name])),
[{first,Nl,record_fields(Is, Opts)},$)];
diff --git a/lib/stdlib/src/io.erl b/lib/stdlib/src/io.erl
index 3dddb0d6e7..c92e9e3ade 100644
--- a/lib/stdlib/src/io.erl
+++ b/lib/stdlib/src/io.erl
@@ -32,6 +32,8 @@
parse_erl_exprs/4,parse_erl_form/1,parse_erl_form/2,
parse_erl_form/3,parse_erl_form/4]).
-export([request/1,request/2,requests/1,requests/2]).
+%% Implemented in native code
+-export([printable_range/0]).
-export_type([device/0, format/0, server_no_data/0]).
@@ -66,6 +68,11 @@ o_request(Io, Request, Func) ->
Other
end.
+%% Request what the user considers printable characters
+-spec printable_range() -> 'unicode' | 'latin1'.
+printable_range() ->
+ erlang:nif_error(undefined).
+
%% Put chars takes mixed *unicode* list from R13 onwards.
-spec put_chars(CharData) -> 'ok' when
CharData :: unicode:chardata().
diff --git a/lib/stdlib/src/io_lib.erl b/lib/stdlib/src/io_lib.erl
index b7ec848e1e..a9b6d4131e 100644
--- a/lib/stdlib/src/io_lib.erl
+++ b/lib/stdlib/src/io_lib.erl
@@ -72,7 +72,7 @@
-export([quote_atom/2, char_list/1, latin1_char_list/1,
deep_char_list/1, deep_latin1_char_list/1,
- printable_list/1, printable_latin1_list/1]).
+ printable_list/1, printable_latin1_list/1, printable_unicode_list/1]).
%% Utilities for collecting characters.
-export([collect_chars/3, collect_chars/4,
@@ -533,27 +533,45 @@ printable_latin1_list(_) -> false. %Everything else is false
%% Return true if CharList is a list of printable characters, else
%% false. The notion of printable in Unicode terms is somewhat floating.
%% Everything that is not a control character and not invalid unicode
-%% will be considered printable.
+%% will be considered printable.
+%% What the user has noted as printable characters is what actually
+%% specifies when this function will return true. If the VM is started
+%% with +pc latin1, only the latin1 range will be deemed as printable
+%% if on the other hand +pc unicode is given, all characters in the Unicode
+%% character set are deemed printable. latin1 is default.
-spec printable_list(Term) -> boolean() when
Term :: term().
-printable_list([C|Cs]) when is_integer(C), C >= $\040, C =< $\176 ->
- printable_list(Cs);
-printable_list([C|Cs])
+printable_list(L) ->
+ %% There will be more alternatives returns from io:printable range
+ %% in the future. To not have a catch-all clause is deliberate.
+ case io:printable_range() of
+ latin1 ->
+ printable_latin1_list(L);
+ unicode ->
+ printable_unicode_list(L)
+ end.
+
+-spec printable_unicode_list(Term) -> boolean() when
+ Term :: term().
+
+printable_unicode_list([C|Cs]) when is_integer(C), C >= $\040, C =< $\176 ->
+ printable_unicode_list(Cs);
+printable_unicode_list([C|Cs])
when is_integer(C), C >= 16#A0, C < 16#D800;
is_integer(C), C > 16#DFFF, C < 16#FFFE;
is_integer(C), C > 16#FFFF, C =< 16#10FFFF ->
- printable_list(Cs);
-printable_list([$\n|Cs]) -> printable_list(Cs);
-printable_list([$\r|Cs]) -> printable_list(Cs);
-printable_list([$\t|Cs]) -> printable_list(Cs);
-printable_list([$\v|Cs]) -> printable_list(Cs);
-printable_list([$\b|Cs]) -> printable_list(Cs);
-printable_list([$\f|Cs]) -> printable_list(Cs);
-printable_list([$\e|Cs]) -> printable_list(Cs);
-printable_list([]) -> true;
-printable_list(_) -> false. %Everything else is false
+ printable_unicode_list(Cs);
+printable_unicode_list([$\n|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\r|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\t|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\v|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\b|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\f|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([$\e|Cs]) -> printable_unicode_list(Cs);
+printable_unicode_list([]) -> true;
+printable_unicode_list(_) -> false. %Everything else is false
%% List = nl()
%% Return a list of characters to generate a newline.
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 525b534249..7637ad7a3d 100644
--- a/lib/stdlib/src/io_lib_pretty.erl
+++ b/lib/stdlib/src/io_lib_pretty.erl
@@ -485,13 +485,18 @@ printable_bin(Bin, Len, D, latin1) ->
false
end;
printable_bin(Bin, Len, D, _Uni) ->
- case printable_unicode(Bin, Len, []) of
- {_, <<>>, L} ->
- {byte_size(Bin) =:= length(L), L};
- {NC, Bin1, L} when D > 0, Len - NC >= D ->
- {byte_size(Bin)-byte_size(Bin1) =:= length(L), true, L};
- {_NC, _Bin, _L} ->
- false
+ case valid_utf8(Bin,Len) of
+ true ->
+ case printable_unicode(Bin, Len, [], io:printable_range()) of
+ {_, <<>>, L} ->
+ {byte_size(Bin) =:= length(L), L};
+ {NC, Bin1, L} when D > 0, Len - NC >= D ->
+ {byte_size(Bin)-byte_size(Bin1) =:= length(L), true, L};
+ {_NC, _Bin, _L} ->
+ false
+ end;
+ false ->
+ printable_bin(Bin, Len, D, latin1)
end.
printable_bin1(_Bin, _Start, 0) ->
@@ -522,24 +527,36 @@ printable_latin1_list([$\e | Cs], N) -> printable_latin1_list(Cs, N - 1);
printable_latin1_list([], _) -> all;
printable_latin1_list(_, N) -> N.
-printable_unicode(<<C/utf8, R/binary>>=Bin, I, L) when I > 0 ->
- case printable_char(C) of
+valid_utf8(<<>>,_) ->
+ true;
+valid_utf8(_,0) ->
+ true;
+valid_utf8(<<_/utf8, R/binary>>,N) ->
+ valid_utf8(R,N-1);
+valid_utf8(_,_) ->
+ false.
+
+printable_unicode(<<C/utf8, R/binary>>=Bin, I, L, Range) when I > 0 ->
+ case printable_char(C,Range) of
true ->
- printable_unicode(R, I - 1, [C | L]);
+ printable_unicode(R, I - 1, [C | L],Range);
false ->
{I, Bin, lists:reverse(L)}
end;
-printable_unicode(Bin, I, L) ->
+printable_unicode(Bin, I, L,_) ->
{I, Bin, lists:reverse(L)}.
-printable_char($\n) -> true;
-printable_char($\r) -> true;
-printable_char($\t) -> true;
-printable_char($\v) -> true;
-printable_char($\b) -> true;
-printable_char($\f) -> true;
-printable_char($\e) -> true;
-printable_char(C) ->
+printable_char($\n,_) -> true;
+printable_char($\r,_) -> true;
+printable_char($\t,_) -> true;
+printable_char($\v,_) -> true;
+printable_char($\b,_) -> true;
+printable_char($\f,_) -> true;
+printable_char($\e,_) -> true;
+printable_char(C,latin1) ->
+ C >= $\s andalso C =< $~ orelse
+ C >= 16#A0 andalso C =< 16#FF;
+printable_char(C,unicode) ->
C >= $\s andalso C =< $~ orelse
C >= 16#A0 andalso C < 16#D800 orelse
C > 16#DFFF andalso C < 16#FFFE orelse
diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl
index df66acb97b..96f3e5dd32 100644
--- a/lib/stdlib/src/shell.erl
+++ b/lib/stdlib/src/shell.erl
@@ -129,7 +129,7 @@ start_restricted(RShMod) when is_atom(RShMod) ->
error_logger:error_report(
lists:flatten(
io_lib:fwrite(
- "Restricted shell module ~w not found: ~"++cs_p() ++"\n",
+ "Restricted shell module ~w not found: ~tp\n",
[RShMod,What]))),
Error
end.
@@ -214,8 +214,7 @@ server(StartSync) ->
ok;
{RShMod2,What2} ->
io:fwrite(
- ("Warning! Restricted shell module ~w not found: ~"
- ++cs_p()++".\n"
+ ("Warning! Restricted shell module ~w not found: ~tp.\n"
"Only the commands q() and init:stop() will be allowed!\n"),
[RShMod2,What2]),
application:set_env(stdlib, restricted_shell, ?MODULE)
@@ -337,7 +336,7 @@ get_prompt_func() ->
end.
bad_prompt_func(M) ->
- fwrite_severity(benign, "Bad prompt function: ~"++cs_p(), [M]).
+ fwrite_severity(benign, "Bad prompt function: ~tp", [M]).
default_prompt(N) ->
%% Don't bother flattening the list irrespective of what the
@@ -1380,27 +1379,18 @@ pp(V, I, RT, Enc) ->
{record_print_fun, record_print_fun(RT)}]
++ Enc)).
-%% Control sequence 'p' possibly with Unicode translation modifier
-cs_p() ->
- case encoding() of
- latin1 -> "p";
- unicode -> "tp"
- end.
-
columns() ->
case io:columns() of
{ok,N} -> N;
_ -> 80
end.
-
encoding() ->
[{encoding, Encoding}] = enc(),
Encoding.
-
enc() ->
case lists:keyfind(encoding, 1, io:getopts()) of
- false -> [{encoding,latin1}]; % should never happen
- Enc -> [Enc]
+ false -> [{encoding,latin1}]; % should never happen
+ Enc -> [Enc]
end.
garb(Shell) ->
@@ -1424,10 +1414,9 @@ check_env(V) ->
{ok, Val} when is_integer(Val), Val >= 0 ->
ok;
{ok, Val} ->
- Txt = io_lib:fwrite(
- ("Invalid value of STDLIB configuration parameter ~w: ~"
- ++cs_p()++"\n"),
- [V, Val]),
+ Txt = io_lib:fwrite
+ ("Invalid value of STDLIB configuration parameter"
+ "~w: ~tp\n", [V, Val]),
error_logger:info_report(lists:flatten(Txt))
end.
diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl
index 041d521514..b2f1aa955a 100644
--- a/lib/stdlib/test/epp_SUITE.erl
+++ b/lib/stdlib/test/epp_SUITE.erl
@@ -25,7 +25,7 @@
variable_1/1, otp_4870/1, otp_4871/1, otp_5362/1,
pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1,
otp_8130/1, overload_mac/1, otp_8388/1, otp_8470/1, otp_8503/1,
- otp_8562/1, otp_8665/1, otp_8911/1, otp_10302/1]).
+ otp_8562/1, otp_8665/1, otp_8911/1, otp_10302/1, otp_10820/1]).
-export([epp_parse_erl_form/2]).
@@ -67,7 +67,7 @@ all() ->
{group, variable}, otp_4870, otp_4871, otp_5362, pmod,
not_circular, skip_header, otp_6277, otp_7702, otp_8130,
overload_mac, otp_8388, otp_8470, otp_8503, otp_8562,
- otp_8665, otp_8911, otp_10302].
+ otp_8665, otp_8911, otp_10302, otp_10820].
groups() ->
[{upcase_mac, [], [upcase_mac_1, upcase_mac_2]},
@@ -1359,6 +1359,30 @@ encoding_nocom(Enc, File) ->
ok = file:close(Fd),
E = epp:read_encoding(File, Options).
+otp_10820(doc) ->
+ "OTP-10820. Unicode filenames.";
+otp_10820(suite) ->
+ [];
+otp_10820(Config) when is_list(Config) ->
+ L = [915,953,959,973,957,953,954,959,957,964],
+ Dir = ?config(priv_dir, Config),
+ File = filename:join(Dir, L++".erl"),
+ C1 = <<"%% coding: utf-8\n -module(any).">>,
+ ok = do_otp_10820(File, C1, "+pc latin1"),
+ ok = do_otp_10820(File, C1, "+pc unicode"),
+ C2 = <<"\n-module(any).">>,
+ ok = do_otp_10820(File, C2, "+pc latin1"),
+ ok = do_otp_10820(File, C2, "+pc unicode").
+
+do_otp_10820(File, C, PC) ->
+ {ok,Node} = start_node(erl_pp_helper, "+fnu " ++ PC),
+ ok = rpc:call(Node, file, write_file, [File, C]),
+ {ok,[{attribute,1,file,{File,1}},
+ {attribute,2,module,any},
+ {eof,2}]} = rpc:call(Node, epp, parse_file, [File, [],[]]),
+ true = test_server:stop_node(Node),
+ ok.
+
check(Config, Tests) ->
eval_tests(Config, fun check_test/2, Tests).
@@ -1475,3 +1499,8 @@ ln2({error,M}) ->
{error,ln2(M)};
ln2(M) ->
M.
+
+%% +fnu means a peer node has to be started; slave will not do
+start_node(Name, Xargs) ->
+ ?line PA = filename:dirname(code:which(?MODULE)),
+ test_server:start_node(Name, peer, [{args, "-pa " ++ PA ++ " " ++ Xargs}]).
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 37be61d665..9c0a43abcc 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -49,7 +49,7 @@
otp_6321/1, otp_6911/1, otp_6914/1, otp_8150/1, otp_8238/1,
otp_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1,
- otp_10302/1]).
+ otp_10302/1, otp_10820/1]).
%% Internal export.
-export([ehook/6]).
@@ -80,7 +80,8 @@ groups() ->
{attributes, [], [misc_attrs, import_export]},
{tickets, [],
[otp_6321, otp_6911, otp_6914, otp_8150, otp_8238,
- otp_8473, otp_8522, otp_8567, otp_8664, otp_9147, otp_10302]}].
+ otp_8473, otp_8522, otp_8567, otp_8664, otp_9147,
+ otp_10302, otp_10820]}].
init_per_suite(Config) ->
Config.
@@ -1074,6 +1075,34 @@ otp_10302(Config) when is_list(Config) ->
unicode_hook({foo,E}, I, P, H) ->
erl_pp:expr({call,0,{atom,0,foo},[E]}, I, P, H).
+otp_10820(doc) ->
+ "OTP-10820. Unicode filenames.";
+otp_10820(suite) -> [];
+otp_10820(Config) when is_list(Config) ->
+ C1 = <<"%% coding: utf-8\n -module(any).">>,
+ ok = do_otp_10820(Config, C1, "+pc latin1"),
+ ok = do_otp_10820(Config, C1, "+pc unicode"),
+ C2 = <<"-module(any).">>,
+ ok = do_otp_10820(Config, C2, "+pc latin1"),
+ ok = do_otp_10820(Config, C2, "+pc unicode").
+
+do_otp_10820(Config, C, PC) ->
+ {ok,Node} = start_node(erl_pp_helper, "+fnu " ++ PC),
+ L = [915,953,959,973,957,953,954,959,957,964],
+ FileName = filename(L++".erl", Config),
+ ok = rpc:call(Node, file, write_file, [FileName, C]),
+ {ok, _, []} = rpc:call(Node, compile, file,
+ [FileName, [return,'P',{outdir,?privdir}]]),
+ PFileName = filename(L++".P", Config),
+ {ok, Bin} = rpc:call(Node, file, read_file, [PFileName]),
+ true = test_server:stop_node(Node),
+ true = file_attr_is_string(binary_to_list(Bin)),
+ ok.
+
+file_attr_is_string("-file(\"" ++ _) -> true;
+file_attr_is_string([_ | L]) ->
+ file_attr_is_string(L).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
compile(Config, Tests) ->
@@ -1247,3 +1276,8 @@ filename(Name, Config) ->
fail() ->
io:format("failed~n"),
?t:fail().
+
+%% +fnu means a peer node has to be started; slave will not do
+start_node(Name, Xargs) ->
+ ?line PA = filename:dirname(code:which(?MODULE)),
+ test_server:start_node(Name, peer, [{args, "-pa " ++ PA ++ " " ++ Xargs}]).
diff --git a/lib/stdlib/test/escript_SUITE.erl b/lib/stdlib/test/escript_SUITE.erl
index be8fb1b37a..cf5fb12686 100644
--- a/lib/stdlib/test/escript_SUITE.erl
+++ b/lib/stdlib/test/escript_SUITE.erl
@@ -913,7 +913,7 @@ unicode(Config) when is_list(Config) ->
run(Dir, "unicode1",
[<<"escript: exception error: an error occurred when evaluating"
" an arithmetic expression\n in operator '/'/2\n "
- "called as <<170>> / <<170>>\nExitCode:127">>]),
+ "called as <<224,170,170>> / <<224,170,170>>\nExitCode:127">>]),
run(Dir, "unicode2",
[<<"escript: exception error: an error occurred when evaluating"
" an arithmetic expression\n in operator '/'/2\n "
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode1 b/lib/stdlib/test/escript_SUITE_data/unicode1
index a77574625e..351bb785e5 100755
--- a/lib/stdlib/test/escript_SUITE_data/unicode1
+++ b/lib/stdlib/test/escript_SUITE_data/unicode1
@@ -6,7 +6,7 @@
main(_) ->
ok = io:setopts([{encoding,unicode}]),
_D = erlang:system_flag(backtrace_depth, 0),
- A = <<"\x{aa}">>,
+ A = <<"\x{aaa}"/utf8>>,
S = lists:flatten(io_lib:format("~p/~p.", [A, A])),
{ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
{ok, Es} = erl_parse:parse_exprs(Ts),
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl
index aa698ecaa2..9f828c6d2d 100644
--- a/lib/stdlib/test/io_SUITE.erl
+++ b/lib/stdlib/test/io_SUITE.erl
@@ -29,9 +29,12 @@
manpage/1, otp_6708/1, otp_7084/1, otp_7421/1,
io_lib_collect_line_3_wb/1, cr_whitespace_in_string/1,
io_fread_newlines/1, otp_8989/1, io_lib_fread_literal/1,
+ printable_range/1,
io_lib_print_binary_depth_one/1, otp_10302/1, otp_10755/1,
otp_10836/1]).
+-export([pretty/2]).
+
%-define(debug, true).
-ifdef(debug).
@@ -66,6 +69,7 @@ all() ->
manpage, otp_6708, otp_7084, otp_7421,
io_lib_collect_line_3_wb, cr_whitespace_in_string,
io_fread_newlines, otp_8989, io_lib_fread_literal,
+ printable_range,
io_lib_print_binary_depth_one, otp_10302, otp_10755, otp_10836].
groups() ->
@@ -2026,6 +2030,79 @@ io_lib_fread_literal(Suite) when is_list(Suite) ->
?line {done,{ok,[]},[]} = io_lib:fread(C2, "d\n", " d"),
ok.
+
+printable_range(doc) ->
+ "Check that the printable range set by the user actually works";
+printable_range(Suite) when is_list(Suite) ->
+ Pa = filename:dirname(code:which(?MODULE)),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pc unicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pc latin1 -pa " ++ Pa}]),
+ {ok, DNode} = test_server:start_node(printable_range_default, slave,
+ [{args, " -pa " ++ Pa}]),
+ unicode = rpc:call(UNode,io,printable_range,[]),
+ latin1 = rpc:call(LNode,io,printable_range,[]),
+ latin1 = rpc:call(DNode,io,printable_range,[]),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pcunicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pclatin1 -pa " ++ Pa}]),
+ unicode = rpc:call(UNode,io,printable_range,[]),
+ latin1 = rpc:call(LNode,io,printable_range,[]),
+ {error, _} = test_server:start_node(printable_range_unnicode, slave,
+ [{args, " +pcunnicode -pa " ++ Pa}]),
+ PrettyOptions = [{column,1},
+ {line_length,109},
+ {depth,30},
+ {max_chars,60},
+ {record_print_fun,
+ fun(_,_) -> no end},
+ {encoding,unicode}],
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
+ test_server:stop_node(DNode),
+ ok.
+
io_lib_print_binary_depth_one(doc) ->
"Test binaries printed with a depth of one behave correctly";
io_lib_print_binary_depth_one(Suite) when is_list(Suite) ->
@@ -2040,16 +2117,30 @@ io_lib_print_binary_depth_one(Suite) when is_list(Suite) ->
otp_10302(doc) ->
"OTP-10302. Unicode";
otp_10302(Suite) when is_list(Suite) ->
- "\"\x{400}\"" = pretty("\x{400}", -1),
- "<<\"\x{400}\"/utf8>>" = pretty(<<"\x{400}"/utf8>>, -1),
+ Pa = filename:dirname(code:which(?MODULE)),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pc unicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pc latin1 -pa " ++ Pa}]),
+ "\"\x{400}\"" = rpc:call(UNode,?MODULE,pretty,["\x{400}", -1]),
+ "<<\"\x{400}\"/utf8>>" = rpc:call(UNode,?MODULE,pretty,
+ [<<"\x{400}"/utf8>>, -1]),
+
+ "<<\"\x{400}foo\"/utf8>>" = rpc:call(UNode,?MODULE,pretty,
+ [<<"\x{400}foo"/utf8>>, 2]),
+ "[1024]" = rpc:call(LNode,?MODULE,pretty,["\x{400}", -1]),
+ "<<208,128>>" = rpc:call(LNode,?MODULE,pretty,[<<"\x{400}"/utf8>>, -1]),
+
+ "<<208,...>>" = rpc:call(LNode,?MODULE,pretty,[<<"\x{400}foo"/utf8>>, 2]),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
- "<<\"\x{400}foo\"/utf8>>" = pretty(<<"\x{400}foo"/utf8>>, 2),
"<<\"äppl\"/utf8>>" = pretty(<<"äppl"/utf8>>, 2),
"<<\"äppl\"/utf8...>>" = pretty(<<"äpple"/utf8>>, 2),
"<<\"apel\">>" = pretty(<<"apel">>, 2),
"<<\"apel\"...>>" = pretty(<<"apelsin">>, 2),
- "<<228,112,112,108>>" = fmt("~tp", [<<"äppl">>]),
- "<<228,...>>" = fmt("~tP", [<<"äppl">>, 2]),
+ "<<\"äppl\">>" = fmt("~tp", [<<"äppl">>]),
+ "<<\"äppl\"...>>" = fmt("~tP", [<<"äpple">>, 2]),
"<<0,0,0,0,0,0,1,0>>" = fmt("~p", [<<256:64/unsigned-integer>>]),
"<<0,0,0,0,0,0,1,0>>" = fmt("~tp", [<<256:64/unsigned-integer>>]),
diff --git a/lib/stdlib/test/io_proto_SUITE.erl b/lib/stdlib/test/io_proto_SUITE.erl
index 299daf0e42..ddcc8dfdab 100644
--- a/lib/stdlib/test/io_proto_SUITE.erl
+++ b/lib/stdlib/test/io_proto_SUITE.erl
@@ -716,7 +716,7 @@ binary_options(Config) when is_list(Config) ->
{getline, "<<\"hej\\n\">>"},
{putline, "io:get_line('')."},
{putline, binary_to_list(<<"\345\344\366"/utf8>>)},
- {getline, "<<\""++binary_to_list(unicode:characters_to_binary(<<"\345\344\366"/utf8>>,latin1,utf8))++"\\n\">>"}
+ {getline, "<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\n\"/utf8>>"}
],[])
end,
%% And one with oldshell
@@ -1784,8 +1784,8 @@ get_default_shell() ->
{putline, "whereis(user_drv)."},
{getline, "undefined"}],[]),
old
- catch E:R ->
- ?dbg({E,R}),
+ catch _E:_R ->
+ ?dbg({_E,_R}),
new
end.
diff --git a/lib/stdlib/test/shell_SUITE.erl b/lib/stdlib/test/shell_SUITE.erl
index f22df96697..990b1f5eb2 100644
--- a/lib/stdlib/test/shell_SUITE.erl
+++ b/lib/stdlib/test/shell_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -2742,6 +2742,9 @@ otp_10302(doc) ->
"OTP-10302. Unicode.";
otp_10302(suite) -> [];
otp_10302(Config) when is_list(Config) ->
+ {ok,Node} = start_node(shell_suite_helper_2,
+ "-pa "++?config(priv_dir,Config)++
+ " +pc unicode"),
Test1 =
<<"begin
io:setopts([{encoding,utf8}]),
@@ -2749,13 +2752,13 @@ otp_10302(Config) when is_list(Config) ->
rd(rec, {a = \"\\x{400}\"}),
ok = rl(rec)
end.">>,
- "-record(rec,{a = \"\x{400}\"}).\nok.\n" = t(Test1),
+ "-record(rec,{a = \"\x{400}\"}).\nok.\n" = t({Node,Test1}),
Test3 =
<<"io:setopts([{encoding,utf8}]).
rd(rec, {a = \"\\x{400}\"}).
ok = rp(#rec{}).">>,
- "ok.\nrec\n#rec{a = \"\x{400}\"}.\nok.\n" = t(Test3),
+ "ok.\nrec\n#rec{a = \"\x{400}\"}.\nok.\n" = t({Node,Test3}),
Test4 =
<<"io:setopts([{encoding,utf8}]).
@@ -2766,7 +2769,7 @@ otp_10302(Config) when is_list(Config) ->
"ok.\n\"\x{400}\"\nA = \"\x{400}\".\nok.\n"
"1: io:setopts([{encoding,utf8}])\n-> ok.\n"
"2: A = [1024] = \"\x{400}\"\n-> \"\x{400}\"\n"
- "3: b()\n-> ok.\nok.\n" = t(Test4),
+ "3: b()\n-> ok.\nok.\n" = t({Node,Test4}),
Test5 =
<<"begin
@@ -2776,18 +2779,20 @@ otp_10302(Config) when is_list(Config) ->
b(),
h()
end.">>,
- "A = \"\x{400}\".\nok.\n" = t(Test5),
+ "A = \"\x{400}\".\nok.\n" = t({Node,Test5}),
%% One $" is "lost":
true =
"\x{400}\": command not found" =:=
- prompt_err({<<"io:setopts([{encoding,utf8}]). v(\"\x{400}\")."/utf8>>,
+ prompt_err({Node,
+ <<"io:setopts([{encoding,utf8}]). v(\"\x{400}\")."/utf8>>,
unicode}),
"ok.\ndefault\n* Bad prompt function: \"\x{400}\".\n" =
- t({<<"io:setopts([{encoding,utf8}]). "
+ t({Node,<<"io:setopts([{encoding,utf8}]). "
"shell:prompt_func(\"\x{400}\")."/utf8>>,
unicode}),
+ rpc:call(Node,shell, prompt_func, [default]),
_ = shell:prompt_func(default),
%% Test lib:format_exception() (cf. OTP-6554)
@@ -2812,10 +2817,10 @@ otp_10302(Config) when is_list(Config) ->
{ok, Es} = erl_parse:parse_exprs(Ts),
B = erl_eval:new_bindings(),
erl_eval:exprs(Es, B).">>,
-
+
"ok.\n** exception error: an error occurred when evaluating"
" an arithmetic expression\n in operator '/'/2\n"
- " called as <<170>> / <<170>>.\n" = t(Test7),
+ " called as <<\"�\">> / <<\"�\">>.\n" = t({Node,Test7}),
Test8 =
<<"begin
A = [1089],
@@ -2839,7 +2844,7 @@ otp_10302(Config) when is_list(Config) ->
"ok.\n** exception error: an error occurred when evaluating"
" an arithmetic expression\n in operator '/'/2\n"
- " called as \"\x{441}\" / \"\x{441}\".\n" = t(Test9),
+ " called as \"\x{441}\" / \"\x{441}\".\n" = t({Node,Test9}),
Test10 =
<<"A = {\"1\\xaa\",
$\\xaa,
@@ -2861,7 +2866,7 @@ otp_10302(Config) when is_list(Config) ->
"ok.\n** exception error: no function clause matching \n"
" erl_eval:'-inside-an-interpreted-fun-'"
"({\"1\xaa\",170,<<\"hi\">>,\n "
- " <<\"1\xaa\"/utf8>>}) .\n" = t(Test11),
+ " <<\"1\xaa\"/utf8>>}) .\n" = t({Node,Test11}),
Test12 = <<"fun(a, b) -> false end(65, [1089]).">>,
"** exception error: no function clause matching \n"
" erl_eval:'-inside-an-interpreted-fun-'(65,[1089])"
@@ -2871,8 +2876,9 @@ otp_10302(Config) when is_list(Config) ->
fun(a, b) -> false end(65, [1089]).">>,
"ok.\n** exception error: no function clause matching \n"
" erl_eval:'-inside-an-interpreted-fun-'(65,\"\x{441}\")"
- " .\n" = t(Test13),
+ " .\n" = t({Node,Test13}),
+ test_server:stop_node(Node),
ok.
scan(B) ->
@@ -2895,6 +2901,8 @@ scan(S0, F) ->
[]
end.
+t({Node,Bin,Enc}) when is_atom(Node),is_binary(Bin), is_atom(Enc) ->
+ t0({Bin,Enc}, fun() -> start_new_shell(Node) end);
t({Node,Bin}) when is_atom(Node),is_binary(Bin) ->
t0({Bin,latin1}, fun() -> start_new_shell(Node) end);
t(Bin) when is_binary(Bin) ->