Patch 8.2.1908
Problem:    Lua is initialized even when not used.
Solution:   Put lua_init() after check for "eap->skip". (Christian Brabandt,
            closes #7191).  Avoid compiler warnings.
Files:      src/if_lua.c, src/testdir/test_lua.vim


*** ../vim-8.2.1907/src/if_lua.c        2020-07-18 12:50:29.493696710 +0200
--- src/if_lua.c        2020-10-26 20:10:44.097433545 +0100
***************
*** 33,39 ****
      char_u    *name;  // funcref
      dict_T    *self;  // selfdict
  } luaV_Funcref;
! typedef void (*msgfunc_T)(char_u *);
  
  typedef struct {
      int lua_funcref;    // ref to a lua func
--- 33,39 ----
      char_u    *name;  // funcref
      dict_T    *self;  // selfdict
  } luaV_Funcref;
! typedef int (*msgfunc_T)(char *);
  
  typedef struct {
      int lua_funcref;    // ref to a lua func
***************
*** 788,798 ****
      {
        if (*p++ == '\0') // break?
        {
!           mf((char_u *) s);
            s = p;
        }
      }
!     mf((char_u *) s);
      lua_pop(L, 2); // original and modified strings
  }
  
--- 788,798 ----
      {
        if (*p++ == '\0') // break?
        {
!           mf((char *)s);
            s = p;
        }
      }
!     mf((char *)s);
      lua_pop(L, 2); // original and modified strings
  }
  
***************
*** 2372,2389 ****
      void
  ex_lua(exarg_T *eap)
  {
!     char *script;
!     if (lua_init() == FAIL) return;
!     script = (char *) script_get(eap, eap->arg);
!     if (!eap->skip)
      {
!       char *s = (script) ? 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);
  }
  
      void
--- 2372,2390 ----
      void
  ex_lua(exarg_T *eap)
  {
!     char *script = (char *)script_get(eap, eap->arg);
! 
!     if (!eap->skip && lua_init() == OK)
      {
!       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);
  }
  
      void
*** ../vim-8.2.1907/src/testdir/test_lua.vim    2020-07-12 18:33:49.597789885 
+0200
--- src/testdir/test_lua.vim    2020-10-26 20:13:38.808937428 +0100
***************
*** 1,6 ****
--- 1,14 ----
  " Tests for Lua.
  
  source check.vim
+ 
+ " This test also works without the lua feature.
+ func Test_skip_lua()
+   if 0
+     lua print("Not executed")
+   endif
+ endfunc
+ 
  CheckFeature lua
  CheckFeature float
  
*** ../vim-8.2.1907/src/version.c       2020-10-26 19:22:35.513731793 +0100
--- src/version.c       2020-10-26 20:14:38.696766779 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1908,
  /**/

-- 
In a world without fences, who needs Gates and Windows?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010261918.09QJIXkn1677040%40masaka.moolenaar.net.

Raspunde prin e-mail lui