dunst/test/data/test-ini
Luke Shumaker 82fa79c786 option_parser.c: Allow comments on lines with quoted strings.
The current behavior is
 - If the value contains a double-quote:
   - 1. Verify that it must contains at least two quotes.
   - 2. If one of the quotes is the first character, trim it.
   - 3. If one of the quotes is the last character, trim it.
 - Else:
   - 1. Trim a trailing comment from the value.

This has the effect that

    `key = "value" # comment` => `value" #comment`

This is surprising and almost certainly not what the user wants.

However, it allows simple nested quotes like:

    `key = "A string "with quotes""` => `A string "with quotes"`

Fix the brokenness of the first example at the expense of breaking the
second.  A user seeking that value will now have to type:

    key = "A string \"with quotes\""

Do this by treating double-quote as a toggle that simply changes whether
`;` and `#` start comments (not too different than Bash using it to toggle
field separation).

In order to have strings that contain a literal double-quote, add
rudimentary support for backslash-escaping.  For now, only recognize
double-quote and backslash-itself; anything else is undefined; and the
program is free to do whatever it likes with them; for now, silently treat
the backslash as an ordinary character.

Note that this formulation of quoting implies that backslash-escaping works
identically both inside and outside of quotes.
2017-02-26 09:35:06 -05:00

47 lines
1.0 KiB
Plaintext

#General comment
[bool]
booltrue = true #This is a test inline comment
booltrue_capital = TRUE
#This is a comment
boolfalse = false
boolfalse_capital = FALSE
boolyes = yes
boolyes_capital = YES
boolno = no
boolno_capital = NO
boolbin0 = 0
boolbin1 = 1
boolinvalid = invalidbool
[string]
simple = A simple string
simple_with_hcomment = A simple string # a comment
simple_with_scomment = A simple string ; a comment
quoted = "A quoted string"
quoted_with_hcomment = "A quoted string" # a comment
quoted_with_scomment = "A quoted string" ; a comment
quoted_with_quotes = "A string \"with quotes\""
quoted_with_escapes = "A string \\\"with escapes\\"
quoted_with_cchar = "A string; with #comment characters" # a comment
quoted_in_middle = A string"; with #comment" characters # a comment
escaped_quotes = String \"with quotes\"
[int]
simple = 5
negative = -10
decimal = 2.71828
leading_zeroes = 007
multi_char = 1024
[double]
simple = 1
decimal = 1.5
negative = -1.2
zeroes = 0.005
long = 3.141592653589793