diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-08-20 17:26:44 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 17:26:44 +0800 |
| commit | ff5cfcdeab2446459ab59d44ce173ef811902c49 (patch) | |
| tree | 2cad932a46390cb0d5821f13aa39f30b5be11770 /src | |
| parent | 1cc4706e94489498b12c4844c1b3a2e9aa5cc921 (diff) | |
| download | rneovim-ff5cfcdeab2446459ab59d44ce173ef811902c49.tar.gz rneovim-ff5cfcdeab2446459ab59d44ce173ef811902c49.tar.bz2 rneovim-ff5cfcdeab2446459ab59d44ce173ef811902c49.zip | |
vim-patch:8.1.2045: the option.c file is too big (#19854)
Problem: The option.c file is too big.
Solution: Split off the code dealing with strings. (Yegappan Lakshmanan,
closes vim/vim#4937)
https://github.com/vim/vim/commit/dac1347b4d9c1a1aef6aa73fdea08a9d1077d6ea
Cherry-pick set_string_option_direct_in_win() from patch 8.1.1405.
Cherry-pick shift_line() comment change from patch 8.1.2096.
Move 'clipboard' default parsing to didset_string_options().
Reorder option flags to put Nvim-only flags at the end.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/api/vim.c | 1 | ||||
| -rw-r--r-- | src/nvim/autocmd.c | 2 | ||||
| -rw-r--r-- | src/nvim/buffer.c | 1 | ||||
| -rw-r--r-- | src/nvim/diff.c | 7 | ||||
| -rw-r--r-- | src/nvim/eval.c | 1 | ||||
| -rw-r--r-- | src/nvim/eval/funcs.c | 1 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 1 | ||||
| -rw-r--r-- | src/nvim/ex_docmd.c | 1 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 1 | ||||
| -rw-r--r-- | src/nvim/fileio.c | 1 | ||||
| -rw-r--r-- | src/nvim/help.c | 1 | ||||
| -rw-r--r-- | src/nvim/main.c | 1 | ||||
| -rw-r--r-- | src/nvim/ops.c | 39 | ||||
| -rw-r--r-- | src/nvim/option.c | 1827 | ||||
| -rw-r--r-- | src/nvim/option.h | 17 | ||||
| -rw-r--r-- | src/nvim/option_defs.h | 212 | ||||
| -rw-r--r-- | src/nvim/optionstr.c | 1665 | ||||
| -rw-r--r-- | src/nvim/optionstr.h | 10 | ||||
| -rw-r--r-- | src/nvim/quickfix.c | 1 | ||||
| -rw-r--r-- | src/nvim/screen.c | 1 | ||||
| -rw-r--r-- | src/nvim/statusline.c | 1 | ||||
| -rw-r--r-- | src/nvim/syntax.c | 1 | ||||
| -rw-r--r-- | src/nvim/tag.c | 1 | ||||
| -rw-r--r-- | src/nvim/terminal.c | 1 | ||||
| -rw-r--r-- | src/nvim/window.c | 1 |
25 files changed, 1932 insertions, 1864 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index a9787787d1..ce91c1b4af 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -52,6 +52,7 @@ #include "nvim/msgpack_rpc/unpacker.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/process.h" #include "nvim/popupmenu.h" diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index b5b2a73be1..579c6c029f 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -25,7 +25,7 @@ #include "nvim/insexpand.h" #include "nvim/lua/executor.h" #include "nvim/map.h" -#include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/profile.h" #include "nvim/regexp.h" diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 88b7cfc8ee..1ff0140162 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -66,6 +66,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" diff --git a/src/nvim/diff.c b/src/nvim/diff.c index c1fdbc1b9a..5485d528f7 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -34,6 +34,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os/shell.h" #include "nvim/path.h" @@ -1407,8 +1408,6 @@ void diff_win_options(win_T *wp, int addbuf) } wp->w_p_wrap = false; } - curwin = wp; // -V519 - curbuf = curwin->w_buffer; if (!wp->w_p_diff) { if (wp->w_p_diff_saved) { @@ -1416,9 +1415,7 @@ void diff_win_options(win_T *wp, int addbuf) } wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm); } - set_string_option_direct("fdm", -1, "diff", OPT_LOCAL | OPT_FREE, 0); - curwin = old_curwin; - curbuf = curwin->w_buffer; + set_string_option_direct_in_win(wp, "fdm", -1, "diff", OPT_LOCAL | OPT_FREE, 0); if (!wp->w_p_diff) { wp->w_p_fen_save = wp->w_p_fen; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f2fe106224..c39fe44162 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -41,6 +41,7 @@ #include "nvim/move.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/shell.h" #include "nvim/path.h" diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 1798d43c6c..940f245d53 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -56,6 +56,7 @@ #include "nvim/msgpack_rpc/server.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/dl.h" #include "nvim/os/shell.h" #include "nvim/path.h" diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 66176620a5..06a372bb93 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -56,6 +56,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/shell.h" diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index afa8a276c8..6cd6e32e72 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -61,6 +61,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 776bdd935b..4629cb98ea 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -63,6 +63,7 @@ #include "nvim/move.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d29a0f0a08..5dfcbb0668 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -42,6 +42,7 @@ #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" diff --git a/src/nvim/help.c b/src/nvim/help.c index 172d389e74..569f68e330 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -17,6 +17,7 @@ #include "nvim/help.h" #include "nvim/memory.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/path.h" #include "nvim/strings.h" diff --git a/src/nvim/main.c b/src/nvim/main.c index fd31ba6c66..d06b475934 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -52,6 +52,7 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/fileio.h" #include "nvim/os/input.h" #include "nvim/os/os.h" diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 50f9650a8a..3be4536f16 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -288,13 +288,13 @@ void shift_line(int left, int round, int amount, int call_changed_bytes) { int count; int i, j; - int p_sw = (int)get_sw_value_indent(curbuf); + const int sw_val = (int)get_sw_value_indent(curbuf); count = get_indent(); // get current indent if (round) { // round off indent - i = count / p_sw; // number of p_sw rounded down - j = count % p_sw; // extra spaces + i = count / sw_val; // number of 'shiftwidth' rounded down + j = count % sw_val; // extra spaces if (j && left) { // first remove extra spaces amount--; } @@ -306,15 +306,15 @@ void shift_line(int left, int round, int amount, int call_changed_bytes) } else { i += amount; } - count = i * p_sw; + count = i * sw_val; } else { // original vi indent if (left) { - count -= p_sw * amount; + count -= sw_val * amount; if (count < 0) { count = 0; } } else { - count += p_sw * amount; + count += sw_val * amount; } } @@ -334,9 +334,8 @@ static void shift_block(oparg_T *oap, int amount) const int oldstate = State; char_u *newp; const int oldcol = curwin->w_cursor.col; - int p_sw = (int)get_sw_value_indent(curbuf); - long *p_vts = curbuf->b_p_vts_array; - const long p_ts = curbuf->b_p_ts; + const int sw_val = (int)get_sw_value_indent(curbuf); + const int ts_val = (int)curbuf->b_p_ts; struct block_def bd; int incr; int i = 0, j = 0; @@ -351,8 +350,8 @@ static void shift_block(oparg_T *oap, int amount) } // total is number of screen columns to be inserted/removed - int total = (int)((unsigned)amount * (unsigned)p_sw); - if ((total / p_sw) != amount) { + int total = (int)((unsigned)amount * (unsigned)sw_val); + if ((total / sw_val) != amount) { return; // multiplication overflow } @@ -387,7 +386,7 @@ static void shift_block(oparg_T *oap, int amount) // OK, now total=all the VWS reqd, and textstart points at the 1st // non-ws char in the block. if (!curbuf->b_p_et) { - tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j); + tabstop_fromto(ws_vcol, ws_vcol + total, ts_val, curbuf->b_p_vts_array, &i, &j); } else { j = total; } @@ -511,7 +510,7 @@ static void shift_block(oparg_T *oap, int amount) /// Caller must prepare for undo. static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def *bdp) { - int p_ts; + int ts_val; int count = 0; // extra spaces to replace a cut TAB int spaces = 0; // non-zero if cutting a TAB colnr_T offset; // pointer along new line @@ -530,18 +529,18 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def oldp = ml_get(lnum); if (b_insert) { - p_ts = bdp->start_char_vcols; + ts_val = bdp->start_char_vcols; spaces = bdp->startspaces; if (spaces != 0) { - count = p_ts - 1; // we're cutting a TAB + count = ts_val - 1; // we're cutting a TAB } offset = bdp->textcol; } else { // append - p_ts = bdp->end_char_vcols; + ts_val = bdp->end_char_vcols; if (!bdp->is_short) { // spaces = padding after block - spaces = (bdp->endspaces ? p_ts - bdp->endspaces : 0); + spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0); if (spaces != 0) { - count = p_ts - 1; // we're cutting a TAB + count = ts_val - 1; // we're cutting a TAB } offset = bdp->textcol + bdp->textlen - (spaces != 0); } else { // spaces = padding to block edge @@ -565,7 +564,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def assert(count >= 0); // Make sure the allocated size matches what is actually copied below. newp = xmalloc(STRLEN(oldp) + (size_t)spaces + s_len - + (spaces > 0 && !bdp->is_short ? (size_t)p_ts - (size_t)spaces : 0) + + (spaces > 0 && !bdp->is_short ? (size_t)ts_val - (size_t)spaces : 0) + (size_t)count + 1); // copy up to shifted part @@ -584,7 +583,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def if (spaces > 0 && !bdp->is_short) { if (*oldp == TAB) { // insert post-padding - memset(newp + offset + spaces, ' ', (size_t)(p_ts - spaces)); + memset(newp + offset + spaces, ' ', (size_t)(ts_val - spaces)); // We're splitting a TAB, don't copy it. oldp++; // We allowed for that TAB, remember this now diff --git a/src/nvim/option.c b/src/nvim/option.c index e85a0d9ee4..5c487a7c62 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -31,16 +31,13 @@ #include "nvim/ascii.h" #include "nvim/buffer.h" #include "nvim/charset.h" -#include "nvim/cursor.h" #include "nvim/cursor_shape.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" -#include "nvim/digraph.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/vars.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" @@ -54,7 +51,6 @@ #include "nvim/highlight_group.h" #include "nvim/indent.h" #include "nvim/indent_c.h" -#include "nvim/insexpand.h" #include "nvim/keycodes.h" #include "nvim/macros.h" #include "nvim/mapping.h" @@ -68,12 +64,12 @@ #include "nvim/normal.h" #include "nvim/ops.h" #include "nvim/option.h" +#include "nvim/optionstr.h" #include "nvim/os/os.h" #include "nvim/os_unix.h" #include "nvim/path.h" #include "nvim/popupmenu.h" #include "nvim/regexp.h" -#include "nvim/runtime.h" #include "nvim/screen.h" #include "nvim/spell.h" #include "nvim/spellfile.h" @@ -94,7 +90,6 @@ #include "nvim/lua/executor.h" #include "nvim/os/input.h" #include "nvim/os/lang.h" -#include "nvim/quickfix.h" /* * The options that are local to a window or buffer have "indir" set to one of @@ -127,73 +122,6 @@ typedef enum { static char *p_term = NULL; static char *p_ttytype = NULL; -/* - * These are the global values for options which are also local to a buffer. - * Only to be used in option.c! - */ -static int p_ai; -static int p_bin; -static int p_bomb; -static char_u *p_bh; -static char_u *p_bt; -static int p_bl; -static long p_channel; -static int p_ci; -static int p_cin; -static char_u *p_cink; -static char_u *p_cino; -static char_u *p_cinw; -static char_u *p_cinsd; -static char_u *p_com; -static char_u *p_cms; -static char_u *p_cpt; -static char_u *p_cfu; -static char_u *p_ofu; -static char_u *p_tfu; -static int p_eol; -static int p_fixeol; -static int p_et; -static char_u *p_fenc; -static char_u *p_ff; -static char_u *p_fo; -static char_u *p_flp; -static char_u *p_ft; -static long p_iminsert; -static long p_imsearch; -static char_u *p_inex; -static char_u *p_inde; -static char_u *p_indk; -static char_u *p_fex; -static int p_inf; -static char_u *p_isk; -static int p_lisp; -static int p_ml; -static int p_ma; -static int p_mod; -static char_u *p_mps; -static char_u *p_nf; -static int p_pi; -static char_u *p_qe; -static int p_ro; -static int p_si; -static long p_sts; -static char_u *p_sua; -static long p_sw; -static int p_swf; -static long p_smc; -static char_u *p_syn; -static char_u *p_spc; -static char_u *p_spf; -static char_u *p_spl; -static char_u *p_spo; -static long p_ts; -static long p_tw; -static int p_udf; -static long p_wm; -static char_u *p_vsts; -static char_u *p_vts; -static char_u *p_keymap; - // Saved values for when 'bin' is set. static int p_et_nobin; static int p_ml_nobin; @@ -222,64 +150,6 @@ typedef struct vimoption { } vimoption_T; /* - * Flags - */ -#define P_BOOL 0x01U // the option is boolean -#define P_NUM 0x02U // the option is numeric -#define P_STRING 0x04U // the option is a string -#define P_ALLOCED 0x08U // the string option is in allocated memory, - // must use free_string_option() when - // assigning new value. Not set if default is - // the same. -#define P_EXPAND 0x10U // environment expansion. NOTE: P_EXPAND can - // never be used for local or hidden options -#define P_NODEFAULT 0x40U // don't set to default value -#define P_DEF_ALLOCED 0x80U // default value is in allocated memory, must - // use free() when assigning new value -#define P_WAS_SET 0x100U // option has been set/reset -#define P_NO_MKRC 0x200U // don't include in :mkvimrc output - -// when option changed, what to display: -#define P_RSTAT 0x1000U ///< redraw status lines -#define P_RWIN 0x2000U ///< redraw current window and recompute text -#define P_RBUF 0x4000U ///< redraw current buffer and recompute text -#define P_RALL 0x6000U ///< redraw all windows -#define P_RCLR 0x7000U ///< clear and redraw all - -#define P_COMMA 0x8000U ///< comma separated list -#define P_ONECOMMA 0x18000U ///< P_COMMA and cannot have two consecutive - ///< commas -#define P_NODUP 0x20000U ///< don't allow duplicate strings -#define P_FLAGLIST 0x40000U ///< list of single-char flags - -#define P_SECURE 0x80000U ///< cannot change in modeline or secure mode -#define P_GETTEXT 0x100000U ///< expand default value with _() -#define P_NOGLOB 0x200000U ///< do not use local value for global vimrc -#define P_NFNAME 0x400000U ///< only normal file name chars allowed -#define P_INSECURE 0x800000U ///< option was set from a modeline -#define P_PRI_MKRC 0x1000000U ///< priority for :mkvimrc (setting option - ///< has side effects) -#define P_NO_ML 0x2000000U ///< not allowed in modeline -#define P_CURSWANT 0x4000000U ///< update curswant required; not needed - ///< when there is a redraw flag -#define P_NO_DEF_EXP 0x8000000U ///< Do not expand default value. - -#define P_RWINONLY 0x10000000U ///< only redraw current window -#define P_NDNAME 0x20000000U ///< only normal dir name chars allowed -#define P_UI_OPTION 0x40000000U ///< send option to remote ui -#define P_MLE 0x80000000U ///< under control of 'modelineexpr' - -#define HIGHLIGHT_INIT \ - "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \ - "i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \ - "N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \ - "r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \ - "W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \ - "-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar," \ - "X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \ - "q:QuickFixLine,0:Whitespace,I:NormalNC" - -/* * options[] is initialized here. * The order of the options MUST be alphabetic for ":set all" and findoption(). * All option names MUST start with a lowercase letter (for findoption()). @@ -294,59 +164,6 @@ typedef struct vimoption { #define OPTION_COUNT ARRAY_SIZE(options) -static char *(p_ambw_values[]) = { "single", "double", NULL }; -static char *(p_bg_values[]) = { "light", "dark", NULL }; -static char *(p_nf_values[]) = { "bin", "octal", "hex", "alpha", - "unsigned", NULL }; -static char *(p_ff_values[]) = { FF_UNIX, FF_DOS, FF_MAC, NULL }; -static char *(p_wak_values[]) = { "yes", "menu", "no", NULL }; -static char *(p_mousem_values[]) = { "extend", "popup", "popup_setpos", - "mac", NULL }; -static char *(p_sel_values[]) = { "inclusive", "exclusive", "old", NULL }; -static char *(p_slm_values[]) = { "mouse", "key", "cmd", NULL }; -static char *(p_km_values[]) = { "startsel", "stopsel", NULL }; -static char *(p_scbopt_values[]) = { "ver", "hor", "jump", NULL }; -static char *(p_debug_values[]) = { "msg", "throw", "beep", NULL }; -static char *(p_ead_values[]) = { "both", "ver", "hor", NULL }; -static char *(p_buftype_values[]) = { "nofile", "nowrite", "quickfix", - "help", "acwrite", "terminal", - "prompt", NULL }; - -static char *(p_bufhidden_values[]) = { "hide", "unload", "delete", - "wipe", NULL }; -static char *(p_bs_values[]) = { "indent", "eol", "start", "nostop", NULL }; -static char *(p_fdm_values[]) = { "manual", "expr", "marker", "indent", - "syntax", "diff", NULL }; -static char *(p_fcl_values[]) = { "all", NULL }; -static char *(p_cot_values[]) = { "menu", "menuone", "longest", "preview", - "noinsert", "noselect", NULL }; -#ifdef BACKSLASH_IN_FILENAME -static char *(p_csl_values[]) = { "slash", "backslash", NULL }; -#endif -static char *(p_icm_values[]) = { "nosplit", "split", NULL }; -static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2", - "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", - "auto:9", - "yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", - "yes:7", "yes:8", - "yes:9", "number", NULL }; -static char *(p_fdc_values[]) = { "auto", "auto:1", "auto:2", - "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", - "auto:9", - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; - -/// All possible flags for 'shm'. -static char_u SHM_ALL[] = { - SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, - SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, - SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, - SHM_RECORDING, SHM_FILEINFO, SHM_SEARCHCOUNT, - 0, -}; - -static char e_unclosed_expression_sequence[] = N_("E540: Unclosed expression sequence"); -static char e_unbalanced_groups[] = N_("E542: unbalanced groups"); - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "option.c.generated.h" #endif @@ -1751,7 +1568,7 @@ theend: /// @param opt_flags possibly with OPT_MODELINE /// @param new_value value was replaced completely /// @param value_checked value was checked to be safe, no need to set P_INSECURE -static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked) +void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked) { options[opt_idx].flags |= P_WAS_SET; @@ -1768,16 +1585,6 @@ static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_ } } -static char *illegal_char(char *errbuf, size_t errbuflen, int c) -{ - if (errbuf == NULL) { - return ""; - } - vim_snprintf(errbuf, errbuflen, _("E539: Illegal character <%s>"), - (char *)transchar(c)); - return errbuf; -} - /// Convert a key name or string into a key value. /// Used for 'wildchar' and 'cedit' options. static int string_to_key(char_u *arg) @@ -1793,7 +1600,7 @@ static int string_to_key(char_u *arg) /// Check value of 'cedit' and set cedit_key. /// Returns NULL if value is OK, error message otherwise. -static char *check_cedit(void) +char *check_cedit(void) { int n; @@ -1813,7 +1620,7 @@ static char *check_cedit(void) // maketitle() to create and display it. // When switching the title or icon off, call ui_set_{icon,title}(NULL) to get // the old value back. -static void did_set_title(void) +void did_set_title(void) { if (starting != NO_SCREEN) { maketitle(); @@ -1952,26 +1759,6 @@ static char_u *option_expand(int opt_idx, char_u *val) /// After setting various option values: recompute variables that depend on /// option values. -static void didset_string_options(void) -{ - (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true); - (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true); - (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, true); - (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true); - (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true); - (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true); - (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, true); - (void)opt_strings_flags(p_rdb, p_rdb_values, &rdb_flags, true); - (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, false); - (void)opt_strings_flags(p_tpf, p_tpf_values, &tpf_flags, true); - (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, true); - (void)opt_strings_flags(p_swb, p_swb_values, &swb_flags, true); - (void)opt_strings_flags(p_wop, p_wop_values, &wop_flags, true); - (void)opt_strings_flags(p_jop, p_jop_values, &jop_flags, true); -} - -/// After setting various option values: recompute variables that depend on -/// option values. static void didset_options(void) { // initialize the table for 'iskeyword' et.al. @@ -1996,9 +1783,6 @@ static void didset_options2(void) // Initialize the highlight_attr[] table. highlight_changed(); - // Parse default for 'clipboard'. - (void)opt_strings_flags(p_cb, p_cb_values, &cb_flags, true); - // Parse default for 'fillchars'. (void)set_chars_option(curwin, &curwin->w_p_fcs, true); @@ -2025,91 +1809,6 @@ void check_options(void) } } -/// Check string options in a buffer for NULL value. -void check_buf_options(buf_T *buf) -{ - check_string_option(&buf->b_p_bh); - check_string_option(&buf->b_p_bt); - check_string_option(&buf->b_p_fenc); - check_string_option(&buf->b_p_ff); - check_string_option(&buf->b_p_def); - check_string_option(&buf->b_p_inc); - check_string_option(&buf->b_p_inex); - check_string_option(&buf->b_p_inde); - check_string_option(&buf->b_p_indk); - check_string_option(&buf->b_p_fp); - check_string_option(&buf->b_p_fex); - check_string_option(&buf->b_p_kp); - check_string_option(&buf->b_p_mps); - check_string_option(&buf->b_p_fo); - check_string_option(&buf->b_p_flp); - check_string_option(&buf->b_p_isk); - check_string_option(&buf->b_p_com); - check_string_option(&buf->b_p_cms); - check_string_option(&buf->b_p_nf); - check_string_option(&buf->b_p_qe); - check_string_option(&buf->b_p_syn); - check_string_option(&buf->b_s.b_syn_isk); - check_string_option(&buf->b_s.b_p_spc); - check_string_option(&buf->b_s.b_p_spf); - check_string_option(&buf->b_s.b_p_spl); - check_string_option(&buf->b_s.b_p_spo); - check_string_option(&buf->b_p_sua); - check_string_option(&buf->b_p_cink); - check_string_option(&buf->b_p_cino); - parse_cino(buf); - check_string_option(&buf->b_p_ft); - check_string_option(&buf->b_p_cinw); - check_string_option(&buf->b_p_cinsd); - check_string_option(&buf->b_p_cpt); - check_string_option(&buf->b_p_cfu); - check_string_option(&buf->b_p_ofu); - check_string_option(&buf->b_p_keymap); - check_string_option(&buf->b_p_gp); - check_string_option(&buf->b_p_mp); - check_string_option(&buf->b_p_efm); - check_string_option(&buf->b_p_ep); - check_string_option(&buf->b_p_path); - check_string_option(&buf->b_p_tags); - check_string_option(&buf->b_p_tfu); - check_string_option(&buf->b_p_tc); - check_string_option(&buf->b_p_dict); - check_string_option(&buf->b_p_tsr); - check_string_option(&buf->b_p_tsrfu); - check_string_option(&buf->b_p_lw); - check_string_option(&buf->b_p_bkc); - check_string_option(&buf->b_p_menc); - check_string_option(&buf->b_p_vsts); - check_string_option(&buf->b_p_vts); -} - -/// Free the string allocated for an option. -/// Checks for the string being empty_option. This may happen if we're out of -/// memory, vim_strsave() returned NULL, which was replaced by empty_option by -/// check_options(). -/// Does NOT check for P_ALLOCED flag! -void free_string_option(char_u *p) -{ - if (p != empty_option) { - xfree(p); - } -} - -void clear_string_option(char_u **pp) -{ - if (*pp != empty_option) { - xfree(*pp); - } - *pp = empty_option; -} - -static void check_string_option(char_u **pp) -{ - if (*pp == NULL) { - *pp = empty_option; - } -} - /// Return true when option "opt" was set from a modeline or in secure mode. /// Return false when it wasn't. /// Return -1 for an unknown option. @@ -2156,166 +1855,12 @@ static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags) } /// Redraw the window title and/or tab page text later. -static void redraw_titles(void) +void redraw_titles(void) { need_maketitle = true; redraw_tabline = true; } -static int shada_idx = -1; - -/// Set a string option to a new value (without checking the effect). -/// The string is copied into allocated memory. -/// if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. -/// When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When -/// "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to -/// "set_sid". -/// -/// @param opt_flags OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL -void set_string_option_direct(const char *name, int opt_idx, const char *val, int opt_flags, - int set_sid) -{ - char *s; - char **varp; - int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; - int idx = opt_idx; - - if (idx == -1) { // Use name. - idx = findoption(name); - if (idx < 0) { // Not found (should not happen). - internal_error("set_string_option_direct()"); - siemsg(_("For option %s"), name); - return; - } - } - - if (options[idx].var == NULL) { // can't set hidden option - return; - } - - assert((void *)options[idx].var != (void *)&p_shada); - - s = xstrdup(val); - { - varp = (char **)get_varp_scope(&(options[idx]), both ? OPT_LOCAL : opt_flags); - if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED)) { - free_string_option((char_u *)(*varp)); - } - *varp = s; - - // For buffer/window local option may also set the global value. - if (both) { - set_string_option_global(idx, (char_u **)varp); - } - - options[idx].flags |= P_ALLOCED; - - /* When setting both values of a global option with a local value, - * make the local value empty, so that the global value is used. */ - if (((int)options[idx].indir & PV_BOTH) && both) { - free_string_option((char_u *)(*varp)); - *varp = (char *)empty_option; - } - if (set_sid != SID_NONE) { - sctx_T script_ctx; - - if (set_sid == 0) { - script_ctx = current_sctx; - } else { - |