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.master
parent
1695463347
commit
a7901dd1e0
31
src/rcfile.c
31
src/rcfile.c
|
@ -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 += strlen(ptr);
|
||||
|
||||
look = take = *storage = mallocstrcpy(NULL, ++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 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue