parse_syntax()
- Properly generate an error if we've read in a previous syntax
without any associated color commands. (DLR)
+ - Don't generate an error if we find a duplicate syntax name,
+ since we might be trying to override a syntax in the global
+ nanorc with one in our local nanorc. Instead, free any
+ duplicate syntaxes we find, so that we always use the last
+ syntax with a given name. (DLR)
parse_colors()
- Check for a color command's not following a syntax line before
anything else. (DLR)
void parse_syntax(char *ptr)
{
const char *fileregptr = NULL, *nameptr = NULL;
- const syntaxtype *tmpsyntax;
+ syntaxtype *tmpsyntax;
exttype *endext = NULL;
/* The end of the extensions list for this syntax. */
if (ptr == NULL)
return;
+ /* Search for a duplicate syntax name. If we find one, free it, so
+ * that we always use the last syntax with a given name. */
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
if (strcmp(nameptr, tmpsyntax->desc) == 0) {
- rcfile_error(N_("Duplicate syntax name %s"), nameptr);
- return;
+ syntaxtype *prev_syntax = tmpsyntax;
+
+ tmpsyntax = tmpsyntax->next;
+ free(prev_syntax);
+ break;
}
}