Don't detect the source file as an include of itself

This commit is contained in:
Vagabond 2010-03-02 18:04:08 -05:00
parent a3f8489340
commit 50832a1a14

View file

@ -109,14 +109,14 @@ inspect(Source, IncludePath) ->
ModuleDefault = filename:basename(Source, ".erl"), ModuleDefault = filename:basename(Source, ".erl"),
case epp:open(Source, IncludePath) of case epp:open(Source, IncludePath) of
{ok, Epp} -> {ok, Epp} ->
inspect_epp(Epp, ModuleDefault, []); inspect_epp(Epp, Source, ModuleDefault, []);
{error, Reason} -> {error, Reason} ->
?DEBUG("Failed to inspect ~s: ~p\n", [Source, Reason]), ?DEBUG("Failed to inspect ~s: ~p\n", [Source, Reason]),
{ModuleDefault, []} {ModuleDefault, []}
end. end.
-spec inspect_epp(Epp::pid(), Module::string(), Includes::[string()]) -> {string(), [string()]}. -spec inspect_epp(Epp::pid(), Source::string(), Module::string(), Includes::[string()]) -> {string(), [string()]}.
inspect_epp(Epp, Module, Includes) -> inspect_epp(Epp, Source, Module, Includes) ->
case epp:parse_erl_form(Epp) of case epp:parse_erl_form(Epp) of
{ok, {attribute, _, module, ModInfo}} -> {ok, {attribute, _, module, ModInfo}} ->
case ModInfo of case ModInfo of
@ -133,16 +133,18 @@ inspect_epp(Epp, Module, Includes) ->
{ActualModule, _} when is_list(ActualModule) -> {ActualModule, _} when is_list(ActualModule) ->
ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".") ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".")
end, end,
inspect_epp(Epp, ActualModuleStr, Includes); inspect_epp(Epp, Source, ActualModuleStr, Includes);
{ok, {attribute, 1, file, {Module, 1}}} -> {ok, {attribute, 1, file, {Module, 1}}} ->
inspect_epp(Epp, Module, Includes); inspect_epp(Epp, Source, Module, Includes);
{ok, {attribute, 1, file, {Source, 1}}} ->
inspect_epp(Epp, Source, Module, Includes);
{ok, {attribute, 1, file, {IncFile, 1}}} -> {ok, {attribute, 1, file, {IncFile, 1}}} ->
inspect_epp(Epp, Module, [IncFile | Includes]); inspect_epp(Epp, Source, Module, [IncFile | Includes]);
{eof, _} -> {eof, _} ->
epp:close(Epp), epp:close(Epp),
{Module, Includes}; {Module, Includes};
_ -> _ ->
inspect_epp(Epp, Module, Includes) inspect_epp(Epp, Source, Module, Includes)
end. end.
-spec needs_compile(Source::string(), Target::string(), Hrls::[string()]) -> boolean(). -spec needs_compile(Source::string(), Target::string(), Hrls::[string()]) -> boolean().