diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-10-26 20:08:35 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-10-26 23:16:36 +0200 |
commit | c373f29292cb8cd630d04b3c1edb2ee636787a65 (patch) | |
tree | c33775ab1b62e544046ab043722dd6aa64286a64 | |
parent | 17616d1078063ea0748d009e3a111c4b615262e8 (diff) |
Fix comments and formatting
-rw-r--r-- | src/rebar_port_compiler.erl | 18 | ||||
-rw-r--r-- | src/rebar_utils.erl | 4 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 1f5ebac..2673160 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -300,23 +300,27 @@ expand_vars_loop([], Recurse, Vars, Count) -> expand_vars_loop(Recurse, [], Vars, Count-1); expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) -> %% Identify the variables that need expansion in this value - case re:run(V, "\\\${?(\\w+)}?", [global, {capture, all_but_first, list}]) of + ReOpts = [global, {capture, all_but_first, list}], + case re:run(V, "\\\${?(\\w+)}?", ReOpts) of {match, Matches} -> %% Identify the unique variables that need to be expanded UniqueMatches = lists:usort([M || [M] <- Matches]), - %% For each variable, expand it and return the final value. Note that - %% if we have a bunch of unresolvable variables, nothing happens and - %% we don't bother attempting further expansion + %% For each variable, expand it and return the final + %% value. Note that if we have a bunch of unresolvable + %% variables, nothing happens and we don't bother + %% attempting further expansion case expand_keys_in_value(UniqueMatches, V, Vars) of V -> %% No change after expansion; move along expand_vars_loop(Rest, Recurse, Vars, Count); Expanded -> - %% Some expansion occurred; move to next k/v but revist - %% this value in the next loop to check for further expansion + %% Some expansion occurred; move to next k/v but + %% revisit this value in the next loop to check + %% for further expansion NewVars = dict:store(K, Expanded, Vars), - expand_vars_loop(Rest, [{K, Expanded} | Recurse], NewVars, Count) + expand_vars_loop(Rest, [{K, Expanded} | Recurse], + NewVars, Count) end; nomatch -> diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 88c0c25..a32adfd 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -191,11 +191,11 @@ expand_env_variable(InStr, VarName, RawVarValue) -> %% No variables to expand InStr; _ -> - ReOpts = [global, {return, list}], VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global]), %% Use a regex to match/replace: - %% $FOO\s | ${FOO} | $FOO eol + %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]), + ReOpts = [global, {return, list}], re:replace(InStr, RegEx, VarValue ++ "\\2", ReOpts) end. |