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

Seek to beginning of config file after looking for verbose key #32

Closed
aaraney opened this issue Sep 12, 2024 · 1 comment · Fixed by #33
Closed

Seek to beginning of config file after looking for verbose key #32

aaraney opened this issue Sep 12, 2024 · 1 comment · Fixed by #33
Labels
bug Something isn't working

Comments

@aaraney
Copy link
Member

aaraney commented Sep 12, 2024

LGAR-C/src/lgar.cxx

Lines 184 to 206 in 567adc7

while (fp) {
string line;
string param_key, param_value, param_unit;
getline(fp, line);
int loc_eq = line.find("=") + 1;
int loc_u = line.find("[");
param_key = line.substr(0,line.find("="));
param_value = line.substr(loc_eq,loc_u - loc_eq);
if (param_key == "verbosity") {
verbosity = param_value;
if (verbosity.compare("none") != 0) {
std::cerr<<"Verbosity is set to \' "<<verbosity<<"\' \n";
std::cerr<<" ***** \n";
}
fp.clear();
break;
}
}

If verbose is not the first key in the config file, lgar will likely not correctly interpret a configuration file. This is because the code looks for the verbose key in all lines of the config and never seeks back to the beginning of the file before parsing the config file for parameters.

@aaraney aaraney added the bug Something isn't working label Sep 12, 2024
@aaraney
Copy link
Member Author

aaraney commented Sep 12, 2024

Ill submit a fix for this in the morning. Just wanted to document it!

aaraney added a commit that referenced this issue Sep 12, 2024
)

* fix: seek to beginning of config file after looking for verbose key; fixes #32

* fix: clear ifstream flags before seeking

Co-authored-by: Nels <[email protected]>

---------

Co-authored-by: Nels <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant