Skip to content

Commit

Permalink
Fixed parsing of game configs that use quotes without spaces.
Browse files Browse the repository at this point in the history
Closes #374.
  • Loading branch information
xvitaly committed May 8, 2024
1 parent 4da42e4 commit d65dbd6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/corelib/ConfigEntryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ private static ConfigEntryParser InternalParse(string Value, bool TryParse)

// Calculating the indices of the first space and the double slash character...
int SpaceIndex = Value.IndexOf(" ", StringComparison.InvariantCulture);
int QuoteIndex = Value.IndexOf(@"""", StringComparison.InvariantCulture);
int CommentIndex = Value.IndexOf("//", StringComparison.InvariantCulture);

// If the source string contains quotes we will use them instead of spaces...
if ((QuoteIndex > 0) && ((SpaceIndex == -1) || (QuoteIndex < SpaceIndex)))
{
return new ConfigEntryParser(Value.Substring(0, QuoteIndex), CommentIndex > QuoteIndex ? Value.Substring(QuoteIndex, CommentIndex - QuoteIndex) : Value.Remove(0, QuoteIndex), CommentIndex > 0 ? Value.Substring(CommentIndex + 2).Trim() : string.Empty);
}

// If the source string contains no spaces, return it as is...
if ((SpaceIndex == -1) && (CommentIndex == -1))
{
Expand Down

0 comments on commit d65dbd6

Please sign in to comment.