nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 03692363a284d35396abc04a339a85a6e1226902
parent 0e94575c6bdd2fcee43996654a75ce7687e29d78
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat, 15 Jun 2019 13:04:01 +0200

tweaks: move a syntax check to a better place, to reduce duplication

Diffstat:
Msrc/rcfile.c | 27++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -716,12 +716,6 @@ void parse_colors(char *ptr, int rex_flags) int attributes; char *item; - if (!opensyntax) { - rcfile_error(N_("A '%s' command requires a preceding 'syntax' command"), - "color"); - return; - } - if (*ptr == '\0') { rcfile_error(N_("Missing color name")); return; @@ -908,12 +902,6 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage) /* Gather and store the string after a comment/linter command. */ void pick_up_name(const char *kind, char *ptr, char **storage) { - if (!opensyntax) { - rcfile_error( - N_("A '%s' command requires a preceding 'syntax' command"), kind); - return; - } - if (*ptr == '\0') { rcfile_error(N_("Missing argument after '%s'"), kind); return; @@ -1097,14 +1085,15 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only) keyword); else break; - } else if (intros_only && opensyntax && - (strcasecmp(keyword, "color") == 0 || - strcasecmp(keyword, "icolor") == 0)) { - seen_color_command = TRUE; - continue; - } else if (intros_only && opensyntax && - (strcasecmp(keyword, "comment") == 0 || + } else if (intros_only && (strcasecmp(keyword, "color") == 0 || + strcasecmp(keyword, "icolor") == 0 || + strcasecmp(keyword, "comment") == 0 || strcasecmp(keyword, "linter") == 0)) { + if (!opensyntax) + rcfile_error(N_("A '%s' command requires a preceding " + "'syntax' command"), keyword); + if (strcasestr("icolor", keyword)) + seen_color_command = TRUE; continue; } else if (parse_syntax_commands(keyword, ptr)) ;