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
..
2016-11-19 12:17:23 +02:00
2017-01-29 15:32:36 +02:00