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
35
src/rcfile.c
35
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*look = '\0';
|
||||
}
|
||||
|
||||
if (*ptr == '\0') {
|
||||
free(*storage);
|
||||
*storage = NULL;
|
||||
return;
|
||||
} else if (*look == '\\' && *(look + 1) != '\0') {
|
||||
look++;
|
||||
}
|
||||
*take++ = *look++;
|
||||
}
|
||||
*take = '\0';
|
||||
}
|
||||
else
|
||||
*storage = mallocstrcpy(NULL, ptr);
|
||||
} else
|
||||
*storage = mallocstrcpy(*storage, ptr);
|
||||
|
||||
}
|
||||
#endif /* !DISABLE_COLOR */
|
||||
|
||||
|
|
Loading…
Reference in New Issue