Skip to content

Commit

Permalink
Ignore unwanted CR in option strings (#62)
Browse files Browse the repository at this point in the history
The SimCoupe.cfg created by older SimCoupe versions used CRLF terminators.
When these were read back in newer versions, std::getline only removed the
system line endings. Under non-Windows plaforms this left an unwanted CR in
the option value.

This lead to strange issues such as the disk image file selector being
blank, because 'inpath' wasn't considered empty due to the CR.
  • Loading branch information
simonowen committed Aug 26, 2021
1 parent 09cb71b commit a89d6f0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Base/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ bool Load(int argc_, char* argv_[])
std::ifstream file(path);
for (std::string line; std::getline(file, line); )
{
if (!line.empty() && line.back() == '\r')
line.pop_back();

std::stringstream ss(line);
std::string key, value;
if (std::getline(ss, key, '=') && std::getline(ss, value))
Expand Down

0 comments on commit a89d6f0

Please sign in to comment.