Patch 9.0.1183
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11805)
Files:      src/if_cscope.c, src/if_lua.c, src/if_mzsch.c, src/if_python.c,
            src/if_python3.c, src/if_ruby.c, src/if_xcmdsrv.c, src/indent.c


*** ../vim-9.0.1182/src/if_cscope.c     2022-10-13 16:34:27.130724804 +0100
--- src/if_cscope.c     2023-01-12 12:30:17.296724449 +0000
***************
*** 221,245 ****
      expand_what = (cmdidx == CMD_scscope)
                        ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
  
      // (part of) subcommand already typed
!     if (*arg != NUL)
!     {
!       p = skiptowhite(arg);
!       if (*p != NUL)              // past first word
!       {
!           xp->xp_pattern = skipwhite(p);
!           if (*skiptowhite(xp->xp_pattern) != NUL)
!               xp->xp_context = EXPAND_NOTHING;
!           else if (STRNICMP(arg, "add", p - arg) == 0)
!               xp->xp_context = EXPAND_FILES;
!           else if (STRNICMP(arg, "kill", p - arg) == 0)
!               expand_what = EXP_CSCOPE_KILL;
!           else if (STRNICMP(arg, "find", p - arg) == 0)
!               expand_what = EXP_CSCOPE_FIND;
!           else
!               xp->xp_context = EXPAND_NOTHING;
!       }
!     }
  }
  
  /*
--- 221,246 ----
      expand_what = (cmdidx == CMD_scscope)
                        ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
  
+     if (*arg == NUL)
+       return;
+ 
      // (part of) subcommand already typed
!     p = skiptowhite(arg);
!     if (*p == NUL)
!       return;
! 
!     // past first word
!     xp->xp_pattern = skipwhite(p);
!     if (*skiptowhite(xp->xp_pattern) != NUL)
!       xp->xp_context = EXPAND_NOTHING;
!     else if (STRNICMP(arg, "add", p - arg) == 0)
!       xp->xp_context = EXPAND_FILES;
!     else if (STRNICMP(arg, "kill", p - arg) == 0)
!       expand_what = EXP_CSCOPE_KILL;
!     else if (STRNICMP(arg, "find", p - arg) == 0)
!       expand_what = EXP_CSCOPE_FIND;
!     else
!       xp->xp_context = EXPAND_NOTHING;
  }
  
  /*
*** ../vim-9.0.1182/src/if_lua.c        2022-11-25 16:31:46.968606662 +0000
--- src/if_lua.c        2023-01-12 12:30:17.296724449 +0000
***************
*** 505,522 ****
  {
      void *p = lua_touserdata(L, ud);
  
!     if (p != NULL) // value is userdata?
      {
!       if (lua_getmetatable(L, ud)) // does it have a metatable?
        {
!           luaV_getfield(L, tname); // get metatable
!           if (lua_rawequal(L, -1, -2)) // MTs match?
!           {
!               lua_pop(L, 2); // MTs
!               return p;
!           }
        }
      }
      return NULL;
  }
  
--- 505,524 ----
  {
      void *p = lua_touserdata(L, ud);
  
!     if (p == NULL)
!       return NULL;
! 
!     // value is userdata
!     if (lua_getmetatable(L, ud)) // does it have a metatable?
      {
!       luaV_getfield(L, tname); // get metatable
!       if (lua_rawequal(L, -1, -2)) // MTs match?
        {
!           lua_pop(L, 2); // MTs
!           return p;
        }
      }
+ 
      return NULL;
  }
  
***************
*** 1090,1106 ****
      dictitem_T *di = dict_find(d, key, -1);
  
      if (di == NULL)
        lua_pushnil(L);
!     else
      {
!       luaV_pushtypval(L, &di->di_tv);
!       if (di->di_tv.v_type == VAR_FUNC) // funcref?
!       {
!           luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1);
!           f->self = d; // keep "self" reference
!           d->dv_refcount++;
!       }
      }
      return 1;
  }
  
--- 1092,1110 ----
      dictitem_T *di = dict_find(d, key, -1);
  
      if (di == NULL)
+     {
        lua_pushnil(L);
!       return 1;
!     }
! 
!     luaV_pushtypval(L, &di->di_tv);
!     if (di->di_tv.v_type == VAR_FUNC) // funcref?
      {
!       luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1);
!       f->self = d; // keep "self" reference
!       d->dv_refcount++;
      }
+ 
      return 1;
  }
  
***************
*** 1235,1254 ****
      blob_T *b = luaV_unbox(L, luaV_Blob, 1);
      if (b->bv_lock)
        luaL_error(L, "blob is locked");
!     if (lua_isnumber(L, 2))
!     {
!       long len = blob_len(b);
!       int idx = luaL_checkinteger(L, 2);
!       int val = luaL_checkinteger(L, 3);
!       if (idx < len || (idx == len && ga_grow(&b->bv_ga, 1) == OK))
!       {
!           blob_set(b, idx, (char_u) val);
!           if (idx == len)
!               ++b->bv_ga.ga_len;
!       }
!       else
!           luaL_error(L, "index out of range");
      }
      return 0;
  }
  
--- 1239,1260 ----
      blob_T *b = luaV_unbox(L, luaV_Blob, 1);
      if (b->bv_lock)
        luaL_error(L, "blob is locked");
! 
!     if (!lua_isnumber(L, 2))
!       return 0;
! 
!     long len = blob_len(b);
!     int idx = luaL_checkinteger(L, 2);
!     int val = luaL_checkinteger(L, 3);
!     if (idx < len || (idx == len && ga_grow(&b->bv_ga, 1) == OK))
!     {
!       blob_set(b, idx, (char_u) val);
!       if (idx == len)
!           ++b->bv_ga.ga_len;
      }
+     else
+       luaL_error(L, "index out of range");
+ 
      return 0;
  }
  
***************
*** 1943,1972 ****
  
      if (initarg && lua_type(L, 1) != LUA_TTABLE)
        luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
      l = list_alloc();
      if (l == NULL)
        lua_pushnil(L);
!     else
      {
!       luaV_newlist(L, l);
!       if (initarg) // traverse table to init list
        {
!           int notnil, i = 0;
!           typval_T v;
!           do
!           {
!               lua_rawgeti(L, 1, ++i);
!               notnil = !lua_isnil(L, -1);
!               if (notnil)
!               {
!                   luaV_checktypval(L, -1, &v, "vim.list");
!                   list_append_tv(l, &v);
!                   clear_tv(&v);
!               }
!               lua_pop(L, 1); // value
!           } while (notnil);
        }
!     }
      return 1;
  }
  
--- 1949,1982 ----
  
      if (initarg && lua_type(L, 1) != LUA_TTABLE)
        luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
+ 
      l = list_alloc();
      if (l == NULL)
+     {
        lua_pushnil(L);
!       return 1;
!     }
! 
!     luaV_newlist(L, l);
!     if (!initarg)
!       return 1;
! 
!     // traverse table to init list
!     int notnil, i = 0;
!     typval_T v;
!     do
      {
!       lua_rawgeti(L, 1, ++i);
!       notnil = !lua_isnil(L, -1);
!       if (notnil)
        {
!           luaV_checktypval(L, -1, &v, "vim.list");
!           list_append_tv(l, &v);
!           clear_tv(&v);
        }
!       lua_pop(L, 1); // value
!     } while (notnil);
! 
      return 1;
  }
  
***************
*** 1978,2020 ****
  
      if (initarg && lua_type(L, 1) != LUA_TTABLE)
        luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
      d = dict_alloc();
      if (d == NULL)
        lua_pushnil(L);
!     else
      {
!       luaV_newdict(L, d);
!       if (initarg) // traverse table to init dict
        {
            lua_pushnil(L);
!           while (lua_next(L, 1))
!           {
!               char_u *key;
!               dictitem_T *di;
!               typval_T v;
! 
!               lua_pushvalue(L, -2); // dup key in case it's a number
!               key = (char_u *) lua_tostring(L, -1);
!               if (key == NULL)
!               {
!                   lua_pushnil(L);
!                   return 1;
!               }
!               if (*key == NUL)
!                   luaL_error(L, "table has empty key");
!               luaV_checktypval(L, -2, &v, "vim.dict"); // value
!               di = dictitem_alloc(key);
!               if (di == NULL || dict_add(d, di) == FAIL)
!               {
!                   vim_free(di);
!                   lua_pushnil(L);
!                   return 1;
!               }
!               di->di_tv = v;
!               lua_pop(L, 2); // key copy and value
!           }
        }
      }
      return 1;
  }
  
--- 1988,2034 ----
  
      if (initarg && lua_type(L, 1) != LUA_TTABLE)
        luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
+ 
      d = dict_alloc();
      if (d == NULL)
+     {
        lua_pushnil(L);
!       return 1;
!     }
! 
!     luaV_newdict(L, d);
!     if (!initarg)
!       return 1;
! 
!     // traverse table to init dict
!     lua_pushnil(L);
!     while (lua_next(L, 1))
      {
!       char_u *key;
!       dictitem_T *di;
!       typval_T v;
! 
!       lua_pushvalue(L, -2); // dup key in case it's a number
!       key = (char_u *) lua_tostring(L, -1);
!       if (key == NULL)
        {
            lua_pushnil(L);
!           return 1;
!       }
!       if (*key == NUL)
!           luaL_error(L, "table has empty key");
!       luaV_checktypval(L, -2, &v, "vim.dict"); // value
!       di = dictitem_alloc(key);
!       if (di == NULL || dict_add(d, di) == FAIL)
!       {
!           vim_free(di);
!           lua_pushnil(L);
!           return 1;
        }
+       di->di_tv = v;
+       lua_pop(L, 2); // key copy and value
      }
+ 
      return 1;
  }
  
***************
*** 2026,2047 ****
  
      if (initarg && !lua_isstring(L, 1))
        luaL_error(L, "string expected, got %s", luaL_typename(L, 1));
      b = blob_alloc();
      if (b == NULL)
-       lua_pushnil(L);
-     else
      {
!       luaV_newblob(L, b);
!       if (initarg)
!       {
!           size_t i, l = 0;
!           const char *s = lua_tolstring(L, 1, &l);
! 
!           if (ga_grow(&b->bv_ga, (int)l) == OK)
!               for (i = 0; i < l; ++i)
!                   ga_append(&b->bv_ga, s[i]);
!       }
      }
      return 1;
  }
  
--- 2040,2065 ----
  
      if (initarg && !lua_isstring(L, 1))
        luaL_error(L, "string expected, got %s", luaL_typename(L, 1));
+ 
      b = blob_alloc();
      if (b == NULL)
      {
!       lua_pushnil(L);
!       return 1;
      }
+ 
+     luaV_newblob(L, b);
+     if (!initarg)
+       return 1;
+ 
+     // traverse table to init blob
+     size_t i, l = 0;
+     const char *s = lua_tolstring(L, 1, &l);
+ 
+     if (ga_grow(&b->bv_ga, (int)l) == OK)
+       for (i = 0; i < l; ++i)
+           ga_append(&b->bv_ga, s[i]);
+ 
      return 1;
  }
  
***************
*** 2548,2575 ****
      static int
  lua_init(void)
  {
!     if (!lua_isopen())
!     {
  #ifdef DYNAMIC_LUA
!       if (!lua_enabled(TRUE))
!       {
!           emsg(_("Lua library cannot be loaded."));
!           return FAIL;
!       }
! #endif
!       L = luaV_newstate();
      }
      return OK;
  }
  
      void
  lua_end(void)
  {
!     if (lua_isopen())
!     {
!       lua_close(L);
!       L = NULL;
!     }
  }
  
  /*
--- 2566,2594 ----
      static int
  lua_init(void)
  {
!     if (lua_isopen())
!       return OK;
! 
  #ifdef DYNAMIC_LUA
!     if (!lua_enabled(TRUE))
!     {
!       emsg(_("Lua library cannot be loaded."));
!       return FAIL;
      }
+ #endif
+     L = luaV_newstate();
+ 
      return OK;
  }
  
      void
  lua_end(void)
  {
!     if (!lua_isopen())
!       return;
! 
!     lua_close(L);
!     L = NULL;
  }
  
  /*
***************
*** 2698,2728 ****
  {
      int aborted = 0;
  
!     if (lua_isopen())
!     {
!       luaV_getfield(L, LUAVIM_SETREF);
!       // call the function with 1 arg, getting 1 result back
!       lua_pushinteger(L, copyID);
!       lua_call(L, 1, 1);
!       // get the result
!       aborted = lua_tointeger(L, -1);
!       // pop result off the stack
!       lua_pop(L, 1);
!     }
      return aborted;
  }
  
      void
  update_package_paths_in_lua()
  {
!     if (lua_isopen())
!     {
!       lua_getglobal(L, "vim");
!       lua_getfield(L, -1, "_update_package_paths");
  
!       if (lua_pcall(L, 0, 0, 0))
!           luaV_emsg(L);
!     }
  }
  
  /*
--- 2717,2748 ----
  {
      int aborted = 0;
  
!     if (!lua_isopen())
!       return 0;
! 
!     luaV_getfield(L, LUAVIM_SETREF);
!     // call the function with 1 arg, getting 1 result back
!     lua_pushinteger(L, copyID);
!     lua_call(L, 1, 1);
!     // get the result
!     aborted = lua_tointeger(L, -1);
!     // pop result off the stack
!     lua_pop(L, 1);
! 
      return aborted;
  }
  
      void
  update_package_paths_in_lua()
  {
!     if (!lua_isopen())
!       return;
  
!     lua_getglobal(L, "vim");
!     lua_getfield(L, -1, "_update_package_paths");
! 
!     if (lua_pcall(L, 0, 0, 0))
!       luaV_emsg(L);
  }
  
  /*
*** ../vim-9.0.1182/src/if_mzsch.c      2022-10-04 16:23:39.006042192 +0100
--- src/if_mzsch.c      2023-01-12 12:30:17.300724443 +0000
***************
*** 1352,1375 ****
      void
  mzscheme_buffer_free(buf_T *buf)
  {
!     if (buf->b_mzscheme_ref)
!     {
!       vim_mz_buffer *bp = NULL;
!       MZ_GC_DECL_REG(1);
!       MZ_GC_VAR_IN_REG(0, bp);
!       MZ_GC_REG();
  
!       bp = BUFFER_REF(buf);
!       bp->buf = INVALID_BUFFER_VALUE;
  #ifndef MZ_PRECISE_GC
!       scheme_gc_ptr_ok(bp);
  #else
!       scheme_free_immobile_box(buf->b_mzscheme_ref);
  #endif
!       buf->b_mzscheme_ref = NULL;
!       MZ_GC_CHECK();
!       MZ_GC_UNREG();
!     }
  }
  
  /*
--- 1352,1375 ----
      void
  mzscheme_buffer_free(buf_T *buf)
  {
!     if (buf->b_mzscheme_ref == NULL)
!       return;
  
!     vim_mz_buffer *bp = NULL;
!     MZ_GC_DECL_REG(1);
!     MZ_GC_VAR_IN_REG(0, bp);
!     MZ_GC_REG();
! 
!     bp = BUFFER_REF(buf);
!     bp->buf = INVALID_BUFFER_VALUE;
  #ifndef MZ_PRECISE_GC
!     scheme_gc_ptr_ok(bp);
  #else
!     scheme_free_immobile_box(buf->b_mzscheme_ref);
  #endif
!     buf->b_mzscheme_ref = NULL;
!     MZ_GC_CHECK();
!     MZ_GC_UNREG();
  }
  
  /*
***************
*** 1378,1400 ****
      void
  mzscheme_window_free(win_T *win)
  {
!     if (win->w_mzscheme_ref)
!     {
!       vim_mz_window *wp = NULL;
!       MZ_GC_DECL_REG(1);
!       MZ_GC_VAR_IN_REG(0, wp);
!       MZ_GC_REG();
!       wp = WINDOW_REF(win);
!       wp->win = INVALID_WINDOW_VALUE;
  #ifndef MZ_PRECISE_GC
!       scheme_gc_ptr_ok(wp);
  #else
!       scheme_free_immobile_box(win->w_mzscheme_ref);
  #endif
!       win->w_mzscheme_ref = NULL;
!       MZ_GC_CHECK();
!       MZ_GC_UNREG();
!     }
  }
  
  /*
--- 1378,1400 ----
      void
  mzscheme_window_free(win_T *win)
  {
!     if (win->w_mzscheme_ref == NULL)
!       return;
! 
!     vim_mz_window *wp = NULL;
!     MZ_GC_DECL_REG(1);
!     MZ_GC_VAR_IN_REG(0, wp);
!     MZ_GC_REG();
!     wp = WINDOW_REF(win);
!     wp->win = INVALID_WINDOW_VALUE;
  #ifndef MZ_PRECISE_GC
!     scheme_gc_ptr_ok(wp);
  #else
!     scheme_free_immobile_box(win->w_mzscheme_ref);
  #endif
!     win->w_mzscheme_ref = NULL;
!     MZ_GC_CHECK();
!     MZ_GC_UNREG();
  }
  
  /*
***************
*** 1406,1420 ****
      char_u    *script;
  
      script = script_get(eap, eap->arg);
!     if (!eap->skip)
      {
!       if (script == NULL)
!           do_mzscheme_command(eap, eap->arg, do_eval);
!       else
!       {
!           do_mzscheme_command(eap, script, do_eval);
!           vim_free(script);
!       }
      }
  }
  
--- 1406,1420 ----
      char_u    *script;
  
      script = script_get(eap, eap->arg);
!     if (eap->skip)
!       return;
! 
!     if (script == NULL)
!       do_mzscheme_command(eap, eap->arg, do_eval);
!     else
      {
!       do_mzscheme_command(eap, script, do_eval);
!       vim_free(script);
      }
  }
  
***************
*** 1489,1508 ****
      static void
  init_exn_catching_apply(void)
  {
!     if (!exn_catching_apply)
!     {
!       char *e =
!           "(lambda (thunk) "
!               "(with-handlers ([void (lambda (exn) (cons #f exn))]) "
!               "(cons #t (thunk))))";
  
!       exn_catching_apply = scheme_eval_string(e, environment);
!       MZ_GC_CHECK();
!       exn_p = scheme_builtin_value("exn?");
!       MZ_GC_CHECK();
!       exn_message = scheme_builtin_value("exn-message");
!       MZ_GC_CHECK();
!     }
  }
  
  /*
--- 1489,1508 ----
      static void
  init_exn_catching_apply(void)
  {
!     if (exn_catching_apply)
!       return;
  
!     char *e =
!       "(lambda (thunk) "
!       "(with-handlers ([void (lambda (exn) (cons #f exn))]) "
!       "(cons #t (thunk))))";
! 
!     exn_catching_apply = scheme_eval_string(e, environment);
!     MZ_GC_CHECK();
!     exn_p = scheme_builtin_value("exn?");
!     MZ_GC_CHECK();
!     exn_message = scheme_builtin_value("exn-message");
!     MZ_GC_CHECK();
  }
  
  /*
***************
*** 3827,3870 ****
      static Scheme_Object *
  sandbox_file_guard(int argc UNUSED, Scheme_Object **argv)
  {
!     if (sandbox)
!     {
!       Scheme_Object *requested_access = argv[2];
  
!       if (M_write == NULL)
!       {
!           MZ_REGISTER_STATIC(M_write);
!           M_write = scheme_intern_symbol("write");
!           MZ_GC_CHECK();
!       }
!       if (M_read == NULL)
!       {
!           MZ_REGISTER_STATIC(M_read);
!           M_read = scheme_intern_symbol("read");
!           MZ_GC_CHECK();
!       }
!       if (M_execute == NULL)
!       {
!           MZ_REGISTER_STATIC(M_execute);
!           M_execute = scheme_intern_symbol("execute");
!           MZ_GC_CHECK();
!       }
!       if (M_delete == NULL)
!       {
!           MZ_REGISTER_STATIC(M_delete);
!           M_delete = scheme_intern_symbol("delete");
!           MZ_GC_CHECK();
!       }
  
!       while (!SCHEME_NULLP(requested_access))
!       {
!           Scheme_Object *item = SCHEME_CAR(requested_access);
!           if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
!                   || scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
!               raise_vim_exn(_("not allowed in the Vim sandbox"));
!           requested_access = SCHEME_CDR(requested_access);
!       }
      }
      return scheme_void;
  }
  
--- 3827,3871 ----
      static Scheme_Object *
  sandbox_file_guard(int argc UNUSED, Scheme_Object **argv)
  {
!     if (!sandbox)
!       return scheme_void;
  
!     Scheme_Object *requested_access = argv[2];
  
!     if (M_write == NULL)
!     {
!       MZ_REGISTER_STATIC(M_write);
!       M_write = scheme_intern_symbol("write");
!       MZ_GC_CHECK();
!     }
!     if (M_read == NULL)
!     {
!       MZ_REGISTER_STATIC(M_read);
!       M_read = scheme_intern_symbol("read");
!       MZ_GC_CHECK();
!     }
!     if (M_execute == NULL)
!     {
!       MZ_REGISTER_STATIC(M_execute);
!       M_execute = scheme_intern_symbol("execute");
!       MZ_GC_CHECK();
!     }
!     if (M_delete == NULL)
!     {
!       MZ_REGISTER_STATIC(M_delete);
!       M_delete = scheme_intern_symbol("delete");
!       MZ_GC_CHECK();
      }
+ 
+     while (!SCHEME_NULLP(requested_access))
+     {
+       Scheme_Object *item = SCHEME_CAR(requested_access);
+       if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
+               || scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
+           raise_vim_exn(_("not allowed in the Vim sandbox"));
+       requested_access = SCHEME_CDR(requested_access);
+     }
+ 
      return scheme_void;
  }
  
*** ../vim-9.0.1182/src/if_python.c     2022-01-05 18:57:05.000000000 +0000
--- src/if_python.c     2023-01-12 12:30:17.300724443 +0000
***************
*** 1393,1426 ****
      void
  python_buffer_free(buf_T *buf)
  {
!     if (BUF_PYTHON_REF(buf) != NULL)
!     {
!       BufferObject *bp = BUF_PYTHON_REF(buf);
!       bp->buf = INVALID_BUFFER_VALUE;
!       BUF_PYTHON_REF(buf) = NULL;
!     }
  }
  
      void
  python_window_free(win_T *win)
  {
!     if (WIN_PYTHON_REF(win) != NULL)
!     {
!       WindowObject *wp = WIN_PYTHON_REF(win);
!       wp->win = INVALID_WINDOW_VALUE;
!       WIN_PYTHON_REF(win) = NULL;
!     }
  }
  
      void
  python_tabpage_free(tabpage_T *tab)
  {
!     if (TAB_PYTHON_REF(tab) != NULL)
!     {
!       TabPageObject *tp = TAB_PYTHON_REF(tab);
!       tp->tab = INVALID_TABPAGE_VALUE;
!       TAB_PYTHON_REF(tab) = NULL;
!     }
  }
  
      static int
--- 1393,1423 ----
      void
  python_buffer_free(buf_T *buf)
  {
!     BufferObject *bp = BUF_PYTHON_REF(buf);
!     if (bp == NULL)
!       return;
!     bp->buf = INVALID_BUFFER_VALUE;
!     BUF_PYTHON_REF(buf) = NULL;
  }
  
      void
  python_window_free(win_T *win)
  {
!     WindowObject *wp = WIN_PYTHON_REF(win);
!     if (wp == NULL)
!       return;
!     wp->win = INVALID_WINDOW_VALUE;
!     WIN_PYTHON_REF(win) = NULL;
  }
  
      void
  python_tabpage_free(tabpage_T *tab)
  {
!     TabPageObject *tp = TAB_PYTHON_REF(tab);
!     if (tp == NULL)
!       return;
!     tp->tab = INVALID_TABPAGE_VALUE;
!     TAB_PYTHON_REF(tab) = NULL;
  }
  
      static int
*** ../vim-9.0.1182/src/if_python3.c    2022-12-26 14:46:43.705801198 +0000
--- src/if_python3.c    2023-01-12 12:30:17.300724443 +0000
***************
*** 1835,1868 ****
      void
  python3_buffer_free(buf_T *buf)
  {
!     if (BUF_PYTHON_REF(buf) != NULL)
!     {
!       BufferObject *bp = BUF_PYTHON_REF(buf);
!       bp->buf = INVALID_BUFFER_VALUE;
!       BUF_PYTHON_REF(buf) = NULL;
!     }
  }
  
      void
  python3_window_free(win_T *win)
  {
!     if (WIN_PYTHON_REF(win) != NULL)
!     {
!       WindowObject *wp = WIN_PYTHON_REF(win);
!       wp->win = INVALID_WINDOW_VALUE;
!       WIN_PYTHON_REF(win) = NULL;
!     }
  }
  
      void
  python3_tabpage_free(tabpage_T *tab)
  {
!     if (TAB_PYTHON_REF(tab) != NULL)
!     {
!       TabPageObject *tp = TAB_PYTHON_REF(tab);
!       tp->tab = INVALID_TABPAGE_VALUE;
!       TAB_PYTHON_REF(tab) = NULL;
!     }
  }
  
      static PyObject *
--- 1835,1865 ----
      void
  python3_buffer_free(buf_T *buf)
  {
!     BufferObject *bp = BUF_PYTHON_REF(buf);
!     if (bp == NULL)
!       return;
!     bp->buf = INVALID_BUFFER_VALUE;
!     BUF_PYTHON_REF(buf) = NULL;
  }
  
      void
  python3_window_free(win_T *win)
  {
!     WindowObject *wp = WIN_PYTHON_REF(win);
!     if (wp == NULL)
!       return;
!     wp->win = INVALID_WINDOW_VALUE;
!     WIN_PYTHON_REF(win) = NULL;
  }
  
      void
  python3_tabpage_free(tabpage_T *tab)
  {
!     TabPageObject *tp = TAB_PYTHON_REF(tab);
!     if (tp == NULL)
!       return;
!     tp->tab = INVALID_TABPAGE_VALUE;
!     TAB_PYTHON_REF(tab) = NULL;
  }
  
      static PyObject *
*** ../vim-9.0.1182/src/if_ruby.c       2022-11-28 18:51:38.963571609 +0000
--- src/if_ruby.c       2023-01-12 12:30:17.300724443 +0000
***************
*** 866,909 ****
      linenr_T i;
      buf_T   *was_curbuf = curbuf;
  
!     if (ensure_ruby_initialized())
      {
!       if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
!           return;
!       for (i = eap->line1; i <= eap->line2; i++)
!       {
!           VALUE line;
  
!           if (i > curbuf->b_ml.ml_line_count)
!               break;
!           line = vim_str2rb_enc_str((char *)ml_get(i));
!           rb_lastline_set(line);
!           eval_enc_string_protect((char *) eap->arg, &state);
!           if (state)
            {
!               error_print(state);
!               break;
            }
!           if (was_curbuf != curbuf)
!               break;
!           line = rb_lastline_get();
!           if (!NIL_P(line))
!           {
!               if (TYPE(line) != T_STRING)
!               {
!                   emsg(_(e_dollar_must_be_an_instance_of_string));
!                   return;
!               }
!               ml_replace(i, (char_u *) StringValuePtr(line), 1);
!               changed();
  #ifdef SYNTAX_HL
!               syn_changed(i); // recompute syntax hl. for this line
  #endif
-           }
        }
-       check_cursor();
-       update_curbuf(UPD_NOT_VALID);
      }
  }
  
      static VALUE
--- 866,909 ----
      linenr_T i;
      buf_T   *was_curbuf = curbuf;
  
!     if (!ensure_ruby_initialized())
!       return;
! 
!     if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
!       return;
!     for (i = eap->line1; i <= eap->line2; i++)
      {
!       VALUE line;
  
!       if (i > curbuf->b_ml.ml_line_count)
!           break;
!       line = vim_str2rb_enc_str((char *)ml_get(i));
!       rb_lastline_set(line);
!       eval_enc_string_protect((char *) eap->arg, &state);
!       if (state)
!       {
!           error_print(state);
!           break;
!       }
!       if (was_curbuf != curbuf)
!           break;
!       line = rb_lastline_get();
!       if (!NIL_P(line))
!       {
!           if (TYPE(line) != T_STRING)
            {
!               emsg(_(e_dollar_must_be_an_instance_of_string));
!               return;
            }
!           ml_replace(i, (char_u *) StringValuePtr(line), 1);
!           changed();
  #ifdef SYNTAX_HL
!           syn_changed(i); // recompute syntax hl. for this line
  #endif
        }
      }
+     check_cursor();
+     update_curbuf(UPD_NOT_VALID);
  }
  
      static VALUE
***************
*** 918,990 ****
  {
      int state;
  
!     if (ensure_ruby_initialized())
!     {
!       VALUE file_to_load = rb_str_new2((const char *)eap->arg);
!       rb_protect(rb_load_wrap, file_to_load, &state);
!       if (state)
!           error_print(state);
!     }
  }
  
      void
  ruby_buffer_free(buf_T *buf)
  {
!     if (buf->b_ruby_ref)
!     {
!       rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
!       RDATA(buf->b_ruby_ref)->data = NULL;
!     }
  }
  
      void
  ruby_window_free(win_T *win)
  {
!     if (win->w_ruby_ref)
!     {
!       rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
!       RDATA(win->w_ruby_ref)->data = NULL;
!     }
  }
  
      static int
  ensure_ruby_initialized(void)
  {
!     if (!ruby_initialized)
!     {
  #ifdef DYNAMIC_RUBY
!       if (ruby_enabled(TRUE))
  #endif
!       {
  #ifdef MSWIN
!           // suggested by Ariya Mizutani
!           int argc = 1;
!           char *argv[] = {"gvim.exe"};
!           char **argvp = argv;
!           ruby_sysinit(&argc, &argvp);
  #endif
!           {
!               ruby_init_stack(ruby_stack_start);
!               ruby_init();
!           }
!           {
!               int dummy_argc = 2;
!               char *dummy_argv[] = {"vim-ruby", "-e_=0"};
!               ruby_options(dummy_argc, dummy_argv);
!           }
!           ruby_script("vim-ruby");
!           ruby_io_init();
!           ruby_vim_init();
!           ruby_initialized = 1;
        }
- #ifdef DYNAMIC_RUBY
-       else
        {
!           
emsg(_(e_sorry_this_command_is_disabled_the_ruby_library_could_not_be_loaded));
!           return 0;
        }
! #endif
      }
      return ruby_initialized;
  }
  
--- 918,991 ----
  {
      int state;
  
!     if (!ensure_ruby_initialized())
!       return;
! 
!     VALUE file_to_load = rb_str_new2((const char *)eap->arg);
!     rb_protect(rb_load_wrap, file_to_load, &state);
!     if (state)
!       error_print(state);
  }
  
      void
  ruby_buffer_free(buf_T *buf)
  {
!     if (buf->b_ruby_ref == NULL)
!       return;
! 
!     rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
!     RDATA(buf->b_ruby_ref)->data = NULL;
  }
  
      void
  ruby_window_free(win_T *win)
  {
!     if (win->w_ruby_ref == NULL)
!       return;
! 
!     rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
!     RDATA(win->w_ruby_ref)->data = NULL;
  }
  
      static int
  ensure_ruby_initialized(void)
  {
!     if (ruby_initialized)
!       return ruby_initialized;
! 
  #ifdef DYNAMIC_RUBY
!     if (ruby_enabled(TRUE))
  #endif
!     {
  #ifdef MSWIN
!       // suggested by Ariya Mizutani
!       int argc = 1;
!       char *argv[] = {"gvim.exe"};
!       char **argvp = argv;
!       ruby_sysinit(&argc, &argvp);
  #endif
!       {
!           ruby_init_stack(ruby_stack_start);
!           ruby_init();
        }
        {
!           int dummy_argc = 2;
!           char *dummy_argv[] = {"vim-ruby", "-e_=0"};
!           ruby_options(dummy_argc, dummy_argv);
        }
!       ruby_script("vim-ruby");
!       ruby_io_init();
!       ruby_vim_init();
!       ruby_initialized = 1;
      }
+ #ifdef DYNAMIC_RUBY
+     else
+     {
+       
emsg(_(e_sorry_this_command_is_disabled_the_ruby_library_could_not_be_loaded));
+       return 0;
+     }
+ #endif
+ 
      return ruby_initialized;
  }
  
*** ../vim-9.0.1182/src/if_xcmdsrv.c    2022-11-30 18:11:52.686904299 +0000
--- src/if_xcmdsrv.c    2023-01-12 12:30:17.300724443 +0000
***************
*** 221,251 ****
      char_u    *p = NULL;
  
      res = DoRegisterName(dpy, name);
!     if (res < 0)
      {
!       i = 1;
!       do
        {
!           if (res < -1 || i >= 1000)
!           {
!               msg_attr(_("Unable to register a command server name"),
!                                                             HL_ATTR(HLF_W));
!               return FAIL;
!           }
!           if (p == NULL)
!               p = alloc(STRLEN(name) + 10);
!           if (p == NULL)
!           {
!               res = -10;
!               continue;
!           }
!           sprintf((char *)p, "%s%d", name, i++);
!           res = DoRegisterName(dpy, p);
        }
!       while (res < 0)
!           ;
!       vim_free(p);
      }
      return OK;
  }
  
--- 221,252 ----
      char_u    *p = NULL;
  
      res = DoRegisterName(dpy, name);
!     if (res >= 0)
!       return OK;
! 
!     i = 1;
!     do
      {
!       if (res < -1 || i >= 1000)
        {
!           msg_attr(_("Unable to register a command server name"),
!                   HL_ATTR(HLF_W));
!           return FAIL;
!       }
!       if (p == NULL)
!           p = alloc(STRLEN(name) + 10);
!       if (p == NULL)
!       {
!           res = -10;
!           continue;
        }
!       sprintf((char *)p, "%s%d", name, i++);
!       res = DoRegisterName(dpy, p);
      }
+     while (res < 0)
+       ;
+     vim_free(p);
+ 
      return OK;
  }
  
***************
*** 756,772 ****
        return -1;
  
      length = STRLEN(p_enc) + STRLEN(str) + 14;
!     if ((property = alloc(length + 30)) != NULL)
!     {
!       sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
!                           0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
!       // Add length of what "%x" resulted in.
!       length += STRLEN(property + length);
!       res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
!       vim_free(property);
!       return res;
!     }
!     return -1;
  }
  
      static int
--- 757,773 ----
        return -1;
  
      length = STRLEN(p_enc) + STRLEN(str) + 14;
!     if ((property = alloc(length + 30)) == NULL)
!       return -1;
! 
!     sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
!           0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
!     // Add length of what "%x" resulted in.
!     length += STRLEN(property + length);
!     res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
!     vim_free(property);
! 
!     return res;
  }
  
      static int
*** ../vim-9.0.1182/src/indent.c        2022-12-19 15:51:40.375943469 +0000
--- src/indent.c        2023-01-12 12:30:17.300724443 +0000
***************
*** 2188,2199 ****
  {
      int amount = get_the_indent();
  
!     if (amount >= 0)
!     {
!       change_indent(INDENT_SET, amount, FALSE, 0, TRUE);
!       if (linewhite(curwin->w_cursor.lnum))
!           did_ai = TRUE;      // delete the indent if the line stays empty
!     }
  }
  
  /*
--- 2188,2199 ----
  {
      int amount = get_the_indent();
  
!     if (amount < 0)
!       return;
! 
!     change_indent(INDENT_SET, amount, FALSE, 0, TRUE);
!     if (linewhite(curwin->w_cursor.lnum))
!       did_ai = TRUE;  // delete the indent if the line stays empty
  }
  
  /*
*** ../vim-9.0.1182/src/version.c       2023-01-11 21:24:23.407844367 +0000
--- src/version.c       2023-01-12 12:31:24.044654931 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1183,
  /**/

-- 
It doesn't really matter what great things you are able to do if
you don't do any of them.  (Bram Moolenaar)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20230112123405.188291C07A0%40moolenaar.net.

Raspunde prin e-mail lui