comparison src/if_lua.c @ 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 f9d87868d77f
children c424821dc031
comparison
equal deleted inserted replaced
22718:ed40ce4d904f 22719:8da5e18effc5
31 typedef blob_T *luaV_Blob; 31 typedef blob_T *luaV_Blob;
32 typedef struct { 32 typedef struct {
33 char_u *name; // funcref 33 char_u *name; // funcref
34 dict_T *self; // selfdict 34 dict_T *self; // selfdict
35 } luaV_Funcref; 35 } luaV_Funcref;
36 typedef void (*msgfunc_T)(char_u *); 36 typedef int (*msgfunc_T)(char *);
37 37
38 typedef struct { 38 typedef struct {
39 int lua_funcref; // ref to a lua func 39 int lua_funcref; // ref to a lua func
40 int lua_tableref; // ref to a lua table if metatable else LUA_NOREF. used 40 int lua_tableref; // ref to a lua table if metatable else LUA_NOREF. used
41 // for __call 41 // for __call
786 p = s = lua_tolstring(L, -1, &l); 786 p = s = lua_tolstring(L, -1, &l);
787 while (l--) 787 while (l--)
788 { 788 {
789 if (*p++ == '\0') // break? 789 if (*p++ == '\0') // break?
790 { 790 {
791 mf((char_u *) s); 791 mf((char *)s);
792 s = p; 792 s = p;
793 } 793 }
794 } 794 }
795 mf((char_u *) s); 795 mf((char *)s);
796 lua_pop(L, 2); // original and modified strings 796 lua_pop(L, 2); // original and modified strings
797 } 797 }
798 798
799 #define luaV_newtype(typ,tname,luatyp,luatname) \ 799 #define luaV_newtype(typ,tname,luatyp,luatname) \
800 static luatyp * \ 800 static luatyp * \
2370 * ex commands 2370 * ex commands
2371 */ 2371 */
2372 void 2372 void
2373 ex_lua(exarg_T *eap) 2373 ex_lua(exarg_T *eap)
2374 { 2374 {
2375 char *script; 2375 char *script = (char *)script_get(eap, eap->arg);
2376 if (lua_init() == FAIL) return; 2376
2377 script = (char *) script_get(eap, eap->arg); 2377 if (!eap->skip && lua_init() == OK)
2378 if (!eap->skip) 2378 {
2379 { 2379 char *s = script != NULL ? script : (char *)eap->arg;
2380 char *s = (script) ? script : (char *) eap->arg; 2380
2381 luaV_setrange(L, eap->line1, eap->line2); 2381 luaV_setrange(L, eap->line1, eap->line2);
2382 if (luaL_loadbuffer(L, s, strlen(s), LUAVIM_CHUNKNAME) 2382 if (luaL_loadbuffer(L, s, strlen(s), LUAVIM_CHUNKNAME)
2383 || lua_pcall(L, 0, 0, 0)) 2383 || lua_pcall(L, 0, 0, 0))
2384 luaV_emsg(L); 2384 luaV_emsg(L);
2385 } 2385 }
2386 if (script != NULL) vim_free(script); 2386 if (script != NULL)
2387 vim_free(script);
2387 } 2388 }
2388 2389
2389 void 2390 void
2390 ex_luado(exarg_T *eap) 2391 ex_luado(exarg_T *eap)
2391 { 2392 {