mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-29 13:49:47 +03:00
Disallowing the addition of further things to a syntax when
an rcfile ends or when an invalid syntax command is found. This fixes Savannah bug #47207 git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5696 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
68d94a0c74
commit
275e9f0092
@ -8,6 +8,9 @@
|
||||
* src/rcfile.c (grab_and_store): Do not drop regexes that were
|
||||
gathered earlier. This fixes Savannah bug #47285.
|
||||
* src/rcfile.c (grab_and_store): Rearrange things in my style.
|
||||
* src/rcfile.c (parse_syntax, parse_rcfile): Disallow adding any
|
||||
further things to a syntax when an rcfile ends or when an invalid
|
||||
syntax command is found. This fixes Savannah bug #47207.
|
||||
|
||||
2016-02-26 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc,
|
||||
|
18
src/rcfile.c
18
src/rcfile.c
@ -120,6 +120,9 @@ static size_t lineno = 0;
|
||||
static char *nanorc = NULL;
|
||||
/* The path to the rcfile we're parsing. */
|
||||
#ifndef DISABLE_COLOR
|
||||
static bool opensyntax = FALSE;
|
||||
/* Whether we're allowed to add to the last syntax. When a file ends,
|
||||
* or when a new syntax command is seen, this bool becomes FALSE. */
|
||||
static syntaxtype *endsyntax = NULL;
|
||||
/* The end of the list of syntaxes. */
|
||||
static colortype *endcolor = NULL;
|
||||
@ -268,6 +271,8 @@ void parse_syntax(char *ptr)
|
||||
regexlisttype *endext = NULL;
|
||||
/* The end of the extensions list for this syntax. */
|
||||
|
||||
opensyntax = FALSE;
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (*ptr == '\0') {
|
||||
@ -335,6 +340,8 @@ void parse_syntax(char *ptr)
|
||||
endsyntax->linter = NULL;
|
||||
endsyntax->formatter = NULL;
|
||||
|
||||
opensyntax = TRUE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
|
||||
#endif
|
||||
@ -691,7 +698,7 @@ void parse_colors(char *ptr, bool icase)
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
if (!opensyntax) {
|
||||
rcfile_error(
|
||||
N_("Cannot add a color command without a syntax command"));
|
||||
return;
|
||||
@ -862,7 +869,7 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
|
||||
{
|
||||
regexlisttype *lastthing;
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
if (!opensyntax) {
|
||||
rcfile_error(
|
||||
N_("A '%s' command requires a preceding 'syntax' command"), kind);
|
||||
return;
|
||||
@ -933,7 +940,7 @@ void parse_linter(char *ptr)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
if (!opensyntax) {
|
||||
rcfile_error(
|
||||
N_("Cannot add a linter without a syntax command"));
|
||||
return;
|
||||
@ -959,7 +966,7 @@ void parse_formatter(char *ptr)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
if (!opensyntax) {
|
||||
rcfile_error(
|
||||
N_("Cannot add formatter without a syntax command"));
|
||||
return;
|
||||
@ -1062,6 +1069,7 @@ void parse_rcfile(FILE *rcstream
|
||||
rcfile_error(N_("Could not find syntax \"%s\" to extend"), syntaxname);
|
||||
continue;
|
||||
} else {
|
||||
opensyntax = TRUE;
|
||||
end_syn_save = endsyntax;
|
||||
endsyntax = ts;
|
||||
keyword = ptr;
|
||||
@ -1313,6 +1321,8 @@ void parse_rcfile(FILE *rcstream
|
||||
endsyntax->desc);
|
||||
#endif
|
||||
|
||||
opensyntax = FALSE;
|
||||
|
||||
free(buf);
|
||||
fclose(rcstream);
|
||||
lineno = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user