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.
Этот коммит содержится в:
родитель
3d6eca3f26
Коммит
a1669e1bfd
21
src/rcfile.c
21
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. */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user