From 8cebd43e9774d2624af43ee5b86939886f2ba490 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 8 Nov 2020 12:49:47 +0100 Subject: patch 8.2.1968: Vim9: has() assumes a feature does not change dynamically Problem: Vim9: has() assumes a feature does not change dynamically. Solution: Check whether a feature may change dynamically. (closes #7265) --- src/evalfunc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'src/evalfunc.c') diff --git a/src/evalfunc.c b/src/evalfunc.c index 5cc9ad755..6a43120d4 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5483,6 +5483,73 @@ f_has(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = n; } +/* + * 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 */ -- cgit v1.2.1