瀏覽代碼

Fix comments and formatting

pull/3/head
Tuncer Ayaz 13 年之前
父節點
當前提交
c373f29292
共有 2 個文件被更改,包括 13 次插入9 次删除
  1. +11
    -7
      src/rebar_port_compiler.erl
  2. +2
    -2
      src/rebar_utils.erl

+ 11
- 7
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(Recurse, [], Vars, Count-1);
expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) -> expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) ->
%% Identify the variables that need expansion in this value %% 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} -> {match, Matches} ->
%% Identify the unique variables that need to be expanded %% Identify the unique variables that need to be expanded
UniqueMatches = lists:usort([M || [M] <- Matches]), 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 case expand_keys_in_value(UniqueMatches, V, Vars) of
V -> V ->
%% No change after expansion; move along %% No change after expansion; move along
expand_vars_loop(Rest, Recurse, Vars, Count); expand_vars_loop(Rest, Recurse, Vars, Count);
Expanded -> 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), 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; end;
nomatch -> nomatch ->

+ 2
- 2
src/rebar_utils.erl 查看文件

@ -191,11 +191,11 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
%% No variables to expand %% No variables to expand
InStr; InStr;
_ -> _ ->
ReOpts = [global, {return, list}],
VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global]), VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global]),
%% Use a regex to match/replace: %% 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]), RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
ReOpts = [global, {return, list}],
re:replace(InStr, RegEx, VarValue ++ "\\2", ReOpts) re:replace(InStr, RegEx, VarValue ++ "\\2", ReOpts)
end. end.

Loading…
取消
儲存