Renaming a variable to better fit its new role.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5717 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
04262f09a4
commit
8a5ae2130b
|
@ -9,6 +9,7 @@
|
||||||
(color_update): Turn the linked list of syntaxes upside-down, so that
|
(color_update): Turn the linked list of syntaxes upside-down, so that
|
||||||
the last-defined one comes first, so that searching can stop at the
|
the last-defined one comes first, so that searching can stop at the
|
||||||
first match instead of always having to run through the entire list.
|
first match instead of always having to run through the entire list.
|
||||||
|
* src/rcfile.c: Rename a variable to better fit its new role.
|
||||||
|
|
||||||
2016-03-09 Benno Schulenberg <bensberg@justemail.net>
|
2016-03-09 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/rcfile.c (parse_syntax): Produce an adequate error message
|
* src/rcfile.c (parse_syntax): Produce an adequate error message
|
||||||
|
|
63
src/rcfile.c
63
src/rcfile.c
|
@ -123,7 +123,7 @@ static char *nanorc = NULL;
|
||||||
static bool opensyntax = FALSE;
|
static bool opensyntax = FALSE;
|
||||||
/* Whether we're allowed to add to the last syntax. When a file ends,
|
/* 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. */
|
* or when a new syntax command is seen, this bool becomes FALSE. */
|
||||||
static syntaxtype *endsyntax = NULL;
|
static syntaxtype *live_syntax;
|
||||||
/* The syntax that is currently being parsed. */
|
/* The syntax that is currently being parsed. */
|
||||||
static colortype *endcolor = NULL;
|
static colortype *endcolor = NULL;
|
||||||
/* The end of the color list for the current syntax. */
|
/* The end of the color list for the current syntax. */
|
||||||
|
@ -299,20 +299,20 @@ void parse_syntax(char *ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize a new syntax struct. */
|
/* Initialize a new syntax struct. */
|
||||||
endsyntax = (syntaxtype *)nmalloc(sizeof(syntaxtype));
|
live_syntax = (syntaxtype *)nmalloc(sizeof(syntaxtype));
|
||||||
endsyntax->name = mallocstrcpy(NULL, nameptr);
|
live_syntax->name = mallocstrcpy(NULL, nameptr);
|
||||||
endsyntax->extensions = NULL;
|
live_syntax->extensions = NULL;
|
||||||
endsyntax->headers = NULL;
|
live_syntax->headers = NULL;
|
||||||
endsyntax->magics = NULL;
|
live_syntax->magics = NULL;
|
||||||
endsyntax->linter = NULL;
|
live_syntax->linter = NULL;
|
||||||
endsyntax->formatter = NULL;
|
live_syntax->formatter = NULL;
|
||||||
endsyntax->color = NULL;
|
live_syntax->color = NULL;
|
||||||
endcolor = NULL;
|
endcolor = NULL;
|
||||||
endsyntax->nmultis = 0;
|
live_syntax->nmultis = 0;
|
||||||
|
|
||||||
/* Hook the new syntax in at the top of the list. */
|
/* Hook the new syntax in at the top of the list. */
|
||||||
endsyntax->next = syntaxes;
|
live_syntax->next = syntaxes;
|
||||||
syntaxes = endsyntax;
|
syntaxes = live_syntax;
|
||||||
|
|
||||||
opensyntax = TRUE;
|
opensyntax = TRUE;
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ void parse_syntax(char *ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The default syntax should have no associated extensions. */
|
/* The default syntax should have no associated extensions. */
|
||||||
if (strcmp(endsyntax->name, "default") == 0 && *ptr != '\0') {
|
if (strcmp(live_syntax->name, "default") == 0 && *ptr != '\0') {
|
||||||
rcfile_error(
|
rcfile_error(
|
||||||
N_("The \"default\" syntax does not accept extensions"));
|
N_("The \"default\" syntax does not accept extensions"));
|
||||||
return;
|
return;
|
||||||
|
@ -329,7 +329,7 @@ void parse_syntax(char *ptr)
|
||||||
|
|
||||||
/* If there seem to be extension regexes, pick them up. */
|
/* If there seem to be extension regexes, pick them up. */
|
||||||
if (*ptr != '\0')
|
if (*ptr != '\0')
|
||||||
grab_and_store("extension", ptr, &endsyntax->extensions);
|
grab_and_store("extension", ptr, &live_syntax->extensions);
|
||||||
}
|
}
|
||||||
#endif /* !DISABLE_COLOR */
|
#endif /* !DISABLE_COLOR */
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ void parse_colors(char *ptr, bool icase)
|
||||||
newcolor->next = NULL;
|
newcolor->next = NULL;
|
||||||
|
|
||||||
if (endcolor == NULL) {
|
if (endcolor == NULL) {
|
||||||
endsyntax->color = newcolor;
|
live_syntax->color = newcolor;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Starting a new colorstring for fg %hd, bg %hd\n", fg, bg);
|
fprintf(stderr, "Starting a new colorstring for fg %hd, bg %hd\n", fg, bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -712,7 +712,7 @@ void parse_colors(char *ptr, bool icase)
|
||||||
#endif
|
#endif
|
||||||
/* Need to recompute endcolor now so we can extend
|
/* Need to recompute endcolor now so we can extend
|
||||||
* colors to syntaxes. */
|
* colors to syntaxes. */
|
||||||
for (endcolor = endsyntax->color; endcolor->next != NULL;)
|
for (endcolor = live_syntax->color; endcolor->next != NULL;)
|
||||||
endcolor = endcolor->next;
|
endcolor = endcolor->next;
|
||||||
endcolor->next = newcolor;
|
endcolor->next = newcolor;
|
||||||
}
|
}
|
||||||
|
@ -749,8 +749,8 @@ void parse_colors(char *ptr, bool icase)
|
||||||
newcolor->end_regex = mallocstrcpy(NULL, fgstr);
|
newcolor->end_regex = mallocstrcpy(NULL, fgstr);
|
||||||
|
|
||||||
/* Lame way to skip another static counter. */
|
/* Lame way to skip another static counter. */
|
||||||
newcolor->id = endsyntax->nmultis;
|
newcolor->id = live_syntax->nmultis;
|
||||||
endsyntax->nmultis++;
|
live_syntax->nmultis++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,7 +800,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
|
||||||
regexlisttype *lastthing;
|
regexlisttype *lastthing;
|
||||||
|
|
||||||
/* The default syntax doesn't take any file matching stuff. */
|
/* The default syntax doesn't take any file matching stuff. */
|
||||||
if (strcmp(endsyntax->name, "default") == 0 && *ptr != '\0') {
|
if (strcmp(live_syntax->name, "default") == 0 && *ptr != '\0') {
|
||||||
rcfile_error(
|
rcfile_error(
|
||||||
N_("The \"default\" syntax does not accept '%s' regexes"), kind);
|
N_("The \"default\" syntax does not accept '%s' regexes"), kind);
|
||||||
return;
|
return;
|
||||||
|
@ -964,7 +964,7 @@ void parse_rcfile(FILE *rcstream
|
||||||
opensyntax = FALSE;
|
opensyntax = FALSE;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
endsyntax = sint;
|
live_syntax = sint;
|
||||||
opensyntax = TRUE;
|
opensyntax = TRUE;
|
||||||
keyword = ptr;
|
keyword = ptr;
|
||||||
ptr = parse_next_word(ptr);
|
ptr = parse_next_word(ptr);
|
||||||
|
@ -1001,28 +1001,28 @@ void parse_rcfile(FILE *rcstream
|
||||||
else
|
else
|
||||||
parse_include(ptr);
|
parse_include(ptr);
|
||||||
} else if (strcasecmp(keyword, "syntax") == 0) {
|
} else if (strcasecmp(keyword, "syntax") == 0) {
|
||||||
if (endsyntax != NULL && endcolor == NULL)
|
if (opensyntax && endcolor == NULL)
|
||||||
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
||||||
endsyntax->name);
|
live_syntax->name);
|
||||||
parse_syntax(ptr);
|
parse_syntax(ptr);
|
||||||
}
|
}
|
||||||
else if (strcasecmp(keyword, "magic") == 0)
|
else if (strcasecmp(keyword, "magic") == 0)
|
||||||
#ifdef HAVE_LIBMAGIC
|
#ifdef HAVE_LIBMAGIC
|
||||||
grab_and_store("magic", ptr, &endsyntax->magics);
|
grab_and_store("magic", ptr, &live_syntax->magics);
|
||||||
#else
|
#else
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
else if (strcasecmp(keyword, "header") == 0)
|
else if (strcasecmp(keyword, "header") == 0)
|
||||||
grab_and_store("header", ptr, &endsyntax->headers);
|
grab_and_store("header", ptr, &live_syntax->headers);
|
||||||
else if (strcasecmp(keyword, "color") == 0)
|
else if (strcasecmp(keyword, "color") == 0)
|
||||||
parse_colors(ptr, FALSE);
|
parse_colors(ptr, FALSE);
|
||||||
else if (strcasecmp(keyword, "icolor") == 0)
|
else if (strcasecmp(keyword, "icolor") == 0)
|
||||||
parse_colors(ptr, TRUE);
|
parse_colors(ptr, TRUE);
|
||||||
else if (strcasecmp(keyword, "linter") == 0)
|
else if (strcasecmp(keyword, "linter") == 0)
|
||||||
pick_up_name("linter", ptr, &endsyntax->linter);
|
pick_up_name("linter", ptr, &live_syntax->linter);
|
||||||
else if (strcasecmp(keyword, "formatter") == 0)
|
else if (strcasecmp(keyword, "formatter") == 0)
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
pick_up_name("formatter", ptr, &endsyntax->formatter);
|
pick_up_name("formatter", ptr, &live_syntax->formatter);
|
||||||
#else
|
#else
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1035,12 +1035,9 @@ void parse_rcfile(FILE *rcstream
|
||||||
rcfile_error(N_("Command \"%s\" not understood"), keyword);
|
rcfile_error(N_("Command \"%s\" not understood"), keyword);
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
/* If we temporarily reset endsyntax to allow extending,
|
/* If a syntax was extended, it stops at the end of the command. */
|
||||||
* restore the value here. */
|
if (live_syntax != syntaxes)
|
||||||
if (endsyntax != syntaxes) {
|
|
||||||
endsyntax = syntaxes;
|
|
||||||
opensyntax = FALSE;
|
opensyntax = FALSE;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (set == 0)
|
if (set == 0)
|
||||||
|
@ -1210,9 +1207,9 @@ void parse_rcfile(FILE *rcstream
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
if (endsyntax != NULL && endcolor == NULL)
|
if (opensyntax && endcolor == NULL)
|
||||||
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
||||||
endsyntax->name);
|
live_syntax->name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
opensyntax = FALSE;
|
opensyntax = FALSE;
|
||||||
|
|
Loading…
Reference in New Issue