From d460e43353fb4d2a005bfd4a4bbd0e6b81e4edc7 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Tue, 22 May 2012 14:11:11 +0400 Subject: [PATCH 6/9] No such function lists:keyfind/3 in R12B5 - use lists:keysearch/3 instead Signed-off-by: Peter Lemenkov --- src/rebar_rel_utils.erl | 18 +++++++++--------- src/rebar_reltool.erl | 10 +++++----- src/rebar_templater.erl | 6 +++--- src/rebar_xref.erl | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl index e502743..21ff2dc 100644 --- a/src/rebar_rel_utils.erl +++ b/src/rebar_rel_utils.erl @@ -137,8 +137,8 @@ load_config(ReltoolFile) -> %% Without this present, we can't run reltool. %% get_sys_tuple(ReltoolConfig) -> - case lists:keyfind(sys, 1, ReltoolConfig) of - {sys, _} = SysTuple -> + case lists:keysearch(sys, 1, ReltoolConfig) of + {value, {sys, _}} = SysTuple -> SysTuple; false -> ?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", []) @@ -151,13 +151,13 @@ get_sys_tuple(ReltoolConfig) -> get_target_dir(ReltoolConfig) -> case rebar_config:get_global(target_dir, undefined) of undefined -> - case lists:keyfind(target_dir, 1, ReltoolConfig) of - {target_dir, TargetDir} -> + case lists:keysearch(target_dir, 1, ReltoolConfig) of + {value, {target_dir, TargetDir}} -> filename:absname(TargetDir); false -> {sys, SysInfo} = get_sys_tuple(ReltoolConfig), - case lists:keyfind(rel, 1, SysInfo) of - {rel, Name, _Vsn, _Apps} -> + case lists:keysearch(rel, 1, SysInfo) of + {value, {rel, Name, _Vsn, _Apps}} -> filename:absname(Name); false -> filename:absname("target") @@ -180,7 +180,7 @@ get_target_parent_dir(ReltoolConfig) -> %% get_root_dir(ReltoolConfig) -> {sys, SysInfo} = get_sys_tuple(ReltoolConfig), - SysRootDirTuple = lists:keyfind(root_dir, 1, SysInfo), + {value, SysRootDirTuple} = lists:keysearch(root_dir, 1, SysInfo), CmdRootDir = rebar_config:get_global(root_dir, undefined), case {SysRootDirTuple, CmdRootDir} of %% root_dir in sys typle and no root_dir on cmd-line @@ -218,8 +218,8 @@ make_proplist([], Acc) -> Acc. expand_version(ReltoolConfig, Dir) -> - case lists:keyfind(sys, 1, ReltoolConfig) of - {sys, Sys} -> + case lists:keysearch(sys, 1, ReltoolConfig) of + {value, {sys, Sys}} -> ExpandedSys = {sys, [expand_rel_version(Term, Dir) || Term <- Sys]}, lists:keyreplace(sys, 1, ReltoolConfig, ExpandedSys); _ -> diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index c114811..eb34385 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -116,8 +116,8 @@ process_overlay(ReltoolConfig) -> OverlayVars1), %% Finally, overlay the files specified by the overlay section - case lists:keyfind(overlay, 1, ReltoolConfig) of - {overlay, Overlay} when is_list(Overlay) -> + case lists:keysearch(overlay, 1, ReltoolConfig) of + {value, {overlay, Overlay}} when is_list(Overlay) -> execute_overlay(Overlay, OverlayVars, rebar_utils:get_cwd(), TargetDir); false -> @@ -156,10 +156,10 @@ load_vars_file(File) -> validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) -> - case lists:keyfind(rel, 1, ReltoolConfig) of + case lists:keysearch(rel, 1, ReltoolConfig) of false -> ok; - {rel, _Name, _Vsn, Apps} -> + {value, {rel, _Name, _Vsn, Apps}} -> %% Identify all the apps that do NOT exist, based on %% what's available from the reltool server Missing = lists:sort( @@ -172,7 +172,7 @@ validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) -> ?ABORT("Apps in {rel, ...} section not found by " "reltool: ~p\n", [Missing]) end; - Rel -> + {value, Rel} -> %% Invalid release format! ?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel]) end. diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index f608512..6b9946f 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -90,8 +90,8 @@ create(_Config, _) -> %% Load the template definition as is and get the list of variables the %% template requires. TemplateTerms = consult(load_file(Type, Template)), - case lists:keyfind(variables, 1, TemplateTerms) of - {variables, Vars} -> + case lists:keysearch(variables, 1, TemplateTerms) of + {value, {variables, Vars}} -> case parse_vars(Vars, dict:new()) of {error, Entry} -> Context0 = undefined, @@ -228,7 +228,7 @@ select_template([{Type, Avail} | Rest], Template) -> %% Read the contents of a file from the appropriate source %% load_file(escript, Name) -> - {Name, Bin} = lists:keyfind(Name, 1, erlang:get(escript_files)), + {value, {Name, Bin}} = lists:keysearch(Name, 1, erlang:get(escript_files)), Bin; load_file(file, Name) -> {ok, Bin} = file:read_file(Name), diff --git a/src/rebar_xref.erl b/src/rebar_xref.erl index 94103eb..17fb2a1 100644 --- a/src/rebar_xref.erl +++ b/src/rebar_xref.erl @@ -159,8 +159,8 @@ filter_away_ignored(UnusedExports) -> kf(Key, List) -> - case lists:keyfind(Key, 1, List) of - {Key, Value} -> + case lists:keysearch(Key, 1, List) of + {value, {Key, Value}} -> Value; false -> [] -- 1.7.10.2