From a63c7bec40f7dfa0532bd25c092d2052e0352a17 Mon Sep 17 00:00:00 2001 From: John DeTreville Date: Wed, 10 Nov 2010 18:42:09 +0000 Subject: Removed rabbit_misc:intersperse; changed clients to call string:join instead; hope that's okay. --- src/rabbit_control.erl | 6 ++---- src/rabbit_misc.erl | 7 +------ src/rabbit_multi.erl | 3 +-- src/rabbit_ssl.erl | 9 +++------ 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index 6b212745..277faeda 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -94,9 +94,7 @@ start() -> halt(); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> print_error("invalid command '~s'", - [lists:flatten( - rabbit_misc:intersperse( - " ", [atom_to_list(Command) | Args]))]), + [string:join([atom_to_list(Command) | Args], " ")]), usage(); {error, Reason} -> print_error("~p", [Reason]), @@ -321,7 +319,7 @@ display_info_list(Other, _) -> Other. display_row(Row) -> - io:fwrite(lists:flatten(rabbit_misc:intersperse("\t", Row))), + io:fwrite(string:join(Row, "\t")), io:nl(). -define(IS_U8(X), (X >= 0 andalso X =< 255)). diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index e5c30c06..7451116d 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -50,7 +50,7 @@ -export([execute_mnesia_transaction/1]). -export([ensure_ok/2]). -export([makenode/1, nodeparts/1, cookie_hash/0, tcp_name/3]). --export([intersperse/2, upmap/2, map_in_order/2]). +-export([upmap/2, map_in_order/2]). -export([table_fold/3]). -export([dirty_read_all/1, dirty_foreach_key/2, dirty_dump_log/1]). -export([read_term_file/1, write_term_file/2]). @@ -148,7 +148,6 @@ -spec(tcp_name/3 :: (atom(), inet:ip_address(), rabbit_networking:ip_port()) -> atom()). --spec(intersperse/2 :: (A, [A]) -> [A]). -spec(upmap/2 :: (fun ((A) -> B), [A]) -> [B]). -spec(map_in_order/2 :: (fun ((A) -> B), [A]) -> [B]). -spec(table_fold/3 :: (fun ((any(), A) -> A), A, atom()) -> A). @@ -404,10 +403,6 @@ tcp_name(Prefix, IPAddress, Port) io_lib:format("~w_~s:~w", [Prefix, inet_parse:ntoa(IPAddress), Port]))). -intersperse(_, []) -> []; -intersperse(_, [E]) -> [E]; -intersperse(Sep, [E|T]) -> [E, Sep | intersperse(Sep, T)]. - %% This is a modified version of Luke Gorrie's pmap - %% http://lukego.livejournal.com/6753.html - that doesn't care about %% the order in which results are received. diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl index 0440dbe4..0030216e 100644 --- a/src/rabbit_multi.erl +++ b/src/rabbit_multi.erl @@ -65,8 +65,7 @@ start() -> halt(); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> print_error("invalid command '~s'", - [lists:flatten( - rabbit_misc:intersperse(" ", FullCommand))]), + [string:join(FullCommand, " ")]), usage(); timeout -> print_error("timeout starting some nodes.", []), diff --git a/src/rabbit_ssl.erl b/src/rabbit_ssl.erl index 4335dd2e..ce218b7b 100644 --- a/src/rabbit_ssl.erl +++ b/src/rabbit_ssl.erl @@ -95,14 +95,11 @@ cert_info(F, Cert) -> %% Format and rdnSequence as a RFC4514 subject string. format_rdn_sequence({rdnSequence, Seq}) -> - lists:flatten( - rabbit_misc:intersperse( - ",", lists:reverse([format_complex_rdn(RDN) || RDN <- Seq]))). + string:join(lists:reverse([format_complex_rdn(RDN) || RDN <- Seq]), ","). %% Format an RDN set. format_complex_rdn(RDNs) -> - lists:flatten( - rabbit_misc:intersperse("+", [format_rdn(RDN) || RDN <- RDNs])). + string:join([format_rdn(RDN) || RDN <- RDNs], "+"). %% Format an RDN. If the type name is unknown, use the dotted decimal %% representation. See RFC4514, section 2.3. @@ -129,7 +126,7 @@ format_rdn(#'AttributeTypeAndValue'{type = T, value = V}) -> io_lib:format(Fmt ++ "=~s", [FV]); none when is_tuple(T) -> TypeL = [io_lib:format("~w", [X]) || X <- tuple_to_list(T)], - io_lib:format("~s:~s", [rabbit_misc:intersperse(".", TypeL), FV]); + io_lib:format("~s:~s", [string:join(TypeL, "."), FV]); none -> io_lib:format("~p:~s", [T, FV]) end. -- cgit v1.2.1 From 4563c988b0d6c218499435074fd02f1d7e128f11 Mon Sep 17 00:00:00 2001 From: John DeTreville Date: Thu, 11 Nov 2010 11:34:38 +0000 Subject: Added some extra polymorphism inside rabbit_ssl.erl. --- src/rabbit_ssl.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rabbit_ssl.erl b/src/rabbit_ssl.erl index ce218b7b..ff79d433 100644 --- a/src/rabbit_ssl.erl +++ b/src/rabbit_ssl.erl @@ -99,7 +99,7 @@ format_rdn_sequence({rdnSequence, Seq}) -> %% Format an RDN set. format_complex_rdn(RDNs) -> - string:join([format_rdn(RDN) || RDN <- RDNs], "+"). + string:join([lists:flatten(format_rdn(RDN)) || RDN <- RDNs], "+"). %% Format an RDN. If the type name is unknown, use the dotted decimal %% representation. See RFC4514, section 2.3. @@ -126,7 +126,8 @@ format_rdn(#'AttributeTypeAndValue'{type = T, value = V}) -> io_lib:format(Fmt ++ "=~s", [FV]); none when is_tuple(T) -> TypeL = [io_lib:format("~w", [X]) || X <- tuple_to_list(T)], - io_lib:format("~s:~s", [string:join(TypeL, "."), FV]); + io_lib:format("~s:~s", + [string:join(lists:flatten(TypeL), "."), FV]); none -> io_lib:format("~p:~s", [T, FV]) end. -- cgit v1.2.1 From 44d4ec091ec09626ae865ed9d0a2b615854243ad Mon Sep 17 00:00:00 2001 From: John DeTreville Date: Mon, 15 Nov 2010 16:27:22 +0000 Subject: Fixed thinkos in calls to string:join. --- src/rabbit_ssl.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rabbit_ssl.erl b/src/rabbit_ssl.erl index ff79d433..ce218b7b 100644 --- a/src/rabbit_ssl.erl +++ b/src/rabbit_ssl.erl @@ -99,7 +99,7 @@ format_rdn_sequence({rdnSequence, Seq}) -> %% Format an RDN set. format_complex_rdn(RDNs) -> - string:join([lists:flatten(format_rdn(RDN)) || RDN <- RDNs], "+"). + string:join([format_rdn(RDN) || RDN <- RDNs], "+"). %% Format an RDN. If the type name is unknown, use the dotted decimal %% representation. See RFC4514, section 2.3. @@ -126,8 +126,7 @@ format_rdn(#'AttributeTypeAndValue'{type = T, value = V}) -> io_lib:format(Fmt ++ "=~s", [FV]); none when is_tuple(T) -> TypeL = [io_lib:format("~w", [X]) || X <- tuple_to_list(T)], - io_lib:format("~s:~s", - [string:join(lists:flatten(TypeL), "."), FV]); + io_lib:format("~s:~s", [string:join(TypeL, "."), FV]); none -> io_lib:format("~p:~s", [T, FV]) end. -- cgit v1.2.1