bother discarding a duplicate syntax (it's too rare, saves little
memory, and freeing it properly would cost even more code), just
select the last-defined one. This addresses Savannah bug #47303.
+ * src/color.c (color_update): Allow to select an empty syntax.
2016-02-29 Benno Schulenberg <bensberg@justemail.net>
* src/nano.h, src/rcfile.c, src/color.c: Rename a struct member.
}
}
- if (openfile->colorstrings == NULL)
+ if (openfile->syntax == NULL)
statusbar(_("Unknown syntax name: %s"), syntaxstr);
}
/* If we didn't specify a syntax override string, or if we did and
* there was no syntax by that name, get the syntax based on the
* file extension, then try the headerline, and then try magic. */
- if (openfile->colorstrings == NULL) {
+ if (openfile->syntax == NULL) {
char *currentdir = getcwd(NULL, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1);
char *fullname = NULL;
free(fullname);
/* Check the headerline if the extension didn't match anything. */
- if (openfile->colorstrings == NULL) {
+ if (openfile->syntax == NULL) {
#ifdef DEBUG
fprintf(stderr, "No result from file extension, trying headerline...\n");
#endif
#ifdef HAVE_LIBMAGIC
/* Check magic if we don't have an answer yet. */
- if (openfile->colorstrings == NULL) {
+ if (openfile->syntax == NULL) {
struct stat fileinfo;
magic_t cookie = NULL;
const char *magicstring = NULL;
if (found_in_list(sint->magics, magicstring)) {
openfile->syntax = sint;
openfile->colorstrings = sint->color;
- break;
}
}
}
}
/* If we didn't find any syntax yet, see if there is a default one. */
- if (openfile->colorstrings == NULL) {
+ if (openfile->syntax == NULL) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, "default") == 0) {
openfile->syntax = sint;