Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-03-07 17:46:16 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-03-07 17:46:16 +0300
commitc3eeb8624baa639e049d113e111a6a4358d6799c (patch)
tree77be4ef86fa0085af12ce92194b59adb2c880ef3
parentbc808ffcde9ae508886b740763c0ac8668e391b9 (diff)
Strip duplicates from module's options
-rw-r--r--src/gen_mod.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gen_mod.erl b/src/gen_mod.erl
index a477ec295..836e9dba8 100644
--- a/src/gen_mod.erl
+++ b/src/gen_mod.erl
@@ -555,7 +555,8 @@ validate_opts(Host, Module, Opts0) ->
undef ->
Opts;
Validators ->
- validate_opts(Host, Module, Opts, Required, Validators)
+ Opts1 = validate_opts(Host, Module, Opts, Required, Validators),
+ remove_duplicated_opts(Opts1)
end}
catch _:{missing_required_option, Opt} ->
ErrTxt = io_lib:format("Module '~s' is missing required option '~s'",
@@ -680,6 +681,16 @@ merge_opts(Opts, DefaultOpts) ->
end
end, Result, Opts).
+remove_duplicated_opts([{Opt, Val}, {Opt, _Default}|Opts]) ->
+ [{Opt, Val}|remove_duplicated_opts(Opts)];
+remove_duplicated_opts([{Opt, [{SubOpt, _}|_] = SubOpts}|Opts])
+ when is_atom(SubOpt) ->
+ [{Opt, remove_duplicated_opts(SubOpts)}|remove_duplicated_opts(Opts)];
+remove_duplicated_opts([OptVal|Opts]) ->
+ [OptVal|remove_duplicated_opts(Opts)];
+remove_duplicated_opts([]) ->
+ [].
+
-spec get_submodules(binary(), module(), opts()) -> [module()].
get_submodules(Host, Module, Opts) ->
try Module:mod_options(Host) of