build: fix compilation when configured with --disable-color

This commit is contained in:
Benno Schulenberg 2019-06-17 09:59:15 +02:00
parent 345cf5accc
commit 47068c3770
2 changed files with 23 additions and 22 deletions

View File

@ -466,10 +466,10 @@ int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */ /* Most functions in rcfile.c. */
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
void display_rcfile_errors(); void display_rcfile_errors();
bool parse_syntax_commands(char *keyword, char *ptr);
void parse_one_include(char *file, syntaxtype *syntax);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
void parse_one_include(char *file, syntaxtype *syntax);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage); void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
bool parse_syntax_commands(char *keyword, char *ptr);
#endif #endif
void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only); void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only);
void do_rcfiles(void); void do_rcfiles(void);

View File

@ -929,6 +929,25 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
*storage = mallocstrcpy(*storage, ptr); *storage = mallocstrcpy(*storage, ptr);
} }
/* Handle the four syntax-only commands. */
bool parse_syntax_commands(char *keyword, char *ptr)
{
if (strcasecmp(keyword, "color") == 0)
parse_colors(ptr, NANO_REG_EXTENDED);
else if (strcasecmp(keyword, "icolor") == 0)
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "comment") == 0) {
#ifdef ENABLE_COMMENT
pick_up_name("comment", ptr, &live_syntax->comment);
#endif
} else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else
return FALSE;
return TRUE;
}
#endif /* ENABLE_COLOR */ #endif /* ENABLE_COLOR */
/* Verify that the user has not unmapped every shortcut for a /* Verify that the user has not unmapped every shortcut for a
@ -959,25 +978,6 @@ static void check_vitals_mapped(void)
} }
} }
/* Handle the four syntax-only commands. */
bool parse_syntax_commands(char *keyword, char *ptr)
{
if (strcasecmp(keyword, "color") == 0)
parse_colors(ptr, NANO_REG_EXTENDED);
else if (strcasecmp(keyword, "icolor") == 0)
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "comment") == 0) {
#ifdef ENABLE_COMMENT
pick_up_name("comment", ptr, &live_syntax->comment);
#endif
} else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else
return FALSE;
return TRUE;
}
/* Parse the rcfile, once it has been opened successfully at rcstream, /* Parse the rcfile, once it has been opened successfully at rcstream,
* and close it afterwards. If just_syntax is TRUE, allow the file to * and close it afterwards. If just_syntax is TRUE, allow the file to
* to contain only color syntax commands. */ * to contain only color syntax commands. */
@ -994,10 +994,11 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
lineno++; lineno++;
#ifdef ENABLE_COLOR
/* If doing a full parse, skip to after the 'syntax' command. */ /* If doing a full parse, skip to after the 'syntax' command. */
if (just_syntax && !intros_only && lineno <= live_syntax->lineno) if (just_syntax && !intros_only && lineno <= live_syntax->lineno)
continue; continue;
#endif
/* Strip the terminating newline, if any. */ /* Strip the terminating newline, if any. */
if (buffer[len - 1] == '\n') if (buffer[len - 1] == '\n')
buffer[len - 1] = '\0'; buffer[len - 1] = '\0';