summaryrefslogtreecommitdiff
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-08 12:49:47 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-08 12:49:47 +0100
commit8cebd43e9774d2624af43ee5b86939886f2ba490 (patch)
tree8c1ac4046620ab8c9e70d0c3035903086c9d5d67 /src/evalfunc.c
parent59d8e56e048eb5d384649284fb35363931fc3697 (diff)
downloadvim-git-8.2.1968.tar.gz
patch 8.2.1968: Vim9: has() assumes a feature does not change dynamicallyv8.2.1968
Problem: Vim9: has() assumes a feature does not change dynamically. Solution: Check whether a feature may change dynamically. (closes #7265)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 5cc9ad755..6a43120d4 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5484,6 +5484,73 @@ f_has(typval_T *argvars, typval_T *rettv)
}
/*
+ * Return TRUE if "feature" can change later.
+ * Also when checking for the feature has side effects, such as loading a DLL.
+ */
+ int
+dynamic_feature(char_u *feature)
+{
+ return (feature == NULL
+#if defined(FEAT_BEVAL) && defined(FEAT_GUI_MSWIN)
+ || STRICMP(feature, "balloon_multiline") == 0
+#endif
+#if defined(FEAT_GUI) && defined(FEAT_BROWSE)
+ || (STRICMP(feature, "browse") == 0 && !gui.in_use)
+#endif
+#ifdef VIMDLL
+ || STRICMP(feature, "filterpipe") == 0
+#endif
+#if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI)
+ // this can only change on Unix where the ":gui" command could be
+ // used.
+ || (STRICMP(feature, "gui_running") == 0 && !gui.in_use)
+#endif
+#if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
+ || STRICMP(feature, "iconv") == 0
+#endif
+#ifdef DYNAMIC_LUA
+ || STRICMP(feature, "lua") == 0
+#endif
+#ifdef FEAT_MOUSE_GPM
+ || (STRICMP(feature, "mouse_gpm_enabled") == 0 && !gpm_enabled())
+#endif
+#ifdef DYNAMIC_MZSCHEME
+ || STRICMP(feature, "mzscheme") == 0
+#endif
+#ifdef FEAT_NETBEANS_INTG
+ || STRICMP(feature, "netbeans_enabled") == 0
+#endif
+#ifdef DYNAMIC_PERL
+ || STRICMP(feature, "perl") == 0
+#endif
+#ifdef DYNAMIC_PYTHON
+ || STRICMP(feature, "python") == 0
+#endif
+#ifdef DYNAMIC_PYTHON3
+ || STRICMP(feature, "python3") == 0
+#endif
+#if defined(DYNAMIC_PYTHON) || defined(DYNAMIC_PYTHON3)
+ || STRICMP(feature, "pythonx") == 0
+#endif
+#ifdef DYNAMIC_RUBY
+ || STRICMP(feature, "ruby") == 0
+#endif
+#ifdef FEAT_SYN_HL
+ || STRICMP(feature, "syntax_items") == 0
+#endif
+#ifdef DYNAMIC_TCL
+ || STRICMP(feature, "tcl") == 0
+#endif
+ // once "starting" is zero it will stay that way
+ || (STRICMP(feature, "vim_starting") == 0 && starting != 0)
+ || STRICMP(feature, "multi_byte_encoding") == 0
+#if defined(FEAT_TERMINAL) && defined(MSWIN)
+ || STRICMP(feature, "conpty") == 0
+#endif
+ );
+}
+
+/*
* "haslocaldir()" function
*/
static void