Patch 9.0.1132
Problem:    Code is indented more than needed.
Solution:   Use an early return to reduce indentation. (Yegappan Lakshmanan,
            closes #11769)
Files:      src/arglist.c, src/buffer.c, src/clientserver.c, src/dosinst.c,
            src/evalfunc.c, src/evalvars.c, src/evalwindow.c, src/ex_docmd.c,
            src/ex_getln.c, src/fileio.c, src/float.c, src/fold.c


*** ../vim-9.0.1131/src/arglist.c       2022-11-24 00:08:58.461010529 +0000
--- src/arglist.c       2023-01-02 16:39:38.825655500 +0000
***************
*** 693,748 ****
            emsg(_(e_cannot_go_before_first_file));
        else
            emsg(_(e_cannot_go_beyond_last_file));
      }
!     else
!     {
!       setpcmark();
  #ifdef FEAT_GUI
!       need_mouse_correct = TRUE;
  #endif
  
!       // split window or create new tab page first
!       if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
!       {
!           if (win_split(0, 0) == FAIL)
!               return;
!           RESET_BINDING(curwin);
!       }
!       else
        {
!           // if 'hidden' set, only check for changed file when re-editing
!           // the same buffer
!           other = TRUE;
!           if (buf_hide(curbuf))
!           {
!               p = fix_fname(alist_name(&ARGLIST[argn]));
!               other = otherfile(p);
!               vim_free(p);
!           }
!           if ((!buf_hide(curbuf) || !other)
!                 && check_changed(curbuf, CCGD_AW
!                                        | (other ? 0 : CCGD_MULTWIN)
!                                        | (eap->forceit ? CCGD_FORCEIT : 0)
!                                        | CCGD_EXCMD))
!               return;
        }
! 
!       curwin->w_arg_idx = argn;
!       if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
!           arg_had_last = TRUE;
! 
!       // Edit the file; always use the last known line number.
!       // When it fails (e.g. Abort for already edited file) restore the
!       // argument index.
!       if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
!                     eap, ECMD_LAST,
!                     (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
!                        + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
!           curwin->w_arg_idx = old_arg_idx;
!       // like Vi: set the mark where the cursor is in the file.
!       else if (eap->cmdidx != CMD_argdo)
!           setmark('\'');
      }
  }
  
  /*
--- 693,748 ----
            emsg(_(e_cannot_go_before_first_file));
        else
            emsg(_(e_cannot_go_beyond_last_file));
+ 
+       return;
      }
! 
!     setpcmark();
  #ifdef FEAT_GUI
!     need_mouse_correct = TRUE;
  #endif
  
!     // split window or create new tab page first
!     if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
!     {
!       if (win_split(0, 0) == FAIL)
!           return;
!       RESET_BINDING(curwin);
!     }
!     else
!     {
!       // if 'hidden' set, only check for changed file when re-editing
!       // the same buffer
!       other = TRUE;
!       if (buf_hide(curbuf))
        {
!           p = fix_fname(alist_name(&ARGLIST[argn]));
!           other = otherfile(p);
!           vim_free(p);
        }
!       if ((!buf_hide(curbuf) || !other)
!               && check_changed(curbuf, CCGD_AW
!                   | (other ? 0 : CCGD_MULTWIN)
!                   | (eap->forceit ? CCGD_FORCEIT : 0)
!                   | CCGD_EXCMD))
!           return;
      }
+ 
+     curwin->w_arg_idx = argn;
+     if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
+       arg_had_last = TRUE;
+ 
+     // Edit the file; always use the last known line number.
+     // When it fails (e.g. Abort for already edited file) restore the
+     // argument index.
+     if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
+               eap, ECMD_LAST,
+               (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
+               + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
+       curwin->w_arg_idx = old_arg_idx;
+     // like Vi: set the mark where the cursor is in the file.
+     else if (eap->cmdidx != CMD_argdo)
+       setmark('\'');
  }
  
  /*
*** ../vim-9.0.1131/src/buffer.c        2022-12-15 13:14:17.411527402 +0000
--- src/buffer.c        2023-01-02 16:39:38.825655500 +0000
***************
*** 146,164 ****
      void
  buffer_ensure_loaded(buf_T *buf)
  {
!     if (buf->b_ml.ml_mfp == NULL)
!     {
!       aco_save_T      aco;
  
!       // Make sure the buffer is in a window.  If not then skip it.
!       aucmd_prepbuf(&aco, buf);
!       if (curbuf == buf)
!       {
!           if (swap_exists_action != SEA_READONLY)
!               swap_exists_action = SEA_NONE;
!           open_buffer(FALSE, NULL, 0);
!           aucmd_restbuf(&aco);
!       }
      }
  }
  #endif
--- 146,164 ----
      void
  buffer_ensure_loaded(buf_T *buf)
  {
!     if (buf->b_ml.ml_mfp != NULL)
!       return;
  
!     aco_save_T        aco;
! 
!     // Make sure the buffer is in a window.  If not then skip it.
!     aucmd_prepbuf(&aco, buf);
!     if (curbuf == buf)
!     {
!       if (swap_exists_action != SEA_READONLY)
!           swap_exists_action = SEA_NONE;
!       open_buffer(FALSE, NULL, 0);
!       aucmd_restbuf(&aco);
      }
  }
  #endif
***************
*** 3582,3599 ****
      buf_T     *buf;
  
      buf = buflist_findnr(fnum);
!     if (buf != NULL)
!     {
!       if (buf->b_sfname != buf->b_ffname)
!           vim_free(buf->b_sfname);
!       vim_free(buf->b_ffname);
!       buf->b_ffname = vim_strsave(name);
!       buf->b_sfname = NULL;
!       // Allocate ffname and expand into full path.  Also resolves .lnk
!       // files on Win32.
!       fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
!       buf->b_fname = buf->b_sfname;
!     }
  }
  
  /*
--- 3582,3599 ----
      buf_T     *buf;
  
      buf = buflist_findnr(fnum);
!     if (buf == NULL)
!       return;
! 
!     if (buf->b_sfname != buf->b_ffname)
!       vim_free(buf->b_sfname);
!     vim_free(buf->b_ffname);
!     buf->b_ffname = vim_strsave(name);
!     buf->b_sfname = NULL;
!     // Allocate ffname and expand into full path.  Also resolves .lnk
!     // files on Win32.
!     fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
!     buf->b_fname = buf->b_sfname;
  }
  
  /*
***************
*** 5921,5934 ****
      void
  set_buflisted(int on)
  {
!     if (on != curbuf->b_p_bl)
!     {
!       curbuf->b_p_bl = on;
!       if (on)
!           apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
!       else
!           apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
!     }
  }
  
  /*
--- 5921,5934 ----
      void
  set_buflisted(int on)
  {
!     if (on == curbuf->b_p_bl)
!       return;
! 
!     curbuf->b_p_bl = on;
!     if (on)
!       apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
!     else
!       apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
  }
  
  /*
*** ../vim-9.0.1131/src/clientserver.c  2022-11-30 18:11:52.686904299 +0000
--- src/clientserver.c  2023-01-02 16:39:38.825655500 +0000
***************
*** 191,228 ****
      void
  exec_on_server(mparm_T *parmp)
  {
!     if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL)
!     {
  # ifdef MSWIN
!       // Initialise the client/server messaging infrastructure.
!       serverInitMessaging();
  # endif
  
!       /*
!        * When a command server argument was found, execute it.  This may
!        * exit Vim when it was successful.  Otherwise it's executed further
!        * on.  Remember the encoding used here in "serverStrEnc".
!        */
!       if (parmp->serverArg)
!       {
!           cmdsrv_main(&parmp->argc, parmp->argv,
!                                   parmp->serverName_arg, &parmp->serverStr);
!           parmp->serverStrEnc = vim_strsave(p_enc);
!       }
  
!       // If we're still running, get the name to register ourselves.
!       // On Win32 can register right now, for X11 need to setup the
!       // clipboard first, it's further down.
!       parmp->servername = serverMakeName(parmp->serverName_arg,
!                                                             parmp->argv[0]);
  # ifdef MSWIN
!       if (parmp->servername != NULL)
!       {
!           serverSetName(parmp->servername);
!           vim_free(parmp->servername);
!       }
! # endif
      }
  }
  
  /*
--- 191,228 ----
      void
  exec_on_server(mparm_T *parmp)
  {
!     if (parmp->serverName_arg != NULL && *parmp->serverName_arg == NUL)
!       return;
! 
  # ifdef MSWIN
!     // Initialise the client/server messaging infrastructure.
!     serverInitMessaging();
  # endif
  
!     /*
!      * When a command server argument was found, execute it.  This may
!      * exit Vim when it was successful.  Otherwise it's executed further
!      * on.  Remember the encoding used here in "serverStrEnc".
!      */
!     if (parmp->serverArg)
!     {
!       cmdsrv_main(&parmp->argc, parmp->argv,
!               parmp->serverName_arg, &parmp->serverStr);
!       parmp->serverStrEnc = vim_strsave(p_enc);
!     }
  
!     // If we're still running, get the name to register ourselves.
!     // On Win32 can register right now, for X11 need to setup the
!     // clipboard first, it's further down.
!     parmp->servername = serverMakeName(parmp->serverName_arg,
!           parmp->argv[0]);
  # ifdef MSWIN
!     if (parmp->servername != NULL)
!     {
!       serverSetName(parmp->servername);
!       vim_free(parmp->servername);
      }
+ # endif
  }
  
  /*
*** ../vim-9.0.1131/src/dosinst.c       2022-06-11 10:34:51.000000000 +0100
--- src/dosinst.c       2023-01-02 16:39:38.825655500 +0000
***************
*** 830,916 ****
      char      *vimarg = targets[choices[idx].arg].exearg;
      FILE      *fd;
  
!     if (*batpath != NUL)
      {
!       fd = fopen(batpath, "w");
!       if (fd == NULL)
!           printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
!       else
!       {
!           need_uninstall_entry = 1;
! 
!           fprintf(fd, "@echo off\n");
!           fprintf(fd, "rem -- Run Vim --\n");
!           fprintf(fd, VIMBAT_UNINSTKEY "\n");
!           fprintf(fd, "\n");
!           fprintf(fd, "setlocal\n");
! 
!           /*
!            * Don't use double quotes for the "set" argument, also when it
!            * contains a space.  The quotes would be included in the value.
!            * The order of preference is:
!            * 1. $VIMRUNTIME/vim.exe       (user preference)
!            * 2. $VIM/vim81/vim.exe        (hard coded version)
!            * 3. installdir/vim.exe        (hard coded install directory)
!            */
!           fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
!           fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set 
VIM_EXE_DIR=%%VIM%%\\%s\n",
!                              VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
!           fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set 
VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
!           fprintf(fd, "\n");
! 
!           // Give an error message when the executable could not be found.
!           fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
!           fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", 
exename);
!           fprintf(fd, "    goto :eof\n");
!           fprintf(fd, ")\n");
!           fprintf(fd, "\n");
! 
!           if (*exename == 'g')
!           {
!               fprintf(fd, "rem check --nofork argument\n");
!               fprintf(fd, "set VIMNOFORK=\n");
!               fprintf(fd, ":loopstart\n");
!               fprintf(fd, "if .%%1==. goto loopend\n");
!               fprintf(fd, "if .%%1==.--nofork (\n");
!               fprintf(fd, "    set VIMNOFORK=1\n");
!               fprintf(fd, ") else if .%%1==.-f (\n");
!               fprintf(fd, "    set VIMNOFORK=1\n");
!               fprintf(fd, ")\n");
!               fprintf(fd, "shift\n");
!               fprintf(fd, "goto loopstart\n");
!               fprintf(fd, ":loopend\n");
!               fprintf(fd, "\n");
!           }
! 
!           if (*exename == 'g')
!           {
!               // For gvim.exe use "start /b" to avoid that the console window
!               // stays open.
!               fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
!               fprintf(fd, "    start \"dummy\" /b /wait ");
!               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
!               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
!                                                            exename, vimarg);
!               fprintf(fd, ") else (\n");
!               fprintf(fd, "    start \"dummy\" /b ");
!               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
!               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
!                                                            exename, vimarg);
!               fprintf(fd, ")\n");
!           }
!           else
!           {
!               // Always use quotes, $VIM or $VIMRUNTIME might have a space.
!               fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
!                                                            exename, vimarg);
!           }
! 
!           fclose(fd);
!           printf("%s has been %s\n", batpath,
!                                oldname == NULL ? "created" : "overwritten");
!       }
      }
  }
  
  /*
--- 830,917 ----
      char      *vimarg = targets[choices[idx].arg].exearg;
      FILE      *fd;
  
!     if (*batpath == NUL)
!       return;
! 
!     fd = fopen(batpath, "w");
!     if (fd == NULL)
!     {
!       printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
!       return;
!     }
! 
!     need_uninstall_entry = 1;
! 
!     fprintf(fd, "@echo off\n");
!     fprintf(fd, "rem -- Run Vim --\n");
!     fprintf(fd, VIMBAT_UNINSTKEY "\n");
!     fprintf(fd, "\n");
!     fprintf(fd, "setlocal\n");
! 
!     /*
!      * Don't use double quotes for the "set" argument, also when it
!      * contains a space.  The quotes would be included in the value.
!      * The order of preference is:
!      * 1. $VIMRUNTIME/vim.exe     (user preference)
!      * 2. $VIM/vim81/vim.exe      (hard coded version)
!      * 3. installdir/vim.exe      (hard coded install directory)
!      */
!     fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
!     fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
!           VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
!     fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set 
VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
!     fprintf(fd, "\n");
! 
!     // Give an error message when the executable could not be found.
!     fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
!     fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
!     fprintf(fd, "    goto :eof\n");
!     fprintf(fd, ")\n");
!     fprintf(fd, "\n");
! 
!     if (*exename == 'g')
      {
!       fprintf(fd, "rem check --nofork argument\n");
!       fprintf(fd, "set VIMNOFORK=\n");
!       fprintf(fd, ":loopstart\n");
!       fprintf(fd, "if .%%1==. goto loopend\n");
!       fprintf(fd, "if .%%1==.--nofork (\n");
!       fprintf(fd, "    set VIMNOFORK=1\n");
!       fprintf(fd, ") else if .%%1==.-f (\n");
!       fprintf(fd, "    set VIMNOFORK=1\n");
!       fprintf(fd, ")\n");
!       fprintf(fd, "shift\n");
!       fprintf(fd, "goto loopstart\n");
!       fprintf(fd, ":loopend\n");
!       fprintf(fd, "\n");
      }
+ 
+     if (*exename == 'g')
+     {
+       // For gvim.exe use "start /b" to avoid that the console window
+       // stays open.
+       fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
+       fprintf(fd, "    start \"dummy\" /b /wait ");
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+       fprintf(fd, ") else (\n");
+       fprintf(fd, "    start \"dummy\" /b ");
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+       fprintf(fd, ")\n");
+     }
+     else
+     {
+       // Always use quotes, $VIM or $VIMRUNTIME might have a space.
+       fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+               exename, vimarg);
+     }
+ 
+     fclose(fd);
+     printf("%s has been %s\n", batpath,
+           oldname == NULL ? "created" : "overwritten");
  }
  
  /*
*** ../vim-9.0.1131/src/evalfunc.c      2022-12-29 20:56:20.025538293 +0000
--- src/evalfunc.c      2023-01-02 16:39:38.825655500 +0000
***************
*** 3172,3219 ****
  f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
  {
      rettv->v_type = VAR_STRING;
!     if (balloonEval != NULL)
!     {
!       if (balloonEval->msg == NULL)
!           rettv->vval.v_string = NULL;
!       else
!           rettv->vval.v_string = vim_strsave(balloonEval->msg);
!     }
  }
  
      static void
  f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
  {
!     if (balloonEval != NULL)
!     {
!       if (in_vim9script()
!               && check_for_string_or_list_arg(argvars, 0) == FAIL)
!           return;
  
!       if (argvars[0].v_type == VAR_LIST
  # ifdef FEAT_GUI
!               && !gui.in_use
  # endif
!          )
!       {
!           list_T *l = argvars[0].vval.v_list;
  
!           // empty list removes the balloon
!           post_balloon(balloonEval, NULL,
!                                      l == NULL || l->lv_len == 0 ? NULL : l);
!       }
!       else
!       {
!           char_u *mesg;
  
!           if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
!               return;
  
!           mesg = tv_get_string_chk(&argvars[0]);
!           if (mesg != NULL)
!               // empty string removes the balloon
!               post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
!       }
      }
  }
  
--- 3172,3219 ----
  f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
  {
      rettv->v_type = VAR_STRING;
!     if (balloonEval == NULL)
!       return;
! 
!     if (balloonEval->msg == NULL)
!       rettv->vval.v_string = NULL;
!     else
!       rettv->vval.v_string = vim_strsave(balloonEval->msg);
  }
  
      static void
  f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
  {
!     if (balloonEval == NULL)
!       return;
  
!     if (in_vim9script()
!           && check_for_string_or_list_arg(argvars, 0) == FAIL)
!       return;
! 
!     if (argvars[0].v_type == VAR_LIST
  # ifdef FEAT_GUI
!           && !gui.in_use
  # endif
!        )
!     {
!       list_T *l = argvars[0].vval.v_list;
  
!       // empty list removes the balloon
!       post_balloon(balloonEval, NULL,
!               l == NULL || l->lv_len == 0 ? NULL : l);
!     }
!     else
!     {
!       char_u *mesg;
  
!       if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
!           return;
  
!       mesg = tv_get_string_chk(&argvars[0]);
!       if (mesg != NULL)
!           // empty string removes the balloon
!           post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
      }
  }
  
***************
*** 3221,3245 ****
      static void
  f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
  {
!     if (rettv_list_alloc(rettv) == OK)
!     {
!       char_u *msg;
  
!       if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
!           return;
!       msg = tv_get_string_chk(&argvars[0]);
!       if (msg != NULL)
!       {
!           pumitem_T   *array;
!           int         size = split_message(msg, &array);
  
!           // Skip the first and last item, they are always empty.
!           for (int i = 1; i < size - 1; ++i)
!               list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
!           while (size > 0)
!               vim_free(array[--size].pum_text);
!           vim_free(array);
!       }
      }
  }
  # endif
--- 3221,3245 ----
      static void
  f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
  {
!     if (rettv_list_alloc(rettv) != OK)
!       return;
  
!     char_u *msg;
  
!     if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
!       return;
!     msg = tv_get_string_chk(&argvars[0]);
!     if (msg != NULL)
!     {
!       pumitem_T       *array;
!       int             size = split_message(msg, &array);
! 
!       // Skip the first and last item, they are always empty.
!       for (int i = 1; i < size - 1; ++i)
!           list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
!       while (size > 0)
!           vim_free(array[--size].pum_text);
!       vim_free(array);
      }
  }
  # endif
***************
*** 3676,3693 ****
  
      pid = (int)tv_get_number(&argvars[0]);
      if (pid == 0)
-       emsg(_(e_invalid_argument));
-     else
      {
!       HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
! 
!       if (hProcess != NULL)
!       {
!           DebugBreakProcess(hProcess);
!           CloseHandle(hProcess);
!           rettv->vval.v_number = OK;
!       }
      }
  }
  #endif
  
--- 3676,3693 ----
  
      pid = (int)tv_get_number(&argvars[0]);
      if (pid == 0)
      {
!       emsg(_(e_invalid_argument));
!       return;
      }
+ 
+     HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
+     if (hProcess == NULL)
+       return;
+ 
+     DebugBreakProcess(hProcess);
+     CloseHandle(hProcess);
+     rettv->vval.v_number = OK;
  }
  #endif
  
***************
*** 3932,3943 ****
        len = (int)STRLEN(value);       // Append the entire string
      else
        len = value_len;                // Append only "value_len" characters
!     if (ga_grow(&redir_execute_ga, len) == OK)
!     {
!       mch_memmove((char *)redir_execute_ga.ga_data
!                                      + redir_execute_ga.ga_len, value, len);
!       redir_execute_ga.ga_len += len;
!     }
  }
  
  #if defined(FEAT_LUA) || defined(PROTO)
--- 3932,3943 ----
        len = (int)STRLEN(value);       // Append the entire string
      else
        len = value_len;                // Append only "value_len" characters
!     if (ga_grow(&redir_execute_ga, len) != OK)
!       return;
! 
!     mch_memmove((char *)redir_execute_ga.ga_data
!           + redir_execute_ga.ga_len, value, len);
!     redir_execute_ga.ga_len += len;
  }
  
  #if defined(FEAT_LUA) || defined(PROTO)
***************
*** 5043,5056 ****
      static void
  f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
  {
!     if (rettv_dict_alloc(rettv) == OK)
!     {
!       dict_T *dict = rettv->vval.v_dict;
  
!       dict_add_string(dict, "char", last_csearch());
!       dict_add_number(dict, "forward", last_csearch_forward());
!       dict_add_number(dict, "until", last_csearch_until());
!     }
  }
  
  /*
--- 5043,5056 ----
      static void
  f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
  {
!     if (rettv_dict_alloc(rettv) != OK)
!       return;
  
!     dict_T *dict = rettv->vval.v_dict;
! 
!     dict_add_string(dict, "char", last_csearch());
!     dict_add_number(dict, "forward", last_csearch_forward());
!     dict_add_number(dict, "until", last_csearch_until());
  }
  
  /*
***************
*** 6792,6820 ****
      }
  
      l = argvars[0].vval.v_list;
!     if (l != NULL)
      {
!       CHECK_LIST_MATERIALIZE(l);
!       item = l->lv_first;
!       if (argvars[2].v_type != VAR_UNKNOWN)
        {
!           // Start at specified item.  Use the cached index that list_find()
!           // sets, so that a negative number also works.
!           item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
!           idx = l->lv_u.mat.lv_idx;
!           if (argvars[3].v_type != VAR_UNKNOWN)
!               ic = (int)tv_get_bool_chk(&argvars[3], &error);
!           if (error)
!               item = NULL;
        }
- 
-       for ( ; item != NULL; item = item->li_next, ++idx)
-           if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
-           {
-               rettv->vval.v_number = idx;
-               break;
-           }
-     }
  }
  
  /*
--- 6792,6820 ----
      }
  
      l = argvars[0].vval.v_list;
!     if (l == NULL)
!       return;
! 
!     CHECK_LIST_MATERIALIZE(l);
!     item = l->lv_first;
!     if (argvars[2].v_type != VAR_UNKNOWN)
      {
!       // Start at specified item.  Use the cached index that list_find()
!       // sets, so that a negative number also works.
!       item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
!       idx = l->lv_u.mat.lv_idx;
!       if (argvars[3].v_type != VAR_UNKNOWN)
!           ic = (int)tv_get_bool_chk(&argvars[3], &error);
!       if (error)
!           item = NULL;
!     }
! 
!     for ( ; item != NULL; item = item->li_next, ++idx)
!       if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
        {
!           rettv->vval.v_number = idx;
!           break;
        }
  }
  
  /*
***************
*** 8363,8384 ****
      if (error)
        return;         // type error; errmsg already given
      if (stride == 0)
        emsg(_(e_stride_is_zero));
!     else if (stride > 0 ? end + 1 < start : end - 1 > start)
!       emsg(_(e_start_past_end));
!     else
      {
!       list_T *list = rettv->vval.v_list;
! 
!       // Create a non-materialized list.  This is much more efficient and
!       // works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
!       // be called.
!       list->lv_first = &range_list_item;
!       list->lv_u.nonmat.lv_start = start;
!       list->lv_u.nonmat.lv_end = end;
!       list->lv_u.nonmat.lv_stride = stride;
!       list->lv_len = (end - start) / stride + 1;
      }
  }
  
  /*
--- 8363,8388 ----
      if (error)
        return;         // type error; errmsg already given
      if (stride == 0)
+     {
        emsg(_(e_stride_is_zero));
!       return;
!     }
!     if (stride > 0 ? end + 1 < start : end - 1 > start)
      {
!       emsg(_(e_start_past_end));
!       return;
      }
+ 
+     list_T *list = rettv->vval.v_list;
+ 
+     // Create a non-materialized list.  This is much more efficient and
+     // works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
+     // be called.
+     list->lv_first = &range_list_item;
+     list->lv_u.nonmat.lv_start = start;
+     list->lv_u.nonmat.lv_end = end;
+     list->lv_u.nonmat.lv_stride = stride;
+     list->lv_len = (end - start) / stride + 1;
  }
  
  /*
***************
*** 9382,9415 ****
        return;
  
      name = tv_get_string_chk(argvars);
!     if (name != NULL)
      {
!       if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) == OK)
        {
!           if (pos.col != MAXCOL && --pos.col < 0)
!               pos.col = 0;
!           if ((name[0] == '.' && name[1] == NUL))
!           {
!               // set cursor; "fnum" is ignored
!               curwin->w_cursor = pos;
!               if (curswant >= 0)
!               {
!                   curwin->w_curswant = curswant - 1;
!                   curwin->w_set_curswant = FALSE;
!               }
!               check_cursor();
!               rettv->vval.v_number = 0;
!           }
!           else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
!           {
!               // set mark
!               if (setmark_pos(name[1], &pos, fnum) == OK)
!                   rettv->vval.v_number = 0;
!           }
!           else
!               emsg(_(e_invalid_argument));
        }
      }
  }
  /*
   * "setcharpos()" function
--- 9386,9419 ----
        return;
  
      name = tv_get_string_chk(argvars);
!     if (name == NULL)
!       return;
! 
!     if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) != OK)
!       return;
! 
!     if (pos.col != MAXCOL && --pos.col < 0)
!       pos.col = 0;
!     if ((name[0] == '.' && name[1] == NUL))
      {
!       // set cursor; "fnum" is ignored
!       curwin->w_cursor = pos;
!       if (curswant >= 0)
        {
!           curwin->w_curswant = curswant - 1;
!           curwin->w_set_curswant = FALSE;
        }
+       check_cursor();
+       rettv->vval.v_number = 0;
+     }
+     else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
+     {
+       // set mark
+       if (setmark_pos(name[1], &pos, fnum) == OK)
+           rettv->vval.v_number = 0;
      }
+     else
+       emsg(_(e_invalid_argument));
  }
  /*
   * "setcharpos()" function
***************
*** 9430,9461 ****
      if (check_for_dict_arg(argvars, 0) == FAIL)
        return;
  
!     if ((d = argvars[0].vval.v_dict) != NULL)
      {
!       csearch = dict_get_string(d, "char", FALSE);
!       if (csearch != NULL)
        {
!           if (enc_utf8)
!           {
!               int pcc[MAX_MCO];
!               int c = utfc_ptr2char(csearch, pcc);
  
!               set_last_csearch(c, csearch, utfc_ptr2len(csearch));
!           }
!           else
!               set_last_csearch(PTR2CHAR(csearch),
!                                               csearch, mb_ptr2len(csearch));
        }
! 
!       di = dict_find(d, (char_u *)"forward", -1);
!       if (di != NULL)
!           set_csearch_direction((int)tv_get_number(&di->di_tv)
!                                                       ? FORWARD : BACKWARD);
! 
!       di = dict_find(d, (char_u *)"until", -1);
!       if (di != NULL)
!           set_csearch_until(!!tv_get_number(&di->di_tv));
      }
  }
  
  /*
--- 9434,9465 ----
      if (check_for_dict_arg(argvars, 0) == FAIL)
        return;
  
!     if ((d = argvars[0].vval.v_dict) == NULL)
!       return;
! 
!     csearch = dict_get_string(d, "char", FALSE);
!     if (csearch != NULL)
      {
!       if (enc_utf8)
        {
!           int pcc[MAX_MCO];
!           int c = utfc_ptr2char(csearch, pcc);
  
!           set_last_csearch(c, csearch, utfc_ptr2len(csearch));
        }
!       else
!           set_last_csearch(PTR2CHAR(csearch),
!                   csearch, mb_ptr2len(csearch));
      }
+ 
+     di = dict_find(d, (char_u *)"forward", -1);
+     if (di != NULL)
+       set_csearch_direction((int)tv_get_number(&di->di_tv)
+               ? FORWARD : BACKWARD);
+ 
+     di = dict_find(d, (char_u *)"until", -1);
+     if (di != NULL)
+       set_csearch_until(!!tv_get_number(&di->di_tv));
  }
  
  /*
*** ../vim-9.0.1131/src/evalvars.c      2022-12-08 15:32:11.079034172 +0000
--- src/evalvars.c      2023-01-02 16:39:38.829655495 +0000
***************
*** 350,364 ****
      typval_T  *tvp;
  
      val = vim_strsave(value);
!     if (val != NULL)
!     {
!       tvp = alloc_string_tv(val);
!       if (tvp != NULL)
!       {
!           set_var(name, tvp, FALSE);
!           free_tv(tvp);
!       }
!     }
  }
  
      int
--- 350,364 ----
      typval_T  *tvp;
  
      val = vim_strsave(value);
!     if (val == NULL)
!       return;
! 
!     tvp = alloc_string_tv(val);
!     if (tvp == NULL)
!       return;
! 
!     set_var(name, tvp, FALSE);
!     free_tv(tvp);
  }
  
      int
***************
*** 576,589 ****
      hashitem_T        *hi;
  
      vimvars[idx].vv_tv = *save_tv;
!     if (vimvars[idx].vv_tv_type == VAR_UNKNOWN)
!     {
!       hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
!       if (HASHITEM_EMPTY(hi))
!           internal_error("restore_vimvar()");
!       else
!           hash_remove(&vimvarht, hi, "restore vimvar");
!     }
  }
  
  /*
--- 576,589 ----
      hashitem_T        *hi;
  
      vimvars[idx].vv_tv = *save_tv;
!     if (vimvars[idx].vv_tv_type != VAR_UNKNOWN)
!       return;
! 
!     hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
!     if (HASHITEM_EMPTY(hi))
!       internal_error("restore_vimvar()");
!     else
!       hash_remove(&vimvarht, hi, "restore vimvar");
  }
  
  /*
***************
*** 2740,2750 ****
      clear_tv(&vimvars[idx].vv_di.di_tv);
      vimvars[idx].vv_tv_type = VAR_DICT;
      vimvars[idx].vv_dict = val;
!     if (val != NULL)
!     {
!       ++val->dv_refcount;
!       dict_set_items_ro(val);
!     }
  }
  
  /*
--- 2740,2750 ----
      clear_tv(&vimvars[idx].vv_di.di_tv);
      vimvars[idx].vv_tv_type = VAR_DICT;
      vimvars[idx].vv_dict = val;
!     if (val == NULL)
!       return;
! 
!     ++val->dv_refcount;
!     dict_set_items_ro(val);
  }
  
  /*
***************
*** 3562,3572 ****
  {
      dictitem_T        *di = HI2DI(hi);
  
!     if (hash_remove(ht, hi, "delete variable") == OK)
!     {
!       clear_tv(&di->di_tv);
!       vim_free(di);
!     }
  }
  
  /*
--- 3562,3572 ----
  {
      dictitem_T        *di = HI2DI(hi);
  
!     if (hash_remove(ht, hi, "delete variable") != OK)
!       return;
! 
!     clear_tv(&di->di_tv);
!     vim_free(di);
  }
  
  /*
***************
*** 4317,4345 ****
      varname = tv_get_string_chk(&argvars[off + 1]);
      varp = &argvars[off + 2];
  
!     if (win != NULL && varname != NULL && varp != NULL)
      {
!       need_switch_win = !(tp == curtab && win == curwin);
!       if (!need_switch_win
!              || switch_win(&switchwin, win, tp, TRUE) == OK)
        {
!           if (*varname == '&')
!               set_option_from_tv(varname + 1, varp);
!           else
            {
!               winvarname = alloc(STRLEN(varname) + 3);
!               if (winvarname != NULL)
!               {
!                   STRCPY(winvarname, "w:");
!                   STRCPY(winvarname + 2, varname);
!                   set_var(winvarname, varp, TRUE);
!                   vim_free(winvarname);
!               }
            }
        }
-       if (need_switch_win)
-           restore_win(&switchwin, TRUE);
      }
  }
  
  /*
--- 4317,4345 ----
      varname = tv_get_string_chk(&argvars[off + 1]);
      varp = &argvars[off + 2];
  
!     if (win == NULL || varname == NULL || varp == NULL)
!       return;
! 
!     need_switch_win = !(tp == curtab && win == curwin);
!     if (!need_switch_win
!           || switch_win(&switchwin, win, tp, TRUE) == OK)
      {
!       if (*varname == '&')
!           set_option_from_tv(varname + 1, varp);
!       else
        {
!           winvarname = alloc(STRLEN(varname) + 3);
!           if (winvarname != NULL)
            {
!               STRCPY(winvarname, "w:");
!               STRCPY(winvarname + 2, varname);
!               set_var(winvarname, varp, TRUE);
!               vim_free(winvarname);
            }
        }
      }
+     if (need_switch_win)
+       restore_win(&switchwin, TRUE);
  }
  
  /*
***************
*** 4686,4709 ****
      varname = tv_get_string_chk(&argvars[1]);
      varp = &argvars[2];
  
!     if (varname != NULL && varp != NULL && tp != NULL)
!     {
!       save_curtab = curtab;
!       goto_tabpage_tp(tp, FALSE, FALSE);
  
!       tabvarname = alloc(STRLEN(varname) + 3);
!       if (tabvarname != NULL)
!       {
!           STRCPY(tabvarname, "t:");
!           STRCPY(tabvarname + 2, varname);
!           set_var(tabvarname, varp, TRUE);
!           vim_free(tabvarname);
!       }
  
!       // Restore current tabpage
!       if (valid_tabpage(save_curtab))
!           goto_tabpage_tp(save_curtab, FALSE, FALSE);
      }
  }
  
  /*
--- 4686,4709 ----
      varname = tv_get_string_chk(&argvars[1]);
      varp = &argvars[2];
  
!     if (varname == NULL || varp == NULL || tp == NULL)
!       return;
  
!     save_curtab = curtab;
!     goto_tabpage_tp(tp, FALSE, FALSE);
  
!     tabvarname = alloc(STRLEN(varname) + 3);
!     if (tabvarname != NULL)
!     {
!       STRCPY(tabvarname, "t:");
!       STRCPY(tabvarname + 2, varname);
!       set_var(tabvarname, varp, TRUE);
!       vim_free(tabvarname);
      }
+ 
+     // Restore current tabpage
+     if (valid_tabpage(save_curtab))
+       goto_tabpage_tp(save_curtab, FALSE, FALSE);
  }
  
  /*
***************
*** 4757,4793 ****
      buf = tv_get_buf_from_arg(&argvars[0]);
      varp = &argvars[2];
  
!     if (buf != NULL && varname != NULL && varp != NULL)
      {
!       if (*varname == '&')
!       {
!           aco_save_T  aco;
  
!           // Set curbuf to be our buf, temporarily.
!           aucmd_prepbuf(&aco, buf);
!           if (curbuf == buf)
!           {
!               // Only when it worked to set "curbuf".
!               set_option_from_tv(varname + 1, varp);
  
!               // reset notion of buffer
!               aucmd_restbuf(&aco);
!           }
        }
!       else
        {
!           bufvarname = alloc(STRLEN(varname) + 3);
!           if (bufvarname != NULL)
!           {
!               buf_T *save_curbuf = curbuf;
  
!               curbuf = buf;
!               STRCPY(bufvarname, "b:");
!               STRCPY(bufvarname + 2, varname);
!               set_var(bufvarname, varp, TRUE);
!               vim_free(bufvarname);
!               curbuf = save_curbuf;
!           }
        }
      }
  }
--- 4757,4793 ----
      buf = tv_get_buf_from_arg(&argvars[0]);
      varp = &argvars[2];
  
!     if (buf == NULL || varname == NULL || varp == NULL)
!       return;
! 
!     if (*varname == '&')
      {
!       aco_save_T      aco;
  
!       // Set curbuf to be our buf, temporarily.
!       aucmd_prepbuf(&aco, buf);
!       if (curbuf == buf)
!       {
!           // Only when it worked to set "curbuf".
!           set_option_from_tv(varname + 1, varp);
  
!           // reset notion of buffer
!           aucmd_restbuf(&aco);
        }
!     }
!     else
!     {
!       bufvarname = alloc(STRLEN(varname) + 3);
!       if (bufvarname != NULL)
        {
!           buf_T *save_curbuf = curbuf;
  
!           curbuf = buf;
!           STRCPY(bufvarname, "b:");
!           STRCPY(bufvarname + 2, varname);
!           set_var(bufvarname, varp, TRUE);
!           vim_free(bufvarname);
!           curbuf = save_curbuf;
        }
      }
  }
***************
*** 4930,4960 ****
      p = vim_strchr(name, '.');
      if (p == NULL)
        return;
      import = find_imported(name, p - name, FALSE);
!     if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
!     {
!       scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
  
!       if (si->sn_autoload_prefix != NULL)
!       {
!           char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
  
!           if (newname != NULL)
!           {
!               if (cb->cb_partial != NULL)
!               {
!                   if (cb->cb_name == cb->cb_partial->pt_name)
!                       cb->cb_name = newname;
!                   vim_free(cb->cb_partial->pt_name);
!                   cb->cb_partial->pt_name = newname;
!               }
!               else
!               {
!                   vim_free(cb->cb_name);
!                   cb->cb_name = newname;
!               }
!           }
!       }
      }
  }
  
--- 4930,4959 ----
      p = vim_strchr(name, '.');
      if (p == NULL)
        return;
+ 
      import = find_imported(name, p - name, FALSE);
!     if (import == NULL || !SCRIPT_ID_VALID(import->imp_sid))
!       return;
  
!     scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
!     if (si->sn_autoload_prefix == NULL)
!       return;
  
!     char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
!     if (newname == NULL)
!       return;
! 
!     if (cb->cb_partial != NULL)
!     {
!       if (cb->cb_name == cb->cb_partial->pt_name)
!           cb->cb_name = newname;
!       vim_free(cb->cb_partial->pt_name);
!       cb->cb_partial->pt_name = newname;
!     }
!     else
!     {
!       vim_free(cb->cb_name);
!       cb->cb_name = newname;
      }
  }
  
*** ../vim-9.0.1131/src/evalwindow.c    2022-11-28 18:51:38.955571567 +0000
--- src/evalwindow.c    2023-01-02 16:39:38.829655495 +0000
***************
*** 718,783 ****
  
      id = (int)tv_get_number(argvars);
      wp = win_id2wp_tp(id, &tp);
!     if (wp != NULL && tp != NULL)
!     {
!       pos_T   curpos = wp->w_cursor;
!       char_u  cwd[MAXPATHL];
!       int     cwd_status = FAIL;
  #ifdef FEAT_AUTOCHDIR
!       char_u  autocwd[MAXPATHL];
!       int     apply_acd = FALSE;
  #endif
  
!       // Getting and setting directory can be slow on some systems, only do
!       // this when the current or target window/tab have a local directory or
!       // 'acd' is set.
!       if (curwin != wp
!               && (curwin->w_localdir != NULL
!                   || wp->w_localdir != NULL
!                   || (curtab != tp
!                       && (curtab->tp_localdir != NULL
!                           || tp->tp_localdir != NULL))
  #ifdef FEAT_AUTOCHDIR
!                   || p_acd
  #endif
!                   ))
!           cwd_status = mch_dirname(cwd, MAXPATHL);
  
  #ifdef FEAT_AUTOCHDIR
!       // If 'acd' is set, check we are using that directory.  If yes, then
!       // apply 'acd' afterwards, otherwise restore the current directory.
!       if (cwd_status == OK && p_acd)
!       {
!           do_autochdir();
!           apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
!                                                 && STRCMP(cwd, autocwd) == 0;
!       }
  #endif
  
!       if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
!       {
!           check_cursor();
!           execute_common(argvars, rettv, 1);
!       }
!       restore_win_noblock(&switchwin, TRUE);
  #ifdef FEAT_AUTOCHDIR
!       if (apply_acd)
!           do_autochdir();
!       else
  #endif
!           if (cwd_status == OK)
            mch_chdir((char *)cwd);
  
!       // Update the status line if the cursor moved.
!       if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
!           wp->w_redr_status = TRUE;
! 
!       // In case the command moved the cursor or changed the Visual area,
!       // check it is valid.
!       check_cursor();
!       if (VIsual_active)
!           check_pos(curbuf, &VIsual);
!     }
  }
  
  /*
--- 718,783 ----
  
      id = (int)tv_get_number(argvars);
      wp = win_id2wp_tp(id, &tp);
!     if (wp == NULL || tp == NULL)
!       return;
! 
!     pos_T     curpos = wp->w_cursor;
!     char_u    cwd[MAXPATHL];
!     int       cwd_status = FAIL;
  #ifdef FEAT_AUTOCHDIR
!     char_u    autocwd[MAXPATHL];
!     int       apply_acd = FALSE;
  #endif
  
!     // Getting and setting directory can be slow on some systems, only do
!     // this when the current or target window/tab have a local directory or
!     // 'acd' is set.
!     if (curwin != wp
!           && (curwin->w_localdir != NULL
!               || wp->w_localdir != NULL
!               || (curtab != tp
!                   && (curtab->tp_localdir != NULL
!                       || tp->tp_localdir != NULL))
  #ifdef FEAT_AUTOCHDIR
!               || p_acd
  #endif
!              ))
!       cwd_status = mch_dirname(cwd, MAXPATHL);
  
  #ifdef FEAT_AUTOCHDIR
!     // If 'acd' is set, check we are using that directory.  If yes, then
!     // apply 'acd' afterwards, otherwise restore the current directory.
!     if (cwd_status == OK && p_acd)
!     {
!       do_autochdir();
!       apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
!           && STRCMP(cwd, autocwd) == 0;
!     }
  #endif
  
!     if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
!     {
!       check_cursor();
!       execute_common(argvars, rettv, 1);
!     }
!     restore_win_noblock(&switchwin, TRUE);
  #ifdef FEAT_AUTOCHDIR
!     if (apply_acd)
!       do_autochdir();
!     else
  #endif
!       if (cwd_status == OK)
            mch_chdir((char *)cwd);
  
!     // Update the status line if the cursor moved.
!     if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
!       wp->w_redr_status = TRUE;
! 
!     // In case the command moved the cursor or changed the Visual area,
!     // check it is valid.
!     check_cursor();
!     if (VIsual_active)
!       check_pos(curbuf, &VIsual);
  }
  
  /*
***************
*** 1093,1103 ****
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = NULL;
      rettv->vval.v_string = alloc(2);
!     if (rettv->vval.v_string != NULL)
!     {
!       rettv->vval.v_string[0] = cmdwin_type;
!       rettv->vval.v_string[1] = NUL;
!     }
  }
  
  /*
--- 1093,1103 ----
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = NULL;
      rettv->vval.v_string = alloc(2);
!     if (rettv->vval.v_string == NULL)
!       return;
! 
!     rettv->vval.v_string[0] = cmdwin_type;
!     rettv->vval.v_string[1] = NUL;
  }
  
  /*
*** ../vim-9.0.1131/src/ex_docmd.c      2022-12-30 18:07:41.694107568 +0000
--- src/ex_docmd.c      2023-01-02 16:39:38.829655495 +0000
***************
*** 7049,7060 ****
        }
      }
  
!     if (fname != NULL)
!     {
!       eap->arg = fname;
!       do_exedit(eap, NULL);
!       vim_free(fname);
!     }
  }
  
  /*
--- 7049,7060 ----
        }
      }
  
!     if (fname == NULL)
!       return;
! 
!     eap->arg = fname;
!     do_exedit(eap, NULL);
!     vim_free(fname);
  }
  
  /*
*** ../vim-9.0.1131/src/ex_getln.c      2022-12-30 18:07:41.694107568 +0000
--- src/ex_getln.c      2023-01-02 16:39:38.829655495 +0000
***************
*** 4210,4220 ****
  {
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = alloc(2);
!     if (rettv->vval.v_string != NULL)
!     {
!       rettv->vval.v_string[0] = get_cmdline_type();
!       rettv->vval.v_string[1] = NUL;
!     }
  }
  
  // Set the command line str to "str".
--- 4210,4220 ----
  {
      rettv->v_type = VAR_STRING;
      rettv->vval.v_string = alloc(2);
!     if (rettv->vval.v_string == NULL)
!       return;
! 
!     rettv->vval.v_string[0] = get_cmdline_type();
!     rettv->vval.v_string[1] = NUL;
  }
  
  // Set the command line str to "str".
*** ../vim-9.0.1131/src/fileio.c        2022-11-28 18:51:38.963571609 +0000
--- src/fileio.c        2023-01-02 16:39:38.829655495 +0000
***************
*** 2767,2781 ****
      void
  set_forced_fenc(exarg_T *eap)
  {
!     if (eap->force_enc != 0)
!     {
!       char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
  
!       if (fenc != NULL)
!           set_string_option_direct((char_u *)"fenc", -1,
!                                fenc, OPT_FREE|OPT_LOCAL, 0);
!       vim_free(fenc);
!     }
  }
  
  /*
--- 2767,2781 ----
      void
  set_forced_fenc(exarg_T *eap)
  {
!     if (eap->force_enc == 0)
!       return;
  
!     char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
! 
!     if (fenc != NULL)
!       set_string_option_direct((char_u *)"fenc", -1,
!               fenc, OPT_FREE|OPT_LOCAL, 0);
!     vim_free(fenc);
  }
  
  /*
***************
*** 5070,5081 ****
        return;
  
      dp = opendir((const char*)vim_tempdir);
  
!     if (dp != NULL)
!     {
!       vim_tempdir_dp = dp;
!       flock(dirfd(vim_tempdir_dp), LOCK_SH);
!     }
  }
  
  /*
--- 5070,5080 ----
        return;
  
      dp = opendir((const char*)vim_tempdir);
+     if (dp == NULL)
+       return;
  
!     vim_tempdir_dp = dp;
!     flock(dirfd(vim_tempdir_dp), LOCK_SH);
  }
  
  /*
***************
*** 5084,5094 ****
     static void
  vim_closetempdir(void)
  {
!     if (vim_tempdir_dp != NULL)
!     {
!       closedir(vim_tempdir_dp);
!       vim_tempdir_dp = NULL;
!     }
  }
  # endif
  
--- 5083,5093 ----
     static void
  vim_closetempdir(void)
  {
!     if (vim_tempdir_dp == NULL)
!       return;
! 
!     closedir(vim_tempdir_dp);
!     vim_tempdir_dp = NULL;
  }
  # endif
  
***************
*** 5098,5113 ****
      void
  vim_deltempdir(void)
  {
!     if (vim_tempdir != NULL)
!     {
  # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
!       vim_closetempdir();
  # endif
!       // remove the trailing path separator
!       gettail(vim_tempdir)[-1] = NUL;
!       delete_recursive(vim_tempdir);
!       VIM_CLEAR(vim_tempdir);
!     }
  }
  
  /*
--- 5097,5112 ----
      void
  vim_deltempdir(void)
  {
!     if (vim_tempdir == NULL)
!       return;
! 
  # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
!     vim_closetempdir();
  # endif
!     // remove the trailing path separator
!     gettail(vim_tempdir)[-1] = NUL;
!     delete_recursive(vim_tempdir);
!     VIM_CLEAR(vim_tempdir);
  }
  
  /*
***************
*** 5121,5137 ****
      char_u    *buf;
  
      buf = alloc(MAXPATHL + 2);
!     if (buf != NULL)
!     {
!       if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
!           STRCPY(buf, tempdir);
!       add_pathsep(buf);
!       vim_tempdir = vim_strsave(buf);
  # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
!       vim_opentempdir();
  # endif
!       vim_free(buf);
!     }
  }
  #endif
  
--- 5120,5136 ----
      char_u    *buf;
  
      buf = alloc(MAXPATHL + 2);
!     if (buf == NULL)
!       return;
! 
!     if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
!       STRCPY(buf, tempdir);
!     add_pathsep(buf);
!     vim_tempdir = vim_strsave(buf);
  # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
!     vim_opentempdir();
  # endif
!     vim_free(buf);
  }
  #endif
  
*** ../vim-9.0.1131/src/float.c 2022-09-17 21:07:52.095993168 +0100
--- src/float.c 2023-01-02 16:39:38.829655495 +0000
***************
*** 288,302 ****
      if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
        return;
  
!     if (get_float_arg(argvars, &f) == OK)
!     {
!       if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
!           rettv->vval.v_number = -VARNUM_MAX;
!       else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
!           rettv->vval.v_number = VARNUM_MAX;
!       else
!           rettv->vval.v_number = (varnumber_T)f;
!     }
  }
  
  /*
--- 288,302 ----
      if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
        return;
  
!     if (get_float_arg(argvars, &f) != OK)
!       return;
! 
!     if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
!       rettv->vval.v_number = -VARNUM_MAX;
!     else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
!       rettv->vval.v_number = VARNUM_MAX;
!     else
!       rettv->vval.v_number = (varnumber_T)f;
  }
  
  /*
*** ../vim-9.0.1131/src/fold.c  2022-10-01 19:43:48.606494048 +0100
--- src/fold.c  2023-01-02 16:39:38.829655495 +0000
***************
*** 644,702 ****
            i = (int)(fp - (fold_T *)gap->ga_data);
      }
  
!     if (ga_grow(gap, 1) == OK)
!     {
!       fp = (fold_T *)gap->ga_data + i;
!       ga_init2(&fold_ga, sizeof(fold_T), 10);
  
!       // Count number of folds that will be contained in the new fold.
!       for (cont = 0; i + cont < gap->ga_len; ++cont)
!           if (fp[cont].fd_top > end_rel)
!               break;
!       if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
!       {
!           // If the first fold starts before the new fold, let the new fold
!           // start there.  Otherwise the existing fold would change.
!           if (start_rel > fp->fd_top)
!               start_rel = fp->fd_top;
! 
!           // When last contained fold isn't completely contained, adjust end
!           // of new fold.
!           if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
!               end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
!           // Move contained folds to inside new fold.
!           mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
!           fold_ga.ga_len += cont;
!           i += cont;
! 
!           // Adjust line numbers in contained folds to be relative to the
!           // new fold.
!           for (j = 0; j < cont; ++j)
!               ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
!       }
!       // Move remaining entries to after the new fold.
!       if (i < gap->ga_len)
!           mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
!                                    sizeof(fold_T) * (gap->ga_len - i));
!       gap->ga_len = gap->ga_len + 1 - cont;
! 
!       // insert new fold
!       fp->fd_nested = fold_ga;
!       fp->fd_top = start_rel;
!       fp->fd_len = end_rel - start_rel + 1;
! 
!       // We want the new fold to be closed.  If it would remain open because
!       // of using 'foldlevel', need to adjust fd_flags of containing folds.
!       if (use_level && !closed && level < curwin->w_p_fdl)
!           closeFold(start, 1L);
!       if (!use_level)
!           curwin->w_fold_manual = TRUE;
!       fp->fd_flags = FD_CLOSED;
!       fp->fd_small = MAYBE;
  
!       // redraw
!       changed_window_setting();
!     }
  }
  
  // deleteFold() {{{2
--- 644,702 ----
            i = (int)(fp - (fold_T *)gap->ga_data);
      }
  
!     if (ga_grow(gap, 1) != OK)
!       return;
  
!     fp = (fold_T *)gap->ga_data + i;
!     ga_init2(&fold_ga, sizeof(fold_T), 10);
  
!     // Count number of folds that will be contained in the new fold.
!     for (cont = 0; i + cont < gap->ga_len; ++cont)
!       if (fp[cont].fd_top > end_rel)
!           break;
!     if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
!     {
!       // If the first fold starts before the new fold, let the new fold
!       // start there.  Otherwise the existing fold would change.
!       if (start_rel > fp->fd_top)
!           start_rel = fp->fd_top;
! 
!       // When last contained fold isn't completely contained, adjust end
!       // of new fold.
!       if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
!           end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
!       // Move contained folds to inside new fold.
!       mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
!       fold_ga.ga_len += cont;
!       i += cont;
! 
!       // Adjust line numbers in contained folds to be relative to the
!       // new fold.
!       for (j = 0; j < cont; ++j)
!           ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
!     }
!     // Move remaining entries to after the new fold.
!     if (i < gap->ga_len)
!       mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
!               sizeof(fold_T) * (gap->ga_len - i));
!     gap->ga_len = gap->ga_len + 1 - cont;
! 
!     // insert new fold
!     fp->fd_nested = fold_ga;
!     fp->fd_top = start_rel;
!     fp->fd_len = end_rel - start_rel + 1;
! 
!     // We want the new fold to be closed.  If it would remain open because
!     // of using 'foldlevel', need to adjust fd_flags of containing folds.
!     if (use_level && !closed && level < curwin->w_p_fdl)
!       closeFold(start, 1L);
!     if (!use_level)
!       curwin->w_fold_manual = TRUE;
!     fp->fd_flags = FD_CLOSED;
!     fp->fd_small = MAYBE;
! 
!     // redraw
!     changed_window_setting();
  }
  
  // deleteFold() {{{2
***************
*** 1719,1745 ****
      int               count;
      int               n;
  
!     if (fp->fd_small == MAYBE)
!     {
!       // Mark any nested folds to maybe-small
!       setSmallMaybe(&fp->fd_nested);
  
!       if (fp->fd_len > curwin->w_p_fml)
!           fp->fd_small = FALSE;
!       else
        {
!           count = 0;
!           for (n = 0; n < fp->fd_len; ++n)
            {
!               count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
!               if (count > curwin->w_p_fml)
!               {
!                   fp->fd_small = FALSE;
!                   return;
!               }
            }
-           fp->fd_small = TRUE;
        }
      }
  }
  
--- 1719,1745 ----
      int               count;
      int               n;
  
!     if (fp->fd_small != MAYBE)
!       return;
  
!     // Mark any nested folds to maybe-small
!     setSmallMaybe(&fp->fd_nested);
! 
!     if (fp->fd_len > curwin->w_p_fml)
!       fp->fd_small = FALSE;
!     else
!     {
!       count = 0;
!       for (n = 0; n < fp->fd_len; ++n)
        {
!           count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
!           if (count > curwin->w_p_fml)
            {
!               fp->fd_small = FALSE;
!               return;
            }
        }
+       fp->fd_small = TRUE;
      }
  }
  
***************
*** 1799,1824 ****
      line = ml_get(lnum);
      line_len = (int)STRLEN(line);
  
!     if (u_save(lnum - 1, lnum + 1) == OK)
!     {
!       // Check if the line ends with an unclosed comment
!       (void)skip_comment(line, FALSE, FALSE, &line_is_comment);
!       newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
!       if (newline == NULL)
!           return;
!       STRCPY(newline, line);
!       // Append the marker to the end of the line
!       if (p == NULL || line_is_comment)
!           vim_strncpy(newline + line_len, marker, markerlen);
!       else
!       {
!           STRCPY(newline + line_len, cms);
!           STRNCPY(newline + line_len + (p - cms), marker, markerlen);
!           STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
!       }
  
!       ml_replace(lnum, newline, FALSE);
      }
  }
  
  // deleteFoldMarkers() {{{2
--- 1799,1824 ----
      line = ml_get(lnum);
      line_len = (int)STRLEN(line);
  
!     if (u_save(lnum - 1, lnum + 1) != OK)
!       return;
  
!     // Check if the line ends with an unclosed comment
!     (void)skip_comment(line, FALSE, FALSE, &line_is_comment);
!     newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
!     if (newline == NULL)
!       return;
!     STRCPY(newline, line);
!     // Append the marker to the end of the line
!     if (p == NULL || line_is_comment)
!       vim_strncpy(newline + line_len, marker, markerlen);
!     else
!     {
!       STRCPY(newline + line_len, cms);
!       STRNCPY(newline + line_len + (p - cms), marker, markerlen);
!       STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
      }
+ 
+     ml_replace(lnum, newline, FALSE);
  }
  
  // deleteFoldMarkers() {{{2
*** ../vim-9.0.1131/src/version.c       2023-01-02 13:41:45.300274390 +0000
--- src/version.c       2023-01-02 16:43:09.601400973 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1132,
  /**/

-- 
Did Adam and Eve have navels?

 /// 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/20230102165526.B8F311C0AA3%40moolenaar.net.

Raspunde prin e-mail lui