Do not initialize subfields of options_ as empty structs if they are already defined (in global_initialization).

issue#70
Stéphane Adjemian (Charybdis) 2014-05-21 16:41:41 +02:00
parent 13358ce992
commit 6ce31cfea0
1 changed files with 5 additions and 1 deletions

View File

@ -135,7 +135,11 @@ OptionsList::writeOutput(ostream &output) const
void
OptionsList::writeOutput(ostream &output, const string &option_group) const
{
output << option_group << " = struct();" << endl;
// Initialize option_group as an empty struct iff the field does not exist!
unsigned idx = option_group.find_last_of(".");
output << "if ~isfield(" << option_group.substr(0,idx) << ",'" << option_group.substr(idx+1) << "')" << endl;
output << " " << option_group << " = struct();" << endl;
output << "end" << endl;
for (num_options_t::const_iterator it = num_options.begin();
it != num_options.end(); it++)