Skip to content

Conversation

@slaimon
Copy link

@slaimon slaimon commented Oct 27, 2025

In .INI files, comments are often essential in order to show the user what each setting is supposed to do. This tiny pull request should allow Tortellini to process .INI files that contain comments.

Comments begin with a # character and end with a newline. In order to allow Strings that contain #, I made it so that the widely accepted escape character \ can be used to override the default behaviour. Some examples:

# The following is a configuration file
v1 = # this is a comment
v2 = \# this is NOT a comment
v3 = \#\#\#

Effect of the above .INI file:

  • The first line is ignored, as if it was just whitespace.
  • Key v1 is invalid data because the comment is removed before processing, leaving only "v1 = ".
  • Key v2 contains the string "# this is NOT a comment".
  • Key v3 contains the string "###".

This pull request includes some test cases I used to make sure the feature was working as intended. Some more test cases could be necessary.

CMake asked me because <3.5 isn't supported anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant