diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-01-19 09:58:00 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-01-25 11:48:52 +0000 |
commit | 696c470e6893954fa3ee706753292b7f340abc8b (patch) | |
tree | 1794d22ba86a626103a92eff7259cadcd11240da /src | |
parent | 47145eb3cd1f120515b9531181f9db177a80fad3 (diff) | |
download | rneovim-696c470e6893954fa3ee706753292b7f340abc8b.tar.gz rneovim-696c470e6893954fa3ee706753292b7f340abc8b.tar.bz2 rneovim-696c470e6893954fa3ee706753292b7f340abc8b.zip |
refactor(optionstr.c): break up did_set_string_option 9
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/optionstr.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index bb83cabb73..9724ea4502 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -829,6 +829,30 @@ static void did_set_fileformat(buf_T *buf, char **varp, const char *oldval, int } } +static void did_set_matchpairs(char **varp, char **errmsg) +{ + for (char *p = *varp; *p != NUL; p++) { + int x2 = -1; + int x3 = -1; + + p += utfc_ptr2len(p); + if (*p != NUL) { + x2 = (unsigned char)(*p++); + } + if (*p != NUL) { + x3 = utf_ptr2char(p); + p += utfc_ptr2len(p); + } + if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) { + *errmsg = e_invarg; + break; + } + if (*p == NUL) { + break; + } + } +} + /// Handle string options that need some action to perform when changed. /// The new value must be allocated. /// @@ -969,26 +993,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf errmsg = e_invarg; } } else if (gvarp == &p_mps) { // 'matchpairs' - for (char *p = *varp; *p != NUL; p++) { - int x2 = -1; - int x3 = -1; - - p += utfc_ptr2len(p); - if (*p != NUL) { - x2 = (unsigned char)(*p++); - } - if (*p != NUL) { - x3 = utf_ptr2char(p); - p += utfc_ptr2len(p); - } - if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) { - errmsg = e_invarg; - break; - } - if (*p == NUL) { - break; - } - } + did_set_matchpairs(varp, &errmsg); } else if (gvarp == &p_com) { // 'comments' for (char *s = *varp; *s;) { while (*s && *s != ':') { |