aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/beam_dict.erl4
-rw-r--r--lib/compiler/src/compile.erl32
-rw-r--r--lib/debugger/src/dbg_icmd.erl29
-rw-r--r--lib/debugger/src/dbg_ieval.erl53
-rw-r--r--lib/debugger/src/dbg_iload.erl31
-rw-r--r--lib/debugger/src/dbg_iserver.erl50
-rw-r--r--lib/debugger/src/dbg_ui_break_win.erl7
-rw-r--r--lib/debugger/src/dbg_ui_filedialog_win.erl13
-rw-r--r--lib/debugger/src/dbg_ui_mon.erl21
-rw-r--r--lib/debugger/src/dbg_ui_mon_win.erl28
-rw-r--r--lib/debugger/src/dbg_ui_trace_win.erl205
-rw-r--r--lib/debugger/src/dbg_ui_view.erl6
-rw-r--r--lib/debugger/src/dbg_ui_win.erl8
-rw-r--r--lib/debugger/src/dbg_ui_winman.erl12
-rw-r--r--lib/debugger/src/dbg_wx_break_win.erl6
-rw-r--r--lib/debugger/src/dbg_wx_interpret.erl10
-rw-r--r--lib/debugger/src/dbg_wx_mon.erl19
-rw-r--r--lib/debugger/src/dbg_wx_mon_win.erl11
-rw-r--r--lib/debugger/src/dbg_wx_trace.erl50
-rwxr-xr-xlib/debugger/src/dbg_wx_trace_win.erl24
-rw-r--r--lib/debugger/src/dbg_wx_view.erl39
-rwxr-xr-xlib/debugger/src/dbg_wx_winman.erl12
-rw-r--r--lib/debugger/src/i.erl8
-rw-r--r--lib/debugger/src/int.erl10
-rw-r--r--lib/docbuilder/src/docb_edoc_xml_cb.erl64
-rw-r--r--lib/docbuilder/src/docb_html.erl27
-rw-r--r--lib/docbuilder/src/docb_html_util.erl17
-rw-r--r--lib/docbuilder/src/docb_main.erl27
-rw-r--r--lib/docbuilder/src/docb_pretty_format.erl4
-rw-r--r--lib/docbuilder/src/docb_tr_application2html.erl12
-rw-r--r--lib/docbuilder/src/docb_tr_cite2html.erl22
-rw-r--r--lib/docbuilder/src/docb_tr_index2html.erl4
-rw-r--r--lib/docbuilder/src/docb_tr_part2html.erl15
-rw-r--r--lib/docbuilder/src/docb_tr_term2html.erl22
-rw-r--r--lib/docbuilder/src/docb_transform.erl4
-rw-r--r--lib/docbuilder/src/docb_util.erl8
-rw-r--r--lib/docbuilder/src/docb_xmerl_tree_cb.erl4
-rw-r--r--lib/hipe/cerl/erl_bif_types.erl21
-rw-r--r--lib/jinterface/java_src/Makefile16
-rw-r--r--lib/jinterface/java_src/pom.xml.src106
-rw-r--r--lib/kernel/doc/src/file.xml2
-rw-r--r--lib/kernel/src/auth.erl6
-rw-r--r--lib/kernel/test/gen_udp_SUITE.erl21
-rw-r--r--lib/stdlib/doc/src/beam_lib.xml1
-rw-r--r--lib/stdlib/doc/src/timer.xml25
-rw-r--r--lib/stdlib/src/beam_lib.erl1
-rw-r--r--lib/stdlib/src/escript.erl88
-rw-r--r--lib/stdlib/src/timer.erl13
-rw-r--r--lib/stdlib/test/timer_simple_SUITE.erl18
49 files changed, 662 insertions, 574 deletions
diff --git a/lib/compiler/src/beam_dict.erl b/lib/compiler/src/beam_dict.erl
index 4ffe8bc606..9164259a94 100644
--- a/lib/compiler/src/beam_dict.erl
+++ b/lib/compiler/src/beam_dict.erl
@@ -33,7 +33,7 @@
exports = [] :: [{label(), arity(), label()}],
locals = [] :: [{label(), arity(), label()}],
imports = gb_trees:empty() :: gb_tree(), %{{M,F,A},Index}
- strings = [] :: [string()], %String pool
+ strings = [] :: string(), %String pool
lambdas = [], %[{...}]
literals = dict:new() :: dict(), %Format: {Literal,Number}
next_atom = 1 :: pos_integer(),
@@ -219,7 +219,7 @@ my_term_to_binary(Term) ->
%% Search for string Str in the string pool Pool.
%% old_string(Str, Pool) -> none | Index
--spec old_string(string(), [string()]) -> 'none' | pos_integer().
+-spec old_string(string(), string()) -> 'none' | pos_integer().
old_string([C|Str]=Str0, [C|Pool]) ->
case lists:prefix(Str, Pool) of
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 4642fb68b3..ed7a9144a8 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -41,8 +41,7 @@
-type option() :: atom() | {atom(), term()} | {'d', atom(), term()}.
--type line() :: integer().
--type err_info() :: {line(), module(), term()}. %% ErrorDescriptor
+-type err_info() :: {erl_scan:line(), module(), term()}. %% ErrorDescriptor
-type errors() :: [{file:filename(), [err_info()]}].
-type warnings() :: [{file:filename(), [err_info()]}].
-type mod_ret() :: {'ok', module()}
@@ -70,7 +69,7 @@
file(File) -> file(File, ?DEFAULT_OPTIONS).
--spec file(module() | file:filename(), [option()]) -> comp_ret().
+-spec file(module() | file:filename(), [option()] | option()) -> comp_ret().
file(File, Opts) when is_list(Opts) ->
do_compile({file,File}, Opts++env_default_opts());
@@ -88,6 +87,8 @@ forms(Forms, Opt) when is_atom(Opt) ->
%% would have generated a Beam file, false otherwise (if only a binary or a
%% listing file would have been generated).
+-spec output_generated([option()]) -> boolean().
+
output_generated(Opts) ->
noenv_output_generated(Opts++env_default_opts()).
@@ -96,6 +97,8 @@ output_generated(Opts) ->
%% for default options.
%%
+-spec noenv_file(module() | file:filename(), [option()] | option()) -> comp_ret().
+
noenv_file(File, Opts) when is_list(Opts) ->
do_compile({file,File}, Opts);
noenv_file(File, Opt) ->
@@ -106,6 +109,8 @@ noenv_forms(Forms, Opts) when is_list(Opts) ->
noenv_forms(Forms, Opt) when is_atom(Opt) ->
noenv_forms(Forms, [Opt|?DEFAULT_OPTIONS]).
+-spec noenv_output_generated([option()]) -> boolean().
+
noenv_output_generated(Opts) ->
any(fun ({save_binary,_F}) -> true;
(_Other) -> false
@@ -216,16 +221,16 @@ format_error({module_name,Mod,Filename}) ->
[Mod,Filename]).
%% The compile state record.
--record(compile, {filename="",
- dir="",
- base="",
- ifile="",
- ofile="",
+-record(compile, {filename="" :: file:filename(),
+ dir="" :: file:filename(),
+ base="" :: file:filename(),
+ ifile="" :: file:filename(),
+ ofile="" :: file:filename(),
module=[],
code=[],
core_code=[],
abstract_code=[], %Abstract code for debugger.
- options=[],
+ options=[] :: [option()],
errors=[],
warnings=[]}).
@@ -362,7 +367,7 @@ mpf(Ms) ->
[{File,[M || {F,M} <- Ms, F =:= File]} ||
File <- lists:usort([F || {F,_} <- Ms])].
-%% passes(form|file, [Option]) -> [{Name,PassFun}]
+%% passes(forms|file, [Option]) -> [{Name,PassFun}]
%% Figure out which passes that need to be run.
passes(forms, Opts) ->
@@ -828,7 +833,6 @@ get_core_transforms(Opts) -> [M || {core_transform,M} <- Opts].
core_transforms(St) ->
%% The options field holds the complete list of options at this
-
Ts = get_core_transforms(St#compile.options),
foldl_core_transforms(St, Ts).
@@ -1172,12 +1176,12 @@ write_binary(Name, Bin, St) ->
%% report_errors(State) -> ok
%% report_warnings(State) -> ok
-report_errors(St) ->
- case member(report_errors, St#compile.options) of
+report_errors(#compile{options=Opts,errors=Errors}) ->
+ case member(report_errors, Opts) of
true ->
foreach(fun ({{F,_L},Eds}) -> list_errors(F, Eds);
({F,Eds}) -> list_errors(F, Eds) end,
- St#compile.errors);
+ Errors);
false -> ok
end.
diff --git a/lib/debugger/src/dbg_icmd.erl b/lib/debugger/src/dbg_icmd.erl
index 7ccb9793a3..a26b16c82d 100644
--- a/lib/debugger/src/dbg_icmd.erl
+++ b/lib/debugger/src/dbg_icmd.erl
@@ -94,7 +94,7 @@ break_p(Mod, Line, Le, Bs) ->
Bool = case Cond of
null -> true;
{CM, CN} ->
- try apply(CM, CN, [Bs]) of
+ try CM:CN(Bs) of
true -> true;
false -> false;
_Term -> false
@@ -245,7 +245,7 @@ handle_int_msg({attached, AttPid}, Status, _Bs,
%% Tell attached process in which module evalution is located
if
- Le==1 ->
+ Le =:= 1 ->
tell_attached({attached, undefined, -1, get(trace)});
true ->
tell_attached({attached, M, Line, get(trace)}),
@@ -269,7 +269,7 @@ handle_int_msg(detached, _Status, _Bs, _Ieval) ->
handle_int_msg({old_code,Mod}, Status, Bs,
#ieval{level=Le,module=M}=Ieval) ->
if
- Status==idle, Le==1 ->
+ Status =:= idle, Le =:= 1 ->
erase([Mod|db]),
put(cache, []);
true ->
@@ -352,9 +352,9 @@ set_stack_trace(true) ->
set_stack_trace(all);
set_stack_trace(Flag) ->
if
- Flag==false ->
+ Flag =:= false ->
put(stack, []);
- Flag==no_tail; Flag==all ->
+ Flag =:= no_tail; Flag =:= all ->
ignore
end,
put(trace_stack, Flag),
@@ -367,7 +367,7 @@ bindings(Bs, nostack) ->
Bs;
bindings(Bs, SP) ->
case dbg_ieval:stack_level() of
- Le when SP>Le ->
+ Le when SP > Le ->
Bs;
_ ->
dbg_ieval:bindings(SP)
@@ -377,7 +377,6 @@ messages() ->
{messages, Msgs} = erlang:process_info(get(self), messages),
Msgs.
-
%%====================================================================
%% Evaluating expressions within process context
%%====================================================================
@@ -398,7 +397,7 @@ eval_restricted({From,_Mod,Cmd,SP}, Bs) ->
From ! {self(), {eval_rsp, Rsp}}
end.
-eval_nonrestricted({From,Mod,Cmd,SP}, Bs, #ieval{level=Le}) when SP<Le->
+eval_nonrestricted({From,Mod,Cmd,SP}, Bs, #ieval{level=Le}) when SP < Le->
%% Evaluate in stack
eval_restricted({From, Mod, Cmd, SP}, Bs),
Bs;
@@ -424,15 +423,15 @@ eval_nonrestricted({From, _Mod, Cmd, _SP}, Bs,
eval_nonrestricted_1({match,_,{var,_,Var},Expr}, Bs, Ieval) ->
{value,Res,Bs2} =
dbg_ieval:eval_expr(Expr, Bs, Ieval#ieval{last_call=false}),
- Bs3 = case lists:keysearch(Var, 1, Bs) of
- {value, {Var,_Value}} ->
+ Bs3 = case lists:keyfind(Var, 1, Bs) of
+ {Var,_Value} ->
lists:keyreplace(Var, 1, Bs2, {Var,Res});
false -> [{Var,Res} | Bs2]
end,
{Res,Bs3};
eval_nonrestricted_1({var,_,Var}, Bs, _Ieval) ->
- Res = case lists:keysearch(Var, 1, Bs) of
- {value, {Var, Value}} -> Value;
+ Res = case lists:keyfind(Var, 1, Bs) of
+ {Var, Value} -> Value;
false -> unbound
end,
{Res,Bs};
@@ -458,7 +457,6 @@ parse_cmd(Cmd, LineNo) ->
{ok,Forms} = erl_parse:parse_exprs(Tokens),
Forms.
-
%%====================================================================
%% Library functions for attached process handling
%%====================================================================
@@ -470,13 +468,12 @@ tell_attached(Msg) ->
AttPid ! {self(), Msg}
end.
-
%%====================================================================
%% get_binding/2
%%====================================================================
get_binding(Var, Bs) ->
- case lists:keysearch(Var, 1, Bs) of
- {value, {Var, Value}} -> {value, Value};
+ case lists:keyfind(Var, 1, Bs) of
+ {Var, Value} -> {value, Value};
false -> unbound
end.
diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl
index c13fda7ac1..476dfd8796 100644
--- a/lib/debugger/src/dbg_ieval.erl
+++ b/lib/debugger/src/dbg_ieval.erl
@@ -120,9 +120,9 @@ check_exit_msg({'EXIT', Int, Reason}, _Bs, #ieval{level=Le}) ->
%% This *must* be interpreter which has terminated,
%% we are not linked to anyone else
if
- Le==1 ->
+ Le =:= 1 ->
exit(Reason);
- Le>1 ->
+ Le > 1 ->
exit({Int, Reason})
end;
check_exit_msg({'DOWN',_,_,_,Reason}, Bs,
@@ -139,9 +139,9 @@ check_exit_msg({'DOWN',_,_,_,Reason}, Bs,
%% importance in this case
%% If we don't save them, however, post-mortem analysis
%% of the process isn't possible
- undefined when Le==1 -> % died outside interpreted code
+ undefined when Le =:= 1 -> % died outside interpreted code
{};
- undefined when Le>1 ->
+ undefined when Le > 1 ->
StackBin = term_to_binary(get(stack)),
{{Mod, Li}, Bs, StackBin};
@@ -152,9 +152,9 @@ check_exit_msg({'DOWN',_,_,_,Reason}, Bs,
dbg_iserver:cast(get(int), {set_exit_info,self(),ExitInfo}),
if
- Le==1 ->
+ Le =:= 1 ->
exit(Reason);
- Le>1 ->
+ Le > 1 ->
exit({get(self), Reason})
end;
check_exit_msg(_Msg, _Bs, _Ieval) ->
@@ -271,7 +271,7 @@ meta_loop(Debugged, Bs, #ieval{level=Le} = Ieval) ->
end;
%% Re-entry to Meta from non-interpreted code
- {re_entry, Debugged, {eval,{M,F,As}}} when Le==1 ->
+ {re_entry, Debugged, {eval,{M,F,As}}} when Le =:= 1 ->
%% Reset process dictionary
%% This is really only necessary if the process left
%% interpreted code at a call level > 1
@@ -346,7 +346,7 @@ push(MFA, Bs, #ieval{level=Le,module=Cm,line=Li,last_call=Lc}) ->
[] -> put(stack, [Entry]);
[_Entry|Entries] -> put(stack, [Entry|Entries])
end;
- _ -> % all | no_tail when Lc==false
+ _ -> % all | no_tail when Lc =:= false
put(stack, [Entry|get(stack)])
end.
@@ -413,10 +413,10 @@ sublist(L, Start, Length) ->
lists:sublist(L, Start, Length).
fix_stacktrace2([{_,{{M,F,As1},_,_}}, {_,{{M,F,As2},_,_}}|_])
- when length(As1)==length(As2) ->
+ when length(As1) =:= length(As2) ->
[{M,F,As1}];
fix_stacktrace2([{_,{{Fun,As1},_,_}}, {_,{{Fun,As2},_,_}}|_])
- when length(As1)==length(As2) ->
+ when length(As1) =:= length(As2) ->
[{Fun,As1}];
fix_stacktrace2([{_,{MFA,_,_}}|Entries]) ->
[MFA|fix_stacktrace2(Entries)];
@@ -465,9 +465,9 @@ stack_frame(SP, Dir, [{SP, _}|Stack]) ->
case Stack of
[{Le, {_MFA,Where,Bs}}|_] ->
{Le, Where, Bs};
- [] when Dir==up ->
+ [] when Dir =:= up ->
top;
- [] when Dir==down ->
+ [] when Dir =:= down ->
bottom
end;
stack_frame(SP, Dir, [_Entry|Stack]) ->
@@ -509,7 +509,7 @@ trace(What, Args, true) ->
end,
io_lib:format(" (~w) receive " ++ Tail, [Le]);
- received when Args==null ->
+ received when Args =:= null ->
io_lib:format("~n", []);
received -> % Args=Msg
io_lib:format("~n<== ~p~n", [Args]);
@@ -586,8 +586,8 @@ eval_mfa(Debugged, M, F, As, Ieval) ->
end.
eval_function(Mod, Fun, As0, Bs0, _Called, Ieval) when is_function(Fun);
- Mod==?MODULE,
- Fun==eval_fun ->
+ Mod =:= ?MODULE,
+ Fun =:= eval_fun ->
#ieval{level=Le, line=Li, last_call=Lc} = Ieval,
case lambda(Fun, As0) of
{Cs,Module,Name,As,Bs} ->
@@ -657,7 +657,7 @@ eval_function(Mod, Name, As0, Bs0, Called, Ieval) ->
lambda(eval_fun, [Cs,As,Bs,{Mod,Name}=F]) ->
%% Fun defined in interpreted code, called from outside
if
- length(element(3,hd(Cs))) == length(As) ->
+ length(element(3,hd(Cs))) =:= length(As) ->
db_ref(Mod), %% Adds ref between module and process
{Cs,Mod,Name,As,Bs};
true ->
@@ -672,7 +672,7 @@ lambda(Fun, As) when is_function(Fun) ->
{env, [{Mod,Name},Bs,Cs]} = erlang:fun_info(Fun, env),
{arity, Arity} = erlang:fun_info(Fun, arity),
if
- length(As) == Arity ->
+ length(As) =:= Arity ->
db_ref(Mod), %% Adds ref between module and process
{Cs,Mod,Name,As,Bs};
true ->
@@ -731,7 +731,7 @@ db_ref(Mod) ->
ModDb ->
Node = node(get(int)),
DbRef = if
- Node/=node() -> {Node,ModDb};
+ Node =/= node() -> {Node,ModDb};
true -> ModDb
end,
put([Mod|db], DbRef),
@@ -741,13 +741,12 @@ db_ref(Mod) ->
DbRef
end.
-
cache(Key, Data) ->
put(cache, lists:sublist([{Key,Data}|get(cache)], 5)).
cached(Key) ->
- case lists:keysearch(Key, 1, get(cache)) of
- {value,{Key,Data}} -> Data;
+ case lists:keyfind(Key, 1, get(cache)) of
+ {Key,Data} -> Data;
false -> false
end.
@@ -844,7 +843,7 @@ expr({'try',Line,Es,CaseCs,CatchCs,[]}, Bs0, Ieval0) ->
case_clauses(Val, CaseCs, Bs, try_clause, Ieval)
end
catch
- Class:Reason when CatchCs=/=[] ->
+ Class:Reason when CatchCs =/= [] ->
catch_clauses({Class,Reason,[]}, CatchCs, Bs0, Ieval)
end;
expr({'try',Line,Es,CaseCs,CatchCs,As}, Bs0, Ieval0) ->
@@ -1498,10 +1497,7 @@ guard(Gs, Bs) -> or_guard(Gs, Bs).
or_guard([G|Gs], Bs) ->
%% Short-circuit OR.
- case and_guard(G, Bs) of
- true -> true;
- false -> or_guard(Gs, Bs)
- end;
+ and_guard(G, Bs) orelse or_guard(Gs, Bs);
or_guard([], _) -> false.
and_guard([G|Gs], Bs) ->
@@ -1598,8 +1594,7 @@ match1({bin,_,Fs}, B, Bs0, BBs0) when is_bitstring(B) ->
try eval_bits:match_bits(Fs, B, Bs1, BBs,
fun(L, R, Bs) -> match1(L, R, Bs, BBs) end,
fun(E, Bs) -> expr(E, Bs, #ieval{}) end,
- false) of
- Match -> Match
+ false)
catch
_:_ -> throw(nomatch)
end;
@@ -1687,7 +1682,7 @@ merge_bindings([{Name,V}|B1s], B2s, Ieval) ->
case binding(Name, B2s) of
{value,V} -> % Already there, and the same
merge_bindings(B1s, B2s, Ieval);
- {value,_} when Name=='_' -> % Already there, but anonymous
+ {value,_} when Name =:= '_' -> % Already there, but anonymous
B2s1 = lists:keydelete('_', 1, B2s),
[{Name,V}|merge_bindings(B1s, B2s1, Ieval)];
{value,_} -> % Already there, but different => badmatch
diff --git a/lib/debugger/src/dbg_iload.erl b/lib/debugger/src/dbg_iload.erl
index ec54c646c8..2ae0c333da 100644
--- a/lib/debugger/src/dbg_iload.erl
+++ b/lib/debugger/src/dbg_iload.erl
@@ -26,7 +26,7 @@
%%--------------------------------------------------------------------
%% load_mod(Mod, File, Binary, Db) -> {ok, Mod}
-%% Mod = atom()
+%% Mod = module()
%% File = string() Source file (including path)
%% Binary = binary()
%% Db = ETS identifier
@@ -408,8 +408,7 @@ expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,fault}},[_]=As}) ->
{dbg,Line,fault,expr_list(As)};
expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,exit}},[_]=As}) ->
{dbg,Line,exit,expr_list(As)};
-expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,apply}},As0})
- when length(As0) == 3 ->
+expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,apply}},[_,_,_]=As0}) ->
As = expr_list(As0),
{apply,Line,As};
expr({call,Line,{remote,_,{atom,_,Mod},{atom,_,Func}},As0}) ->
@@ -517,15 +516,9 @@ expr(Other) ->
%% here as sys_pre_expand has transformed source.
is_guard_test({op,_,Op,L,R}) ->
- case erl_internal:comp_op(Op, 2) of
- true -> is_gexpr_list([L,R]);
- false -> false
- end;
+ erl_internal:comp_op(Op, 2) andalso is_gexpr_list([L,R]);
is_guard_test({call,_,{remote,_,{atom,_,erlang},{atom,_,Test}},As}) ->
- case erl_internal:type_test(Test, length(As)) of
- true -> is_gexpr_list(As);
- false -> false
- end;
+ erl_internal:type_test(Test, length(As)) andalso is_gexpr_list(As);
is_guard_test({atom,_,true}) -> true;
is_guard_test(_) -> false.
@@ -542,22 +535,12 @@ is_gexpr({call,_,{remote,_,{atom,_,erlang},{atom,_,F}},As}) ->
Ar = length(As),
case erl_internal:guard_bif(F, Ar) of
true -> is_gexpr_list(As);
- false ->
- case erl_internal:arith_op(F, Ar) of
- true -> is_gexpr_list(As);
- false -> false
- end
+ false -> erl_internal:arith_op(F, Ar) andalso is_gexpr_list(As)
end;
is_gexpr({op,_,Op,A}) ->
- case erl_internal:arith_op(Op, 1) of
- true -> is_gexpr(A);
- false -> false
- end;
+ erl_internal:arith_op(Op, 1) andalso is_gexpr(A);
is_gexpr({op,_,Op,A1,A2}) ->
- case erl_internal:arith_op(Op, 2) of
- true -> is_gexpr_list([A1,A2]);
- false -> false
- end;
+ erl_internal:arith_op(Op, 2) andalso is_gexpr_list([A1,A2]);
is_gexpr(_) -> false.
is_gexpr_list(Es) -> lists:all(fun (E) -> is_gexpr(E) end, Es).
diff --git a/lib/debugger/src/dbg_iserver.erl b/lib/debugger/src/dbg_iserver.erl
index 4c1e9ccb7b..59188d83a2 100644
--- a/lib/debugger/src/dbg_iserver.erl
+++ b/lib/debugger/src/dbg_iserver.erl
@@ -155,11 +155,8 @@ handle_call(get_stack_trace, _From, State) ->
%% Retrieving information
handle_call(snapshot, _From, State) ->
- Reply = lists:map(fun(Proc) ->
- {Proc#proc.pid, Proc#proc.function,
- Proc#proc.status, Proc#proc.info}
- end,
- State#state.procs),
+ Reply = [{Proc#proc.pid, Proc#proc.function,
+ Proc#proc.status, Proc#proc.info} || Proc <- State#state.procs],
{reply, Reply, State};
handle_call({get_meta, Pid}, _From, State) ->
Reply = case get_proc({pid, Pid}, State#state.procs) of
@@ -181,21 +178,21 @@ handle_call({get_attpid, Pid}, _From, State) ->
%% Breakpoint handling
handle_call({new_break, Point, Options}, _From, State) ->
- case lists:keysearch(Point, 1, State#state.breaks) of
+ case lists:keymember(Point, 1, State#state.breaks) of
false ->
Break = {Point, Options},
send_all([subscriber, meta, attached],
{new_break, Break}, State),
Breaks = keyinsert(Break, 1, State#state.breaks),
{reply, ok, State#state{breaks=Breaks}};
- {value, _Break} ->
+ true ->
{reply, {error, break_exists}, State}
end;
handle_call(all_breaks, _From, State) ->
{reply, State#state.breaks, State};
handle_call({all_breaks, Mod}, _From, State) ->
Reply = lists:filter(fun({{M,_L}, _Options}) ->
- if M==Mod -> true; true -> false end
+ M =/= Mod
end,
State#state.breaks),
{reply, Reply, State};
@@ -276,7 +273,7 @@ handle_call({contents, Mod, Pid}, _From, State) ->
Db = State#state.db,
[{{Mod, refs}, ModDbs}] = ets:lookup(Db, {Mod, refs}),
ModDb = if
- Pid==any -> hd(ModDbs);
+ Pid =:= any -> hd(ModDbs);
true ->
lists:foldl(fun(T, not_found) ->
[{T, Pids}] = ets:lookup(Db, T),
@@ -295,7 +292,7 @@ handle_call({raw_contents, Mod, Pid}, _From, State) ->
Db = State#state.db,
[{{Mod, refs}, ModDbs}] = ets:lookup(Db, {Mod, refs}),
ModDb = if
- Pid==any -> hd(ModDbs);
+ Pid =:= any -> hd(ModDbs);
true ->
lists:foldl(fun(T, not_found) ->
[{T, Pids}] = ets:lookup(Db, T),
@@ -360,15 +357,15 @@ handle_cast({set_stack_trace, Flag}, State) ->
%% Retrieving information
handle_cast(clear, State) ->
Procs = lists:filter(fun(#proc{status=Status}) ->
- if Status==exit -> false; true -> true end
+ Status =/= exit
end,
State#state.procs),
{noreply, State#state{procs=Procs}};
%% Breakpoint handling
handle_cast({delete_break, Point}, State) ->
- case lists:keysearch(Point, 1, State#state.breaks) of
- {value, _Break} ->
+ case lists:keymember(Point, 1, State#state.breaks) of
+ true ->
send_all([subscriber, meta, attached],
{delete_break, Point}, State),
Breaks = lists:keydelete(Point, 1, State#state.breaks),
@@ -377,8 +374,8 @@ handle_cast({delete_break, Point}, State) ->
{noreply, State}
end;
handle_cast({break_option, Point, Option, Value}, State) ->
- case lists:keysearch(Point, 1, State#state.breaks) of
- {value, {Point, Options}} ->
+ case lists:keyfind(Point, 1, State#state.breaks) of
+ {Point, Options} ->
N = case Option of
status -> 1;
action -> 2;
@@ -399,7 +396,7 @@ handle_cast(no_break, State) ->
handle_cast({no_break, Mod}, State) ->
send_all([subscriber, meta, attached], {no_break, Mod}, State),
Breaks = lists:filter(fun({{M, _L}, _O}) ->
- if M==Mod -> false; true -> true end
+ M =/= Mod
end,
State#state.breaks),
{noreply, State#state{breaks=Breaks}};
@@ -409,7 +406,7 @@ handle_cast({set_status, Meta, Status, Info}, State) ->
{true, Proc} = get_proc({meta, Meta}, State#state.procs),
send_all(subscriber, {new_status, Proc#proc.pid, Status, Info}, State),
if
- Status==break ->
+ Status =:= break ->
auto_attach(break, State#state.auto, Proc);
true -> ignore
end,
@@ -526,11 +523,10 @@ code_change(_OldVsn, State, _Extra) ->
%% Internal functions
%%====================================================================
-auto_attach(Why, Auto, Proc) when is_record(Proc, proc) ->
- case Proc#proc.attpid of
- AttPid when is_pid(AttPid) -> ignore;
- undefined ->
- auto_attach(Why, Auto, Proc#proc.pid)
+auto_attach(Why, Auto, #proc{attpid = Attpid, pid = Pid}) ->
+ case Attpid of
+ undefined -> auto_attach(Why, Auto, Pid);
+ _ when is_pid(Attpid) -> ignore
end;
auto_attach(Why, Auto, Pid) when is_pid(Pid) ->
case Auto of
@@ -545,7 +541,7 @@ auto_attach(Why, Auto, Pid) when is_pid(Pid) ->
keyinsert(Tuple1, N, [Tuple2|Tuples]) ->
if
- element(N, Tuple1)<element(N, Tuple2) ->
+ element(N, Tuple1) < element(N, Tuple2) ->
[Tuple1, Tuple2|Tuples];
true ->
[Tuple2 | keyinsert(Tuple1, N, Tuples)]
@@ -576,7 +572,7 @@ send_all([], _Msg, _State) -> ok;
send_all(subscriber, Msg, State) ->
send_all(State#state.subs, Msg);
send_all(meta, Msg, State) ->
- Metas = lists:map(fun(Proc) -> Proc#proc.meta end, State#state.procs),
+ Metas = [Proc#proc.meta || Proc <- State#state.procs],
send_all(Metas, Msg);
send_all(attached, Msg, State) ->
AttPids= mapfilter(fun(Proc) ->
@@ -600,7 +596,7 @@ get_proc({Type, Pid}, Procs) ->
meta -> #proc.meta;
attpid -> #proc.attpid
end,
- case lists:keysearch(Pid, Index, Procs) of
- {value, Proc} -> {true, Proc};
- false -> false
+ case lists:keyfind(Pid, Index, Procs) of
+ false -> false;
+ Proc -> {true, Proc}
end.
diff --git a/lib/debugger/src/dbg_ui_break_win.erl b/lib/debugger/src/dbg_ui_break_win.erl
index a56fe36828..0c1e25e703 100644
--- a/lib/debugger/src/dbg_ui_break_win.erl
+++ b/lib/debugger/src/dbg_ui_break_win.erl
@@ -268,12 +268,7 @@ handle_event({gs, _Id, click, _Data, ["Ok"|_]}, WinInfo) ->
IndexL ->
Funcs = WinInfo#winInfo.funcs,
Breaks =
- lists:map(fun(Index) ->
- Func = lists:nth(Index+1,
- Funcs),
- [Mod | Func]
- end,
- IndexL),
+ [[Mod|lists:nth(Index+1, Funcs)] || Index <- IndexL],
{break, Breaks, enable}
end
end;
diff --git a/lib/debugger/src/dbg_ui_filedialog_win.erl b/lib/debugger/src/dbg_ui_filedialog_win.erl
index f7d76076a5..79ccf20946 100644
--- a/lib/debugger/src/dbg_ui_filedialog_win.erl
+++ b/lib/debugger/src/dbg_ui_filedialog_win.erl
@@ -202,8 +202,7 @@ handle_event({gs, 'Files', doubleclick, _Data, _Arg}, WinInfo) ->
handle_event({gs, _Id, click, select, _Arg}, _WinInfo) ->
{select, gs:read('Selection', text)};
handle_event({gs, _Id, click, multiselect, _Arg}, WinInfo) ->
- Files = lists:map(fun(File) -> untag(File) end,
- gs:read('Files', items)),
+ Files = [untag(File) || File <- gs:read('Files', items)],
{multiselect, WinInfo#winInfo.cwd, Files};
handle_event({gs, _Id, click, filter, _Arg}, WinInfo) ->
{Cwd, Pattern} = update_win(gs:read('Filter', text),
@@ -286,7 +285,7 @@ max_existing([Name | Names]) ->
max_existing(Dir, [Name | Names]) ->
Dir2 = filename:join(Dir, Name),
case filelib:is_file(Dir2, erl_prim_loader) of
- true when Names==[] -> {Dir2, []};
+ true when Names =:= [] -> {Dir2, []};
true -> max_existing(Dir2, Names);
false -> {Dir, [Name | Names]}
end.
@@ -309,11 +308,8 @@ extra_filter([], _Dir, _Fun) -> [].
get_subdirs(Dir) ->
case erl_prim_loader:list_dir(Dir) of
{ok, FileNames} ->
- X = lists:filter(fun(FileName) ->
- File = filename:join(Dir, FileName),
- filelib:is_dir(File, erl_prim_loader)
- end,
- FileNames),
+ X = [FN || FN <- FileNames,
+ filelib:is_dir(filename:join(Dir, FN), erl_prim_loader)],
lists:sort(X);
_Error ->
[]
@@ -335,4 +331,3 @@ compare([], [$/|File]) ->
File;
compare(_, _) ->
error.
-
diff --git a/lib/debugger/src/dbg_ui_mon.erl b/lib/debugger/src/dbg_ui_mon.erl
index 8888075124..82fe210968 100644
--- a/lib/debugger/src/dbg_ui_mon.erl
+++ b/lib/debugger/src/dbg_ui_mon.erl
@@ -162,7 +162,7 @@ init2(CallingPid, Mode, SFile, GS) ->
CallingPid ! {initialization_complete, self()},
if
- SFile==default ->
+ SFile =:= default ->
loop(State3);
true ->
loop(load_settings(SFile, State3))
@@ -226,7 +226,7 @@ loop(State) ->
gui_cmd(stopped, State);
%% From the GUI
- GuiEvent when is_tuple(GuiEvent), element(1, GuiEvent)==gs ->
+ GuiEvent when is_tuple(GuiEvent), element(1, GuiEvent) =:= gs ->
Cmd = dbg_ui_mon_win:handle_event(GuiEvent,State#state.win),
State2 = gui_cmd(Cmd, State),
loop(State2);
@@ -269,7 +269,7 @@ gui_cmd(ignore, State) ->
State;
gui_cmd(stopped, State) ->
if
- State#state.starter==true -> int:stop();
+ State#state.starter =:= true -> int:stop();
true -> int:auto_attach(false)
end,
exit(stop);
@@ -413,9 +413,9 @@ gui_cmd({'Trace Window', TraceWin}, State) ->
State2;
gui_cmd({'Auto Attach', When}, State) ->
if
- When==[] -> int:auto_attach(false);
+ When =:= [] -> int:auto_attach(false);
true ->
- Flags = lists:map(fun(Name) -> map(Name) end, When),
+ Flags = [map(Name) || Name <- When],
int:auto_attach(Flags, trace_function(State))
end,
State;
@@ -676,7 +676,7 @@ load_settings2(Settings, State) ->
Break,
int:break(Mod, Line),
if
- Status==inactive ->
+ Status =:= inactive ->
int:disable_break(Mod, Line);
true -> ignore
end,
@@ -700,12 +700,8 @@ save_settings(SFile, State) ->
int:auto_attach(),
int:stack_trace(),
State#state.backtrace,
- lists:map(fun(Mod) ->
- int:file(Mod)
- end,
- int:interpreted()),
+ [int:file(Mod) || Mod <- int:interpreted()],
int:all_breaks()},
-
Binary = term_to_binary({debugger_settings, Settings}),
case file:write_file(SFile, Binary) of
ok ->
@@ -720,13 +716,12 @@ save_settings(SFile, State) ->
%%====================================================================
registered_name(Pid) ->
-
%% Yield in order to give Pid more time to register its name
timer:sleep(200),
Node = node(Pid),
if
- Node==node() ->
+ Node =:= node() ->
case erlang:process_info(Pid, registered_name) of
{registered_name, Name} -> Name;
_ -> undefined
diff --git a/lib/debugger/src/dbg_ui_mon_win.erl b/lib/debugger/src/dbg_ui_mon_win.erl
index ba2f94c550..66e59a822a 100644
--- a/lib/debugger/src/dbg_ui_mon_win.erl
+++ b/lib/debugger/src/dbg_ui_mon_win.erl
@@ -224,8 +224,7 @@ select(MenuItem, Bool) ->
%%--------------------------------------------------------------------
add_module(WinInfo, Menu, Mod) ->
Modules = WinInfo#winInfo.modules,
- case lists:keysearch(Mod, #moduleInfo.module, Modules) of
- {value, _ModInfo} -> WinInfo;
+ case lists:keymember(Mod, #moduleInfo.module, Modules) of
false ->
%% Create a menu for the module
Font = dbg_ui_win:font(normal),
@@ -244,7 +243,8 @@ add_module(WinInfo, Menu, Mod) ->
gs:config(WinInfo#winInfo.listbox, {add, Mod}),
ModInfo = #moduleInfo{module=Mod, menubtn=MenuBtn},
- WinInfo#winInfo{modules=[ModInfo | Modules]}
+ WinInfo#winInfo{modules=[ModInfo | Modules]};
+ true -> WinInfo
end.
%%--------------------------------------------------------------------
@@ -491,14 +491,13 @@ handle_event({gs, _Id, click, autoattach, _Arg}, WinInfo) ->
%% Process grid
handle_event({gs, _Id, keypress, _Data, [Key|_]}, WinInfo) when
- Key=='Up'; Key=='Down' ->
- Dir = if Key=='Up' -> up; Key=='Down' -> down end,
+ Key =:= 'Up'; Key =:= 'Down' ->
+ Dir = if Key =:= 'Up' -> up; Key =:= 'Down' -> down end,
Row = move(WinInfo, Dir),
-
if Row>1 ->
WinInfo2 = highlight(WinInfo, Row),
- {value, #procInfo{pid=Pid}} =
- lists:keysearch(Row, #procInfo.row, WinInfo#winInfo.processes),
+ #procInfo{pid=Pid} =
+ lists:keyfind(Row, #procInfo.row, WinInfo#winInfo.processes),
{focus, Pid, WinInfo2};
true ->
ignore
@@ -515,10 +514,9 @@ handle_event(_GSEvent, _WinInfo) ->
move(WinInfo, Dir) ->
Row = WinInfo#winInfo.focus,
Last = WinInfo#winInfo.row,
-
if
- Dir==up, Row>1 -> Row-1;
- Dir==down, Row<Last -> Row+1;
+ Dir =:= up, Row > 1 -> Row-1;
+ Dir =:= down, Row < Last -> Row+1;
true -> Row
end.
@@ -533,7 +531,6 @@ highlight(WinInfo, Row) ->
GridLine2 = gs:read(Grid, {obj_at_row, Row}),
gs:config(GridLine2, {fg, white}),
WinInfo#winInfo{focus=Row}.
-
%%====================================================================
%% Internal functions
@@ -545,7 +542,7 @@ configure(WinInfo, {W, H}) ->
Dx = NewW - gs:read(Grid, width),
Dy = H-42 - gs:read(Grid, height),
if
- (Dx+Dy)=/=0 ->
+ (Dx+Dy) =/= 0 ->
gs:config(Grid, [{width, NewW}, {height, H-30}]),
Cols = calc_columnwidths(NewW),
gs:config(Grid, Cols);
@@ -555,10 +552,9 @@ configure(WinInfo, {W, H}) ->
calc_columnwidths(Width) ->
W = if
- Width=<?Wg -> ?Wg;
+ Width =< ?Wg -> ?Wg;
true -> Width
end,
- First = lists:map(fun (X) -> round(X) end,
- [0.13*W, 0.27*W, 0.18*W, 0.18*W]),
+ First = [round(X) || X <- [0.13*W, 0.27*W, 0.18*W, 0.18*W]],
Last = W - lists:sum(First) - 30,
{columnwidths, First++[Last]}.
diff --git a/lib/debugger/src/dbg_ui_trace_win.erl b/lib/debugger/src/dbg_ui_trace_win.erl
index c6f041a63d..82d4199630 100644
--- a/lib/debugger/src/dbg_ui_trace_win.erl
+++ b/lib/debugger/src/dbg_ui_trace_win.erl
@@ -147,17 +147,17 @@ configure(WinInfo, TraceWin) ->
H = gs:read(Win, height),
H2 = if
- Bu1==close, Bu2==open ->
+ Bu1 =:= close, Bu2 =:= open ->
resize_button_area(open, width, W-4),
gs:config('ButtonArea', {height, 30}),
H+30;
- Bu1==open, Bu2==close ->
+ Bu1 =:= open, Bu2 =:= close ->
gs:config('ButtonArea', [{width, 0}, {height, 0}]),
H-30;
true -> H
end,
H3 = if
- Ev1==close, Ev2==open, Bi1==open ->
+ Ev1 =:= close, Ev2 =:= open, Bi1 =:= open ->
Wnew1 = round((W-10-4)/2), % W = window/2 - rb - pads
Hbi1 = gs:read('BindArea', height), % H = bind area h
resize_eval_area(open, width, Wnew1),
@@ -167,25 +167,25 @@ configure(WinInfo, TraceWin) ->
resize_bind_area(open, width,
Wnew1-gs:read('BindArea', width)),
H2;
- Ev1==close, Ev2==open, Bi1==close ->
+ Ev1 =:= close, Ev2 =:= open, Bi1 =:= close ->
resize_eval_area(open, width, W-4),
resize_eval_area(open, height, 200),
H2+200;
- Ev1==open, Ev2==close, Bi1==open ->
+ Ev1 =:= open, Ev2 =:= close, Bi1 =:= open ->
gs:config('EvalArea', [{width,0}, {height,0}]),
gs:config('RB3', [{width, 0}, {height, 0}]),
Wnew2 = W-4,
resize_bind_area(open, width,
Wnew2-gs:read('BindArea', width)),
H2;
- Ev1==open, Ev2==close, Bi1==close ->
+ Ev1 =:= open, Ev2 =:= close, Bi1 =:= close ->
Hs1 = gs:read('EvalArea', height),
gs:config('EvalArea', [{width, 0}, {height, 0}]),
H2-Hs1;
true -> H2
end,
H4 = if
- Bi1==close, Bi2==open, Ev2==open ->
+ Bi1 =:= close, Bi2 =:= open, Ev2 =:= open ->
Wnew3 = round((W-10-4)/2), % W = window/2 - rb - pads
Hs2 = gs:read('EvalArea', height), % H = eval area h
resize_bind_area(open, width, Wnew3),
@@ -194,29 +194,29 @@ configure(WinInfo, TraceWin) ->
resize_eval_area(open, width,
Wnew3-gs:read('EvalArea', width)),
H3;
- Bi1==close, Bi2==open, Ev2==close ->
+ Bi1 =:= close, Bi2 =:= open, Ev2 =:= close ->
resize_bind_area(open, width, W-4),
resize_bind_area(open, height, 200),
H3+200;
- Bi1==open, Bi2==close, Ev2==open ->
+ Bi1 =:= open, Bi2 =:= close, Ev2 =:= open ->
gs:config('BindArea', [{width, 0}, {height, 0}]),
gs:config('RB3', [{width, 0}, {height, 0}]),
Wnew4 = W-4,
resize_eval_area(open, width,
Wnew4-gs:read('EvalArea', width)),
H3;
- Bi1==open, Bi2==close, Ev2==close ->
+ Bi1 =:= open, Bi2 =:= close, Ev2 =:= close ->
Hbi2 = gs:read('BindArea', height),
gs:config('BindArea', [{width, 0}, {height, 0}]),
H3-Hbi2;
true -> H3
end,
H5 = if
- Tr1==close, Tr2==open ->
+ Tr1 =:= close, Tr2 =:= open ->
resize_trace_area(open, width, W-4),
resize_trace_area(open, height, 200),
H4+200;
- Tr1==open, Tr2==close ->
+ Tr1 =:= open, Tr2 =:= close ->
Hf = gs:read('TraceArea', height),
gs:config('TraceArea', [{width, 0}, {height, 0}]),
H4-Hf;
@@ -226,10 +226,10 @@ configure(WinInfo, TraceWin) ->
RB1old = rb1(OldFlags), RB1new = rb1(NewFlags),
if
- RB1old==close, RB1new==open ->
+ RB1old =:= close, RB1new =:= open ->
gs:config('RB1', [{width, W-4}, {height, 10}]),
gs:config(Win, {height, gs:read(Win, height)+10});
- RB1old==open, RB1new==close ->
+ RB1old =:= open, RB1new =:= close ->
gs:config('RB1', [{width, 0}, {height, 0}, lower]),
gs:config(Win, {height, gs:read(Win, height)-10});
true -> ignore
@@ -237,10 +237,10 @@ configure(WinInfo, TraceWin) ->
RB2old = rb2(OldFlags), RB2new = rb2(NewFlags),
if
- RB2old==close, RB2new==open ->
+ RB2old =:= close, RB2new =:= open ->
gs:config('RB2', [{width, W-4}, {height, 10}]),
gs:config(Win, {height,gs:read(Win, height)+10});
- RB2old==open, RB2new==close ->
+ RB2old =:= open, RB2new =:= close ->
gs:config('RB2', [{width, 0}, {height, 0}, lower]),
gs:config(Win, {height, gs:read(Win, height)-10});
true -> ignore
@@ -301,15 +301,15 @@ select(MenuItem, Bool) ->
%% Cond = null | {Mod, Func}
%%--------------------------------------------------------------------
add_break(WinInfo, Menu, {{Mod,Line},[Status|_Options]}=Break) ->
- case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
- {value, {Mod, Editor}} ->
+ case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
+ {Mod, Editor} ->
add_break_to_code(Editor, Line, Status);
false -> ignore
end,
add_break_to_menu(WinInfo, Menu, Break).
add_break_to_code(Editor, Line, Status) ->
- Color = if Status==active -> red; Status==inactive -> blue end,
+ Color = if Status =:= active -> red; Status =:= inactive -> blue end,
config_editor(Editor, [{overwrite,{{Line,0},"-@- "}},
{fg,{{{Line,0},{Line,lineend}}, Color}}]).
@@ -330,8 +330,8 @@ add_break_to_menu(WinInfo, Menu, {Point, [Status|_Options]=Options}) ->
%% Cond = null | {Mod, Func}
%%--------------------------------------------------------------------
update_break(WinInfo, {{Mod,Line},[Status|_Options]}=Break) ->
- case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
- {value, {Mod, Editor}} ->
+ case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
+ {Mod, Editor} ->
add_break_to_code(Editor, Line, Status);
false -> ignore
end,
@@ -352,8 +352,8 @@ update_break_in_menu(WinInfo, {Point, [Status|_Options]=Options}) ->
%% Point = {Mod, Line}
%%--------------------------------------------------------------------
delete_break(WinInfo, {Mod,Line}=Point) ->
- case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
- {value, {Mod, Editor}} -> delete_break_from_code(Editor, Line);
+ case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
+ {Mod, Editor} -> delete_break_from_code(Editor, Line);
false -> ignore
end,
delete_break_from_menu(WinInfo, Point).
@@ -379,11 +379,11 @@ clear_breaks(WinInfo) ->
clear_breaks(WinInfo, all).
clear_breaks(WinInfo, Mod) ->
Remove = if
- Mod==all -> WinInfo#winInfo.breaks;
+ Mod =:= all -> WinInfo#winInfo.breaks;
true ->
lists:filter(fun(#breakInfo{point={Mod2,_L}}) ->
if
- Mod2==Mod -> true;
+ Mod2 =:= Mod -> true;
true -> false
end
end,
@@ -450,8 +450,8 @@ display(Arg) ->
%% Note: remove_code/2 should not be used for currently shown module.
%%--------------------------------------------------------------------
is_shown(WinInfo, Mod) ->
- case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
- {value, {Mod, Editor}} ->
+ case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
+ {Mod, Editor} ->
gs:config(Editor, raise),
{true, WinInfo#winInfo{editor={Mod, Editor}}};
false -> false
@@ -459,24 +459,22 @@ is_shown(WinInfo, Mod) ->
show_code(WinInfo, Mod, Contents) ->
Editors = WinInfo#winInfo.editors,
- {Flag, Editor} = case lists:keysearch(Mod, 1, Editors) of
- {value, {Mod, Ed}} -> {existing, Ed};
+ {Flag, Editor} = case lists:keyfind(Mod, 1, Editors) of
+ {Mod, Ed} -> {existing, Ed};
false -> {new, code_editor()}
end,
-
%% Insert code and update breakpoints, if any
config_editor(Editor, [raise, clear]),
show_code(Editor, Contents),
lists:foreach(fun(BreakInfo) ->
case BreakInfo#breakInfo.point of
- {Mod2, Line} when Mod2==Mod ->
+ {Mod2, Line} when Mod2 =:= Mod ->
Status = BreakInfo#breakInfo.status,
add_break_to_code(Editor, Line,Status);
_Point -> ignore
end
end,
WinInfo#winInfo.breaks),
-
case Flag of
existing ->
WinInfo#winInfo{editor={Mod, Editor}};
@@ -485,7 +483,7 @@ show_code(WinInfo, Mod, Contents) ->
editors=[{Mod, Editor} | Editors]}
end.
-show_code(Editor, Text) when length(Text)>1500 ->
+show_code(Editor, Text) when length(Text) > 1500 ->
%% Add some text at a time so that other processes may get scheduled
Str = string:sub_string(Text, 1, 1500),
config_editor(Editor, {insert,{'end', Str}}),
@@ -494,21 +492,19 @@ show_code(Editor, Text) ->
config_editor(Editor, {insert,{'end',Text}}).
show_no_code(WinInfo) ->
- {value, {'$top', Editor}} =
- lists:keysearch('$top', 1, WinInfo#winInfo.editors),
+ {'$top', Editor} = lists:keyfind('$top', 1, WinInfo#winInfo.editors),
gs:config(Editor, raise),
WinInfo#winInfo{editor={'$top', Editor}}.
remove_code(WinInfo, Mod) ->
Editors = WinInfo#winInfo.editors,
- case lists:keysearch(Mod, 1, Editors) of
- {value, {Mod, Editor}} ->
+ case lists:keyfind(Mod, 1, Editors) of
+ {Mod, Editor} ->
gs:destroy(Editor),
WinInfo#winInfo{editors=lists:keydelete(Mod, 1, Editors)};
false ->
WinInfo
end.
-
%%--------------------------------------------------------------------
%% mark_line(WinInfo, Line, How) -> WinInfo
@@ -522,7 +518,7 @@ mark_line(WinInfo, Line, How) ->
mark_line2(Editor, WinInfo#winInfo.marked_line, false),
mark_line2(Editor, Line, How),
if
- Line/=0 -> config_editor(Editor, {vscrollpos, Line-5});
+ Line =/= 0 -> config_editor(Editor, {vscrollpos, Line-5});
true -> ignore
end,
WinInfo#winInfo{marked_line=Line}.
@@ -537,7 +533,7 @@ mark_line2(Editor, Line, How) ->
false -> " "
end,
Font = if
- How==false -> dbg_ui_win:font(normal);
+ How =:= false -> dbg_ui_win:font(normal);
true -> dbg_ui_win:font(bold)
end,
config_editor(Editor, [{overwrite, {{Line,5}, Prefix}},
@@ -558,10 +554,10 @@ select_line(WinInfo, Line) ->
%% help window, it must be checked that it is correct
Size = gs:read(Editor, size),
if
- Line==0 ->
+ Line =:= 0 ->
select_line(Editor, WinInfo#winInfo.selected_line, false),
WinInfo#winInfo{selected_line=0};
- Line<Size ->
+ Line < Size ->
select_line(Editor, Line, true),
config_editor(Editor, {vscrollpos, Line-5}),
WinInfo#winInfo{selected_line=Line};
@@ -712,10 +708,10 @@ handle_event({gs, Editor, buttonpress, code_editor, _Arg}, WinInfo) ->
{Row, _} ->
{Mod, _Editor} = WinInfo#winInfo.editor,
Point = {Mod, Row},
- case lists:keysearch(Point, #breakInfo.point,
+ case lists:keymember(Point, #breakInfo.point,
WinInfo#winInfo.breaks) of
- {value, _BreakInfo} -> {break, Point, delete};
- false -> {break, Point, add}
+ false -> {break, Point, add};
+ true -> {break, Point, delete}
end;
{Row2, _} ->
select_line(Editor, Row2, true),
@@ -776,7 +772,7 @@ code_editor() ->
code_editor(Name, W, H) ->
Editor = if
- Name==null -> gs:editor('CodeArea', []);
+ Name =:= null -> gs:editor('CodeArea', []);
true -> gs:editor(Name, 'CodeArea', [])
end,
gs:config(Editor, [{x,5}, {y,30}, {width,W}, {height,H},
@@ -814,8 +810,8 @@ buttons() ->
{'Where','WhereButton'}, {'Up','UpButton'}, {'Down','DownButton'}].
is_button(Name) ->
- case lists:keysearch(Name, 1, buttons()) of
- {value, {Name, Button}} -> {true, Button};
+ case lists:keyfind(Name, 1, buttons()) of
+ {Name, Button} -> {true, Button};
false -> false
end.
@@ -847,7 +843,7 @@ resize_button_area(open, width, Diff) ->
eval_area({Ev,Bi}, X, Y, FrameOpts, Win) ->
{W,H} = if
- Ev==open -> {289,200};
+ Ev =:= open -> {289,200};
true -> {0,0}
end,
Font = dbg_ui_win:font(normal),
@@ -870,7 +866,7 @@ eval_area({Ev,Bi}, X, Y, FrameOpts, Win) ->
{font_style,{{{1,0},'end'},Font}}]),
gs:config('EvalEditor', {enable, false}),
if
- Ev==open, Bi==close -> resize_eval_area(Ev, width, 257);
+ Ev =:= open, Bi =:= close -> resize_eval_area(Ev, width, 257);
true -> ignore
end.
@@ -891,7 +887,7 @@ resize_eval_area(open, Key, Diff) ->
bind_area({Ev,Bi}, X, Y, FrameOpts, Win) ->
{W,H} = if
- Bi==open -> {249,200};
+ Bi =:= open -> {249,200};
true -> {0,0}
end,
gs:frame('BindArea', Win,
@@ -908,7 +904,7 @@ bind_area({Ev,Bi}, X, Y, FrameOpts, Win) ->
{text,{1,"Name"}}, {text,{2,"Value"}}, {font,Font}]),
gs:config('BindGrid', {rows,{1,1}}),
if
- Bi==open, Ev==close -> resize_bind_area(Bi, width, 297);
+ Bi =:= open, Ev =:= close -> resize_bind_area(Bi, width, 297);
true -> ignore
end.
@@ -993,15 +989,15 @@ resizebar(Flag, Name, X, Y, W, H, Obj) ->
rb1({_Bu,Ev,Bi,Tr}) ->
if
- Ev==close, Bi==close, Tr==close -> close;
+ Ev =:= close, Bi =:= close, Tr =:= close -> close;
true -> open
end.
rb2({_Bu,Ev,Bi,Tr}) ->
if
- Tr==open ->
+ Tr =:= open ->
if
- Ev==close, Bi==close -> close;
+ Ev =:= close, Bi =:= close -> close;
true -> open
end;
true -> close
@@ -1009,7 +1005,7 @@ rb2({_Bu,Ev,Bi,Tr}) ->
rb3({_Bu,Ev,Bi,_Tr}) ->
if
- Ev==open, Bi==open -> open;
+ Ev =:= open, Bi =:= open -> open;
true -> close
end.
@@ -1067,7 +1063,7 @@ configure(WinInfo, NewW, NewH) ->
%% Adjust width unless it is unchanged or less than minimum width
if
- OldW/=NewW ->
+ OldW =/= NewW ->
{Dcode,Deval,Dbind} = configure_widths(OldW,NewW,Flags),
resize_code_area(WinInfo, width, Dcode),
case rb1(Flags) of
@@ -1090,7 +1086,7 @@ configure(WinInfo, NewW, NewH) ->
%% Adjust height unless it is unchanged or less than minimum height
if
- OldH/=NewH ->
+ OldH =/= NewH ->
{Dcode2,Deval2,Dtrace} = configure_heights(OldH,NewH,Flags),
resize_code_area(WinInfo, height, Dcode2),
resize_eval_area(Ev, height, Deval2),
@@ -1117,11 +1113,11 @@ configure_widths(OldW, NewW, Flags) ->
%% Check how much the frames can be resized in reality
Limits = if
%% Window larger
- NewW>OldW ->
+ NewW > OldW ->
if
- Ev==open,Bi==open -> {0,Diff,Diff};
- Ev==open -> {0,Diff,0};
- Bi==open -> {0,0,Diff};
+ Ev =:= open, Bi =:= open -> {0,Diff,Diff};
+ Ev =:= open -> {0,Diff,0};
+ Bi =:= open -> {0,0,Diff};
true -> {Diff,0,0}
end;
@@ -1129,12 +1125,12 @@ configure_widths(OldW, NewW, Flags) ->
%% and current size
OldW>NewW ->
if
- Ev==open,Bi==open ->
+ Ev =:= open, Bi =:= open ->
{0,
gs:read('EvalArea',width)-204,
gs:read('BindArea',width)-112};
- Ev==open -> {0,Diff,0};
- Bi==open -> {0,0,Diff};
+ Ev =:= open -> {0,Diff,0};
+ Bi =:= open -> {0,0,Diff};
true -> {Diff,0,0}
end
end,
@@ -1142,13 +1138,13 @@ configure_widths(OldW, NewW, Flags) ->
case Limits of
%% No Shell or Bind frame, larger window
- {T,0,0} when NewW>OldW -> {T,0,0};
+ {T,0,0} when NewW > OldW -> {T,0,0};
%% No Shell or Bind frame, smaller window
- {T,0,0} when OldW>NewW -> {-T,0,0};
+ {T,0,0} when OldW > NewW -> {-T,0,0};
%% Window larger; divide Diff among the frames and return result
- {_,Sf,B} when NewW>OldW ->
+ {_,Sf,B} when NewW > OldW ->
{_,Sf2,B2} = divide([{0,0},{0,Sf},{0,B}],Diff),
{Sf2+B2,Sf2,B2};
@@ -1171,33 +1167,33 @@ configure_heights(OldH, NewH, Flags) ->
%% Check how much the frames can be resized in reality
{T,Sf,Ff} = if
%% Window larger
- NewH>OldH ->
+ NewH > OldH ->
{Diff,
if
- Ev==close, Bi==close -> 0;
+ Ev =:= close, Bi =:= close -> 0;
true -> Diff
end,
if
- Tr==open -> Diff;
+ Tr =:= open -> Diff;
true -> 0
end};
%% Window smaller; get difference between min size
%% and current size
- OldH>NewH ->
+ OldH > NewH ->
{gs:read('CodeArea',height)-100,
if
- Ev==close, Bi==close -> 0;
+ Ev =:= close, Bi =:= close -> 0;
true ->
if
- Ev==open ->
+ Ev =:= open ->
gs:read('EvalArea',height)-100;
- Bi==open ->
+ Bi =:= open ->
gs:read('BindArea',height)-100
end
end,
if
- Tr==open -> gs:read('TraceArea',height)-100;
+ Tr =:= open -> gs:read('TraceArea',height)-100;
true -> 0
end}
end,
@@ -1251,10 +1247,8 @@ divide(L, Diff) ->
if
%% All of Diff has been distributed
- D==0 -> {T,S,F};
-
+ D =:= 0 -> {T,S,F};
true ->
-
%% For each element, try to add as much as possible of D
{NewT,Dt} = divide2(D,T,Tmax),
{NewS,Ds} = divide2(D,S,Smax),
@@ -1296,25 +1290,25 @@ resize(WinInfo, ResizeBar) ->
rblimits('RB2',W,H),
rblimits('RB3',W,H)).
-resizeloop(WI, RB, Prev, {Min1,Max1},{Min2,Max2},{Min3,Max3}) ->
+resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3}) ->
receive
- {gs,_,motion,_,[_,Y]} when RB=='RB1', Y>Min1,Y<Max1 ->
+ {gs,_,motion,_,[_,Y]} when RB =:= 'RB1', Y > Min1, Y < Max1 ->
gs:config('RB1', {y,Y}),
- resizeloop(WI, RB, Y, {Min1,Max1},{Min2,Max2},{Min3,Max3});
- {gs,_,motion,_,_} when RB=='RB1' ->
- resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
+ resizeloop(WI, RB, Y, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
+ {gs,_,motion,_,_} when RB =:= 'RB1' ->
+ resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
- {gs,_,motion,_,[_,Y]} when RB=='RB2', Y>Min2,Y<Max2 ->
+ {gs,_,motion,_,[_,Y]} when RB =:= 'RB2', Y > Min2, Y < Max2 ->
gs:config('RB2', {y,Y}),
- resizeloop(WI, RB, Y, {Min1,Max1},{Min2,Max2},{Min3,Max3});
- {gs,_,motion,_,_} when RB=='RB2' ->
- resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
+ resizeloop(WI, RB, Y, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
+ {gs,_,motion,_,_} when RB =:= 'RB2' ->
+ resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
- {gs,_,motion,_,[X,_]} when RB=='RB3', X>Min3,X<Max3 ->
+ {gs,_,motion,_,[X,_]} when RB =:= 'RB3', X > Min3, X < Max3 ->
gs:config('RB3', {x,X}),
- resizeloop(WI, RB, X, {Min1,Max1},{Min2,Max2},{Min3,Max3});
- {gs,_,motion,_,_} when RB=='RB3' ->
- resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
+ resizeloop(WI, RB, X, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
+ {gs,_,motion,_,_} when RB =:= 'RB3' ->
+ resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
{gs,_,buttonrelease,_,_} ->
resize_win(WI, RB, Prev)
@@ -1329,7 +1323,7 @@ resize_win(WinInfo, 'RB1', Y) ->
%% Resize Code, Evaluator and Binding areas
resize_code_area(WinInfo, height, -Diff),
if
- S==close, Bi==close, F==open ->
+ S =:= close, Bi =:= close, F =:= open ->
resize_trace_area(open, height, Diff);
true ->
resize_eval_area(S, height, Diff),
@@ -1388,7 +1382,7 @@ rblimits('RB1',_W,H) ->
RB2 = gs:read('RB2',height),
FF = gs:read('TraceArea',height),
Max = case RB2 of
- 0 when FF/=0 ->
+ 0 when FF =/= 0 ->
H-112;
_ ->
Y = gs:read('RB2',y),
@@ -1397,18 +1391,14 @@ rblimits('RB1',_W,H) ->
{Min,Max};
rblimits('RB2',_W,H) ->
-
- %% TraceFrame should not have height <100
+ %% TraceFrame should not have height < 100
Max = H-112,
-
%% Min is decided by a minimum distance to 'RB1'
Y = gs:read('RB1',y),
Min = erlang:min(Max,Y+140),
-
{Min,Max};
rblimits('RB3',W,_H) ->
-
%% Neither CodeArea nor BindArea should occupy
%% less than 1/3 of the total window width and EvalFrame should
%% be at least 289 pixels wide
@@ -1484,7 +1474,7 @@ helpwin_action(gotoline, default, AttPid, _Editor, Data, Win) ->
end,
Data;
helpwin_action(search, case_sensitive, _AttPid, _Ed, {Pos, CS}, _Win) ->
- Bool = if CS==true -> false; CS==false -> true end,
+ Bool = if CS =:= true -> false; CS =:= false -> true end,
{Pos, Bool};
helpwin_action(search, default, _AttPid, Editor, {Pos, CS}, Win) ->
gs:config(lbl(Win), {label, {text, ""}}),
@@ -1517,13 +1507,9 @@ search(Str, Editor, Max, {Row, Col}, CS) ->
lowercase(true, Str) -> Str;
lowercase(false, Str) ->
- lists:map(fun(Char) ->
- if
- Char>=$A, Char=<$Z -> Char+32;
- true -> Char
- end
- end,
- Str).
+ [if Char >= $A, Char =< $Z -> Char+32;
+ true -> Char
+ end || Char <- Str].
mark_string(Editor, {Row, Col}, Str) ->
Between = {{Row,Col}, {Row,Col+length(Str)}},
@@ -1540,10 +1526,9 @@ unmark_string(Editor, {Row, Col}) ->
{fg, {Between, black}}]).
helpwin(Type, GS, {X, Y}) ->
- W = 200, Pad=10, Wbtn = 50,
+ W = 200, Pad = 10, Wbtn = 50,
- Title =
- case Type of search -> "Search"; gotoline -> "Go To Line" end,
+ Title = case Type of search -> "Search"; gotoline -> "Go To Line" end,
Win = gs:window(GS, [{title, Title}, {x, X}, {y, Y}, {width, W},
{destroy, true}]),
diff --git a/lib/debugger/src/dbg_ui_view.erl b/lib/debugger/src/dbg_ui_view.erl
index 075275f196..7350a830a8 100644
--- a/lib/debugger/src/dbg_ui_view.erl
+++ b/lib/debugger/src/dbg_ui_view.erl
@@ -21,9 +21,6 @@
%% External exports
-export([start/2]).
-%% Internal exports
--export([init/3]).
-
-record(state, {gs, % term() Graphics system id
win, % term() Attach process window data
coords, % {X,Y} Mouse point position
@@ -42,7 +39,7 @@ start(GS, Mod) ->
Title = "View Module " ++ atom_to_list(Mod),
case dbg_ui_winman:is_started(Title) of
true -> ignore;
- false -> spawn(?MODULE, init, [GS, Mod, Title])
+ false -> spawn(fun () -> init(GS, Mod, Title) end)
end.
@@ -51,7 +48,6 @@ start(GS, Mod) ->
%%====================================================================
init(GS, Mod, Title) ->
-
%% Subscribe to messages from the interpreter
int:subscribe(),
diff --git a/lib/debugger/src/dbg_ui_win.erl b/lib/debugger/src/dbg_ui_win.erl
index 74ff2503ab..9bed6a1ec5 100644
--- a/lib/debugger/src/dbg_ui_win.erl
+++ b/lib/debugger/src/dbg_ui_win.erl
@@ -24,7 +24,6 @@
create_menus/2, select/2, selected/1,
add_break/2, update_break/2, delete_break/1,
motion/2
-
]).
-record(break, {mb, smi, emi, dimi, demi}).
@@ -49,11 +48,11 @@ init() ->
font(Style) ->
GS = init(),
Style2 = if
- Style==normal -> [];
+ Style =:= normal -> [];
true -> [Style]
end,
case gs:read(GS, {choose_font, {screen,Style2,12}}) of
- Font when element(1, Font)==screen ->
+ Font when element(1, Font) =:= screen ->
Font;
_ ->
gs:read(GS, {choose_font, {courier,Style2,12}})
@@ -168,8 +167,7 @@ select(MenuItem, Bool) ->
%%--------------------------------------------------------------------
selected(Menu) ->
Children = gs:read(Menu, children),
- Selected = lists:filter(fun(Child) -> gs:read(Child, select) end,
- Children),
+ Selected = [gs:read(Child, select) || Child <- Children],
lists:map(fun(Child) ->
{text, Name} = gs:read(Child, label),
list_to_atom(Name)
diff --git a/lib/debugger/src/dbg_ui_winman.erl b/lib/debugger/src/dbg_ui_winman.erl
index 71023cd0d6..398735a7ca 100644
--- a/lib/debugger/src/dbg_ui_winman.erl
+++ b/lib/debugger/src/dbg_ui_winman.erl
@@ -120,9 +120,9 @@ init(_Arg) ->
{ok, #state{}}.
handle_call({is_started, Title}, _From, State) ->
- Reply = case lists:keysearch(Title, #win.title, State#state.wins) of
- {value, Win} -> {true, Win#win.win};
- false -> false
+ Reply = case lists:keyfind(Title, #win.title, State#state.wins) of
+ false -> false;
+ Win -> {true, Win#win.win}
end,
{reply, Reply, State}.
@@ -134,8 +134,8 @@ handle_cast({insert, Pid, Title, Win}, State) ->
handle_cast({clear_process, Title}, State) ->
OldWins = State#state.wins,
- Wins = case lists:keysearch(Title, #win.title, OldWins) of
- {value, #win{owner=Pid}} ->
+ Wins = case lists:keyfind(Title, #win.title, OldWins) of
+ #win{owner=Pid} ->
Msg = {dbg_ui_winman, destroy},
Pid ! Msg,
lists:keydelete(Title, #win.title, OldWins);
@@ -147,7 +147,7 @@ handle_cast({clear_process, Title}, State) ->
handle_info({'EXIT', Pid, _Reason}, State) ->
[Mon | _Wins] = State#state.wins,
if
- Pid==Mon#win.owner -> {stop, normal, State};
+ Pid =:= Mon#win.owner -> {stop, normal, State};
true ->
Wins2 = lists:keydelete(Pid, #win.owner, State#state.wins),
inform_all(Wins2),
diff --git a/lib/debugger/src/dbg_wx_break_win.erl b/lib/debugger/src/dbg_wx_break_win.erl
index 5dafb0fbe6..78733c98c8 100644
--- a/lib/debugger/src/dbg_wx_break_win.erl
+++ b/lib/debugger/src/dbg_wx_break_win.erl
@@ -206,11 +206,7 @@ handle_event(#wx{id=OKorListBox, event=#wxCommand{type=OkorDoubleClick}},
OkorDoubleClick =:= command_listbox_doubleclicked ->
Mod = wxComboBox:getValue(Text),
{_, IndexL} = wxListBox:getSelections(LB),
- Breaks = lists:map(fun(Index) ->
- Func = lists:nth(Index+1, Funcs),
- [list_to_atom(Mod) | Func]
- end,
- IndexL),
+ Breaks = [[list_to_atom(Mod)|lists:nth(Index+1, Funcs)] || Index <- IndexL],
wxDialog:destroy(Win),
{break, Breaks, enable};
handle_event(#wx{id=?wxID_OK},#winInfo{win=Win,text=Text, entries=Es, trigger=Trigger}) ->
diff --git a/lib/debugger/src/dbg_wx_interpret.erl b/lib/debugger/src/dbg_wx_interpret.erl
index f711ba679d..ffcfbcf36b 100644
--- a/lib/debugger/src/dbg_wx_interpret.erl
+++ b/lib/debugger/src/dbg_wx_interpret.erl
@@ -115,11 +115,11 @@ interpret_all(Dir, [File0|Files], Mode, Window, Errors) ->
interpret_all(_Dir, [], _Mode, _Window, []) ->
true;
interpret_all(Dir, [], _Mode, Window, Errors) ->
- Msg = lists:map(fun(Name) ->
- File = filename:join(Dir, Name),
- Error = format_error(int:interpretable(File)),
- ["\n ",Name,": ",Error]
- end, Errors),
+ Msg = [begin
+ File = filename:join(Dir, Name),
+ Error = format_error(int:interpretable(File)),
+ ["\n ",Name,": ",Error]
+ end || Name <- Errors],
All = ["Error when interpreting: ", Msg],
dbg_wx_win:confirm(Window, lists:flatten(All)),
true.
diff --git a/lib/debugger/src/dbg_wx_mon.erl b/lib/debugger/src/dbg_wx_mon.erl
index 3f55c38d35..6bdec994b1 100644
--- a/lib/debugger/src/dbg_wx_mon.erl
+++ b/lib/debugger/src/dbg_wx_mon.erl
@@ -170,7 +170,7 @@ init2(CallingPid, Mode, SFile, GS) ->
CallingPid ! {initialization_complete, self()},
if
- SFile==default ->
+ SFile =:= default ->
loop(State3);
true ->
loop(load_settings(SFile, State3))
@@ -268,7 +268,7 @@ gui_cmd(ignore, State) ->
State;
gui_cmd(stopped, State) ->
if
- State#state.starter==true -> int:stop();
+ State#state.starter =:= true -> int:stop();
true -> int:auto_attach(false)
end,
exit(stop);
@@ -420,9 +420,9 @@ gui_cmd({'Trace Window', TraceWin}, State) ->
State2;
gui_cmd({'Auto Attach', When}, State) ->
if
- When==[] -> int:auto_attach(false);
+ When =:= [] -> int:auto_attach(false);
true ->
- Flags = lists:map(fun(Name) -> map(Name) end, When),
+ Flags = [map(Name) || Name <- When],
int:auto_attach(Flags, trace_function(State))
end,
State;
@@ -691,12 +691,12 @@ load_settings2(Settings, State) ->
Break,
int:break(Mod, Line),
if
- Status==inactive ->
+ Status =:= inactive ->
int:disable_break(Mod, Line);
true -> ignore
end,
if
- Action/=enable ->
+ Action =/= enable ->
int:action_at_break(Mod,Line,Action);
true -> ignore
end,
@@ -715,10 +715,7 @@ save_settings(SFile, State) ->
int:auto_attach(),
int:stack_trace(),
State#state.backtrace,
- lists:map(fun(Mod) ->
- int:file(Mod)
- end,
- int:interpreted()),
+ [int:file(Mod) || Mod <- int:interpreted()],
int:all_breaks()},
Binary = term_to_binary({debugger_settings, Settings}),
@@ -741,7 +738,7 @@ registered_name(Pid) ->
Node = node(Pid),
if
- Node==node() ->
+ Node =:= node() ->
case erlang:process_info(Pid, registered_name) of
{registered_name, Name} -> Name;
_ -> undefined
diff --git a/lib/debugger/src/dbg_wx_mon_win.erl b/lib/debugger/src/dbg_wx_mon_win.erl
index 8ad4f4213f..04c3501b8c 100644
--- a/lib/debugger/src/dbg_wx_mon_win.erl
+++ b/lib/debugger/src/dbg_wx_mon_win.erl
@@ -266,8 +266,7 @@ select(MenuItem, Bool) ->
add_module(WinInfo, MenuName, Mod) ->
Win = WinInfo#winInfo.window,
Modules = WinInfo#winInfo.modules,
- case lists:keysearch(Mod, #moduleInfo.module, Modules) of
- {value, _ModInfo} -> WinInfo;
+ case lists:keymember(Mod, #moduleInfo.module, Modules) of
false ->
%% Create a menu for the module
Menu = get(MenuName),
@@ -284,8 +283,9 @@ add_module(WinInfo, MenuName, Mod) ->
wxListBox:append(WinInfo#winInfo.listbox, atom_to_list(Mod)),
ModInfo = #moduleInfo{module=Mod, menubtn={Menu,MenuBtn}},
- WinInfo#winInfo{modules=[ModInfo | Modules]}
- end.
+ WinInfo#winInfo{modules=[ModInfo | Modules]};
+ true -> WinInfo
+ end.
%%--------------------------------------------------------------------
%% delete_module(WinInfo, Mod) -> WinInfo
@@ -559,8 +559,7 @@ handle_event(#wx{event=#wxCommand{type=command_checkbox_clicked}},
handle_event(#wx{event=#wxList{type=command_list_item_selected,
itemIndex=Row}}, WinInfo) ->
#winInfo{processes=Pids} = WinInfo,
- {value, #procInfo{pid=Pid}} =
- lists:keysearch(Row, #procInfo.row, Pids),
+ #procInfo{pid=Pid} = lists:keyfind(Row, #procInfo.row, Pids),
{focus, Pid, WinInfo#winInfo{focus=Row}};
handle_event(#wx{event=#wxList{type=command_list_item_activated}},
_WinInfo) ->
diff --git a/lib/debugger/src/dbg_wx_trace.erl b/lib/debugger/src/dbg_wx_trace.erl
index f9fdf593c4..6675ea33e7 100644
--- a/lib/debugger/src/dbg_wx_trace.erl
+++ b/lib/debugger/src/dbg_wx_trace.erl
@@ -180,12 +180,12 @@ init_contents(Breaks, State) ->
State#state{win=Win}.
-loop(#state{meta=Meta} = State) ->
+loop(#state{meta=Meta, win=Win} = State) ->
receive
%% From the GUI main window
- GuiEvent when element(1, GuiEvent)==wx ->
+ GuiEvent when element(1, GuiEvent) =:= wx ->
Cmd = wx:batch(fun() ->
- dbg_wx_trace_win:handle_event(GuiEvent,State#state.win)
+ dbg_wx_trace_win:handle_event(GuiEvent,Win)
end),
State2 = gui_cmd(Cmd, State),
loop(State2);
@@ -211,11 +211,11 @@ loop(#state{meta=Meta} = State) ->
%% From the dbg_wx_winman process (Debugger window manager)
{dbg_ui_winman, update_windows_menu, Data} ->
- Window = dbg_wx_trace_win:get_window(State#state.win),
+ Window = dbg_wx_trace_win:get_window(Win),
dbg_wx_winman:update_windows_menu(Window,Data),
loop(State);
{dbg_ui_winman, destroy} ->
- dbg_wx_trace_win:stop(State#state.win),
+ dbg_wx_trace_win:stop(Win),
exit(stop)
end.
@@ -269,7 +269,7 @@ gui_cmd('Continue', State) ->
int:meta(State#state.meta, continue),
{Status, Mod, Line} = State#state.status,
if
- Status==wait_break ->
+ Status =:= wait_break ->
Win = dbg_wx_trace_win:unmark_line(State#state.win),
gui_enable_functions(wait_running),
State#state{win=Win, status={wait_running,Mod,Line}};
@@ -291,7 +291,7 @@ gui_cmd('Stop', State) ->
int:meta(State#state.meta, stop),
{Status, Mod, Line} = State#state.status,
if
- Status==wait_running ->
+ Status =:= wait_running ->
Win = dbg_wx_trace_win:mark_line(State#state.win, Line,
break),
gui_enable_functions(wait_break),
@@ -421,7 +421,7 @@ gui_cmd('Function Break...', State) ->
gui_cmd('Enable All', State) ->
Breaks = int:all_breaks(),
ThisMod = State#state.cm,
- lists:foreach(fun ({{Mod, Line}, _Options}) when Mod==ThisMod ->
+ lists:foreach(fun ({{Mod, Line}, _Options}) when Mod =:= ThisMod ->
int:enable_break(Mod, Line);
(_Break) ->
ignore
@@ -431,7 +431,7 @@ gui_cmd('Enable All', State) ->
gui_cmd('Disable All', State) ->
Breaks = int:all_breaks(),
ThisMod = State#state.cm,
- lists:foreach(fun ({{Mod, Line}, _Options}) when Mod==ThisMod ->
+ lists:foreach(fun ({{Mod, Line}, _Options}) when Mod =:= ThisMod ->
int:disable_break(Mod, Line);
(_Break) ->
ignore
@@ -458,7 +458,7 @@ gui_cmd({'Trace Window', TraceWin}, State) ->
Win = dbg_wx_trace_win:configure(State#state.win, TraceWin),
{Status,_,_} = State#state.status,
if
- Status==break; Status==wait_break ->
+ Status =:= break; Status =:= wait_break ->
gui_enable_btrace(Trace, State#state.stack_trace);
true -> ignore
end,
@@ -467,7 +467,7 @@ gui_cmd({'Stack Trace', [Name]}, State) ->
int:meta(State#state.meta, stack_trace, map(Name)),
{Status,_,_} = State#state.status,
if
- Status==break; Status==wait_break ->
+ Status =:= break; Status =:= wait_break ->
gui_enable_btrace(State#state.trace, map(Name));
true -> ignore
end,
@@ -490,9 +490,9 @@ gui_cmd('Debugger', State) ->
gui_cmd({user_command, Cmd}, State) ->
{Status, _Mod, _Line} = State#state.status,
if
- Status==break;
- Status==wait_break;
- Status==wait_running ->
+ Status =:= break;
+ Status =:= wait_break;
+ Status =:= wait_running ->
Cm = State#state.cm,
Arg = case State#state.stack of
{Cur, Max} when Cur<Max -> {Cm, Cmd, Cur};
@@ -531,14 +531,14 @@ add_break(WI, Coords, Type, Mod, Line) ->
int_cmd({interpret, Mod}, State) ->
if
- Mod==State#state.cm ->
+ Mod =:= State#state.cm ->
State#state{cm_obsolete=true};
true ->
State
end;
int_cmd({no_interpret, Mod}, State) ->
if
- Mod==State#state.cm ->
+ Mod =:= State#state.cm ->
State#state{cm_obsolete=true};
true ->
Win = dbg_wx_trace_win:remove_code(State#state.win, Mod),
@@ -584,7 +584,7 @@ meta_cmd({re_entry, dbg_ieval, eval_fun}, State) ->
meta_cmd({re_entry, Mod, _Func}, State) ->
Obs = State#state.cm_obsolete,
case State#state.cm of
- Mod when Obs==true ->
+ Mod when Obs =:= true ->
Win = gui_load_module(State#state.win, Mod,State#state.pid),
State#state{win=Win, cm_obsolete=false};
Mod -> State;
@@ -630,11 +630,11 @@ meta_cmd({func_at, Mod, Line, Cur}, State) ->
gui_enable_functions(idle),
dbg_wx_trace_win:display(State#state.win, idle),
State#state{win=Win, cm=Mod, status={idle,Mod,Line}, stack=Stack};
-meta_cmd({wait_at, Mod, Line, Cur}, #state{status={Status,_,_}}=State)
- when Status/=init, Status/=break ->
+meta_cmd({wait_at, Mod, Line, Cur}, #state{status={Status,_,_}, win=Win}=State)
+ when Status =/= init, Status =/= break ->
Stack = {Cur,Cur},
gui_enable_functions(wait_running),
- dbg_wx_trace_win:display(State#state.win, {wait,Mod,Line}),
+ dbg_wx_trace_win:display(Win, {wait,Mod,Line}),
State#state{status={wait_running,Mod,Line}, stack=Stack};
meta_cmd({wait_at, Mod, Line, Cur}, State) ->
Stack = {Cur,Cur},
@@ -675,7 +675,7 @@ meta_cmd({stack_trace, Flag}, State) ->
gui_enable_updown(Flag, State#state.stack),
{Status,_,_} = State#state.status,
if
- Status==break; Status==wait_break ->
+ Status =:= break; Status =:= wait_break ->
gui_enable_btrace(State#state.trace, Flag);
true -> ignore
end,
@@ -813,7 +813,7 @@ gui_enable_functions(Status) ->
gui_enable_updown(Flag, Stack) ->
{Enable, Disable} =
if
- Flag==false -> {[], ['Up', 'Down']};
+ Flag =:= false -> {[], ['Up', 'Down']};
true ->
case Stack of
{1,1} -> {[], ['Up', 'Down']};
@@ -826,14 +826,14 @@ gui_enable_updown(Flag, Stack) ->
dbg_wx_trace_win:enable(Enable, true),
dbg_wx_trace_win:enable(Disable, false),
if
- Enable==[] -> dbg_wx_trace_win:enable(['Where'], false);
+ Enable =:= [] -> dbg_wx_trace_win:enable(['Where'], false);
true -> dbg_wx_trace_win:enable(['Where'], true)
end.
gui_enable_btrace(Trace, StackTrace) ->
Bool = if
- Trace==false -> false;
- StackTrace==false -> false;
+ Trace =:= false -> false;
+ StackTrace =:= false -> false;
true -> true
end,
dbg_wx_trace_win:enable(['Back Trace'], Bool).
diff --git a/lib/debugger/src/dbg_wx_trace_win.erl b/lib/debugger/src/dbg_wx_trace_win.erl
index 2b4a1164ad..720b913024 100755
--- a/lib/debugger/src/dbg_wx_trace_win.erl
+++ b/lib/debugger/src/dbg_wx_trace_win.erl
@@ -410,11 +410,11 @@ clear_breaks(WinInfo) ->
clear_breaks(WinInfo, all).
clear_breaks(WinInfo, Mod) ->
Remove = if
- Mod==all -> WinInfo#winInfo.breaks;
+ Mod =:= all -> WinInfo#winInfo.breaks;
true ->
lists:filter(fun(#breakInfo{point={Mod2,_L}}) ->
if
- Mod2==Mod -> true;
+ Mod2 =:= Mod -> true;
true -> false
end
end,
@@ -481,8 +481,8 @@ display(#winInfo{window=Win, sb=Sb},Arg) ->
%% Note: remove_code/2 should not be used for currently shown module.
%%--------------------------------------------------------------------
is_shown(WinInfo, Mod) ->
- case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
- {value, {Mod, Editor}} ->
+ case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
+ {Mod, Editor} ->
gs:config(Editor, raise), %% BUGBUG
{true, WinInfo#winInfo{editor={Mod, Editor}}};
false -> false
@@ -494,7 +494,7 @@ show_code(WinInfo = #winInfo{editor={_, Ed}}, Mod, Contents) ->
lists:foreach(fun(BreakInfo) ->
case BreakInfo#breakInfo.point of
- {Mod2, Line} when Mod2==Mod ->
+ {Mod2, Line} when Mod2 =:= Mod ->
Status = BreakInfo#breakInfo.status,
dbg_wx_code:add_break_to_code(Ed, Line,Status);
_Point -> ignore
@@ -540,10 +540,10 @@ select_line(WinInfo, Line) ->
%% help window, it must be checked that it is correct
Size = dbg_wx_code:get_no_lines(Ed),
if
- Line==0 ->
+ Line =:= 0 ->
dbg_wx_code:goto_line(Ed,1),
WinInfo#winInfo{selected_line=0};
- Line<Size ->
+ Line < Size ->
dbg_wx_code:goto_line(Ed,Line),
WinInfo#winInfo{selected_line=Line};
true ->
@@ -764,8 +764,8 @@ handle_event(#wx{event=#wxStyledText{type=stc_doubleclick}},
WinInfo = #winInfo{editor={Mod,Ed}}) ->
Line = wxStyledTextCtrl:getCurrentLine(Ed),
Point = {Mod, Line+1},
- case lists:keysearch(Point, #breakInfo.point,WinInfo#winInfo.breaks) of
- {value, _BreakInfo} -> {break, Point, delete};
+ case lists:keymember(Point, #breakInfo.point, WinInfo#winInfo.breaks) of
+ true -> {break, Point, delete};
false -> {break, Point, add}
end;
@@ -837,7 +837,7 @@ handle_event(#wx{id=?SEARCH_ENTRY, event=#wxCommand{cmdString=Str}},
%% Button area
handle_event(#wx{id=ID, event=#wxCommand{type=command_button_clicked}},_Wi) ->
- {value, {Button, _}} = lists:keysearch(ID, 2, buttons()),
+ {Button, _} = lists:keyfind(ID, 2, buttons()),
Button;
%% Evaluator area
@@ -908,8 +908,8 @@ buttons() ->
{'Where',?WhereButton}, {'Up',?UpButton}, {'Down',?DownButton}].
is_button(Name) ->
- case lists:keysearch(Name, 1, buttons()) of
- {value, {Name, Button}} -> {true, Button};
+ case lists:keyfind(Name, 1, buttons()) of
+ {Name, Button} -> {true, Button};
false -> false
end.
diff --git a/lib/debugger/src/dbg_wx_view.erl b/lib/debugger/src/dbg_wx_view.erl
index 6d34e5650c..8ff89a4847 100644
--- a/lib/debugger/src/dbg_wx_view.erl
+++ b/lib/debugger/src/dbg_wx_view.erl
@@ -23,9 +23,6 @@
%% External exports
-export([start/2]).
-%% Internal exports
--export([init/4]).
-
-record(state, {gs, % term() Graphics system id
win, % term() Attach process window data
coords, % {X,Y} Mouse point position
@@ -46,7 +43,7 @@ start(GS, Mod) ->
true -> ignore;
false ->
Env = wx:get_env(),
- spawn_link(?MODULE, init, [GS, Env, Mod, Title])
+ spawn_link(fun () -> init(GS, Env, Mod, Title) end)
end.
@@ -84,7 +81,7 @@ loop(State) ->
receive
%% From the GUI main window
- GuiEvent when element(1, GuiEvent)==wx ->
+ GuiEvent when element(1, GuiEvent) =:= wx ->
Cmd = wx:batch(fun() ->
dbg_wx_trace_win:handle_event(GuiEvent, State#state.win)
end),
@@ -167,7 +164,7 @@ gui_cmd('Function Break...', State) ->
gui_cmd('Enable All', State) ->
Breaks = int:all_breaks(),
ThisMod = State#state.mod,
- lists:foreach(fun ({{Mod, Line}, _Options}) when Mod==ThisMod ->
+ lists:foreach(fun ({{Mod, Line}, _Options}) when Mod =:= ThisMod ->
int:enable_break(Mod, Line);
(_Break) ->
ignore
@@ -177,7 +174,7 @@ gui_cmd('Enable All', State) ->
gui_cmd('Disable All', State) ->
Breaks = int:all_breaks(),
ThisMod = State#state.mod,
- lists:foreach(fun ({{Mod, Line}, _Options}) when Mod==ThisMod ->
+ lists:foreach(fun ({{Mod, Line}, _Options}) when Mod =:= ThisMod ->
int:disable_break(Mod, Line);
(_Break) ->
ignore
@@ -214,21 +211,19 @@ add_break(GS, Coords, Type, Mod, Line) ->
%%--Commands from the interpreter-------------------------------------
-int_cmd({new_break, {{Mod,_Line},_Options}=Break}, #state{mod=Mod}=State) ->
- Win = dbg_wx_trace_win:add_break(State#state.win, 'Break', Break),
- State#state{win=Win};
-int_cmd({delete_break, {Mod,_Line}=Point}, #state{mod=Mod}=State) ->
- Win = dbg_wx_trace_win:delete_break(State#state.win, Point),
- State#state{win=Win};
-int_cmd({break_options, {{Mod,_Line},_Options}=Break}, #state{mod=Mod}=State) ->
- Win = dbg_wx_trace_win:update_break(State#state.win, Break),
- State#state{win=Win};
-int_cmd(no_break, State) ->
- Win = dbg_wx_trace_win:clear_breaks(State#state.win),
- State#state{win=Win};
-int_cmd({no_break, _Mod}, State) ->
- Win = dbg_wx_trace_win:clear_breaks(State#state.win),
- State#state{win=Win};
+int_cmd({new_break, {{Mod,_Line},_Options}=Break},
+ #state{mod = Mod, win = Win}=State) ->
+ State#state{win = dbg_wx_trace_win:add_break(Win, 'Break', Break)};
+int_cmd({delete_break, {Mod,_Line}=Point},
+ #state{mod = Mod, win = Win}=State) ->
+ State#state{win = dbg_wx_trace_win:delete_break(Win, Point)};
+int_cmd({break_options, {{Mod,_Line},_Options}=Break},
+ #state{mod = Mod, win = Win}=State) ->
+ State#state{win = dbg_wx_trace_win:update_break(Win, Break)};
+int_cmd(no_break, #state{win = Win}=State) ->
+ State#state{win = dbg_wx_trace_win:clear_breaks(Win)};
+int_cmd({no_break, _Mod}, #state{win = Win}=State) ->
+ State#state{win = dbg_wx_trace_win:clear_breaks(Win)};
int_cmd(_, State) ->
State.
diff --git a/lib/debugger/src/dbg_wx_winman.erl b/lib/debugger/src/dbg_wx_winman.erl
index 1daabe3435..d0ddfeb51a 100755
--- a/lib/debugger/src/dbg_wx_winman.erl
+++ b/lib/debugger/src/dbg_wx_winman.erl
@@ -118,9 +118,9 @@ init([]) ->
{ok, #state{}}.
handle_call({is_started, Title}, _From, State) ->
- Reply = case lists:keysearch(Title, #win.title, State#state.wins) of
- {value, Win} -> {true, Win#win.win};
- false -> false
+ Reply = case lists:keyfind(Title, #win.title, State#state.wins) of
+ false -> false;
+ Win -> {true, Win#win.win}
end,
{reply, Reply, State}.
@@ -132,8 +132,8 @@ handle_cast({insert, Pid, Title, Win}, State) ->
handle_cast({clear_process, Title}, State) ->
OldWins = State#state.wins,
- Wins = case lists:keysearch(Title, #win.title, OldWins) of
- {value, #win{owner=Pid}} ->
+ Wins = case lists:keyfind(Title, #win.title, OldWins) of
+ #win{owner=Pid} ->
Msg = {dbg_ui_winman, destroy},
Pid ! Msg,
lists:keydelete(Title, #win.title, OldWins);
@@ -145,7 +145,7 @@ handle_cast({clear_process, Title}, State) ->
handle_info({'EXIT', Pid, _Reason}, State) ->
[Mon | _Wins] = State#state.wins,
if
- Pid==Mon#win.owner -> {stop, normal, State};
+ Pid =:= Mon#win.owner -> {stop, normal, State};
true ->
Wins2 = lists:keydelete(Pid, #win.owner, State#state.wins),
inform_all(Wins2),
diff --git a/lib/debugger/src/i.erl b/lib/debugger/src/i.erl
index 7c2fb22946..476a53482e 100644
--- a/lib/debugger/src/i.erl
+++ b/lib/debugger/src/i.erl
@@ -31,7 +31,6 @@
iv() ->
Vsn = string:substr(filename:basename(code:lib_dir(debugger)), 10),
list_to_atom(Vsn).
-
%% -------------------------------------------
%% Start a new graphical monitor.
@@ -288,10 +287,9 @@ ia(X,Y,Z) ->
%% -------------------------------------------
ia(Pid,Fnk) ->
- case lists:keysearch(Pid, 1, int:snapshot()) of
- {value, _PidTuple} ->
- int:attach(Pid,Fnk);
- false -> no_proc
+ case lists:keymember(Pid, 1, int:snapshot()) of
+ false -> no_proc;
+ true -> int:attach(Pid,Fnk)
end.
ia(X,Y,Z,Fnk) ->
diff --git a/lib/debugger/src/int.erl b/lib/debugger/src/int.erl
index eeb4df4a8e..9ee2102a19 100644
--- a/lib/debugger/src/int.erl
+++ b/lib/debugger/src/int.erl
@@ -261,7 +261,7 @@ del_break_in(Mod, Func, Arity) when is_atom(Mod), is_atom(Func), is_integer(Arit
end.
first_lines(Clauses) ->
- lists:map(fun(Clause) -> first_line(Clause) end, Clauses).
+ [first_line(Clause) || Clause <- Clauses].
first_line({clause,_L,_Vars,_,Exprs}) ->
first_line(Exprs);
@@ -469,10 +469,10 @@ contents(Mod, Pid) ->
%% Arity = integer()
%%--------------------------------------------------------------------
functions(Mod) ->
- lists:filter(fun([module_info, _Arity]) -> false;
- (_Func) -> true
- end,
- dbg_iserver:call({functions, Mod})).
+ [F || F <- dbg_iserver:call({functions, Mod}), functions_1(F)].
+
+functions_1([module_info, _Arity]) -> false;
+functions_1(_Func) -> true.
%%====================================================================
diff --git a/lib/docbuilder/src/docb_edoc_xml_cb.erl b/lib/docbuilder/src/docb_edoc_xml_cb.erl
index 4dba843341..f5cfc0fe18 100644
--- a/lib/docbuilder/src/docb_edoc_xml_cb.erl
+++ b/lib/docbuilder/src/docb_edoc_xml_cb.erl
@@ -478,31 +478,29 @@ otp_xmlify_a_href("#"++_ = Marker, Es0) -> % <seealso marker="#what">
otp_xmlify_a_href("http:"++_ = URL, Es0) -> % external URL
{URL, Es0};
otp_xmlify_a_href("OTPROOT"++AppRef, Es0) -> % <.. marker="App:FileRef
- case split(AppRef, "/") of
- [AppS, "doc", FileRef1] ->
- FileRef = AppS++":"++otp_xmlify_a_fileref(FileRef1, AppS),
- [#xmlText{value=Str0} = T] = Es0,
- Str = case split(Str0, "/") of
- %% //Application
- [AppS2] ->
- %% AppS2 can differ from AppS
- %% Example: xmerl/XMerL
- AppS2;
- [_AppS,ModRef] ->
- case split(ModRef, ":") of
- %% //Application/Module
- [Module] ->
- Module++"(3)";
- %% //Application/Module:Type()
- [_Module,_Type] ->
- ModRef
- end;
- %% //Application/Module:Function/Arity
- [_AppS,ModFunc,Arity] ->
- ModFunc++"/"++Arity
- end,
- {FileRef, [T#xmlText{value=Str}]}
- end;
+ [AppS, "doc", FileRef1] = split(AppRef, "/"),
+ FileRef = AppS++":"++otp_xmlify_a_fileref(FileRef1, AppS),
+ [#xmlText{value=Str0} = T] = Es0,
+ Str = case split(Str0, "/") of
+ %% //Application
+ [AppS2] ->
+ %% AppS2 can differ from AppS
+ %% Example: xmerl/XMerL
+ AppS2;
+ [_AppS,ModRef] ->
+ case split(ModRef, ":") of
+ %% //Application/Module
+ [Module] ->
+ Module++"(3)";
+ %% //Application/Module:Type()
+ [_Module,_Type] ->
+ ModRef
+ end;
+ %% //Application/Module:Function/Arity
+ [_AppS,ModFunc,Arity] ->
+ ModFunc++"/"++Arity
+ end,
+ {FileRef, [T#xmlText{value=Str}]};
otp_xmlify_a_href("../"++File, Es0) ->
%% Special case: This kind of relative path is used on some
%% places within i.e. EDoc and refers to a file within the same
@@ -639,13 +637,13 @@ otp_xmlify_table([#xmlText{} = E|Es]) ->
[E | otp_xmlify_table(Es)];
otp_xmlify_table([#xmlElement{name=tbody} = E|Es]) ->
otp_xmlify_table(E#xmlElement.content)++otp_xmlify_table(Es);
-otp_xmlify_table([#xmlElement{name=tr} = E|Es]) ->
+otp_xmlify_table([#xmlElement{name=tr, content=Content}|Es]) ->
%% Insert newlines between table rows
- otp_xmlify_table(E#xmlElement.content)++[{br,[]}]++otp_xmlify_table(Es);
-otp_xmlify_table([#xmlElement{name=th} = E|Es]) ->
- [{em, E#xmlElement.content} | otp_xmlify_table(Es)];
-otp_xmlify_table([#xmlElement{name=td} = E|Es]) ->
- otp_xmlify_e(E#xmlElement.content) ++ otp_xmlify_table(Es);
+ otp_xmlify_table(Content)++[{br,[]}]++otp_xmlify_table(Es);
+otp_xmlify_table([#xmlElement{name=th, content=Content}|Es]) ->
+ [{em, Content} | otp_xmlify_table(Es)];
+otp_xmlify_table([#xmlElement{name=td, content=Content}|Es]) ->
+ otp_xmlify_e(Content) ++ otp_xmlify_table(Es);
otp_xmlify_table([]) ->
[].
@@ -1155,8 +1153,8 @@ get_text(#xmlElement{content=[E]}) ->
%% text_only(Es) -> Ts
%% Takes a list of xmlElement and xmlText and return a lists of xmlText.
-text_only([#xmlElement{} = E |Es]) ->
- text_only(E#xmlElement.content) ++ text_only(Es);
+text_only([#xmlElement{content = Content}|Es]) ->
+ text_only(Content) ++ text_only(Es);
text_only([#xmlText{} = E |Es]) ->
[E | text_only(Es)];
text_only([]) ->
diff --git a/lib/docbuilder/src/docb_html.erl b/lib/docbuilder/src/docb_html.erl
index 9aea4c8a66..bdfc5ea876 100644
--- a/lib/docbuilder/src/docb_html.erl
+++ b/lib/docbuilder/src/docb_html.erl
@@ -283,16 +283,16 @@ rule([term|_], {_, [ID], _}, Opts) ->
ID,
"</strong></em> "]}, Opts};
TermList ->
- case lists:keysearch(ID, 1, TermList) of
+ case lists:keyfind(ID, 1, TermList) of
false ->
{{drop, ["<em><strong>", ID,
"</strong></em> "]},
Opts};
- {value, {ID, Name, _Description, _Resp}} ->
+ {ID, Name, _Description, _Resp} ->
{{drop, ["<em><strong>", Name,
"</strong></em> "]},
Opts};
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
{{drop, [ "<em><strong>", Name,
"</strong></em> "]},
Opts}
@@ -306,16 +306,16 @@ rule([term|_], {_, [ID], _}, Opts) ->
TermList ->
PartApplication =
docb_util:lookup_option(part_application, Opts),
- case lists:keysearch(ID, 1, TermList) of
+ case lists:keyfind(ID, 1, TermList) of
false ->
{{drop, ["<a href=\"", PartApplication,
"_term.html#", ID, "\">", ID,
"</a> "]}, Opts};
- {value, {ID, Name, _Description, _Resp}} ->
+ {ID, Name, _Description, _Resp} ->
{{drop, ["<a href=\"", PartApplication,
"_term.html#", ID, "\">", Name,
"</a> "]}, Opts};
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
{{drop, ["<a href=\"", PartApplication,
"_term.html#", ID, "\">", Name,
"</a> "]}, Opts}
@@ -331,17 +331,16 @@ rule([cite|_], {_, [ID], _}, Opts) ->
{{drop, ["<em><strong>", ID, "</strong></em> "]},
Opts};
CiteList ->
- case lists:keysearch(ID, 1, CiteList) of
+ case lists:keyfind(ID, 1, CiteList) of
false ->
{{drop,
["<em><strong>", ID, "</strong></em> "]},
Opts};
-
- {value, {ID, Name, _Description, _Resp}} ->
+ {ID, Name, _Description, _Resp} ->
{{drop, ["<em><strong>", Name,
"</strong></em> "]},
Opts};
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
{{drop, ["<em><strong>", Name,
"</strong></em> "]},
Opts}
@@ -355,18 +354,18 @@ rule([cite|_], {_, [ID], _}, Opts) ->
CiteList ->
PartApp =
docb_util:lookup_option(part_application, Opts),
- case lists:keysearch(ID, 1, CiteList) of
+ case lists:keyfind(ID, 1, CiteList) of
false ->
{{drop, ["<a href=\"", PartApp,
"_cite.html#", ID, "\">", ID,
"</a> "]},
Opts};
- {value, {ID, Name, _Description, _Resp}} ->
+ {ID, Name, _Description, _Resp} ->
{{drop, ["<a href=\"", PartApp,
"_cite.html#", ID, "\">", Name,
"</a> "]},
Opts};
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
{{drop, ["<a href=\"", PartApp,
"_cite.html#", ID, "\">", Name,
"</a> "]},
@@ -376,7 +375,7 @@ rule([cite|_], {_, [ID], _}, Opts) ->
end;
rule([code|_], {_, [Type], [{pcdata, _, Code}]}, Opts) ->
- case lists:member(Type,["ERL","C","NONE"]) of
+ case lists:member(Type, ["ERL","C","NONE"]) of
true ->
{{drop, ["\n<div class=\"example\"><pre>\n", docb_html_util:element_cdata_to_html(Code),
"\n</pre></div>\n"]}, Opts};
diff --git a/lib/docbuilder/src/docb_html_util.erl b/lib/docbuilder/src/docb_html_util.erl
index b2951706ea..02ce8b52a7 100644
--- a/lib/docbuilder/src/docb_html_util.erl
+++ b/lib/docbuilder/src/docb_html_util.erl
@@ -136,7 +136,6 @@ copy_pics(Src, Dest, Opts) ->
Dir = code:lib_dir(docbuilder),
InFile = filename:join([Dir, "etc", Src]),
OutFile = docb_util:outfile(Dest, "", Opts),
-
case filelib:last_modified(OutFile) of
0 -> % File doesn't exist
file:copy(InFile, OutFile);
@@ -156,10 +155,10 @@ copy_pics(Src, Dest, Opts) ->
%%--Resolve header data-------------------------------------------------
extract_header_data(Key, {header, [], List}) ->
- case lists:keysearch(Key, 1, List) of
- {value, {Key, [], []}} ->
+ case lists:keyfind(Key, 1, List) of
+ {Key, [], []} ->
"";
- {value, {Key, [], [{pcdata, [], Value}]}} ->
+ {Key, [], [{pcdata, [], Value}]} ->
pcdata_to_html(Value);
false ->
""
@@ -253,7 +252,7 @@ make_anchor_href(HRef) ->
{ok, [HRef]} ->
%% No `#' in HRef, i.e. only path
make_anchor_href(HRef, "");
- {ok, [Path, Fragment]}->
+ {ok, [Path, Fragment]} ->
make_anchor_href(Path, Fragment)
end.
@@ -398,10 +397,10 @@ count_sections([]) ->
%%--Make a ToC----------------------------------------------------------
format_toc(Toc) ->
- lists:map(fun({Number, Title}) ->
- [Number, " <a href = \"#", Number,
- "\">", Title, "</a><br/>\n"]
- end, Toc).
+ [format_toc1(T) || T <- Toc].
+
+format_toc1({Number, Title}) ->
+ [Number, " <a href = \"#", Number, "\">", Title, "</a><br/>\n"].
%%--Convert HTML ISO Latin 1 characters to ordinary characters----------
diff --git a/lib/docbuilder/src/docb_main.erl b/lib/docbuilder/src/docb_main.erl
index ef21f65557..87a1401a02 100644
--- a/lib/docbuilder/src/docb_main.erl
+++ b/lib/docbuilder/src/docb_main.erl
@@ -55,7 +55,7 @@ process(File, Opts) ->
%% If no target format is specified, assume HTML:
Tos = if
- Tos0==[] -> [html];
+ Tos0 =:= [] -> [html];
true -> Tos0
end,
@@ -327,12 +327,8 @@ verify(Tree) -> verify(Tree, [], 1).
verify({pcdata, Optional, _}, Path, Level) ->
verify_optional(Optional, Path, Level);
verify({Tag, Optional, Args}, Path, Level) when is_list(Args) ->
- case verify_optional(Optional, Path, Level) of
- true ->
- verify_list(Args, [Tag|Path], Level);
- false ->
- false
- end;
+ verify_optional(Optional, Path, Level)
+ andalso verify_list(Args, [Tag|Path], Level);
verify(Other, Path, Level) ->
verify_error(Other, Path, Level).
@@ -342,12 +338,7 @@ verify_error(X, Path, Level) ->
false.
verify_list([H|T], Path, Level) ->
- case verify(H, Path, Level) of
- true ->
- verify_list(T, Path, Level +1);
- false ->
- false
- end;
+ verify(H, Path, Level) andalso verify_list(T, Path, Level + 1);
verify_list([], _, _) ->
true.
@@ -419,7 +410,7 @@ edit1_list(_Tag, [], _Op) ->
%% Actual transformation of tree structure to desired format.
transform(From, To, Opts, File, Tree) ->
Filter = if
- To==html; To==kwic ->
+ To =:= html; To =:= kwic ->
list_to_atom("docb_tr_" ++ atom_to_list(From) ++
[$2|atom_to_list(To)]);
true ->
@@ -427,7 +418,7 @@ transform(From, To, Opts, File, Tree) ->
[$2|atom_to_list(To)])
end,
- case catch apply(Filter, transform, [File, Tree, Opts]) of
+ case catch Filter:transform(File, Tree, Opts) of
%% R5C
{'EXIT', {undef, [{Filter, transform, [File, Tree, Opts]}|_]}}->
@@ -459,9 +450,9 @@ transform(From, To, Opts, File, Tree) ->
finish_transform(Tree, File, Opts, Filter) ->
{Str, NewOpts} = pp(Tree, [], 1, Filter, Opts),
Extension =
- case catch apply(Filter, extension, [NewOpts]) of
+ case catch Filter:extension(NewOpts) of
{'EXIT', _} ->
- apply(Filter, extension, []);
+ Filter:extension();
Others ->
Others
end,
@@ -606,7 +597,7 @@ include_all(Fd) ->
eof ->
[];
ListOfChars ->
- lists:append(ListOfChars, include_all(Fd))
+ ListOfChars ++ include_all(Fd)
end.
extract(File, Fd, StartTag, StopTag, State) ->
diff --git a/lib/docbuilder/src/docb_pretty_format.erl b/lib/docbuilder/src/docb_pretty_format.erl
index 0c4fb0507b..25dcd8987b 100644
--- a/lib/docbuilder/src/docb_pretty_format.erl
+++ b/lib/docbuilder/src/docb_pretty_format.erl
@@ -47,7 +47,7 @@ term(Term) ->
%% the next line to need an "extra" indent!).
term([], Indent) ->
{Indent, [$[,$]]};
-term(L, Indent) when list(L) ->
+term(L, Indent) when is_list(L) ->
case is_string(L) of
true ->
{Indent, io_lib:write_string(L)};
@@ -59,7 +59,7 @@ term(L, Indent) when list(L) ->
write_simple_list(L, Indent)
end
end;
-term(T, Indent) when tuple(T) ->
+term(T, Indent) when is_tuple(T) ->
case complex_tuple(T) of
true ->
write_complex_tuple(T, Indent);
diff --git a/lib/docbuilder/src/docb_tr_application2html.erl b/lib/docbuilder/src/docb_tr_application2html.erl
index 4084cfe6ba..d8cb214d0a 100644
--- a/lib/docbuilder/src/docb_tr_application2html.erl
+++ b/lib/docbuilder/src/docb_tr_application2html.erl
@@ -119,8 +119,8 @@ transform(File, {application, _Attrs, [Header|Rest]}, Opts0) ->
case docb_main:parse1("fascicules", Opts0) of
{ok, Parse} ->
FascData = get_fasc_data(Parse),
- case lists:keysearch(File, 1, FascData) of
- {value, {_, _, "YES", _}} ->
+ case lists:keyfind(File, 1, FascData) of
+ {_, _, "YES", _} ->
OrigFile =
docb_util:outfile(File++"_frame",
".html", Opts0),
@@ -167,7 +167,7 @@ concat_files([File|Rest], Body, Opts) ->
%% Remove the reference manual header
[{Ref, [], [_Hdr| NewBody]}] = NewParse,
RefParse = [{Ref, [], NewBody}],
- lists:append(Body, concat_files(Rest, RefParse, Opts));
+ Body ++ concat_files(Rest, RefParse, Opts);
errors ->
errors
end;
@@ -216,7 +216,7 @@ make_toc([{lib, Attrs, More}|Rest]) ->
make_toc([{com, Attrs, More}|Rest]) ->
[{com, Attrs, More}|make_toc(Rest)];
make_toc([{_Tag, _Attrs, More}|Rest]) ->
- lists:append(make_toc(More), make_toc(Rest)).
+ make_toc(More) ++ make_toc(Rest).
rule([module|_], {_, [File], _}) ->
{"<small><a target=\"document\" href=\"" ++
@@ -280,9 +280,7 @@ get_fasc_data({fascicules, _, Fascs}) ->
Fascs).
get_avals(Atts) ->
- lists:map(fun(Tuple) ->
- element(3, Tuple) end,
- Atts).
+ [element(3, Tuple) || Tuple <- Atts].
get_pc_text([{pcdata, _, Text}]) ->
Text.
diff --git a/lib/docbuilder/src/docb_tr_cite2html.erl b/lib/docbuilder/src/docb_tr_cite2html.erl
index 4ecbfa4e91..77f1c4e636 100644
--- a/lib/docbuilder/src/docb_tr_cite2html.erl
+++ b/lib/docbuilder/src/docb_tr_cite2html.erl
@@ -39,24 +39,22 @@ purge_body([], _) ->
purge_body([{pcdata,_Attrs,_More}|Rest], CiteList) ->
purge_body(Rest, CiteList);
purge_body([{cite,[{"ID","CDATA",ID}],More}|Rest], CiteList) ->
- case lists:keysearch(ID, 1, CiteList) of
+ case lists:keyfind(ID, 1, CiteList) of
false ->
[{cite, [{"NAME","CDATA",ID}, {"ID","CDATA",ID}], More}|
purge_body(Rest, CiteList)];
- {value, {ID, Name, _Description, _Responsible}} ->
+ {ID, Name, _Description, _Responsible} ->
[{cite, [{"NAME","CDATA",Name}, {"ID","CDATA",ID}], More}|
purge_body(Rest, CiteList)];
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
[{cite, [{"NAME","CDATA",Name}, {"ID","CDATA",ID}], More}|
purge_body(Rest, CiteList)]
end;
purge_body([{_Tag,_Attrs,More}|Rest], CiteList) ->
- lists:append(purge_body(More, CiteList),
- purge_body(Rest, CiteList)).
+ purge_body(More, CiteList) ++ purge_body(Rest, CiteList).
rule([header|_], _) ->
{drop, ""};
-
rule(_, _) ->
{drop, ""}.
@@ -91,19 +89,19 @@ rule([cite|_], {_,[Name,ID], [{citedef,[],[{pcdata,[],Def}]}]}, Opts) ->
false -> [];
Value -> Value
end,
- case lists:keysearch(ID, 1, CiteList) of
+ case lists:keyfind(ID, 1, CiteList) of
false ->
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Def) ++ "\n</dd>\n"}, Opts};
- {value, {ID, Name, Description, _Responsible}} ->
+ {ID, Name, Description, _Responsible} ->
docb_util:message(warning,
"Global cite ~s overriding local", [ID]),
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"},
Opts};
- {value, {ID, Name, Description}} ->
+ {ID, Name, Description} ->
docb_util:message(warning,
"Global cite ~s overriding local", [ID]),
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
@@ -117,19 +115,19 @@ rule([cite|_], {_,[Name,ID],_}, Opts) ->
false -> [];
Value -> Value
end,
- case lists:keysearch(ID, 1, CiteList) of
+ case lists:keyfind(ID, 1, CiteList) of
false ->
docb_util:message(error,
"The cite ~s has no definition", [ID]),
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++
"??" ++ "\n</dd>\n"}, Opts};
- {value, {ID, Name, Description, _Responsible}} ->
+ {ID, Name, Description, _Responsible} ->
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"},
Opts};
- {value, {ID, Name, Description}} ->
+ {ID, Name, Description} ->
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts}
diff --git a/lib/docbuilder/src/docb_tr_index2html.erl b/lib/docbuilder/src/docb_tr_index2html.erl
index bbf419f3ef..312342add2 100644
--- a/lib/docbuilder/src/docb_tr_index2html.erl
+++ b/lib/docbuilder/src/docb_tr_index2html.erl
@@ -73,9 +73,7 @@ prune_flat([], _) ->
[].
keep_pcdata(Trees) ->
- lists:filter(fun({pcdata, _, _}) -> true;
- (_) -> false
- end, Trees).
+ [T || T = {pcdata, _, _} <- Trees].
new_trees(FileFuncs) ->
Files0 = [{File, RefType} || {File, RefType, _} <- FileFuncs],
diff --git a/lib/docbuilder/src/docb_tr_part2html.erl b/lib/docbuilder/src/docb_tr_part2html.erl
index dd44c4a8df..30befe8432 100644
--- a/lib/docbuilder/src/docb_tr_part2html.erl
+++ b/lib/docbuilder/src/docb_tr_part2html.erl
@@ -93,8 +93,8 @@ transform(File, {part, _Attrs, [Header| Rest]}, Opts0) ->
case docb_main:parse1("fascicules", Opts0) of
{ok, Parse} ->
FascData = get_fasc_data(Parse),
- case lists:keysearch(File, 1, FascData) of
- {value, {_, _, "YES", _}} ->
+ case lists:keyfind(File, 1, FascData) of
+ {_, _, "YES", _} ->
OrigFile =
docb_util:outfile(File++"_frame",
".html", Opts0),
@@ -137,7 +137,7 @@ concat_files([File | Rest], Body, ChLevel, Opts, TP, TOpts, Ext) ->
case docb_main:parse1(File, Opts) of
{ok, Parse} ->
{TopTag, Attrs, [Header = {header, _, HeaderContents} | More]} = Parse,
- {value,{title,_,Title}} = lists:keysearch(title,1,HeaderContents),
+ {title,_,Title} = lists:keyfind(title,1,HeaderContents),
NewMore = [{section, [], [{title, [], Title}| More]}],
NewParse = {TopTag, Attrs, [Header| NewMore]},
if
@@ -156,9 +156,8 @@ concat_files([File | Rest], Body, ChLevel, Opts, TP, TOpts, Ext) ->
docb_html_util:number(NewParse,
integer_to_list(ChLevel), File),
{_, [], [_| NewBody]} = NumberTree,
- lists:append(Body,
- concat_files(Rest, NewBody, ChLevel+1, Opts,
- TP, TOpts, Ext));
+ Body ++ concat_files(Rest, NewBody, ChLevel+1, Opts,
+ TP, TOpts, Ext);
errors ->
throw({error,"Parse error when building chapter "++File})
end;
@@ -232,9 +231,7 @@ get_fasc_data({fascicules, _, Fascs}) ->
Fascs).
get_avals(Atts) ->
- lists:map(fun(Tuple) ->
- element(3, Tuple) end,
- Atts).
+ [element(3, Tuple) || Tuple <- Atts].
get_pc_text([{pcdata, _, Text}]) ->
Text.
diff --git a/lib/docbuilder/src/docb_tr_term2html.erl b/lib/docbuilder/src/docb_tr_term2html.erl
index 0a993cebb1..a3c4a5312a 100644
--- a/lib/docbuilder/src/docb_tr_term2html.erl
+++ b/lib/docbuilder/src/docb_tr_term2html.erl
@@ -39,24 +39,22 @@ purge_body([], _) ->
purge_body([{pcdata,_Attrs,_More}|Rest], TermList) ->
purge_body(Rest, TermList);
purge_body([{term,[{"ID","CDATA",ID}],More}|Rest], TermList) ->
- case lists:keysearch(ID, 1, TermList) of
+ case lists:keyfind(ID, 1, TermList) of
false ->
[{term,[{"NAME","CDATA",ID},{"ID","CDATA",ID}],More}|
purge_body(Rest, TermList)];
- {value, {ID, Name, _Description, _Responsible}} ->
+ {ID, Name, _Description, _Responsible} ->
[{term,[{"NAME","CDATA",Name},{"ID","CDATA",ID}],More}|
purge_body(Rest, TermList)];
- {value, {ID, Name, _Description}} ->
+ {ID, Name, _Description} ->
[{term,[{"NAME","CDATA",Name},{"ID","CDATA",ID}],More}|
purge_body(Rest, TermList)]
end;
purge_body([{_Tag,_Attrs,More}|Rest], TermList) ->
- lists:append(purge_body(More, TermList),
- purge_body(Rest, TermList)).
+ purge_body(More, TermList) ++ purge_body(Rest, TermList).
rule([header|_], _) ->
{drop, ""};
-
rule(_, _) ->
{drop, ""}.
@@ -82,19 +80,19 @@ rule([term|_], {_,[Name,ID],[{termdef,[],[{pcdata,[],Def}]}]}, Opts) ->
false -> [];
Value -> Value
end,
- case lists:keysearch(ID, 1, TermList) of
+ case lists:keyfind(ID, 1, TermList) of
false ->
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ ID ++ "</strong></a>\n</dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Def) ++ "\n</dd>\n"}, Opts};
- {value, {ID, Name, Description, _Responsible}} ->
+ {ID, Name, Description, _Responsible} ->
docb_util:message(warning,
"Global term ~s overriding local", [ID]),
{{drop,"\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"},
Opts};
- {value, {ID, Name, Description}} ->
+ {ID, Name, Description} ->
docb_util:message(warning,
"Global term ~s overriding local", [ID]),
{{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++
@@ -107,19 +105,19 @@ rule([term|_], {_,[Name,ID],_}, Opts) ->
false -> [];
Value -> Value
end,
- case lists:keysearch(ID, 1, TermList) of
+ case lists:keyfind(ID, 1, TermList) of
false ->
docb_util:message(error,
"The term ~s has no definition", [ID]),
{{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ ID ++ "</strong></a></dt>\n<dd>" ++
"??" ++ "\n</dd>\n"}, Opts};
- {value, {ID, Name, Description, _Responsible}} ->
+ {ID, Name, Description, _Responsible} ->
{{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"},
Opts};
- {value, {ID, Name, Description}} ->
+ {ID, Name, Description} ->
{{drop, "\n<dt><a name=\"" ++ ID ++ "\">" ++
"<strong>" ++ Name ++ "</strong></a></dt>\n<dd>" ++
docb_html_util:pcdata_to_html(Description) ++ "\n</dd>\n"}, Opts}
diff --git a/lib/docbuilder/src/docb_transform.erl b/lib/docbuilder/src/docb_transform.erl
index a432038adf..9c7561b07b 100644
--- a/lib/docbuilder/src/docb_transform.erl
+++ b/lib/docbuilder/src/docb_transform.erl
@@ -135,8 +135,8 @@ parse([Opt | _RawOpts], _Opts) ->
get_defs(Type, File, Opts) ->
Key = {defs,Type},
{PrevDefs, Opts2} =
- case lists:keysearch(Key, 1, Opts) of
- {value, {_, Defs0}} ->
+ case lists:keyfind(Key, 1, Opts) of
+ {_, Defs0} ->
{Defs0, lists:keydelete(Key, 1, Opts)};
false ->
{[], Opts}
diff --git a/lib/docbuilder/src/docb_util.erl b/lib/docbuilder/src/docb_util.erl
index 59673ef3a4..9b2eec7733 100644
--- a/lib/docbuilder/src/docb_util.erl
+++ b/lib/docbuilder/src/docb_util.erl
@@ -61,7 +61,7 @@ html_snippet(What, Opts) ->
case lookup_option(html_mod, Opts) of
false -> "";
Module ->
- case catch apply(Module, What, []) of
+ case catch Module:What() of
HTML when is_list(HTML) ->
HTML;
{'EXIT', {undef, _}} ->
@@ -82,7 +82,7 @@ html_snippet(What, Arg, Opts) ->
case lookup_option(html_mod, Opts) of
false -> "";
Module ->
- case catch apply(Module, What, [Arg]) of
+ case catch Module:What(Arg) of
HTML when is_list(HTML) ->
HTML;
{'EXIT', {undef, _}} ->
@@ -106,8 +106,8 @@ html_snippet(What, Arg, Opts) ->
%% lookup_option(Opt, Opts) -> Value | false
lookup_option(Opt, Opts) ->
- case lists:keysearch(Opt, 1, Opts) of
- {value, {Opt,Value}} -> Value;
+ case lists:keyfind(Opt, 1, Opts) of
+ {Opt,Value} -> Value;
false -> false
end.
diff --git a/lib/docbuilder/src/docb_xmerl_tree_cb.erl b/lib/docbuilder/src/docb_xmerl_tree_cb.erl
index d57f55bff8..bc62069230 100644
--- a/lib/docbuilder/src/docb_xmerl_tree_cb.erl
+++ b/lib/docbuilder/src/docb_xmerl_tree_cb.erl
@@ -188,8 +188,8 @@ attrs(DTD, Tag, GivenAttrs) ->
merge_attrs(Tag, default_attrs(DTD, Tag), GivenAttrs).
merge_attrs(Tag, [{NameA, Type, DefVal}|Default], GivenAttrs) ->
- Val = case lists:keysearch(NameA, #xmlAttribute.name, GivenAttrs) of
- {value, #xmlAttribute{value=Val0}} -> Val0;
+ Val = case lists:keyfind(NameA, #xmlAttribute.name, GivenAttrs) of
+ #xmlAttribute{value=Val0} -> Val0;
false -> DefVal
end,
Attr = {attr_name(NameA), Type, attr_val(Type, Val)},
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl
index 9df3dedb45..1f0247a040 100644
--- a/lib/hipe/cerl/erl_bif_types.erl
+++ b/lib/hipe/cerl/erl_bif_types.erl
@@ -2337,8 +2337,7 @@ type(lists, flatten, 1, Xs) ->
t_list();
false ->
X2 = type(lists, flatten, 1, [t_inf(X1, t_list())]),
- t_sup(t_list(t_subtract(X1, t_list())),
- X2)
+ t_sup(t_list(t_subtract(X1, t_list())), X2)
end
end
end);
@@ -2349,10 +2348,20 @@ type(lists, flatmap, 2, Xs) ->
true -> t_nil();
false ->
case check_fun_application(F, [t_list_elements(List)]) of
- ok ->
- case t_is_cons(List) of
- true -> t_nonempty_list(t_list_elements(t_fun_range(F)));
- false -> t_list(t_list_elements(t_fun_range(F)))
+ ok ->
+ R = t_fun_range(F),
+ case t_is_nil(R) of
+ true -> t_nil();
+ false ->
+ Elems = t_list_elements(R),
+ case t_is_cons(List) of
+ true ->
+ case t_is_subtype(t_nil(), R) of
+ true -> t_list(Elems);
+ false -> t_nonempty_list(Elems)
+ end;
+ false -> t_list(Elems)
+ end
end;
error ->
case t_is_cons(List) of
diff --git a/lib/jinterface/java_src/Makefile b/lib/jinterface/java_src/Makefile
index 37a57352ad..22c55328b8 100644
--- a/lib/jinterface/java_src/Makefile
+++ b/lib/jinterface/java_src/Makefile
@@ -35,7 +35,21 @@ VSN=$(JINTERFACE_VSN)
SPECIAL_TARGETS =
+TARGET_FILES= $(POM_TARGET)
+SPECIAL_TARGETS =
+
+POM_FILE= pom.xml
+
+POM_TARGET= ../$(POM_FILE)
+POM_SRC= $(POM_FILE).src
+
+# ----------------------------------------------------
+# Special Build Targets
+# ----------------------------------------------------
+
+$(POM_TARGET): $(POM_SRC) ../vsn.mk
+ sed -e 's;%VSN%;$(VSN);' $< > $@
# ----------------------------------------------------
# Default Subdir Targets
@@ -43,7 +57,7 @@ SPECIAL_TARGETS =
.PHONY: debug opt instr release docs release_docs tests release_tests clean depend
-debug opt instr release docs release_docs tests release_tests clean depend:
+debug opt instr release docs release_docs tests release_tests clean depend: $(TARGET_FILES)
set -e; set -x; \
case "$(MAKE)" in *clearmake*) tflag="-T";; *) tflag="";; esac; \
if test -f com/ericsson/otp/erlang/ignore_config_record.inf; then xflag=$$tflag; fi; \
diff --git a/lib/jinterface/java_src/pom.xml.src b/lib/jinterface/java_src/pom.xml.src
new file mode 100644
index 0000000000..cef49b735a
--- /dev/null
+++ b/lib/jinterface/java_src/pom.xml.src
@@ -0,0 +1,106 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.erlang.otp</groupId>
+ <artifactId>jinterface</artifactId>
+ <packaging>jar</packaging>
+ <version>%VSN%</version>
+ <name>jinterface</name>
+ <description>
+ Jinterface Java package contains java classes, which help you integrate programs written in Java with Erlang.
+ Erlang is a programming language designed at the Ericsson Computer Science Laboratory.
+ </description>
+ <url>http://erlang.org/</url>
+ <licenses>
+ <license>
+ <name>ERLANG PUBLIC LICENSE 1.1</name>
+ <url>http://www.erlang.org/EPLICENSE</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <connection>git://github.com/erlang/otp.git</connection>
+ <developerConnection>git://github.com/erlang/otp.git</developerConnection>
+ <url>http://github.com/erlang/otp</url>
+ </scm>
+ <developers>
+ <developer>
+ <email>[email protected]</email>
+ </developer>
+ </developers>
+ <organization>
+ <name>Open Source Erlang</name>
+ <url>http://www.erlang.org/</url>
+ </organization>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>java_src</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <distributionManagement>
+ <repository>
+ <id>ossrh</id>
+ <url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
+ </repository>
+ <snapshotRepository>
+ <id>ossrh</id>
+ <url>http://oss.sonatype.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+ <profiles>
+ <profile>
+ <id>release-sign-artifacts</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.0-alpha-4</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index a9ceac0bcf..2044b074ee 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -1229,7 +1229,7 @@ f.txt: {person, "kalle", 25}.
</item>
<tag><c>{no_translation, unicode, latin1}</c></tag>
<item>
- <p>The file is was opened with another <c>encoding</c> than <c>latin1</c> and the data on the file can not be translated to the byte-oriented data that this function returns.</p>
+ <p>The file was opened with another <c>encoding</c> than <c>latin1</c> and the data in the file can not be translated to the byte-oriented data that this function returns.</p>
</item>
</taglist>
</desc>
diff --git a/lib/kernel/src/auth.erl b/lib/kernel/src/auth.erl
index 7fe30ae828..5c7fe2421d 100644
--- a/lib/kernel/src/auth.erl
+++ b/lib/kernel/src/auth.erl
@@ -50,6 +50,8 @@
%% Exported functions
%%----------------------------------------------------------------------
+-spec start_link() -> {'ok',pid()} | {'error', term()} | 'ignore'.
+
start_link() ->
gen_server:start_link({local, auth}, auth, [], []).
@@ -134,7 +136,9 @@ init([]) ->
%% The net kernel will let all message to the auth server
%% through as is
--type calls() :: 'echo' | 'sync_cookie' | {'set_cookie', node(), term()}.
+-type calls() :: 'echo' | 'sync_cookie'
+ | {'get_cookie', node()}
+ | {'set_cookie', node(), term()}.
-spec handle_call(calls(), {pid(), term()}, state()) ->
{'reply', 'hello' | 'true' | 'nocookie' | cookie(), state()}.
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl
index bd5685952e..fa1991872b 100644
--- a/lib/kernel/test/gen_udp_SUITE.erl
+++ b/lib/kernel/test/gen_udp_SUITE.erl
@@ -34,12 +34,12 @@
-export([send_to_closed/1,
buffer_size/1, binary_passive_recv/1, bad_address/1,
- read_packets/1, open_fd/1]).
+ read_packets/1, open_fd/1, connect/1]).
all(suite) ->
[send_to_closed,
buffer_size, binary_passive_recv, bad_address, read_packets,
- open_fd].
+ open_fd, connect].
init_per_testcase(_Case, Config) ->
?line Dog=test_server:timetrap(?default_timeout),
@@ -408,3 +408,20 @@ start_node(Name) ->
stop_node(Node) ->
?t:stop_node(Node).
+
+
+connect(suite) ->
+ [];
+connect(doc) ->
+ ["Test that connect/3 has effect"];
+connect(Config) when is_list(Config) ->
+ Addr = {127,0,0,1},
+ {ok,S1} = gen_udp:open(0),
+ {ok,P1} = inet:port(S1),
+ {ok,S2} = gen_udp:open(0),
+ ok = inet:setopts(S2, [{active,false}]),
+ ok = gen_udp:close(S1),
+ ok = gen_udp:connect(S2, Addr, P1),
+ ok = gen_udp:send(S2, <<16#deadbeef:32>>),
+ {error,econnrefused} = gen_udp:recv(S2, 0, 5),
+ ok.
diff --git a/lib/stdlib/doc/src/beam_lib.xml b/lib/stdlib/doc/src/beam_lib.xml
index 27308e02f3..adc411e272 100644
--- a/lib/stdlib/doc/src/beam_lib.xml
+++ b/lib/stdlib/doc/src/beam_lib.xml
@@ -341,6 +341,7 @@ chunkref() = chunkname() | chunkid()</code>
<v>Beam1 = Beam2 = beam()</v>
<v>Reason = {modules_different, Module1, Module2}</v>
<v>&nbsp;&nbsp;| {chunks_different, ChunkId}</v>
+ <v>&nbsp;&nbsp;| different_chunks</v>
<v>&nbsp;&nbsp;| Reason1 -- see info/1</v>
<v>&nbsp;Module1 = Module2 = atom()</v>
<v>&nbsp;ChunkId = chunkid()</v>
diff --git a/lib/stdlib/doc/src/timer.xml b/lib/stdlib/doc/src/timer.xml
index 0b6807dd6c..1b34e71490 100644
--- a/lib/stdlib/doc/src/timer.xml
+++ b/lib/stdlib/doc/src/timer.xml
@@ -202,18 +202,33 @@
</func>
<func>
<name>tc(Module, Function, Arguments) -> {Time, Value}</name>
- <fsummary>Measure the real time it takes to evaluate <c>apply(Module, Function, Arguments)</c></fsummary>
+ <name>tc(Fun, Arguments) -> {Time, Value}</name>
+ <fsummary>Measure the real time it takes to evaluate <c>apply(Module,
+ Function, Arguments)</c> or <c>apply(Fun, Arguments)</c></fsummary>
<type>
<v>Module = Function = atom()</v>
+ <v>Fun = fun()</v>
<v>Arguments = [term()]</v>
<v>Time = integer() in microseconds</v>
<v>Value = term()</v>
</type>
<desc>
- <p>Evaluates <c>apply(Module, Function, Arguments)</c> and measures
- the elapsed real time. Returns <c>{Time, Value}</c>, where
- <c>Time</c> is the elapsed real time in <em>microseconds</em>,
- and <c>Value</c> is what is returned from the apply.</p>
+ <p></p>
+ <taglist>
+ <tag><c>tc/3</c></tag>
+ <item>
+ <p>Evaluates <c>apply(Module, Function, Arguments)</c> and measures
+ the elapsed real time as reported by <c>now/0</c>.
+ Returns <c>{Time, Value}</c>, where
+ <c>Time</c> is the elapsed real time in <em>microseconds</em>,
+ and <c>Value</c> is what is returned from the apply.</p>
+ </item>
+ <tag><c>tc/2</c></tag>
+ <item>
+ <p>Evaluates <c>apply(Fun, Arguments)</c>. Otherwise works
+ like <c>tc/3</c>.</p>
+ </item>
+ </taglist>
</desc>
</func>
<func>
diff --git a/lib/stdlib/src/beam_lib.erl b/lib/stdlib/src/beam_lib.erl
index 91ff2438c6..e612bf71e7 100644
--- a/lib/stdlib/src/beam_lib.erl
+++ b/lib/stdlib/src/beam_lib.erl
@@ -105,6 +105,7 @@
| info_rsn().
-type cmp_rsn() :: {'modules_different', module(), module()}
| {'chunks_different', chunkid()}
+ | 'different_chunks'
| info_rsn().
%%-------------------------------------------------------------------------
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl
index d26443f277..99e454f593 100644
--- a/lib/stdlib/src/escript.erl
+++ b/lib/stdlib/src/escript.erl
@@ -24,35 +24,41 @@
%% Internal API.
-export([start/0, start/1]).
--include_lib("kernel/include/file.hrl").
+%%-----------------------------------------------------------------------
-define(SHEBANG, "/usr/bin/env escript").
-define(COMMENT, "This is an -*- erlang -*- file").
--record(state, {file,
- module,
+%%-----------------------------------------------------------------------
+
+-type mode() :: 'compile' | 'debug' | 'interpret' | 'run'.
+-type source() :: 'archive' | 'beam' | 'text'.
+
+-record(state, {file :: file:filename(),
+ module :: module(),
forms_or_bin,
- source,
- n_errors,
- mode,
- exports_main,
- has_records}).
--record(sections, {type,
- shebang,
- comment,
- emu_args,
- body}).
--record(extract_options, {compile_source}).
+ source :: source(),
+ n_errors :: non_neg_integer(),
+ mode :: mode(),
+ exports_main :: boolean(),
+ has_records :: boolean()}).
-type shebang() :: string().
-type comment() :: string().
-type emu_args() :: string().
--type escript_filename() :: string().
--type filename() :: string().
+
+-record(sections, {type,
+ shebang :: shebang(),
+ comment :: comment(),
+ emu_args :: emu_args(),
+ body}).
+
+-record(extract_options, {compile_source}).
+
-type zip_file() ::
- filename()
- | {filename(), binary()}
- | {filename(), binary(), #file_info{}}.
+ file:filename()
+ | {file:filename(), binary()}
+ | {file:filename(), binary(), file:file_info()}.
-type zip_create_option() :: term().
-type section() ::
shebang
@@ -60,13 +66,15 @@
| comment
| {comment, comment()}
| {emu_args, emu_args()}
- | {source, filename() | binary()}
- | {beam, filename() | binary()}
- | {archive, filename() | binary()}
+ | {source, file:filename() | binary()}
+ | {beam, file:filename() | binary()}
+ | {archive, file:filename() | binary()}
| {archive, [zip_file()], [zip_create_option()]}.
+%%-----------------------------------------------------------------------
+
%% Create a complete escript file with both header and body
--spec create(escript_filename() | binary, [section()]) ->
+-spec create(file:filename() | binary, [section()]) ->
ok | {ok, binary()} | {error, term()}.
create(File, Options) when is_list(Options) ->
@@ -149,7 +157,9 @@ prepare(BadOptions, _) ->
-type section_name() :: shebang | comment | emu_args | body .
-type extract_option() :: compile_source | {section, [section_name()]}.
--spec extract(filename(), [extract_option()]) -> {ok, [section()]} | {error, term()}.
+-spec extract(file:filename(), [extract_option()]) ->
+ {ok, [section()]} | {error, term()}.
+
extract(File, Options) when is_list(File), is_list(Options) ->
try
EO = parse_extract_options(Options,
@@ -239,6 +249,7 @@ normalize_section(Name, Chars) ->
{Name, Chars}.
-spec script_name() -> string().
+
script_name() ->
[ScriptName|_] = init:get_plain_arguments(),
ScriptName.
@@ -248,10 +259,12 @@ script_name() ->
%%
-spec start() -> no_return().
+
start() ->
start([]).
-spec start([string()]) -> no_return().
+
start(EscriptOptions) ->
try
%% Commands run using -run or -s are run in a process
@@ -484,18 +497,12 @@ find_first_body_line(Fd, HeaderSz0, LineNo, KeepFirst, Sections) ->
classify_line(Line) ->
case Line of
- [$\#, $\! | _] ->
- shebang;
- [$P, $K | _] ->
- archive;
- [$F, $O, $R, $1 | _] ->
- beam;
- [$%, $%, $\! | _] ->
- emu_args;
- [$% | _] ->
- comment;
- _ ->
- undefined
+ "#!" ++ _ -> shebang;
+ "PK" ++ _ -> archive;
+ "FOR1" ++ _ -> beam;
+ "%%!" ++ _ -> emu_args;
+ "%" ++ _ -> comment;
+ _ -> undefined
end.
guess_type(Line) ->
@@ -531,7 +538,6 @@ parse_archive(S, File, HeaderSz) ->
end,
list_to_atom(lists:reverse(RevBase2))
end,
-
S#state{source = archive,
mode = run,
module = Mod,
@@ -587,8 +593,8 @@ parse_source(S, File, Fd, StartLine, HeaderSz, CheckOnly) ->
epp_parse_file2(Epp, S2, [ModForm, FileForm], OptModRes);
{error, _} ->
epp_parse_file2(Epp, S2, [FileForm], OptModRes);
- {eof,LastLine} ->
- S#state{forms_or_bin = [FileForm, {eof,LastLine}]}
+ {eof, _LastLine} = Eof ->
+ S#state{forms_or_bin = [FileForm, Eof]}
end,
ok = epp:close(Epp),
ok = file:close(Fd),
@@ -683,8 +689,8 @@ epp_parse_file2(Epp, S, Forms, Parsed) ->
io:format("~s:~w: ~s\n",
[S#state.file,Ln,Mod:format_error(Args)]),
epp_parse_file(Epp, S#state{n_errors = S#state.n_errors + 1}, [Form | Forms]);
- {eof,LastLine} ->
- S#state{forms_or_bin = lists:reverse([{eof, LastLine} | Forms])}
+ {eof, _LastLine} = Eof ->
+ S#state{forms_or_bin = lists:reverse([Eof | Forms])}
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/lib/stdlib/src/timer.erl b/lib/stdlib/src/timer.erl
index 6ee837c3e6..24e14caa69 100644
--- a/lib/stdlib/src/timer.erl
+++ b/lib/stdlib/src/timer.erl
@@ -22,7 +22,7 @@
send_after/3, send_after/2,
exit_after/3, exit_after/2, kill_after/2, kill_after/1,
apply_interval/4, send_interval/3, send_interval/2,
- cancel/1, sleep/1, tc/3, now_diff/2,
+ cancel/1, sleep/1, tc/2, tc/3, now_diff/2,
seconds/1, minutes/1, hours/1, hms/3]).
-export([start_link/0, start/0,
@@ -98,6 +98,17 @@ sleep(T) ->
after T -> ok
end.
+
+%%
+%% Measure the execution time (in microseconds) for Fun(Args).
+%%
+-spec tc(function(), [_]) -> {time(), term()}.
+tc(F, A) ->
+ Before = erlang:now(),
+ Val = (catch apply(F, A)),
+ After = erlang:now(),
+ {now_diff(After, Before), Val}.
+
%%
%% Measure the execution time (in microseconds) for an MFA.
%%
diff --git a/lib/stdlib/test/timer_simple_SUITE.erl b/lib/stdlib/test/timer_simple_SUITE.erl
index 021a22c61b..6aa2b7b945 100644
--- a/lib/stdlib/test/timer_simple_SUITE.erl
+++ b/lib/stdlib/test/timer_simple_SUITE.erl
@@ -224,11 +224,19 @@ cancel2(Config) when is_list(Config) ->
tc(doc) -> "Test sleep/1 and tc/3.";
tc(suite) -> [];
tc(Config) when is_list(Config) ->
- % This should both sleep and tc
- ?line {Res, ok} = timer:tc(timer, sleep, [500]),
- ?line ok = if
- Res < 500*1000 -> {too_early, Res}; % Too early
- Res > 800*1000 -> {too_late, Res}; % Too much time
+ % This should both sleep and tc/3
+ ?line {Res1, ok} = timer:tc(timer, sleep, [500]),
+ ?line ok = if
+ Res1 < 500*1000 -> {too_early, Res1}; % Too early
+ Res1 > 800*1000 -> {too_late, Res1}; % Too much time
+ true -> ok
+ end,
+
+ % This should both sleep and tc/2
+ ?line {Res2, ok} = timer:tc(fun(T) -> timer:sleep(T) end, [500]),
+ ?line ok = if
+ Res2 < 500*1000 -> {too_early, Res2}; % Too early
+ Res2 > 800*1000 -> {too_late, Res2}; % Too much time
true -> ok
end,