Tue 04 Jul 2017 09:26:27 PM UTC, comment #1:
I've tested this with current git (7473105), and parsing of the comment string is odd. Despite what the documentation says, backslashing of double quotes is actually required for the comment option, since the comment string is parsed via rcfile.c:pick_up_name(), which requires such backslashing. However, not backslashing double quotes leads to erroneous commenting behavior without generating errors. You can reproduce it via the following steps:
1. Create a new syntax file in /usr/share/nano/unquoted.nanorc, containing:
syntax "unquoted"
comment """
2. Build nano from git with --sysconfdir=/etc and --prefix=/usr.
3. Run:
./nano -Y unquoted
nano won't generate any errors when it parses the "unquoted" syntax, although the syntax highlighting of the unquoted.nanorc file will color the third quote of """ bright red.
4. Type several lines' worth of text, turn the mark on and highlight those lines, and then press Meta-3. The file will be marked as modified, but the text won't change. (In this case, the comment string is apparently empty, although erroneously not flagged as such.)
Now, change the comment line in /usr/share/nano/unquoted.nanorc to:
comment "\""
and repeat the above steps. In step 4, the lines will now be commented with a ", as expected.
(For the record, the method used to separate the beginning and ending portions of a comment with a '|' is also odd. The '|' is checked for in text.c:comment_line() with a simple strchr(), so it's impossible to use '|' as a commenting character at all. Maybe '|' should be allowed if it's backslashed first, for maximum flexibility? But that would make parsing it more complex and possibly break compatibility. Not to mention, that's outside the scope of this bug.)
|