From 0de222d998e372661c7ba1c1d0cecc8b7a23b0aa Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Wed, 3 Feb 2016 11:30:48 +0100 Subject: [PATCH] Convert code to use Fast YAML --- src/ejabberd_app.erl | 2 +- src/ejabberd_config.erl | 6 +++--- src/ext_mod.erl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index ae74b5963..5589c31b9 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -252,7 +252,7 @@ start_apps() -> crypto:start(), ejabberd:start_app(sasl), ejabberd:start_app(ssl), - ejabberd:start_app(p1_yaml), + ejabberd:start_app(fast_yaml), ejabberd:start_app(p1_tls), ejabberd:start_app(p1_xml), ejabberd:start_app(stringprep), diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 8d2d19975..1f2eaa142 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -162,7 +162,7 @@ convert_to_yaml(File, Output) -> fun({Host, Opts1}) -> {host_config, [{Host, Opts1}]} end, HOpts), - Data = p1_yaml:encode(lists:reverse(NewOpts)), + Data = fast_yaml:encode(lists:reverse(NewOpts)), case Output of stdout -> io:format("~s~n", [Data]); @@ -226,14 +226,14 @@ get_plain_terms_file(File1, Opts) -> consult(File) -> case filename:extension(File) of Ex when (Ex == ".yml") or (Ex == ".yaml") -> - case p1_yaml:decode_from_file(File, [plain_as_atom]) of + case fast_yaml:decode_from_file(File, [plain_as_atom]) of {ok, []} -> {ok, []}; {ok, [Document|_]} -> {ok, parserl(Document)}; {error, Err} -> Msg1 = "Cannot load " ++ File ++ ": ", - Msg2 = p1_yaml:format_error(Err), + Msg2 = fast_yaml:format_error(Err), {error, Msg1 ++ Msg2} end; _ -> diff --git a/src/ext_mod.erl b/src/ext_mod.erl index 46ece873c..14ac21316 100644 --- a/src/ext_mod.erl +++ b/src/ext_mod.erl @@ -589,10 +589,10 @@ rebar_dep({App, _, {git, Url, Ref}}) -> %% -- YAML spec parser consult(File) -> - case p1_yaml:decode_from_file(File, [plain_as_atom]) of + case fast_yaml:decode_from_file(File, [plain_as_atom]) of {ok, []} -> {ok, []}; {ok, [Doc|_]} -> {ok, [format(Spec) || Spec <- Doc]}; - {error, Err} -> {error, p1_yaml:format_error(Err)} + {error, Err} -> {error, fast_yaml:format_error(Err)} end. format({Key, Val}) when is_binary(Val) ->