Skip to content

Commit

Permalink
chmgen: Handle empty navigation groups and those with a bad first child
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Feb 17, 2015
1 parent 3b39489 commit 53bf707
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions chmgen.d
Expand Up @@ -41,8 +41,16 @@ Nav loadNav(string fileName, string base, bool warn)
if (json.type == JSON_TYPE.ARRAY)
{
auto nodes = json.array;
auto root = parseNav(nodes[0]);
root.children = nodes[1..$].map!parseNav.array().filter!`a`.array();
auto parsedNodes = nodes.map!parseNav.array().filter!`a`.array();
if (!parsedNodes.length)
{
if (warn)
stderr.writeln("Warning: Empty navigation group");
return null;
}

auto root = parsedNodes[0];
root.children = parsedNodes[1..$];
return root;
}
else
Expand Down

0 comments on commit 53bf707

Please sign in to comment.