Mercurial > vim
changeset 22719:8da5e18effc5 v8.2.1908
patch 8.2.1908: Lua is initialized even when not used
Commit: https://github.com/vim/vim/commit/c8970b94645d0730f4a7cc42388ff32665398e8b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 26 20:18:08 2020 +0100
patch 8.2.1908: Lua is initialized even when not used
Problem: Lua is initialized even when not used.
Solution: Put lua_init() after check for "eap->skip". (Christian Brabandt,
closes #7191). Avoid compiler warnings.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Oct 2020 20:30:03 +0100 |
parents | ed40ce4d904f |
children | 51ceeb95d655 |
files | src/if_lua.c src/testdir/test_lua.vim src/version.c |
diffstat | 3 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if_lua.c +++ b/src/if_lua.c @@ -33,7 +33,7 @@ typedef struct { char_u *name; // funcref dict_T *self; // selfdict } luaV_Funcref; -typedef void (*msgfunc_T)(char_u *); +typedef int (*msgfunc_T)(char *); typedef struct { int lua_funcref; // ref to a lua func @@ -788,11 +788,11 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf) { if (*p++ == '\0') // break? { - mf((char_u *) s); + mf((char *)s); s = p; } } - mf((char_u *) s); + mf((char *)s); lua_pop(L, 2); // original and modified strings } @@ -2372,18 +2372,19 @@ lua_end(void) void ex_lua(exarg_T *eap) { - char *script; - if (lua_init() == FAIL) return; - script = (char *) script_get(eap, eap->arg); - if (!eap->skip) + char *script = (char *)script_get(eap, eap->arg); + + if (!eap->skip && lua_init() == OK) { - char *s = (script) ? script : (char *) eap->arg; + char *s = script != NULL ? script : (char *)eap->arg; + luaV_setrange(L, eap->line1, eap->line2); if (luaL_loadbuffer(L, s, strlen(s), LUAVIM_CHUNKNAME) || lua_pcall(L, 0, 0, 0)) luaV_emsg(L); } - if (script != NULL) vim_free(script); + if (script != NULL) + vim_free(script); } void