From 3281fb505692b40672ddedae6d8a33ffb890b530 Mon Sep 17 00:00:00 2001 From: Michael Mullis Date: Fri, 26 Sep 2008 11:11:51 -0400 Subject: [PATCH] use string:join instead and remove unnecessary join --- src/macaddr.erl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/macaddr.erl b/src/macaddr.erl index eb6a352..ba168fe 100755 --- a/src/macaddr.erl +++ b/src/macaddr.erl @@ -34,10 +34,6 @@ -export([address/0, address_list/0]). -export([mac_matcher/2]). -%%% @doc Join elements of a list using separator. -join([H|T], Sep) -> - lists:flatten([H | [[Sep, X] || X <- T]]). - file_exists(FileName) -> case filelib:is_regular(FileName) of true -> @@ -72,7 +68,7 @@ get_interface_info(Cmd) -> %%% @doc Exported for testability. Internal use only. mac_matcher(Line, Acc) -> MACRegex = " (?([0-9A-F][0-9A-F][:\\-]){5}[0-9A-F][0-9A-F])([^:\\-0-9A-F]|$)", - case re:run(join(Line, ""), MACRegex, [caseless, {capture,['FOO']}]) of + case re:run(Line, MACRegex, [caseless, {capture,['FOO']}]) of {match, [{Start, Length}]} -> MACAddress = string:strip(lists:sublist(Line, Start, Length+1)), {ok, StdMACAddress, _} = regexp:gsub(MACAddress, "-", ":"), @@ -85,7 +81,7 @@ mac_matcher(Line, Acc) -> %%% @spec address_list() -> List address_list() -> LinesLists = lists:map(fun get_interface_info/1, ["/sbin/ifconfig", "/bin/ifconfig", "ifconfig", "ipconfig /all"]), - {ok, ALines} = regexp:split(join(LinesLists," "), "[\r\n]"), + {ok, ALines} = regexp:split(string:join(LinesLists," "), "[\r\n]"), Lines = lists:filter(fun(Elem) -> Elem /= [] end, ALines), Candidates0 = lists:foldl(fun mac_matcher/2, [], Lines),