From e334f5a57d3d00d4fc6ca0aeca8a6254e7e5da81 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 19 Jan 2023 09:54:12 +0000 Subject: refactor(optionstr.c): break up did_set_string_option 4 --- src/nvim/optionstr.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index fa26db5c12..dcefd450ca 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -690,6 +690,20 @@ static void did_set_helpfile(void) } } +static void did_set_helplang(char **errmsg) +{ + // Check for "", "ab", "ab,cd", etc. + for (char *s = p_hlg; *s != NUL; s += 3) { + if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { + *errmsg = e_invarg; + break; + } + if (s[2] == NUL) { + break; + } + } +} + /// Handle string options that need some action to perform when changed. /// The new value must be allocated. /// @@ -759,16 +773,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } else if (varp == &curwin->w_p_cc) { // 'colorcolumn' errmsg = check_colorcolumn(curwin); } else if (varp == &p_hlg) { // 'helplang' - // Check for "", "ab", "ab,cd", etc. - for (char *s = p_hlg; *s != NUL; s += 3) { - if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { - errmsg = e_invarg; - break; - } - if (s[2] == NUL) { - break; - } - } + did_set_helplang(&errmsg); } else if (varp == &p_hl) { // 'highlight' if (strcmp(*varp, HIGHLIGHT_INIT) != 0) { errmsg = e_unsupportedoption; -- cgit