Skip to content

Commit

Permalink
Fixed issue where command line arguments were not overriding options …
Browse files Browse the repository at this point in the history
…set in input file.
  • Loading branch information
feldergast committed Nov 1, 2023
1 parent d21175b commit b953509
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/sst/core/configBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ ConfigBase::parseCmdLine(int argc, char* argv[], bool ignore_unknown)
my_argc = end_arg_index == 0 ? argc : end_arg_index;
}

int ok = 0;
while ( 0 == ok ) {
int status = 0;
while ( 0 == status ) {
int option_index = 0;
const int intC = getopt_long(my_argc, argv, short_options_string.c_str(), sst_long_options, &option_index);

Expand All @@ -332,29 +332,29 @@ ConfigBase::parseCmdLine(int argc, char* argv[], bool ignore_unknown)
// is an unknown command
if ( c == '?' ) {
// Unknown option
if ( !ignore_unknown ) { ok = printUsage(); }
if ( !ignore_unknown ) { status = printUsage(); }
}
else if ( option_index != 0 ) {
// Long options
int real_index = option_map[option_index];
if ( optarg )
ok = options[real_index].callback(optarg);
status = options[real_index].callback(optarg);
else
ok = options[real_index].callback("");
if ( ok ) options[real_index].set_cmdline = true;
status = options[real_index].callback("");
if ( !status ) options[real_index].set_cmdline = true;
}
else {
// Short option
int real_index = short_options[c];
if ( optarg )
ok = options[real_index].callback(optarg);
status = options[real_index].callback(optarg);
else
ok = options[real_index].callback("");
if ( ok ) options[real_index].set_cmdline = true;
status = options[real_index].callback("");
if ( !status ) options[real_index].set_cmdline = true;
}
}

if ( ok != 0 ) { return ok; }
if ( status != 0 ) { return status; }

/* Handle positional arguments */
int pos = optind;
Expand All @@ -369,7 +369,7 @@ ConfigBase::parseCmdLine(int argc, char* argv[], bool ignore_unknown)
// If we aren't ignoring unknown arguments, we'll get an error
// above. Otherwise, just ignore all the positional arguments.
if ( positional_args )
ok = positional_args(count, argv[pos++]);
status = positional_args(count, argv[pos++]);
else
pos++;
}
Expand All @@ -388,8 +388,8 @@ ConfigBase::parseCmdLine(int argc, char* argv[], bool ignore_unknown)
}

// If everything parsed okay, call the check function
if ( ok == 0 ) return checkArgsAfterParsing();
return ok;
if ( status == 0 ) return checkArgsAfterParsing();
return status;
}


Expand Down

0 comments on commit b953509

Please sign in to comment.