From a0732e9e78ea543178b9f29aaf8fa6e72011506e Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 12 Feb 2010 11:57:50 -0700 Subject: Make sure to cover all edge cases when parsing module names --- src/rebar_erlc_compiler.erl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 51b7f17..c41b96d 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -106,13 +106,20 @@ inspect(Source, IncludePath) -> -spec inspect_epp(Epp::pid(), Module::string(), Includes::[string()]) -> {string(), [string()]}. inspect_epp(Epp, Module, Includes) -> case epp:parse_erl_form(Epp) of - {ok, {attribute, _, module, ActualModule}} -> - %% If the module name includes package info, we get a list of atoms... - case is_list(ActualModule) of - true -> + {ok, {attribute, _, module, ModInfo}} -> + case ModInfo of + %% Typical module name, single atom + ActualModule when is_atom(ActualModule) -> + ActualModuleStr = atom_to_list(ActualModule); + %% Packag-ized module name, list of atoms + ActualModule when is_list(ActualModule) -> ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], "."); - false -> - ActualModuleStr = atom_to_list(ActualModule) + %% Parameterized module name, single atom + {ActualModule, _} when is_atom(ActualModule) -> + ActualModuleStr = atom_to_list(ActualModule); + %% Parameterized and packagized module name, list of atoms + {ActualModule, _} when is_list(ActualModule) -> + ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".") end, inspect_epp(Epp, ActualModuleStr, Includes); {ok, {attribute, 1, file, {Module, 1}}} -> -- cgit v1.1