Fix ini section parsing

This commit is contained in:
Alexander Batalov 2022-11-09 11:11:19 +03:00
parent 67351b8b09
commit a70912d311
1 changed files with 19 additions and 4 deletions

View File

@ -379,10 +379,25 @@ static bool configParseLine(Config* config, char* string)
*pch = '\0'; *pch = '\0';
} }
// Find opening bracket. // CE: Original implementation treats any line with brackets as section key.
pch = strchr(string, '['); // The problem can be seen when loading Olympus settings (ddraw.ini), which
if (pch != NULL) { // contains the following line:
char* sectionKey = pch + 1; //
// ```ini
// VersionString=Olympus 2207 [Complete].
// ```
//
// It thinks that [Complete] is a start of new section, and puts remaining
// keys there.
// Skip leading whitespace.
while (isspace(*string)) {
string++;
}
// Check if it's a section key.
if (*string == '[') {
char* sectionKey = string + 1;
// Find closing bracket. // Find closing bracket.
pch = strchr(sectionKey, ']'); pch = strchr(sectionKey, ']');