Mercurial > vim
comparison src/eval.c @ 23493:f8382c4e6551 v8.2.2289
patch 8.2.2289: Vim9: 'cpo' can become empty
Commit: https://github.com/vim/vim/commit/e5a2dc87fd9d63dfd0d9c379e363ee8b8c05b14c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 3 19:52:05 2021 +0100
patch 8.2.2289: Vim9: 'cpo' can become empty
Problem: Vim9: 'cpo' can become empty.
Solution: Use empty_option instead of an empty string. Update quickfix
buffer after restoring 'cpo'. (closes #7608)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 03 Jan 2021 20:00:03 +0100 |
parents | a8e7acf71fa4 |
children | 1f85acfb23cd |
comparison
equal
deleted
inserted
replaced
23492:27c9e319653b | 23493:f8382c4e6551 |
---|---|
1938 char_u *save_cpo; | 1938 char_u *save_cpo; |
1939 regmatch_T regmatch; | 1939 regmatch_T regmatch; |
1940 | 1940 |
1941 // avoid 'l' flag in 'cpoptions' | 1941 // avoid 'l' flag in 'cpoptions' |
1942 save_cpo = p_cpo; | 1942 save_cpo = p_cpo; |
1943 p_cpo = (char_u *)""; | 1943 p_cpo = empty_option; |
1944 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); | 1944 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); |
1945 if (regmatch.regprog != NULL) | 1945 if (regmatch.regprog != NULL) |
1946 { | 1946 { |
1947 regmatch.rm_ic = ic; | 1947 regmatch.rm_ic = ic; |
1948 matches = vim_regexec_nl(®match, text, (colnr_T)0); | 1948 matches = vim_regexec_nl(®match, text, (colnr_T)0); |
6198 ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); | 6198 ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); |
6199 ga_clear(&ga); | 6199 ga_clear(&ga); |
6200 if (p_cpo == empty_option) | 6200 if (p_cpo == empty_option) |
6201 p_cpo = save_cpo; | 6201 p_cpo = save_cpo; |
6202 else | 6202 else |
6203 { | |
6203 // Darn, evaluating {sub} expression or {expr} changed the value. | 6204 // Darn, evaluating {sub} expression or {expr} changed the value. |
6205 // If it's still empty it was changed and restored, need to restore in | |
6206 // the complicated way. | |
6207 if (*p_cpo == NUL) | |
6208 set_option_value((char_u *)"cpo", 0L, save_cpo, 0); | |
6204 free_string_option(save_cpo); | 6209 free_string_option(save_cpo); |
6210 } | |
6205 | 6211 |
6206 return ret; | 6212 return ret; |
6207 } | 6213 } |