diff options
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 != ':') { |