Commit a7901dd1 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

rcfile: don't require backslashing in the argument of 'comment'

Eradicate the need for backslashes, so that the start of the nanorc
manual becomes true, where it says that quotes inside strings don't
need to be escaped.  In the bargain achieve that the empty string
always switches commenting off.

This fixes https://savannah.gnu.org/bugs/?51370,
and fixes https://savannah.gnu.org/bugs/?51394.
No related merge requests found
Showing with 13 additions and 18 deletions
+13 -18
......@@ -879,32 +879,27 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
return;
}
free(*storage);
/* If the argument starts with a quote, find the terminating quote. */
if (*ptr == '"') {
char *look = ++ptr;
/* Allow unsetting the command by using an empty string. */
if (!strcmp(ptr, "\"\""))
*storage = NULL;
else if (*ptr == '"') {
char *look, *take;
look = take = *storage = mallocstrcpy(NULL, ++ptr);
look += strlen(ptr);
/* Snip out the backslashes of escaped characters. */
while (*look != '"') {
if (*look == '\0') {
if (--look < ptr) {
rcfile_error(N_("Argument of '%s' lacks closing \""), kind);
free(*storage);
*storage = NULL;
return;
} else if (*look == '\\' && *(look + 1) != '\0') {
look++;
}
*take++ = *look++;
}
*take = '\0';
*look = '\0';
}
else
*storage = mallocstrcpy(NULL, ptr);
if (*ptr == '\0') {
free(*storage);
*storage = NULL;
} else
*storage = mallocstrcpy(*storage, ptr);
}
#endif /* !DISABLE_COLOR */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment