diff options
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r-- | src/rebar_utils.erl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index c8b9e10..04f1d09 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -56,6 +56,7 @@ wordsize/0, tup_umerge/2, tup_sort/1, + tup_find/2, line_count/1, set_httpc_options/0, escape_chars/1, @@ -264,6 +265,20 @@ tup_umerge([], Olds) -> tup_umerge([New|News], Olds) -> lists:reverse(umerge(News, Olds, [], New)). +tup_find(_Elem, []) -> + false; +tup_find(Elem, [Elem | _Elems]) -> + Elem; +tup_find(Elem, [Elem1 | Elems]) when is_tuple(Elem1) -> + case element(1, Elem1) =:= Elem of + true -> + Elem1; + false -> + tup_find(Elem, Elems) + end; +tup_find(Elem, [_Elem | Elems]) -> + tup_find(Elem, Elems). + %% This is equivalent to umerge2_2 in the stdlib, except we use the expanded %% value/key only to compare umerge(News, [Old|Olds], Merged, Cmp) when element(1, Cmp) == element(1, Old); |