Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue where command line arguments were not overriding options … #1017

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading