25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/ejabberd_config.erl: Removed a dependency on string:to_upper

SVN Revision: 1288
This commit is contained in:
Alexey Shchepin 2008-04-11 05:52:10 +00:00
parent 8b690c9f9f
commit 9733e6874e
2 changed files with 25 additions and 22 deletions

View File

@ -1,5 +1,7 @@
2008-04-11 Alexey Shchepin <alexey@process-one.net> 2008-04-11 Alexey Shchepin <alexey@process-one.net>
* src/ejabberd_config.erl: Removed a dependency on string:to_upper
* src/tls/tls_drv.c: Fixed gcc signedness warnings * src/tls/tls_drv.c: Fixed gcc signedness warnings
* src/ejabberd_zlib/ejabberd_zlib_drv.c: Likewise * src/ejabberd_zlib/ejabberd_zlib_drv.c: Likewise

View File

@ -239,18 +239,18 @@ split_terms_macros(Terms) ->
lists:foldl( lists:foldl(
fun(Term, {TOs, Ms}) -> fun(Term, {TOs, Ms}) ->
case Term of case Term of
{define_macro, Key, Value} -> {define_macro, Key, Value} ->
case is_atom(Key) and is_all_uppercase(Key) of case is_atom(Key) and is_all_uppercase(Key) of
true -> true ->
{TOs, Ms++[{Key, Value}]}; {TOs, Ms++[{Key, Value}]};
false -> false ->
exit({macro_not_properly_defined, Term}) exit({macro_not_properly_defined, Term})
end; end;
Term -> Term ->
{TOs ++ [Term], Ms} {TOs ++ [Term], Ms}
end end
end, end,
{[], []}, {[], []},
Terms). Terms).
%% @doc Recursively replace in Terms macro usages with the defined value. %% @doc Recursively replace in Terms macro usages with the defined value.
@ -263,15 +263,15 @@ replace([Term|Terms], Macros) ->
[replace_term(Term, Macros) | replace(Terms, Macros)]. [replace_term(Term, Macros) | replace(Terms, Macros)].
replace_term(Key, Macros) when is_atom(Key) -> replace_term(Key, Macros) when is_atom(Key) ->
case is_all_uppercase(Key) of case is_all_uppercase(Key) of
true -> true ->
case proplists:get_value(Key, Macros) of case proplists:get_value(Key, Macros) of
undefined -> exit({undefined_macro, Key}); undefined -> exit({undefined_macro, Key});
Value -> Value Value -> Value
end; end;
false -> false ->
Key Key
end; end;
replace_term({use_macro, Key, Value}, Macros) -> replace_term({use_macro, Key, Value}, Macros) ->
proplists:get_value(Key, Macros, Value); proplists:get_value(Key, Macros, Value);
replace_term(Term, Macros) when is_list(Term) -> replace_term(Term, Macros) when is_list(Term) ->
@ -284,9 +284,10 @@ replace_term(Term, _) ->
Term. Term.
is_all_uppercase(Atom) -> is_all_uppercase(Atom) ->
String = erlang:atom_to_list(Atom), String = erlang:atom_to_list(Atom),
(String == string:to_upper(String)). lists:all(fun(C) when C >= $a, C =< $z -> false;
(_) -> true
end, String).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Process terms %%% Process terms