]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_config.erl: Removed a dependency on string:to_upper
authorAlexey Shchepin <alexey@process-one.net>
Fri, 11 Apr 2008 05:52:10 +0000 (05:52 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Fri, 11 Apr 2008 05:52:10 +0000 (05:52 +0000)
SVN Revision: 1288

ChangeLog
src/ejabberd_config.erl

index 3f8b8337453e213694f23717fc6cd66de4c9d971..89ebf88b9a2b27fbf505d8c8a9f9224fd86698c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 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/ejabberd_zlib/ejabberd_zlib_drv.c: Likewise
 
index a585b39fb114744940f2d69bd721d8247217587e..6d110ed1347c5c6384aff462cd37cfe07418a855 100644 (file)
@@ -239,18 +239,18 @@ split_terms_macros(Terms) ->
     lists:foldl(
       fun(Term, {TOs, Ms}) ->
              case Term of
-                         {define_macro, Key, Value} -> 
-                         case is_atom(Key) and is_all_uppercase(Key) of
-                               true -> 
-                                       {TOs, Ms++[{Key, Value}]};
-                               false -> 
-                                       exit({macro_not_properly_defined, Term})
-                               end;
-                               Term ->
-                                       {TOs ++ [Term], Ms}
+                 {define_macro, Key, Value} -> 
+                     case is_atom(Key) and is_all_uppercase(Key) of
+                         true -> 
+                             {TOs, Ms++[{Key, Value}]};
+                         false -> 
+                             exit({macro_not_properly_defined, Term})
+                     end;
+                 Term ->
+                     {TOs ++ [Term], Ms}
              end
       end,
-         {[], []},
+      {[], []},
       Terms).
 
 %% @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(Key, Macros) when is_atom(Key) ->
-       case is_all_uppercase(Key) of
-               true ->
-                       case proplists:get_value(Key, Macros) of
-                               undefined -> exit({undefined_macro, Key});
-                               Value -> Value
-                       end;
-               false ->
-                       Key
-       end;
+    case is_all_uppercase(Key) of
+       true ->
+           case proplists:get_value(Key, Macros) of
+               undefined -> exit({undefined_macro, Key});
+               Value -> Value
+           end;
+       false ->
+           Key
+    end;
 replace_term({use_macro, Key, Value}, Macros) ->
     proplists:get_value(Key, Macros, Value);
 replace_term(Term, Macros) when is_list(Term) ->
@@ -284,9 +284,10 @@ replace_term(Term, _) ->
     Term.
 
 is_all_uppercase(Atom) ->
-       String = erlang:atom_to_list(Atom),
-       (String == string:to_upper(String)).
-
+    String = erlang:atom_to_list(Atom),
+    lists:all(fun(C) when C >= $a, C =< $z -> false;
+                (_) -> true
+             end, String).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%% Process terms