commit a1669e1bfdbfb547627375a92a880449f017514f
parent 3d6eca3f26c14887e9d6ebe248c434db21d6dd88
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 3 Jun 2019 15:32:05 +0200
rcfile: disallow extending a syntax that is defined in a main nanorc
The /etc/nanorc file should not define any syntax directly (and
preferably not include any either, to not slow startup down with
syntaxes the user is never going to use), and if the ~/.nanorc file
defines a syntax directly, there is no need to use 'extendsyntax':
the command can be added to the syntax itself -- it would be better
even: it keeps things together.
Diffstat:
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -1038,8 +1038,14 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only)
continue;
}
+ /* Disallow extending a syntax that is defined in a main nanorc. */
+ if (sint->filename == NULL) {
+ rcfile_error(N_("Only an 'include' syntax can be extended"));
+ opensyntax = FALSE;
+ continue;
+ }
+
/* When the syntax isn't loaded yet, store extendsyntax commands. */
- if (sint->filename != NULL) {
augmentstruct *newitem = nmalloc(sizeof(augmentstruct));;
newitem->filename = strdup(nanorc);
@@ -1057,19 +1063,6 @@ void parse_rcfile(FILE *rcstream, bool syntax_only, bool headers_only)
sint->augmentations = newitem;
continue;
- }
-
- live_syntax = sint;
- opensyntax = TRUE;
-
- /* Refind the tail of the color list for this syntax. */
- lastcolor = sint->color;
- if (lastcolor != NULL)
- while (lastcolor->next != NULL)
- lastcolor = lastcolor->next;
-
- keyword = ptr;
- ptr = parse_next_word(ptr);
}
/* Try to parse the keyword. */