vim-patch:8.2.2289: Vim9: 'cpo' can become empty (#19887)

Problem:    Vim9: 'cpo' can become empty.
Solution:   Use empty_option instead of an empty string.  Update quickfix
            buffer after restoring 'cpo'.  (closes vim/vim#7608)
e5a2dc87fd

Omit test as it is Vim9 script.
This commit is contained in:
zeertzjq
2022-08-22 12:02:45 +08:00
committed by GitHub
parent d5cc161dea
commit 4f6d0d6da9
5 changed files with 30 additions and 9 deletions

View File

@@ -2192,7 +2192,7 @@ int pattern_match(char *pat, char *text, bool ic)
// avoid 'l' flag in 'cpoptions'
char *save_cpo = p_cpo;
p_cpo = "";
p_cpo = (char *)empty_option;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
regmatch.rm_ic = ic;
@@ -8389,6 +8389,11 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
p_cpo = save_cpo;
} else {
// Darn, evaluating {sub} expression or {expr} changed the value.
// If it's still empty it was changed and restored, need to restore in
// the complicated way.
if (*p_cpo == NUL) {
set_option_value("cpo", 0L, save_cpo, 0);
}
free_string_option((char_u *)save_cpo);
}