summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-16 21:06:21 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-16 21:06:21 +0200
commitdac1347b4d9c1a1aef6aa73fdea08a9d1077d6ea (patch)
tree4c9124f2de51bedb339bc5cdb47a3086c0e92af9
parent8aeec40207b5adcd3a155277dc4f29189343b963 (diff)
patch 8.1.2045: the option.c file is too bigv8.1.2045
Problem: The option.c file is too big. Solution: Split off the code dealing with strings. (Yegappan Lakshmanan, closes #4937)
-rw-r--r--Filelist2
-rw-r--r--src/Make_cyg_ming.mak1
-rw-r--r--src/Make_morph.mak1
-rw-r--r--src/Make_mvc.mak4
-rw-r--r--src/Make_vms.mms12
-rw-r--r--src/Makefile10
-rw-r--r--src/README.md1
-rw-r--r--src/ops.c52
-rw-r--r--src/option.c2599
-rw-r--r--src/option.h203
-rw-r--r--src/optiondefs.h197
-rw-r--r--src/optionstr.c2491
-rw-r--r--src/os_unix.c8
-rw-r--r--src/proto.h1
-rw-r--r--src/proto/option.pro31
-rw-r--r--src/proto/optionstr.pro14
-rw-r--r--src/version.c2
17 files changed, 2882 insertions, 2747 deletions
diff --git a/Filelist b/Filelist
index b40cea6ee8..d7c6e0fe29 100644
--- a/Filelist
+++ b/Filelist
@@ -88,6 +88,7 @@ SRC_ALL = \
src/option.c \
src/option.h \
src/optiondefs.h \
+ src/optionstr.c \
src/popupmnu.c \
src/popupwin.c \
src/profiler.c \
@@ -231,6 +232,7 @@ SRC_ALL = \
src/proto/normal.pro \
src/proto/ops.pro \
src/proto/option.pro \
+ src/proto/optionstr.pro \
src/proto/popupmnu.pro \
src/proto/popupwin.pro \
src/proto/profiler.pro \
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index f9c5367e9f..9d8abf8be3 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -757,6 +757,7 @@ OBJ = \
$(OUTDIR)/normal.o \
$(OUTDIR)/ops.o \
$(OUTDIR)/option.o \
+ $(OUTDIR)/optionstr.o \
$(OUTDIR)/os_mswin.o \
$(OUTDIR)/os_win32.o \
$(OUTDIR)/pathdef.o \
diff --git a/src/Make_morph.mak b/src/Make_morph.mak
index 3f896da5b6..87b7e45cc5 100644
--- a/src/Make_morph.mak
+++ b/src/Make_morph.mak
@@ -76,6 +76,7 @@ SRC = arabic.c \
normal.c \
ops.c \
option.c \
+ optionstr.c \
os_amiga.c \
popupmnu.c \
profiler.c \
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index 7aa7ef83db..1205a6e230 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -764,6 +764,7 @@ OBJ = \
$(OUTDIR)\normal.obj \
$(OUTDIR)\ops.obj \
$(OUTDIR)\option.obj \
+ $(OUTDIR)\optionstr.obj \
$(OUTDIR)\os_mswin.obj \
$(OUTDIR)\os_win32.obj \
$(OUTDIR)\pathdef.obj \
@@ -1606,6 +1607,8 @@ $(OUTDIR)/normal.obj: $(OUTDIR) normal.c $(INCL)
$(OUTDIR)/option.obj: $(OUTDIR) option.c $(INCL) optiondefs.h
+$(OUTDIR)/optionstr.obj: $(OUTDIR) optionstr.c $(INCL)
+
$(OUTDIR)/ops.obj: $(OUTDIR) ops.c $(INCL)
$(OUTDIR)/os_mswin.obj: $(OUTDIR) os_mswin.c $(INCL)
@@ -1816,6 +1819,7 @@ proto.h: \
proto/normal.pro \
proto/ops.pro \
proto/option.pro \
+ proto/optionstr.pro \
proto/os_mswin.pro \
proto/winclip.pro \
proto/os_win32.pro \
diff --git a/src/Make_vms.mms b/src/Make_vms.mms
index c3b795820d..42adcb8d19 100644
--- a/src/Make_vms.mms
+++ b/src/Make_vms.mms
@@ -317,8 +317,8 @@ SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
getchar.c hardcopy.c hashtab.c highlight.c \
indent.c insexpand.c json.c list.c main.c map.c mark.c menu.c mbyte.c \
memfile.c memline.c message.c misc1.c misc2.c move.c normal.c ops.c \
- option.c popupmnu.c popupwin.c profiler.c quickfix.c regexp.c \
- scriptfile.c \
+ option.c optionstr.c popupmnu.c popupwin.c profiler.c quickfix.c \
+ regexp.c scriptfile.c \
search.c session.c sha256.c sign.c spell.c spellfile.c syntax.c tag.c \
term.c termlib.c testing.c textprop.c ui.c undo.c usercmd.c \
userfunc.c version.c viminfo.c screen.c window.c os_unix.c os_vms.c \
@@ -337,8 +337,8 @@ OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \
highlight.obj indent.obj insexpand.obj json.obj list.obj main.obj \
map.obj mark.obj menu.obj memfile.obj memline.obj message.obj \
misc1.obj misc2.obj move.obj mbyte.obj normal.obj ops.obj option.obj \
- popupmnu.obj popupwin.obj profiler.obj quickfix.obj regexp.obj \
- scriptfile.obj \
+ optionstr.obj popupmnu.obj popupwin.obj profiler.obj quickfix.obj \
+ regexp.obj scriptfile.obj \
search.obj session.obj sha256.obj sign.obj spell.obj spellfile.obj \
syntax.obj tag.obj term.obj termlib.obj testing.obj textprop.obj \
ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \
@@ -715,6 +715,10 @@ option.obj : option.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
globals.h optiondefs.h
+optionstr.obj : optionstr.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h
os_unix.obj : os_unix.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
diff --git a/src/Makefile b/src/Makefile
index 0efd88f70d..c89fdb1351 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1632,6 +1632,7 @@ BASIC_SRC = \
normal.c \
ops.c \
option.c \
+ optionstr.c \
os_unix.c \
auto/pathdef.c \
popupmnu.c \
@@ -1762,6 +1763,7 @@ OBJ_COMMON = \
objects/normal.o \
objects/ops.o \
objects/option.o \
+ objects/optionstr.o \
objects/os_unix.o \
objects/pathdef.o \
objects/popupmnu.o \
@@ -1917,6 +1919,7 @@ PRO_AUTO = \
normal.pro \
ops.pro \
option.pro \
+ optionstr.pro \
os_mac_conv.pro \
os_unix.pro \
popupmnu.pro \
@@ -3287,6 +3290,9 @@ objects/ops.o: ops.c
objects/option.o: option.c optiondefs.h
$(CCC_NF) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ option.c
+objects/optionstr.o: optionstr.c
+ $(CCC_NF) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ optionstr.c
+
objects/os_beos.o: os_beos.c
$(CCC) -o $@ os_beos.c
@@ -3763,6 +3769,10 @@ objects/option.o: option.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h optiondefs.h
+objects/optionstr.o: optionstr.c vim.h protodef.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
+ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
+ proto.h globals.h
objects/os_unix.o: os_unix.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
diff --git a/src/README.md b/src/README.md
index 6ba83910ee..f4f9df1f4e 100644
--- a/src/README.md
+++ b/src/README.md
@@ -54,6 +54,7 @@ menu.c | menus
message.c | (error) messages
ops.c | handling operators ("d", "y", "p")
option.c | options
+optionstr.c | handling string options
popupmnu.c | popup menu
popupwin.c | popup window
profiler.c | vim script profiler
diff --git a/src/ops.c b/src/ops.c
index 5f0181ba5a..89a25b19a5 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -315,14 +315,14 @@ shift_line(
{
int count;
int i, j;
- int p_sw = (int)get_sw_value_indent(curbuf);
+ 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 p_sw rounded down */
+ j = count % sw_val; /* extra spaces */
if (j && left) /* first remove extra spaces */
--amount;
if (left)
@@ -333,18 +333,18 @@ shift_line(
}
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;
}
/* Set new indent */
@@ -366,11 +366,8 @@ shift_block(oparg_T *oap, int amount)
int total;
char_u *newp, *oldp;
int oldcol = curwin->w_cursor.col;
- int p_sw = (int)get_sw_value_indent(curbuf);
-#ifdef FEAT_VARTABS
- int *p_vts = curbuf->b_p_vts_array;
-#endif
- int p_ts = (int)curbuf->b_p_ts;
+ int sw_val = (int)get_sw_value_indent(curbuf);
+ int ts_val = (int)curbuf->b_p_ts;
struct block_def bd;
int incr;
colnr_T ws_vcol;
@@ -388,8 +385,8 @@ shift_block(oparg_T *oap, int amount)
return;
/* total is number of screen columns to be inserted/removed */
- total = (int)((unsigned)amount * (unsigned)p_sw);
- if ((total / p_sw) != amount)
+ total = (int)((unsigned)amount * (unsigned)sw_val);
+ if ((total / sw_val) != amount)
return; /* multiplication overflow */
oldp = ml_get_curline();
@@ -431,14 +428,15 @@ shift_block(oparg_T *oap, int amount)
* non-ws char in the block. */
#ifdef FEAT_VARTABS
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;
#else
if (!curbuf->b_p_et)
- i = ((ws_vcol % p_ts) + total) / p_ts; /* number of tabs */
+ i = ((ws_vcol % ts_val) + total) / ts_val; /* number of tabs */
if (i)
- j = ((ws_vcol % p_ts) + total) % p_ts; /* number of spp */
+ j = ((ws_vcol % ts_val) + total) % ts_val; /* number of spp */
else
j = total;
#endif
@@ -567,7 +565,7 @@ block_insert(
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 */
@@ -589,20 +587,20 @@ block_insert(
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 */
@@ -651,7 +649,7 @@ block_insert(
if (spaces && !bdp->is_short)
{
/* insert post-padding */
- vim_memset(newp + offset + spaces, ' ', (size_t)(p_ts - spaces));
+ vim_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 */
@@ -5591,10 +5589,10 @@ do_addsub(
pos_T startpos;
pos_T endpos;
- dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */
- dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
- dobin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); /* "Bin" */
- doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); /* "alPha" */
+ dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
+ dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
+ dobin = (vim_strchr(curbuf->b_p_nf, 'b') != NULL); // "Bin"
+ doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha"
curwin->w_cursor = *pos;
ptr = ml_get(pos->lnum);
diff --git a/src/option.c b/src/option.c
index 99e046f3f1..1ffa11d121 100644
--- a/src/option.c
+++ b/src/option.c
@@ -38,31 +38,16 @@
static void set_options_default(int opt_flags);
static void set_string_default_esc(char *name, char_u *val, int escape);
static char_u *term_bg_default(void);
-static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked);
static char_u *option_expand(int opt_idx, char_u *val);
static void didset_options(void);
static void didset_options2(void);
-static void check_string_option(char_u **pp);
#if defined(FEAT_EVAL) || defined(PROTO)
static long_u *insecure_flag(int opt_idx, int opt_flags);
#else
# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
#endif
-static void set_string_option_global(int opt_idx, char_u **varp);
-static char *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char *errbuf, int opt_flags, int *value_checked);
-#ifdef FEAT_STL_OPT
-static char *check_stl_option(char_u *s);
-#endif
-#ifdef FEAT_CLIPBOARD
-static char *check_clipboard_option(void);
-#endif
-#ifdef FEAT_EVAL
-static void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
-#endif
static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags);
-static void check_redraw(long_u flags);
-static int findoption(char_u *);
static int find_key_option(char_u *arg_arg, int has_lt);
static void showoptions(int all, int opt_flags);
static int optval_default(struct vimoption *, char_u *varp, int compatible);
@@ -70,7 +55,7 @@ static void showoneopt(struct vimoption *, int opt_flags);
static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags);
static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
static int put_setbool(FILE *fd, char *cmd, char *name, int value);
-static int istermoption(struct vimoption *);
+static int istermoption(struct vimoption *p);
static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
static char_u *get_varp(struct vimoption *);
static void check_win_options(win_T *win);
@@ -79,18 +64,6 @@ static void check_winopt(winopt_T *wop);
static int wc_use_keyname(char_u *varp, long *wcp);
static void paste_option_changed(void);
static void compatible_set(void);
-#ifdef FEAT_LINEBREAK
-static void fill_breakat_flags(void);
-#endif
-static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
-static int check_opt_strings(char_u *val, char **values, int);
-static int check_opt_wim(void);
-#ifdef FEAT_LINEBREAK
-static int briopt_check(win_T *wp);
-#endif
-#ifdef FEAT_SYN_HL
-static int fill_culopt_flags(char_u *val, win_T *wp);
-#endif
/*
* Initialize the options, first part.
@@ -356,7 +329,7 @@ set_init_1(int clean_arg)
* Don't set the P_ALLOCED flag, because we don't want to free the
* default.
*/
- for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
+ for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++)
{
if ((options[opt_idx].flags & P_GETTEXT)
&& options[opt_idx].var != NULL)
@@ -622,7 +595,7 @@ set_options_default(
win_T *wp;
tabpage_T *tp;
- for (i = 0; !istermoption(&options[i]); i++)
+ for (i = 0; !istermoption_idx(i); i++)
if (!(options[i].flags & P_NODEFAULT)
&& (opt_flags == 0
|| (options[i].var != (char_u *)&p_enc
@@ -704,7 +677,7 @@ set_local_options_default(win_T *wp, int do_buffer)
curbuf = curwin->w_buffer;
block_autocmds();
- for (i = 0; !istermoption(&options[i]); i++)
+ for (i = 0; !istermoption_idx(i); i++)
{
struct vimoption *p = &(options[i]);
char_u *varp = get_varp_scope(p, OPT_LOCAL);
@@ -730,7 +703,7 @@ free_all_options(void)
{
int i;
- for (i = 0; !istermoption(&options[i]); i++)
+ for (i = 0; !istermoption_idx(i); i++)
{
if (options[i].indir == PV_NONE)
{
@@ -1133,66 +1106,6 @@ set_title_defaults(void)
}
#endif
-#if defined(FEAT_EVAL)
-/*
- * Trigger the OptionSet autocommand.
- * "opt_idx" is the index of the option being set.
- * "opt_flags" can be OPT_LOCAL etc.
- * "oldval" the old value
- * "oldval_l" the old local value (only non-NULL if global and local value
- * are set)
- * "oldval_g" the old global value (only non-NULL if global and local value
- * are set)
- * "newval" the new value
- */
- static void
-trigger_optionsset_string(
- int opt_idx,
- int opt_flags,
- char_u *oldval,
- char_u *oldval_l,
- char_u *oldval_g,
- char_u *newval)
-{
- // Don't do this recursively.
- if (oldval != NULL && newval != NULL
- && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
- {
- char_u buf_type[7];
-
- sprintf((char *)buf_type, "%s",
- (opt_flags & OPT_LOCAL) ? "local" : "global");
- set_vim_var_string(VV_OPTION_OLD, oldval, -1);
- set_vim_var_string(VV_OPTION_NEW, newval, -1);
- set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
- if (opt_flags & OPT_LOCAL)
- {
- set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
- set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
- }
- if (opt_flags & OPT_GLOBAL)
- {
- set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
- set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
- }
- if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
- {
- set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
- set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
- set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
- }
- if (opt_flags & OPT_MODELINE)
- {
- set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
- set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
- }
- apply_autocmds(EVENT_OPTIONSET,
- (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
- reset_v_option_vars();
- }
-}
-#endif
-
/*
* Parse 'arg' for option settings.
*
@@ -2199,7 +2112,7 @@ theend:
* Call this when an option has been given a new value through a user command.
* Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
*/
- static void
+ void
did_set_option(
int opt_idx,
int opt_flags, // possibly with OPT_MODELINE
@@ -2225,16 +2138,6 @@ did_set_option(
*p = *p & ~P_INSECURE;
}
- static char *
-illegal_char(char *errbuf, int c)
-{
- if (errbuf == NULL)
- return "";
- sprintf((char *)errbuf, _("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.
@@ -2252,12 +2155,12 @@ string_to_key(char_u *arg, int multi_byte)
return *arg;
}
-#ifdef FEAT_CMDWIN
+#if defined(FEAT_CMDWIN) || defined(PROTO)
/*
* Check value of 'cedit' and set cedit_key.
* Returns NULL if value is OK, error message otherwise.
*/
- static char *
+ char *
check_cedit(void)
{
int n;
@@ -2282,7 +2185,7 @@ check_cedit(void)
* When switching the title or icon off, call mch_restore_title() to get
* the old value back.
*/
- static void
+ void
did_set_title(void)
{
if (starting != NO_SCREEN
@@ -2411,34 +2314,14 @@ didset_options(void)
/* initialize the table for 'iskeyword' et.al. */
(void)init_chartab();
- (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);
-#ifdef FEAT_SESSION
- (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
- (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
-#endif
-#ifdef FEAT_FOLDING
- (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
-#endif
- (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
- (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
- (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
-#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
- (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
-#endif
+ didset_string_options();
+
#ifdef FEAT_SPELL
(void)spell_check_msm();
(void)spell_check_sps();
(void)compile_cap_prog(curwin->w_s);
(void)did_set_spell_option(TRUE);
#endif
-#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
- (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
-#endif
-#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
- (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
-#endif
#ifdef FEAT_CMDWIN
/* set cedit_key */
(void)check_cedit();
@@ -2497,138 +2380,6 @@ 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);
-#ifdef FEAT_FIND_ID
- check_string_option(&buf->b_p_def);
- check_string_option(&buf->b_p_inc);
-# ifdef FEAT_EVAL
- check_string_option(&buf->b_p_inex);
-# endif
-#endif
-#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
- check_string_option(&buf->b_p_inde);
- check_string_option(&buf->b_p_indk);
-#endif
-#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
- check_string_option(&buf->b_p_bexpr);
-#endif
-#if defined(FEAT_CRYPT)
- check_string_option(&buf->b_p_cm);
-#endif
- check_string_option(&buf->b_p_fp);
-#if defined(FEAT_EVAL)
- check_string_option(&buf->b_p_fex);
-#endif
-#ifdef FEAT_CRYPT
- check_string_option(&buf->b_p_key);
-#endif
- 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);
-#ifdef FEAT_COMMENTS
- check_string_option(&buf->b_p_com);
-#endif
-#ifdef FEAT_FOLDING
- check_string_option(&buf->b_p_cms);
-#endif
- check_string_option(&buf->b_p_nf);
-#ifdef FEAT_TEXTOBJ
- check_string_option(&buf->b_p_qe);
-#endif
-#ifdef FEAT_SYN_HL
- check_string_option(&buf->b_p_syn);
- check_string_option(&buf->b_s.b_syn_isk);
-#endif
-#ifdef FEAT_SPELL
- 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);
-#endif
-#ifdef FEAT_SEARCHPATH
- check_string_option(&buf->b_p_sua);
-#endif
-#ifdef FEAT_CINDENT
- check_string_option(&buf->b_p_cink);
- check_string_option(&buf->b_p_cino);
- parse_cino(buf);
-#endif
- check_string_option(&buf->b_p_ft);
-#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
- check_string_option(&buf->b_p_cinw);
-#endif
- check_string_option(&buf->b_p_cpt);
-#ifdef FEAT_COMPL_FUNC
- check_string_option(&buf->b_p_cfu);
- check_string_option(&buf->b_p_ofu);
-#endif
-#ifdef FEAT_EVAL
- check_string_option(&buf->b_p_tfu);
-#endif
-#ifdef FEAT_KEYMAP
- check_string_option(&buf->b_p_keymap);
-#endif
-#ifdef FEAT_QUICKFIX
- check_string_option(&buf->b_p_gp);
- check_string_option(&buf->b_p_mp);
- check_string_option(&buf->b_p_efm);
-#endif
- 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_tc);
- check_string_option(&buf->b_p_dict);
- check_string_option(&buf->b_p_tsr);
-#ifdef FEAT_LISP
- check_string_option(&buf->b_p_lw);
-#endif
- check_string_option(&buf->b_p_bkc);
- check_string_option(&buf->b_p_menc);
-#ifdef FEAT_VARTABS
- check_string_option(&buf->b_p_vsts);
- check_string_option(&buf->b_p_vts);
-#endif
-}
-
-/*
- * 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)
- vim_free(p);
-}
-
- void
-clear_string_option(char_u **pp)
-{
- if (*pp != empty_option)
- vim_free(*pp);
- *pp = empty_option;
-}
-
- static void
-check_string_option(char_u **pp)
-{
- if (*pp == NULL)
- *pp = empty_option;
-}
-
-/*
* Return the option index found by a pointer into term_strings[].
* Return -1 if not found.
*/
@@ -2714,11 +2465,11 @@ insecure_flag(int opt_idx, int opt_flags)
}
#endif
-#ifdef FEAT_TITLE
+#if defined(FEAT_TITLE) || defined(PROTO)
/*
* 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;
@@ -2726,237 +2477,6 @@ static void redraw_titles(void)
#endif
/*
- * 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".
- */
- void
-set_string_option_direct(
- char_u *name,
- int opt_idx,
- char_u *val,
- int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
- int set_sid UNUSED)
-{
- char_u *s;
- char_u **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) */
- {
- semsg(_(e_intern2), "set_string_option_direct()");
- siemsg(_("For option %s"), name);
- return;
- }
- }
-
- if (options[idx].var == NULL) /* can't set hidden option */
- return;
-
- s = vim_strsave(val);
- if (s != NULL)
- {
- varp = (char_u **)get_varp_scope(&(options[idx]),
- both ? OPT_LOCAL : opt_flags);
- if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
- free_string_option(*varp);
- *varp = s;
-
- /* For buffer/window local option may also set the global value. */
- if (both)
- set_string_option_global(idx, 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(*varp);
- *varp = empty_option;
- }
-# ifdef FEAT_EVAL
- if (set_sid != SID_NONE)
- {
- sctx_T script_ctx;
-
- if (set_sid == 0)
- script_ctx = current_sctx;
- else
- {
- script_ctx.sc_sid = set_sid;
- script_ctx.sc_seq = 0;
- script_ctx.sc_lnum = 0;
- script_ctx.sc_version = 1;
- }
- set_option_sctx_idx(idx, opt_flags, script_ctx);
- }
-# endif
- }
-}
-
-/*
- * Like set_string_option_direct(), but for a window-local option in "wp".
- * Blocks autocommands to avoid the old curwin becoming invalid.
- */
- void
-set_string_option_direct_in_win(
- win_T *wp,
- char_u *name,
- int opt_idx,
- char_u *val,
- int opt_flags,
- int set_sid)
-{
- win_T *save_curwin = curwin;
-
- block_autocmds();
- curwin = wp;
- curbuf = curwin->w_buffer;
- set_string_option_direct(name, opt_idx, val, opt_flags, set_sid);
- curwin = save_curwin;
- curbuf = curwin->w_buffer;
- unblock_autocmds();
-}
-
-/*
- * Like set_string_option_direct(), but for a buffer-local option in "buf".
- * Blocks autocommands to avoid the old curbuf becoming invalid.
- */
- void
-set_string_option_direct_in_buf(
- buf_T *buf,
- char_u *name,
- int opt_idx,
- char_u *val,
- int opt_flags,
- int set_sid)
-{
- buf_T *save_curbuf = curbuf;
-
- block_autocmds();
- curbuf = buf;
- curwin->w_buffer = curbuf;
- set_string_option_direct(name, opt_idx, val, opt_flags, set_sid);
- curbuf = save_curbuf;
- curwin->w_buffer = curbuf;
- unblock_autocmds();
-}
-
-/*
- * Set global value for string option when it's a local option.
- */
- static void
-set_string_option_global(
- int opt_idx, /* option index */
- char_u **varp) /* pointer to option variable */
-{
- char_u **p, *s;
-
- /* the global value is always allocated */
- if (options[opt_idx].var == VAR_WIN)
- p = (char_u **)GLOBAL_WO(varp);
- else
- p = (char_u **)options[opt_idx].var;
- if (options[opt_idx].indir != PV_NONE
- && p != varp
- && (s = vim_strsave(*varp)) != NULL)
- {
- free_string_option(*p);
- *p = s;
- }
-}
-
-/*
- * Set a string option to a new value, and handle the effects.
- *
- * Returns NULL on success or error message on error.
- */
- static char *
-set_string_option(
- int opt_idx,
- char_u *value,
- int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
-{
- char_u *s;
- char_u **varp;
- char_u *oldval;
-#if defined(FEAT_EVAL)
- char_u *oldval_l = NULL;
- char_u *oldval_g = NULL;
- char_u *saved_oldval = NULL;
- char_u *saved_oldval_l = NULL;
- char_u *saved_oldval_g = NULL;
- char_u *saved_newval = NULL;
-#endif
- char *r = NULL;
- int value_checked = FALSE;
-
- if (options[opt_idx].var == NULL) /* don't set hidden option */
- return NULL;
-
- s = vim_strsave(value);
- if (s != NULL)
- {
- varp = (char_u **)get_varp_scope(&(options[opt_idx]),
- (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
- ? (((int)options[opt_idx].indir & PV_BOTH)
- ? OPT_GLOBAL : OPT_LOCAL)
- : opt_flags);
- oldval = *varp;
-#if defined(FEAT_EVAL)
- if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
- {
- oldval_l = *(char_u **)get_varp_scope(&(options[opt_idx]),
- OPT_LOCAL);
- oldval_g = *(char_u **)get_varp_scope(&(options[opt_idx]),
- OPT_GLOBAL);
- }
-#endif
- *varp = s;
-
-#if defined(FEAT_EVAL)
- if (!starting
-# ifdef FEAT_CRYPT
- && options[opt_idx].indir != PV_KEY
-# endif
- )
- {
- if (oldval_l != NULL)
- saved_oldval_l = vim_strsave(oldval_l);
- if (oldval_g != NULL)
- saved_oldval_g = vim_strsave(oldval_g);
- saved_oldval = vim_strsave(oldval);
- saved_newval = vim_strsave(s);
- }
-#endif
- if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
- opt_flags, &value_checked)) == NULL)
- did_set_option(opt_idx, opt_flags, TRUE, value_checked);
-
-#if defined(FEAT_EVAL)
- /* call autocommand after handling side effects */
- if (r == NULL)
- trigger_optionsset_string(opt_idx, opt_flags,
- saved_oldval, saved_oldval_l,
- saved_oldval_g, saved_newval);
- vim_free(saved_oldval);
- vim_free(saved_oldval_l);
- vim_free(saved_oldval_g);
- vim_free(saved_newval);
-#endif
- }
- return r;