Patch 9.0.1208
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11819)
Files:      src/netbeans.c, src/normal.c, src/ops.c, src/option.c,
            src/optionstr.c, src/os_amiga.c, src/os_mac_conv.c,
            src/os_mswin.c, src/os_qnx.c, src/os_unix.c, src/os_win32.c


*** ../vim-9.0.1207/src/netbeans.c      2022-08-25 15:11:11.400084545 +0100
--- src/netbeans.c      2023-01-16 18:14:06.722813345 +0000
***************
*** 938,950 ****
      if (lastbyte >= oldlen)
        lastbyte = oldlen - 1;
      newtext = alloc(oldlen - (int)(lastbyte - first));
!     if (newtext != NULL)
!     {
!       mch_memmove(newtext, oldtext, first);
!       STRMOVE(newtext + first, oldtext + lastbyte + 1);
!       nbdebug(("    NEW LINE %ld: %s\n", lnum, newtext));
!       ml_replace(lnum, newtext, FALSE);
!     }
  }
  
  /*
--- 938,950 ----
      if (lastbyte >= oldlen)
        lastbyte = oldlen - 1;
      newtext = alloc(oldlen - (int)(lastbyte - first));
!     if (newtext == NULL)
!       return;
! 
!     mch_memmove(newtext, oldtext, first);
!     STRMOVE(newtext + first, oldtext + lastbyte + 1);
!     nbdebug(("    NEW LINE %ld: %s\n", lnum, newtext));
!     ml_replace(lnum, newtext, FALSE);
  }
  
  /*
***************
*** 960,971 ****
      len_first = (int)STRLEN(ml_get(first));
      len_other = (int)STRLEN(ml_get(other));
      p = alloc(len_first + len_other + 1);
!     if (p != NULL)
!     {
!       mch_memmove(p, ml_get(first), len_first);
!       mch_memmove(p + len_first, ml_get(other), len_other + 1);
!       ml_replace(first, p, FALSE);
!     }
  }
  
  #define SKIP_STOP 2
--- 960,971 ----
      len_first = (int)STRLEN(ml_get(first));
      len_other = (int)STRLEN(ml_get(other));
      p = alloc(len_first + len_other + 1);
!     if (p == NULL)
!       return;
! 
!     mch_memmove(p, ml_get(first), len_first);
!     mch_memmove(p + len_first, ml_get(other), len_other + 1);
!     ml_replace(first, p, FALSE);
  }
  
  #define SKIP_STOP 2
***************
*** 2247,2259 ****
      static void
  nb_set_curbuf(buf_T *buf)
  {
!     if (curbuf != buf) {
!       if (buf_jump_open_win(buf) != NULL)
!           return;
!       if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
!           return;
!       set_curbuf(buf, DOBUF_GOTO);
!     }
  }
  
  /*
--- 2247,2260 ----
      static void
  nb_set_curbuf(buf_T *buf)
  {
!     if (curbuf == buf)
!       return;
! 
!     if (buf_jump_open_win(buf) != NULL)
!       return;
!     if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
!       return;
!     set_curbuf(buf, DOBUF_GOTO);
  }
  
  /*
***************
*** 2364,2377 ****
  {
      static int did_init = FALSE;
  
!     if (!did_init)
!     {
!       coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
!                           " ctermbg=LightCyan ctermfg=Black");
!       coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
  
!       did_init = TRUE;
!     }
  }
  
  /*
--- 2365,2378 ----
  {
      static int did_init = FALSE;
  
!     if (did_init)
!       return;
  
!     coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
!           " ctermbg=LightCyan ctermfg=Black");
!     coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
! 
!     did_init = TRUE;
  }
  
  /*
***************
*** 2468,2496 ****
      if (!can_use_beval() || !NETBEANS_OPEN)
        return;
  
!     if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
      {
!       // Send debugger request.  Only when the text is of reasonable
!       // length.
!       if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
        {
!           buf = alloc(MAXPATHL * 2 + 25);
!           if (buf != NULL)
            {
!               p = nb_quote(text);
!               if (p != NULL)
!               {
!                   vim_snprintf(buf, MAXPATHL * 2 + 25,
!                                    "0:balloonText=%d \"%s\"\n", r_cmdno, p);
!                   vim_free(p);
!               }
!               nbdebug(("EVT: %s", buf));
!               nb_send(buf, "netbeans_beval_cb");
!               vim_free(buf);
            }
        }
-       vim_free(text);
      }
  }
  #endif
  
--- 2469,2497 ----
      if (!can_use_beval() || !NETBEANS_OPEN)
        return;
  
!     if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) != OK)
!       return;
! 
!     // Send debugger request.  Only when the text is of reasonable
!     // length.
!     if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
      {
!       buf = alloc(MAXPATHL * 2 + 25);
!       if (buf != NULL)
        {
!           p = nb_quote(text);
!           if (p != NULL)
            {
!               vim_snprintf(buf, MAXPATHL * 2 + 25,
!                       "0:balloonText=%d \"%s\"\n", r_cmdno, p);
!               vim_free(p);
            }
+           nbdebug(("EVT: %s", buf));
+           nb_send(buf, "netbeans_beval_cb");
+           vim_free(buf);
        }
      }
+     vim_free(text);
  }
  #endif
  
***************
*** 2555,2566 ****
      int abort = FALSE;
      typval_T tv;
  
!     if (nb_channel != NULL)
!     {
!       tv.v_type = VAR_CHANNEL;
!       tv.vval.v_channel = nb_channel;
!       abort = set_ref_in_item(&tv, copyID, NULL, NULL);
!     }
      return abort;
  }
  #endif
--- 2556,2567 ----
      int abort = FALSE;
      typval_T tv;
  
!     if (nb_channel == NULL)
!       return FALSE;
! 
!     tv.v_type = VAR_CHANNEL;
!     tv.vval.v_channel = nb_channel;
!     abort = set_ref_in_item(&tv, copyID, NULL, NULL);
      return abort;
  }
  #endif
***************
*** 2827,2848 ****
  
      bufno = nb_getbufno(curbuf);
  
!     if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
!     {
!       int col = mouse_col - curwin->w_wincol
!                             - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
!       long off = pos2off(curbuf, &curwin->w_cursor);
  
!       // sync the cursor position
!       sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
!       nbdebug(("EVT: %s", buf));
!       nb_send(buf, "netbeans_button_release[newDotAndMark]");
  
!       sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
!                                   button, (long)curwin->w_cursor.lnum, col);
!       nbdebug(("EVT: %s", buf));
!       nb_send(buf, "netbeans_button_release");
!     }
  }
  
  
--- 2828,2849 ----
  
      bufno = nb_getbufno(curbuf);
  
!     if (bufno < 0 || curwin == NULL || curwin->w_buffer != curbuf)
!       return;
  
!     int col = mouse_col - curwin->w_wincol
!       - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
!     long off = pos2off(curbuf, &curwin->w_cursor);
  
!     // sync the cursor position
!     sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
!     nbdebug(("EVT: %s", buf));
!     nb_send(buf, "netbeans_button_release[newDotAndMark]");
! 
!     sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
!           button, (long)curwin->w_cursor.lnum, col);
!     nbdebug(("EVT: %s", buf));
!     nb_send(buf, "netbeans_button_release");
  }
  
  
***************
*** 3308,3336 ****
  
      if (bufp->b_ml.ml_flags & ML_EMPTY)
        return 0;
      else
      {
!       if (get_fileformat(bufp) == EOL_DOS)
!           eol_size = 2;
!       else
!           eol_size = 1;
!       for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
!       {
!           char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
!                                                                  + eol_size;
!           // Check for a CTRL-C every 100000 characters
!           if (char_count > last_check)
!           {
!               ui_breakcheck();
!               if (got_int)
!                   return char_count;
!               last_check = char_count + 100000L;
!           }
!       }
!       // Correction for when last line doesn't have an EOL.
!       if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
!           char_count -= eol_size;
!     }
  
      return char_count;
  }
--- 3309,3335 ----
  
      if (bufp->b_ml.ml_flags & ML_EMPTY)
        return 0;
+ 
+     if (get_fileformat(bufp) == EOL_DOS)
+       eol_size = 2;
      else
+       eol_size = 1;
+     for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
      {
!       char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
!           + eol_size;
!       // Check for a CTRL-C every 100000 characters
!       if (char_count > last_check)
!       {
!           ui_breakcheck();
!           if (got_int)
!               return char_count;
!           last_check = char_count + 100000L;
!       }
!     }
!     // Correction for when last line doesn't have an EOL.
!     if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
!       char_count -= eol_size;
  
      return char_count;
  }
***************
*** 3393,3404 ****
  {
      long       offset = 0;
  
!     if (!(buf->b_ml.ml_flags & ML_EMPTY))
!     {
!       if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
!           return 0;
!       offset += pos->col;
!     }
  
      return offset;
  }
--- 3392,3403 ----
  {
      long       offset = 0;
  
!     if (buf->b_ml.ml_flags & ML_EMPTY)
!       return 0;
! 
!     if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
!       return 0;
!     offset += pos->col;
  
      return offset;
  }
*** ../vim-9.0.1207/src/normal.c        2023-01-13 14:17:54.014430905 +0000
--- src/normal.c        2023-01-16 18:14:06.722813345 +0000
***************
*** 186,199 ****
      static int
  check_text_locked(oparg_T *oap)
  {
!     if (text_locked())
!     {
!       if (oap != NULL)
!           clearopbeep(oap);
!       text_locked_msg();
!       return TRUE;
!     }
!     return FALSE;
  }
  
  /*
--- 186,198 ----
      static int
  check_text_locked(oparg_T *oap)
  {
!     if (!text_locked())
!       return FALSE;
! 
!     if (oap != NULL)
!       clearopbeep(oap);
!     text_locked_msg();
!     return TRUE;
  }
  
  /*
***************
*** 206,218 ****
  {
      if (check_text_locked(oap))
        return TRUE;
!     if (curbuf_locked())
!     {
!       if (oap != NULL)
!           clearop(oap);
!       return TRUE;
!     }
!     return FALSE;
  }
  
  /*
--- 205,217 ----
  {
      if (check_text_locked(oap))
        return TRUE;
! 
!     if (!curbuf_locked())
!       return FALSE;
! 
!     if (oap != NULL)
!       clearop(oap);
!     return TRUE;
  }
  
  /*
***************
*** 2030,2048 ****
      static void
  nv_page(cmdarg_T *cap)
  {
!     if (!checkclearop(cap->oap))
      {
!       if (mod_mask & MOD_MASK_CTRL)
!       {
!           // <C-PageUp>: tab page back; <C-PageDown>: tab page forward
!           if (cap->arg == BACKWARD)
!               goto_tabpage(-(int)cap->count1);
!           else
!               goto_tabpage((int)cap->count0);
!       }
        else
!           (void)onepage(cap->arg, cap->count1);
      }
  }
  
  /*
--- 2029,2047 ----
      static void
  nv_page(cmdarg_T *cap)
  {
!     if (checkclearop(cap->oap))
!       return;
! 
!     if (mod_mask & MOD_MASK_CTRL)
      {
!       // <C-PageUp>: tab page back; <C-PageDown>: tab page forward
!       if (cap->arg == BACKWARD)
!           goto_tabpage(-(int)cap->count1);
        else
!           goto_tabpage((int)cap->count0);
      }
+     else
+       (void)onepage(cap->arg, cap->count1);
  }
  
  /*
***************
*** 2062,2078 ****
                                                                       == FAIL)
      {
        clearopbeep(oap);
      }
!     else
!     {
  #ifdef FEAT_FOLDING
!       if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
!           foldOpenCursor();
  #endif
!       // clear any search statistics
!       if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
!           clear_cmdline = TRUE;
!     }
  }
  
  /*
--- 2061,2076 ----
                                                                       == FAIL)
      {
        clearopbeep(oap);
+       return;
      }
! 
  #ifdef FEAT_FOLDING
!     if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
!       foldOpenCursor();
  #endif
!     // clear any search statistics
!     if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
!       clear_cmdline = TRUE;
  }
  
  /*
***************
*** 3157,3216 ****
      int       flags;
  
      if (VIsual_active && !is_cmdkey)
        nv_operator(cap);
!     else
      {
!       if (cap->oap->op_type != OP_NOP)
!       {
!           // Using ":" as a movement is characterwise exclusive.
!           cap->oap->motion_type = MCHAR;
!           cap->oap->inclusive = FALSE;
!       }
!       else if (cap->count0 && !is_cmdkey)
        {
!           // translate "count:" into ":.,.+(count - 1)"
!           stuffcharReadbuff('.');
!           if (cap->count0 > 1)
!           {
!               stuffReadbuff((char_u *)",.+");
!               stuffnumReadbuff((long)cap->count0 - 1L);
!           }
        }
  
!       // When typing, don't type below an old message
!       if (KeyTyped)
!           compute_cmdrow();
! 
!       old_p_im = p_im;
  
!       // get a command line and execute it
!       flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0;
!       if (is_cmdkey)
!           cmd_result = do_cmdkey_command(cap->cmdchar, flags);
!       else
!           cmd_result = do_cmdline(NULL, getexline, NULL, flags);
  
!       // If 'insertmode' changed, enter or exit Insert mode
!       if (p_im != old_p_im)
!       {
!           if (p_im)
!               restart_edit = 'i';
!           else
!               restart_edit = 0;
!       }
  
!       if (cmd_result == FAIL)
!           // The Ex command failed, do not execute the operator.
!           clearop(cap->oap);
!       else if (cap->oap->op_type != OP_NOP
!               && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
!                   || cap->oap->start.col >
!                              (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
!                   || did_emsg
!                   ))
!           // The start of the operator has become invalid by the Ex command.
!           clearopbeep(cap->oap);
      }
  }
  
  /*
--- 3155,3215 ----
      int       flags;
  
      if (VIsual_active && !is_cmdkey)
+     {
        nv_operator(cap);
!       return;
!     }
! 
!     if (cap->oap->op_type != OP_NOP)
      {
!       // Using ":" as a movement is characterwise exclusive.
!       cap->oap->motion_type = MCHAR;
!       cap->oap->inclusive = FALSE;
!     }
!     else if (cap->count0 && !is_cmdkey)
!     {
!       // translate "count:" into ":.,.+(count - 1)"
!       stuffcharReadbuff('.');
!       if (cap->count0 > 1)
        {
!           stuffReadbuff((char_u *)",.+");
!           stuffnumReadbuff((long)cap->count0 - 1L);
        }
+     }
  
!     // When typing, don't type below an old message
!     if (KeyTyped)
!       compute_cmdrow();
  
!     old_p_im = p_im;
  
!     // get a command line and execute it
!     flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0;
!     if (is_cmdkey)
!       cmd_result = do_cmdkey_command(cap->cmdchar, flags);
!     else
!       cmd_result = do_cmdline(NULL, getexline, NULL, flags);
  
!     // If 'insertmode' changed, enter or exit Insert mode
!     if (p_im != old_p_im)
!     {
!       if (p_im)
!           restart_edit = 'i';
!       else
!           restart_edit = 0;
      }
+ 
+     if (cmd_result == FAIL)
+       // The Ex command failed, do not execute the operator.
+       clearop(cap->oap);
+     else if (cap->oap->op_type != OP_NOP
+           && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
+               || cap->oap->start.col >
+               (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
+               || did_emsg
+              ))
+       // The start of the operator has become invalid by the Ex command.
+       clearopbeep(cap->oap);
  }
  
  /*
***************
*** 3251,3278 ****
      static void
  nv_clear(cmdarg_T *cap)
  {
!     if (!checkclearop(cap->oap))
!     {
  #ifdef FEAT_SYN_HL
!       // Clear all syntax states to force resyncing.
!       syn_stack_free_all(curwin->w_s);
  # ifdef FEAT_RELTIME
!       {
!           win_T *wp;
  
!           FOR_ALL_WINDOWS(wp)
!               wp->w_s->b_syn_slow = FALSE;
!       }
  # endif
  #endif
!       redraw_later(UPD_CLEAR);
  #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
  # ifdef VIMDLL
!       if (!gui.in_use)
  # endif
!           resize_console_buf();
  #endif
-     }
  }
  
  /*
--- 3250,3277 ----
      static void
  nv_clear(cmdarg_T *cap)
  {
!     if (checkclearop(cap->oap))
!       return;
! 
  #ifdef FEAT_SYN_HL
!     // Clear all syntax states to force resyncing.
!     syn_stack_free_all(curwin->w_s);
  # ifdef FEAT_RELTIME
!     {
!       win_T *wp;
  
!       FOR_ALL_WINDOWS(wp)
!           wp->w_s->b_syn_slow = FALSE;
!     }
  # endif
  #endif
!     redraw_later(UPD_CLEAR);
  #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
  # ifdef VIMDLL
!     if (!gui.in_use)
  # endif
!       resize_console_buf();
  #endif
  }
  
  /*
***************
*** 3314,3333 ****
      static void
  nv_Zet(cmdarg_T *cap)
  {
!     if (!checkclearopq(cap->oap))
      {
!       switch (cap->nchar)
!       {
!                       // "ZZ": equivalent to ":x".
!           case 'Z':   do_cmdline_cmd((char_u *)"x");
                        break;
  
                        // "ZQ": equivalent to ":q!" (Elvis compatible).
!           case 'Q':   do_cmdline_cmd((char_u *)"q!");
                        break;
  
!           default:    clearopbeep(cap->oap);
!       }
      }
  }
  
--- 3313,3332 ----
      static void
  nv_Zet(cmdarg_T *cap)
  {
!     if (checkclearopq(cap->oap))
!       return;
! 
!     switch (cap->nchar)
      {
!       // "ZZ": equivalent to ":x".
!       case 'Z':       do_cmdline_cmd((char_u *)"x");
                        break;
  
                        // "ZQ": equivalent to ":q!" (Elvis compatible).
!       case 'Q':       do_cmdline_cmd((char_u *)"q!");
                        break;
  
!       default:        clearopbeep(cap->oap);
      }
  }
  
***************
*** 3982,3996 ****
        // <S-Up> is page up
        cap->arg = BACKWARD;
        nv_page(cap);
      }
!     else
!     {
!       cap->oap->motion_type = MLINE;
!       if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
!           clearopbeep(cap->oap);
!       else if (cap->arg)
!           beginline(BL_WHITE | BL_FIX);
!     }
  }
  
  /*
--- 3981,3994 ----
        // <S-Up> is page up
        cap->arg = BACKWARD;
        nv_page(cap);
+       return;
      }
! 
!     cap->oap->motion_type = MLINE;
!     if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
!       clearopbeep(cap->oap);
!     else if (cap->arg)
!       beginline(BL_WHITE | BL_FIX);
  }
  
  /*
***************
*** 4249,4275 ****
  
      cap->oap->motion_type = MCHAR;
      if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
        clearopbeep(cap->oap);
!     else
      {
!       curwin->w_set_curswant = TRUE;
!       // Include a Tab for "tx" and for "dfx".
!       if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
!               && (t_cmd || cap->oap->op_type != OP_NOP))
!       {
!           colnr_T     scol, ecol;
  
!           getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
!           curwin->w_cursor.coladd = ecol - scol;
!       }
!       else
!           curwin->w_cursor.coladd = 0;
!       adjust_for_sel(cap);
  #ifdef FEAT_FOLDING
!       if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
!           foldOpenCursor();
  #endif
-     }
  }
  
  /*
--- 4247,4274 ----
  
      cap->oap->motion_type = MCHAR;
      if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
+     {
        clearopbeep(cap->oap);
!       return;
!     }
! 
!     curwin->w_set_curswant = TRUE;
!     // Include a Tab for "tx" and for "dfx".
!     if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
!           && (t_cmd || cap->oap->op_type != OP_NOP))
      {
!       colnr_T scol, ecol;
  
!       getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
!       curwin->w_cursor.coladd = ecol - scol;
!     }
!     else
!       curwin->w_cursor.coladd = 0;
!     adjust_for_sel(cap);
  #ifdef FEAT_FOLDING
!     if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
!       foldOpenCursor();
  #endif
  }
  
  /*
***************
*** 4654,4670 ****
      curwin->w_set_curswant = TRUE;
  
      if (findsent(cap->arg, cap->count1) == FAIL)
-       clearopbeep(cap->oap);
-     else
      {
!       // Don't leave the cursor on the NUL past end of line.
!       adjust_cursor(cap->oap);
!       curwin->w_cursor.coladd = 0;
  #ifdef FEAT_FOLDING
!       if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
!           foldOpenCursor();
  #endif
-     }
  }
  
  /*
--- 4653,4670 ----
      curwin->w_set_curswant = TRUE;
  
      if (findsent(cap->arg, cap->count1) == FAIL)
      {
!       clearopbeep(cap->oap);
!       return;
!     }
! 
!     // Don't leave the cursor on the NUL past end of line.
!     adjust_cursor(cap->oap);
!     curwin->w_cursor.coladd = 0;
  #ifdef FEAT_FOLDING
!     if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
!       foldOpenCursor();
  #endif
  }
  
  /*
***************
*** 4673,4683 ****
      static void
  nv_mark(cmdarg_T *cap)
  {
!     if (!checkclearop(cap->oap))
!     {
!       if (setmark(cap->nchar) == FAIL)
!           clearopbeep(cap->oap);
!     }
  }
  
  /*
--- 4673,4683 ----
      static void
  nv_mark(cmdarg_T *cap)
  {
!     if (checkclearop(cap->oap))
!       return;
! 
!     if (setmark(cap->nchar) == FAIL)
!       clearopbeep(cap->oap);
  }
  
  /*
***************
*** 4692,4706 ****
      cap->oap->use_reg_one = TRUE;
      curwin->w_set_curswant = TRUE;
      if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE))
-       clearopbeep(cap->oap);
-     else
      {
!       curwin->w_cursor.coladd = 0;
  #ifdef FEAT_FOLDING
!       if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
!           foldOpenCursor();
  #endif
-     }
  }
  
  /*
--- 4692,4707 ----
      cap->oap->use_reg_one = TRUE;
      curwin->w_set_curswant = TRUE;
      if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE))
      {
!       clearopbeep(cap->oap);
!       return;
!     }
! 
!     curwin->w_cursor.coladd = 0;
  #ifdef FEAT_FOLDING
!     if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
!       foldOpenCursor();
  #endif
  }
  
  /*
***************
*** 4726,4743 ****
      static void
  nv_kundo(cmdarg_T *cap)
  {
!     if (!checkclearopq(cap->oap))
!     {
  #ifdef FEAT_JOB_CHANNEL
!       if (bt_prompt(curbuf))
!       {
!           clearopbeep(cap->oap);
!           return;
!       }
! #endif
!       u_undo((int)cap->count1);
!       curwin->w_set_curswant = TRUE;
      }
  }
  
  /*
--- 4727,4744 ----
      static void
  nv_kundo(cmdarg_T *cap)
  {
!     if (checkclearopq(cap->oap))
!       return;
! 
  #ifdef FEAT_JOB_CHANNEL
!     if (bt_prompt(curbuf))
!     {
!       clearopbeep(cap->oap);
!       return;
      }
+ #endif
+     u_undo((int)cap->count1);
+     curwin->w_set_curswant = TRUE;
  }
  
  /*
***************
*** 5008,5024 ****
        VIsual_mode_orig = VIsual_mode; // remember original area for gv
        VIsual_mode = 'V';
        nv_operator(cap);
      }
!     else if (!checkclearopq(cap->oap))
      {
!       if (!curbuf->b_p_ma)
!           emsg(_(e_cannot_make_changes_modifiable_is_off));
!       else
!       {
!           if (virtual_active())
!               coladvance(getviscol());
!           invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
!       }
      }
  }
  
--- 5009,5027 ----
        VIsual_mode_orig = VIsual_mode; // remember original area for gv
        VIsual_mode = 'V';
        nv_operator(cap);
+       return;
      }
! 
!     if (checkclearopq(cap->oap))
!       return;
! 
!     if (!curbuf->b_p_ma)
!       emsg(_(e_cannot_make_changes_modifiable_is_off));
!     else
      {
!       if (virtual_active())
!           coladvance(getviscol());
!       invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
      }
  }
  
***************
*** 5033,5053 ****
        cap->cmdchar = 'r';
        cap->nchar = cap->extra_char;
        nv_replace(cap);        // Do same as "r" in Visual mode for now
      }
!     else if (!checkclearopq(cap->oap))
      {
!       if (!curbuf->b_p_ma)
!           emsg(_(e_cannot_make_changes_modifiable_is_off));
!       else
!       {
!           if (cap->extra_char == Ctrl_V)      // get another character
!               cap->extra_char = get_literal(FALSE);
!           stuffcharReadbuff(cap->extra_char);
!           stuffcharReadbuff(ESC);
!           if (virtual_active())
!               coladvance(getviscol());
!           invoke_edit(cap, TRUE, 'v', FALSE);
!       }
      }
  }
  
--- 5036,5058 ----
        cap->cmdchar = 'r';
        cap->nchar = cap->extra_char;
        nv_replace(cap);        // Do same as "r" in Visual mode for now
+       return;
      }
! 
!     if (checkclearopq(cap->oap))
!       return;
! 
!     if (!curbuf->b_p_ma)
!       emsg(_(e_cannot_make_changes_modifiable_is_off));
!     else
      {
!       if (cap->extra_char == Ctrl_V)  // get another character
!           cap->extra_char = get_literal(FALSE);
!       stuffcharReadbuff(cap->extra_char);
!       stuffcharReadbuff(ESC);
!       if (virtual_active())
!           coladvance(getviscol());
!       invoke_edit(cap, TRUE, 'v', FALSE);
      }
  }
  
***************
*** 5345,5388 ****
      int               old_KeyTyped = KeyTyped;    // getting file may reset it
  #endif
  
!     if (!checkclearopq(cap->oap))
      {
!       if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL)
!       {
!           if (goto_tabpage_lastused() == FAIL)
!               clearopbeep(cap->oap);
!           return;
!       }
!       if (cap->cmdchar == 'g')
!           pos = movechangelist((int)cap->count1);
!       else
!           pos = movemark((int)cap->count1);
!       if (pos == (pos_T *)-1)         // jump to other file
!       {
!           curwin->w_set_curswant = TRUE;
!           check_cursor();
!       }
!       else if (pos != NULL)               // can jump
!           nv_cursormark(cap, FALSE, pos);
!       else if (cap->cmdchar == 'g')
!       {
!           if (curbuf->b_changelistlen == 0)
!               emsg(_(e_changelist_is_empty));
!           else if (cap->count1 < 0)
!               emsg(_(e_at_start_of_changelist));
!           else
!               emsg(_(e_at_end_of_changelist));
!       }
!       else
            clearopbeep(cap->oap);
  # ifdef FEAT_FOLDING
!       if (cap->oap->op_type == OP_NOP
!               && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
!               && (fdo_flags & FDO_MARK)
!               && old_KeyTyped)
!           foldOpenCursor();
  # endif
-     }
  }
  
  /*
--- 5350,5393 ----
      int               old_KeyTyped = KeyTyped;    // getting file may reset it
  #endif
  
!     if (checkclearopq(cap->oap))
!       return;
! 
!     if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL)
      {
!       if (goto_tabpage_lastused() == FAIL)
            clearopbeep(cap->oap);
+       return;
+     }
+     if (cap->cmdchar == 'g')
+       pos = movechangelist((int)cap->count1);
+     else
+       pos = movemark((int)cap->count1);
+     if (pos == (pos_T *)-1)           // jump to other file
+     {
+       curwin->w_set_curswant = TRUE;
+       check_cursor();
+     }
+     else if (pos != NULL)                 // can jump
+       nv_cursormark(cap, FALSE, pos);
+     else if (cap->cmdchar == 'g')
+     {
+       if (curbuf->b_changelistlen == 0)
+           emsg(_(e_changelist_is_empty));
+       else if (cap->count1 < 0)
+           emsg(_(e_at_start_of_changelist));
+       else
+           emsg(_(e_at_end_of_changelist));
+     }
+     else
+       clearopbeep(cap->oap);
  # ifdef FEAT_FOLDING
!     if (cap->oap->op_type == OP_NOP
!           && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
!           && (fdo_flags & FDO_MARK)
!           && old_KeyTyped)
!       foldOpenCursor();
  # endif
  }
  
  /*
***************
*** 6237,6277 ****
      linenr_T  oldline = curwin->w_cursor.lnum;
  #endif
  
!     if (!checkclearopq(cap->oap))
!     {
  #ifdef FEAT_FOLDING
!       if (cap->cmdchar == 'O')
!           // Open above the first line of a folded sequence of lines
!           (void)hasFolding(curwin->w_cursor.lnum,
!                                               &curwin->w_cursor.lnum, NULL);
!       else
!           // Open below the last line of a folded sequence of lines
!           (void)hasFolding(curwin->w_cursor.lnum,
!                                               NULL, &curwin->w_cursor.lnum);
! #endif
!       if (u_save((linenr_T)(curwin->w_cursor.lnum -
!                                              (cap->cmdchar == 'O' ? 1 : 0)),
!                  (linenr_T)(curwin->w_cursor.lnum +
!                                              (cap->cmdchar == 'o' ? 1 : 0))
!                      ) == OK
!               && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
!                        has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
!                                                               0, NULL) == OK)
!       {
  #ifdef FEAT_CONCEAL
!           if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
!               redrawWinline(curwin, oldline);
  #endif
  #ifdef FEAT_SYN_HL
!           if (curwin->w_p_cul)
!               // force redraw of cursorline
!               curwin->w_valid &= ~VALID_CROW;
! #endif
!           // When '#' is in 'cpoptions' ignore the count.
!           if (vim_strchr(p_cpo, CPO_HASH) != NULL)
!               cap->count1 = 1;
!           invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
!       }
      }
  }
  
--- 6242,6282 ----
      linenr_T  oldline = curwin->w_cursor.lnum;
  #endif
  
!     if (checkclearopq(cap->oap))
!       return;
! 
  #ifdef FEAT_FOLDING
!     if (cap->cmdchar == 'O')
!       // Open above the first line of a folded sequence of lines
!       (void)hasFolding(curwin->w_cursor.lnum,
!               &curwin->w_cursor.lnum, NULL);
!     else
!       // Open below the last line of a folded sequence of lines
!       (void)hasFolding(curwin->w_cursor.lnum,
!               NULL, &curwin->w_cursor.lnum);
! #endif
!     if (u_save((linenr_T)(curwin->w_cursor.lnum -
!                   (cap->cmdchar == 'O' ? 1 : 0)),
!               (linenr_T)(curwin->w_cursor.lnum +
!                   (cap->cmdchar == 'o' ? 1 : 0))
!             ) == OK
!           && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD,
!               has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0,
!               0, NULL) == OK)
!     {
  #ifdef FEAT_CONCEAL
!       if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
!           redrawWinline(curwin, oldline);
  #endif
  #ifdef FEAT_SYN_HL
!       if (curwin->w_p_cul)
!           // force redraw of cursorline
!           curwin->w_valid &= ~VALID_CROW;
! #endif
!       // When '#' is in 'cpoptions' ignore the count.
!       if (vim_strchr(p_cpo, CPO_HASH) != NULL)
!           cap->count1 = 1;
!       invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
      }
  }
  
***************
*** 6281,6294 ****
      static void
  nv_dot(cmdarg_T *cap)
  {
!     if (!checkclearopq(cap->oap))
!     {
!       // If "restart_edit" is TRUE, the last but one command is repeated
!       // instead of the last command (inserting text). This is used for
!       // CTRL-O <.> in insert mode.
!       if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
!           clearopbeep(cap->oap);
!     }
  }
  
  /*
--- 6286,6299 ----
      static void
  nv_dot(cmdarg_T *cap)
  {
!     if (checkclearopq(cap->oap))
!       return;
! 
!     // If "restart_edit" is TRUE, the last but one command is repeated
!     // instead of the last command (inserting text). This is used for
!     // CTRL-O <.> in insert mode.
!     if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
!       clearopbeep(cap->oap);
  }
  
  /*
***************
*** 6316,6326 ****
        return;
      }
  
!     if (!checkclearopq(cap->oap))
!     {
!       u_redo((int)cap->count1);
!       curwin->w_set_curswant = TRUE;
!     }
  }
  
  /*
--- 6321,6331 ----
        return;
      }
  
!     if (checkclearopq(cap->oap))
!       return;
! 
!     u_redo((int)cap->count1);
!     curwin->w_set_curswant = TRUE;
  }
  
  /*
***************
*** 6336,6347 ****
        cap->cmdchar = 'g';
        cap->nchar = 'U';
        nv_operator(cap);
      }
!     else if (!checkclearopq(cap->oap))
!     {
!       u_undoline();
!       curwin->w_set_curswant = TRUE;
!     }
  }
  
  /*
--- 6341,6354 ----
        cap->cmdchar = 'g';
        cap->nchar = 'U';
        nv_operator(cap);
+       return;
      }
! 
!     if (checkclearopq(cap->oap))
!       return;
! 
!     u_undoline();
!     curwin->w_set_curswant = TRUE;
  }
  
  /*
***************
*** 7146,7170 ****
        cap->cmdchar = 'g';
        cap->nchar = 'q';
        nv_operator(cap);
      }
!     else if (!checkclearop(cap->oap))
      {
!       if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?')
        {
!           if (cmdwin_type != 0)
!           {
!               emsg(_(e_cmdline_window_already_open));
!               return;
!           }
!           stuffcharReadbuff(cap->nchar);
!           stuffcharReadbuff(K_CMDWIN);
        }
!       else
!           // (stop) recording into a named register, unless executing a
!           // register
!           if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
!               clearopbeep(cap->oap);
      }
  }
  
  /*
--- 7153,7179 ----
        cap->cmdchar = 'g';
        cap->nchar = 'q';
        nv_operator(cap);
+       return;
      }
! 
!     if (checkclearop(cap->oap))
!       return;
! 
!     if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?')
      {
!       if (cmdwin_type != 0)
        {
!           emsg(_(e_cmdline_window_already_open));
!           return;
        }
!       stuffcharReadbuff(cap->nchar);
!       stuffcharReadbuff(K_CMDWIN);
      }
+     else
+       // (stop) recording into a named register, unless executing a
+       // register
+       if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
+           clearopbeep(cap->oap);
  }
  
  /*
***************
*** 7214,7241 ****
  nv_join(cmdarg_T *cap)
  {
      if (VIsual_active)        // join the visual lines
        nv_operator(cap);
!     else if (!checkclearop(cap->oap))
      {
!       if (cap->count0 <= 1)
!           cap->count0 = 2;        // default for join is two lines!
!       if (curwin->w_cursor.lnum + cap->count0 - 1 >
!                                                  curbuf->b_ml.ml_line_count)
        {
!           // can't join when on the last line
!           if (cap->count0 <= 2)
!           {
!               clearopbeep(cap->oap);
!               return;
!           }
!           cap->count0 = curbuf->b_ml.ml_line_count
!                                                 - curwin->w_cursor.lnum + 1;
        }
! 
!       prep_redo(cap->oap->regname, cap->count0,
!                                    NUL, cap->cmdchar, NUL, NUL, cap->nchar);
!       (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE);
      }
  }
  
  /*
--- 7223,7254 ----
  nv_join(cmdarg_T *cap)
  {
      if (VIsual_active)        // join the visual lines
+     {
        nv_operator(cap);
!       return;
!     }
! 
!     if (checkclearop(cap->oap))
!       return;
! 
!     if (cap->count0 <= 1)
!       cap->count0 = 2;            // default for join is two lines!
!     if (curwin->w_cursor.lnum + cap->count0 - 1 >
!           curbuf->b_ml.ml_line_count)
      {
!       // can't join when on the last line
!       if (cap->count0 <= 2)
        {
!           clearopbeep(cap->oap);
!           return;
        }
!       cap->count0 = curbuf->b_ml.ml_line_count
!           - curwin->w_cursor.lnum + 1;
      }
+ 
+     prep_redo(cap->oap->regname, cap->count0,
+           NUL, cap->cmdchar, NUL, NUL, cap->nchar);
+     (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE);
  }
  
  /*
***************
*** 7273,7404 ****
        }
        else
  #endif
!       clearopbeep(cap->oap);
      }
  #ifdef FEAT_JOB_CHANNEL
!     else if (bt_prompt(curbuf) && !prompt_curpos_editable())
      {
        clearopbeep(cap->oap);
      }
  #endif
!     else
      {
!       if (fix_indent)
!       {
!           dir = (cap->cmdchar == ']' && cap->nchar == 'p')
!                                                        ? FORWARD : BACKWARD;
!           flags |= PUT_FIXINDENT;
!       }
!       else
!           dir = (cap->cmdchar == 'P'
!                   || ((cap->cmdchar == 'g' || cap->cmdchar == 'z')
!                       && cap->nchar == 'P')) ? BACKWARD : FORWARD;
!       prep_redo_cmd(cap);
!       if (cap->cmdchar == 'g')
!           flags |= PUT_CURSEND;
!       else if (cap->cmdchar == 'z')
!           flags |= PUT_BLOCK_INNER;
  
!       if (VIsual_active)
!       {
!           // Putting in Visual mode: The put text replaces the selected
!           // text.  First delete the selected text, then put the new text.
!           // Need to save and restore the registers that the delete
!           // overwrites if the old contents is being put.
!           was_visual = TRUE;
!           regname = cap->oap->regname;
!           keep_registers = cap->cmdchar == 'P';
  #ifdef FEAT_CLIPBOARD
!           adjust_clip_reg(&regname);
  #endif
!          if (regname == 0 || regname == '"'
!                                    || VIM_ISDIGIT(regname) || regname == '-'
  #ifdef FEAT_CLIPBOARD
!                   || (clip_unnamed && (regname == '*' || regname == '+'))
  #endif
  
!                   )
!           {
!               // The delete is going to overwrite the register we want to
!               // put, save it first.
!               reg1 = get_register(regname, TRUE);
!           }
! 
!           // Now delete the selected text. Avoid messages here.
!           cap->cmdchar = 'd';
!           cap->nchar = NUL;
!           cap->oap->regname = keep_registers ? '_' : NUL;
!           ++msg_silent;
!           nv_operator(cap);
!           do_pending_operator(cap, 0, FALSE);
!           empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
!           --msg_silent;
! 
!           // delete PUT_LINE_BACKWARD;
!           cap->oap->regname = regname;
! 
!           if (reg1 != NULL)
!           {
!               // Delete probably changed the register we want to put, save
!               // it first. Then put back what was there before the delete.
!               reg2 = get_register(regname, FALSE);
!               put_register(regname, reg1);
!           }
! 
!           // When deleted a linewise Visual area, put the register as
!           // lines to avoid it joined with the next line.  When deletion was
!           // characterwise, split a line when putting lines.
!           if (VIsual_mode == 'V')
!               flags |= PUT_LINE;
!           else if (VIsual_mode == 'v')
!               flags |= PUT_LINE_SPLIT;
!           if (VIsual_mode == Ctrl_V && dir == FORWARD)
!               flags |= PUT_LINE_FORWARD;
!           dir = BACKWARD;
!           if ((VIsual_mode != 'V'
!                       && curwin->w_cursor.col < curbuf->b_op_start.col)
!                   || (VIsual_mode == 'V'
!                       && curwin->w_cursor.lnum < curbuf->b_op_start.lnum))
!               // cursor is at the end of the line or end of file, put
!               // forward.
!               dir = FORWARD;
!           // May have been reset in do_put().
!           VIsual_active = TRUE;
        }
-       do_put(cap->oap->regname, NULL, dir, cap->count1, flags);
  
!       // If a register was saved, put it back now.
!       if (reg2 != NULL)
!           put_register(regname, reg2);
  
!       // What to reselect with "gv"?  Selecting the just put text seems to
!       // be the most useful, since the original text was removed.
!       if (was_visual)
!       {
!           curbuf->b_visual.vi_start = curbuf->b_op_start;
!           curbuf->b_visual.vi_end = curbuf->b_op_end;
!           // need to adjust cursor position
!           if (*p_sel == 'e')
!               inc(&curbuf->b_visual.vi_end);
!       }
  
!       // When all lines were selected and deleted do_put() leaves an empty
!       // line that needs to be deleted now.
!       if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL)
        {
!           ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);
!           deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
  
!           // If the cursor was in that line, move it to the end of the last
!           // line.
!           if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
!           {
!               curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
!               coladvance((colnr_T)MAXCOL);
!           }
        }
-       auto_format(FALSE, TRUE);
      }
  }
  
  /*
--- 7286,7418 ----
        }
        else
  #endif
!           clearopbeep(cap->oap);
!       return;
      }
+ 
  #ifdef FEAT_JOB_CHANNEL
!     if (bt_prompt(curbuf) && !prompt_curpos_editable())
      {
        clearopbeep(cap->oap);
+       return;
      }
  #endif
! 
!     if (fix_indent)
      {
!       dir = (cap->cmdchar == ']' && cap->nchar == 'p')
!           ? FORWARD : BACKWARD;
!       flags |= PUT_FIXINDENT;
!     }
!     else
!       dir = (cap->cmdchar == 'P'
!               || ((cap->cmdchar == 'g' || cap->cmdchar == 'z')
!                   && cap->nchar == 'P')) ? BACKWARD : FORWARD;
!     prep_redo_cmd(cap);
!     if (cap->cmdchar == 'g')
!       flags |= PUT_CURSEND;
!     else if (cap->cmdchar == 'z')
!       flags |= PUT_BLOCK_INNER;
  
!     if (VIsual_active)
!     {
!       // Putting in Visual mode: The put text replaces the selected
!       // text.  First delete the selected text, then put the new text.
!       // Need to save and restore the registers that the delete
!       // overwrites if the old contents is being put.
!       was_visual = TRUE;
!       regname = cap->oap->regname;
!       keep_registers = cap->cmdchar == 'P';
  #ifdef FEAT_CLIPBOARD
!       adjust_clip_reg(&regname);
  #endif
!       if (regname == 0 || regname == '"'
!               || VIM_ISDIGIT(regname) || regname == '-'
  #ifdef FEAT_CLIPBOARD
!               || (clip_unnamed && (regname == '*' || regname == '+'))
  #endif
  
!          )
!       {
!           // The delete is going to overwrite the register we want to
!           // put, save it first.
!           reg1 = get_register(regname, TRUE);
        }
  
!       // Now delete the selected text. Avoid messages here.
!       cap->cmdchar = 'd';
!       cap->nchar = NUL;
!       cap->oap->regname = keep_registers ? '_' : NUL;
!       ++msg_silent;
!       nv_operator(cap);
!       do_pending_operator(cap, 0, FALSE);
!       empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
!       --msg_silent;
  
!       // delete PUT_LINE_BACKWARD;
!       cap->oap->regname = regname;
  
!       if (reg1 != NULL)
        {
!           // Delete probably changed the register we want to put, save
!           // it first. Then put back what was there before the delete.
!           reg2 = get_register(regname, FALSE);
!           put_register(regname, reg1);
!       }
! 
!       // When deleted a linewise Visual area, put the register as
!       // lines to avoid it joined with the next line.  When deletion was
!       // characterwise, split a line when putting lines.
!       if (VIsual_mode == 'V')
!           flags |= PUT_LINE;
!       else if (VIsual_mode == 'v')
!           flags |= PUT_LINE_SPLIT;
!       if (VIsual_mode == Ctrl_V && dir == FORWARD)
!           flags |= PUT_LINE_FORWARD;
!       dir = BACKWARD;
!       if ((VIsual_mode != 'V'
!                   && curwin->w_cursor.col < curbuf->b_op_start.col)
!               || (VIsual_mode == 'V'
!                   && curwin->w_cursor.lnum < curbuf->b_op_start.lnum))
!           // cursor is at the end of the line or end of file, put
!           // forward.
!           dir = FORWARD;
!       // May have been reset in do_put().
!       VIsual_active = TRUE;
!     }
!     do_put(cap->oap->regname, NULL, dir, cap->count1, flags);
! 
!     // If a register was saved, put it back now.
!     if (reg2 != NULL)
!       put_register(regname, reg2);
! 
!     // What to reselect with "gv"?  Selecting the just put text seems to
!     // be the most useful, since the original text was removed.
!     if (was_visual)
!     {
!       curbuf->b_visual.vi_start = curbuf->b_op_start;
!       curbuf->b_visual.vi_end = curbuf->b_op_end;
!       // need to adjust cursor position
!       if (*p_sel == 'e')
!           inc(&curbuf->b_visual.vi_end);
!     }
! 
!     // When all lines were selected and deleted do_put() leaves an empty
!     // line that needs to be deleted now.
!     if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL)
!     {
!       ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);
!       deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
  
!       // If the cursor was in that line, move it to the end of the last
!       // line.
!       if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
!       {
!           curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
!           coladvance((colnr_T)MAXCOL);
        }
      }
+     auto_format(FALSE, TRUE);
  }
  
  /*
*** ../vim-9.0.1207/src/ops.c   2022-11-24 00:08:58.465010528 +0000
--- src/ops.c   2023-01-16 18:14:06.722813345 +0000
***************
*** 989,999 ****
  {
      char_u    *p;
  
!     if (oap->inclusive)
!     {
!       p = ml_get(oap->end.lnum);
!       oap->end.col += mb_tail_off(p, p + oap->end.col);
!     }
  }
  
  /*
--- 989,999 ----
  {
      char_u    *p;
  
!     if (!oap->inclusive)
!       return;
! 
!     p = ml_get(oap->end.lnum);
!     oap->end.col += mb_tail_off(p, p + oap->end.col);
  }
  
  /*
***************
*** 1869,1890 ****
  {
      unsigned int cur_ve_flags = get_ve_flags();
  
!     if (curwin->w_cursor.col > 0
!           && gchar_cursor() == NUL
!           && (cur_ve_flags & VE_ONEMORE) == 0
!           && !(restart_edit || (State & MODE_INSERT)))
!     {
!       // Put the cursor on the last character in the line.
!       dec_cursor();
  
!       if (cur_ve_flags == VE_ALL)
!       {
!           colnr_T         scol, ecol;
  
!           // Coladd is set to the width of the last character.
!           getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
!           curwin->w_cursor.coladd = ecol - scol + 1;
!       }
      }
  }
  
--- 1869,1891 ----
  {
      unsigned int cur_ve_flags = get_ve_flags();
  
!     int adj_cursor = (curwin->w_cursor.col > 0
!                               && gchar_cursor() == NUL
!                               && (cur_ve_flags & VE_ONEMORE) == 0
!                               && !(restart_edit || (State & MODE_INSERT)));
!     if (!adj_cursor)
!       return;
  
!     // Put the cursor on the last character in the line.
!     dec_cursor();
  
!     if (cur_ve_flags == VE_ALL)
!     {
!       colnr_T     scol, ecol;
! 
!       // Coladd is set to the width of the last character.
!       getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
!       curwin->w_cursor.coladd = ecol - scol + 1;
      }
  }
  
***************
*** 2235,2246 ****
      static void
  restore_lbr(int lbr_saved)
  {
!     if (!curwin->w_p_lbr && lbr_saved)
!     {
!       // changing 'linebreak' may require w_virtcol to be updated
!       curwin->w_p_lbr = TRUE;
!       curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
!     }
  }
  #endif
  
--- 2236,2247 ----
      static void
  restore_lbr(int lbr_saved)
  {
!     if (curwin->w_p_lbr || !lbr_saved)
!       return;
! 
!     // changing 'linebreak' may require w_virtcol to be updated
!     curwin->w_p_lbr = TRUE;
!     curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
  }
  #endif
  
*** ../vim-9.0.1207/src/option.c        2022-12-02 15:58:34.602705473 +0000
--- src/option.c        2023-01-16 18:14:06.722813345 +0000
***************
*** 672,688 ****
        p = vim_strsave_escaped(val, (char_u *)" ");
      else
        p = vim_strsave(val);
!     if (p != NULL)            // we don't want a NULL
!     {
!       opt_idx = findoption((char_u *)name);
!       if (opt_idx >= 0)
!       {
!           if (options[opt_idx].flags & P_DEF_ALLOCED)
!               vim_free(options[opt_idx].def_val[VI_DEFAULT]);
!           options[opt_idx].def_val[VI_DEFAULT] = p;
!           options[opt_idx].flags |= P_DEF_ALLOCED;
!       }
!     }
  }
  
      void
--- 672,688 ----
        p = vim_strsave_escaped(val, (char_u *)" ");
      else
        p = vim_strsave(val);
!     if (p == NULL)            // we don't want a NULL
!       return;
! 
!     opt_idx = findoption((char_u *)name);
!     if (opt_idx < 0)
!       return;
! 
!     if (options[opt_idx].flags & P_DEF_ALLOCED)
!       vim_free(options[opt_idx].def_val[VI_DEFAULT]);
!     options[opt_idx].def_val[VI_DEFAULT] = p;
!     options[opt_idx].flags |= P_DEF_ALLOCED;
  }
  
      void
***************
*** 1112,1142 ****
      if (lang == NULL || STRLEN(lang) < 2)     // safety check
        return;
      idx = findoption((char_u *)"hlg");
!     if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
      {
!       if (options[idx].flags & P_ALLOCED)
!           free_string_option(p_hlg);
!       p_hlg = vim_strsave(lang);
!       if (p_hlg == NULL)
!           p_hlg = empty_option;
!       else
        {
!           // zh_CN becomes "cn", zh_TW becomes "tw"
!           if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
!           {
!               p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
!               p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
!           }
!           // any C like setting, such as C.UTF-8, becomes "en"
!           else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
!           {
!               p_hlg[0] = 'e';
!               p_hlg[1] = 'n';
!           }
!           p_hlg[2] = NUL;
        }
!       options[idx].flags |= P_ALLOCED;
      }
  }
  #endif
  
--- 1112,1142 ----
      if (lang == NULL || STRLEN(lang) < 2)     // safety check
        return;
      idx = findoption((char_u *)"hlg");
!     if (idx < 0 || (options[idx].flags & P_WAS_SET))
!       return;
! 
!     if (options[idx].flags & P_ALLOCED)
!       free_string_option(p_hlg);
!     p_hlg = vim_strsave(lang);
!     if (p_hlg == NULL)
!       p_hlg = empty_option;
!     else
      {
!       // zh_CN becomes "cn", zh_TW becomes "tw"
!       if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
        {
!           p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
!           p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
!       }
!       // any C like setting, such as C.UTF-8, becomes "en"
!       else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
!       {
!           p_hlg[0] = 'e';
!           p_hlg[1] = 'n';
        }
!       p_hlg[2] = NUL;
      }
+     options[idx].flags |= P_ALLOCED;
  }
  #endif
  
***************
*** 1171,1187 ****
        p_title = val;
      }
      idx1 = findoption((char_u *)"icon");
!     if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
      {
  #ifdef FEAT_GUI
!       if (gui.starting || gui.in_use)
!           val = TRUE;
!       else
  #endif
!           val = mch_can_restore_icon();
!       options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
!       p_icon = val;
!     }
  }
  
      void
--- 1171,1189 ----
        p_title = val;
      }
      idx1 = findoption((char_u *)"icon");
!     if (idx1 < 0 || (options[idx1].flags & P_WAS_SET))
      {
+       return;
+     }
+ 
  #ifdef FEAT_GUI
!     if (gui.starting || gui.in_use)
!       val = TRUE;
!     else
  #endif
!       val = mch_can_restore_icon();
!     options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
!     p_icon = val;
  }
  
      void
***************
*** 7084,7095 ****
  {
      int idx = findoption(name);
  
!     if (idx >= 0)
!     {
!       options[idx].flags &= ~P_WAS_SET;
!       return OK;
!     }
!     return FAIL;
  }
  
  /*
--- 7086,7096 ----
  {
      int idx = findoption(name);
  
!     if (idx < 0)
!       return FAIL;
! 
!     options[idx].flags &= ~P_WAS_SET;
!     return OK;
  }
  
  /*
*** ../vim-9.0.1207/src/optionstr.c     2022-12-16 16:41:19.208714806 +0000
--- src/optionstr.c     2023-01-16 18:14:06.722813345 +0000
***************
*** 155,196 ****
        char_u  *newval)
  {
      // Don't do this recursively.
!     if (oldval != NULL && newval != NULL
!                                   && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
!     {
!       char_u buf_type[7];
  
!       sprintf((char *)buf_type, "%s",
            (opt_flags & OPT_LOCAL) ? "local" : "global");
!       set_vim_var_string(VV_OPTION_OLD, oldval, -1);
!       set_vim_var_string(VV_OPTION_NEW, newval, -1);
!       set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
!       if (opt_flags & OPT_LOCAL)
!       {
!           set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
!           set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
!       }
!       if (opt_flags & OPT_GLOBAL)
!       {
!           set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
!           set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
!       }
!       if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
!       {
!           set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
!           set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
!           set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
!       }
!       if (opt_flags & OPT_MODELINE)
!       {
!           set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
!           set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
!       }
!       apply_autocmds(EVENT_OPTIONSET,
!                      get_option_fullname(opt_idx), NULL, FALSE,
!                      NULL);
!       reset_v_option_vars();
      }
  }
  #endif
  
--- 155,196 ----
        char_u  *newval)
  {
      // Don't do this recursively.
!     if (oldval == NULL || newval == NULL
!                                   || *get_vim_var_str(VV_OPTION_TYPE) != NUL)
!       return;
! 
!     char_u buf_type[7];
  
!     sprintf((char *)buf_type, "%s",
            (opt_flags & OPT_LOCAL) ? "local" : "global");
!     set_vim_var_string(VV_OPTION_OLD, oldval, -1);
!     set_vim_var_string(VV_OPTION_NEW, newval, -1);
!     set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
!     if (opt_flags & OPT_LOCAL)
!     {
!       set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
!       set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
!     }
!     if (opt_flags & OPT_GLOBAL)
!     {
!       set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
!       set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
!     }
!     if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
!     {
!       set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
!       set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
!       set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
!     }
!     if (opt_flags & OPT_MODELINE)
!     {
!       set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
!       set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
      }
+     apply_autocmds(EVENT_OPTIONSET,
+           get_option_fullname(opt_idx), NULL, FALSE,
+           NULL);
+     reset_v_option_vars();
  }
  #endif
  
***************
*** 387,431 ****
        return;
  
      s = vim_strsave(val);
!     if (s != NULL)
      {
!       varp = (char_u **)get_option_varp_scope(idx,
!                                              both ? OPT_LOCAL : opt_flags);
!       if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
!           free_string_option(*varp);
!       *varp = s;
! 
!       // For buffer/window local option may also set the global value.
!       if (both)
!           set_string_option_global(idx, varp);
! 
!       set_option_flag(idx, P_ALLOCED);
! 
!       // When setting both values of a global option with a local value,
!       // make the local value empty, so that the global value is used.
!       if (is_global_local_option(idx) && both)
!       {
!           free_string_option(*varp);
!           *varp = empty_option;
!       }
  # ifdef FEAT_EVAL
!       if (set_sid != SID_NONE)
!       {
!           sctx_T script_ctx;
  
!           if (set_sid == 0)
!               script_ctx = current_sctx;
!           else
!           {
!               script_ctx.sc_sid = set_sid;
!               script_ctx.sc_seq = 0;
!               script_ctx.sc_lnum = 0;
!               script_ctx.sc_version = 1;
!           }
!           set_option_sctx_idx(idx, opt_flags, script_ctx);
        }
! # endif
      }
  }
  
  /*
--- 387,431 ----
        return;
  
      s = vim_strsave(val);
!     if (s == NULL)
!       return;
! 
!     varp = (char_u **)get_option_varp_scope(idx,
!           both ? OPT_LOCAL : opt_flags);
!     if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
!       free_string_option(*varp);
!     *varp = s;
! 
!     // For buffer/window local option may also set the global value.
!     if (both)
!       set_string_option_global(idx, varp);
! 
!     set_option_flag(idx, P_ALLOCED);
! 
!     // When setting both values of a global option with a local value,
!     // make the local value empty, so that the global value is used.
!     if (is_global_local_option(idx) && both)
      {
!       free_string_option(*varp);
!       *varp = empty_option;
!     }
  # ifdef FEAT_EVAL
!     if (set_sid != SID_NONE)
!     {
!       sctx_T script_ctx;
  
!       if (set_sid == 0)
!           script_ctx = current_sctx;
!       else
!       {
!           script_ctx.sc_sid = set_sid;
!           script_ctx.sc_seq = 0;
!           script_ctx.sc_lnum = 0;
!           script_ctx.sc_version = 1;
        }
!       set_option_sctx_idx(idx, opt_flags, script_ctx);
      }
+ # endif
  }
  
  /*
***************
*** 507,560 ****
        return NULL;
  
      s = vim_strsave(value == NULL ? (char_u *)"" : value);
!     if (s != NULL)
!     {
!       varp = (char_u **)get_option_varp_scope(opt_idx,
!               (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
!                   ? (is_global_local_option(opt_idx)
!                       ? OPT_GLOBAL : OPT_LOCAL)
!                   : opt_flags);
!       oldval = *varp;
  #if defined(FEAT_EVAL)
!       if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
!       {
!           oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
!           oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
!       }
  #endif
!       *varp = s;
  
  #if defined(FEAT_EVAL)
!       if (!starting
  # ifdef FEAT_CRYPT
!               && !is_crypt_key_option(opt_idx)
  # endif
!               )
!       {
!           if (oldval_l != NULL)
!               saved_oldval_l = vim_strsave(oldval_l);
!           if (oldval_g != NULL)
!               saved_oldval_g = vim_strsave(oldval_g);
!           saved_oldval = vim_strsave(oldval);
!           saved_newval = vim_strsave(s);
!       }
  #endif
!       if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
!                                          opt_flags, &value_checked)) == NULL)
!           did_set_option(opt_idx, opt_flags, TRUE, value_checked);
  
  #if defined(FEAT_EVAL)
!       // call autocommand after handling side effects
!       if (errmsg == NULL)
!           trigger_optionset_string(opt_idx, opt_flags,
!                                  saved_oldval, saved_oldval_l,
!                                  saved_oldval_g, saved_newval);
!       vim_free(saved_oldval);
!       vim_free(saved_oldval_l);
!       vim_free(saved_oldval_g);
!       vim_free(saved_newval);
  #endif
-     }
      return errmsg;
  }
  
--- 507,560 ----
        return NULL;
  
      s = vim_strsave(value == NULL ? (char_u *)"" : value);
!     if (s == NULL)
!       return NULL;
! 
!     varp = (char_u **)get_option_varp_scope(opt_idx,
!           (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
!           ? (is_global_local_option(opt_idx)
!               ? OPT_GLOBAL : OPT_LOCAL)
!           : opt_flags);
!     oldval = *varp;
  #if defined(FEAT_EVAL)
!     if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
!     {
!       oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
!       oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
!     }
  #endif
!     *varp = s;
  
  #if defined(FEAT_EVAL)
!     if (!starting
  # ifdef FEAT_CRYPT
!           && !is_crypt_key_option(opt_idx)
  # endif
!        )
!     {
!       if (oldval_l != NULL)
!           saved_oldval_l = vim_strsave(oldval_l);
!       if (oldval_g != NULL)
!           saved_oldval_g = vim_strsave(oldval_g);
!       saved_oldval = vim_strsave(oldval);
!       saved_newval = vim_strsave(s);
!     }
  #endif
!     if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
!                   opt_flags, &value_checked)) == NULL)
!       did_set_option(opt_idx, opt_flags, TRUE, value_checked);
  
  #if defined(FEAT_EVAL)
!     // call autocommand after handling side effects
!     if (errmsg == NULL)
!       trigger_optionset_string(opt_idx, opt_flags,
!               saved_oldval, saved_oldval_l,
!               saved_oldval_g, saved_newval);
!     vim_free(saved_oldval);
!     vim_free(saved_oldval_l);
!     vim_free(saved_oldval_g);
!     vim_free(saved_newval);
  #endif
      return errmsg;
  }
  
*** ../vim-9.0.1207/src/os_amiga.c      2022-09-25 20:12:17.852221938 +0100
--- src/os_amiga.c      2023-01-16 18:14:06.726813355 +0000
***************
*** 234,246 ****
      void          Delay(long);
  #endif
  
!     if (msec > 0)
!     {
!       if (flags & MCH_DELAY_IGNOREINPUT)
!           Delay(msec / 20L);      // Delay works with 20 msec intervals
!       else
!           WaitForChar(raw_in, msec * 1000L);
!     }
  }
  
  /*
--- 234,246 ----
      void          Delay(long);
  #endif
  
!     if (msec <= 0)
!       return;
! 
!     if (flags & MCH_DELAY_IGNOREINPUT)
!       Delay(msec / 20L);          // Delay works with 20 msec intervals
!     else
!       WaitForChar(raw_in, msec * 1000L);
  }
  
  /*
***************
*** 577,594 ****
      size_t                flen;
  
      fib = get_fib(name);
!     if (fib != NULL)
!     {
!       flen = STRLEN(name);
!       // TODO: Check if this fix applies to AmigaOS < 4 too.
  #ifdef __amigaos4__
!       if (fib->fib_DirEntryType == ST_ROOT)
!           strcat(fib->fib_FileName, ":");
  #endif
!       if (flen == strlen(fib->fib_FileName))  // safety check
!           mch_memmove(name, fib->fib_FileName, flen);
!       free_fib(fib);
!     }
  }
  
  /*
--- 577,594 ----
      size_t                flen;
  
      fib = get_fib(name);
!     if (fib == NULL)
!       return;
! 
!     flen = STRLEN(name);
!     // TODO: Check if this fix applies to AmigaOS < 4 too.
  #ifdef __amigaos4__
!     if (fib->fib_DirEntryType == ST_ROOT)
!       strcat(fib->fib_FileName, ":");
  #endif
!     if (flen == strlen(fib->fib_FileName))    // safety check
!       mch_memmove(name, fib->fib_FileName, flen);
!     free_fib(fib);
  }
  
  /*
***************
*** 609,625 ****
  #else
      fib = ALLOC_ONE(struct FileInfoBlock);
  #endif
!     if (fib != NULL)
      {
!       flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
!       if (flock == (BPTR)NULL || !Examine(flock, fib))
!       {
!           free_fib(fib);  // in case of an error the memory is freed here
!           fib = NULL;
!       }
!       if (flock)
!           UnLock(flock);
      }
      return fib;
  }
  
--- 609,625 ----
  #else
      fib = ALLOC_ONE(struct FileInfoBlock);
  #endif
!     if (fib == NULL)
!       return;
! 
!     flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
!     if (flock == (BPTR)NULL || !Examine(flock, fib))
      {
!       free_fib(fib);  // in case of an error the memory is freed here
!       fib = NULL;
      }
+     if (flock)
+       UnLock(flock);
      return fib;
  }
  
***************
*** 815,825 ****
      long                  retval = -1;
  
      fib = get_fib(name);
!     if (fib != NULL)
!     {
!       retval = fib->fib_Protection;
!       free_fib(fib);
!     }
      return retval;
  }
  
--- 815,825 ----
      long                  retval = -1;
  
      fib = get_fib(name);
!     if (fib == NULL)
!       return -1;
! 
!     retval = fib->fib_Protection;
!     free_fib(fib);
      return retval;
  }
  
***************
*** 856,870 ****
      int                           retval = FALSE;
  
      fib = get_fib(name);
!     if (fib != NULL)
!     {
  #ifdef __amigaos4__
!       retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
  #else
!       retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
  #endif
!       free_fib(fib);
!     }
      return retval;
  }
  
--- 856,870 ----
      int                           retval = FALSE;
  
      fib = get_fib(name);
!     if (fib == NULL)
!       return FALSE;
! 
  #ifdef __amigaos4__
!     retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
  #else
!     retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
  #endif
!     free_fib(fib);
      return retval;
  }
  
***************
*** 877,888 ****
      BPTR      lock;
  
      lock = CreateDir(name);
!     if (lock != NULL)
!     {
!       UnLock(lock);
!       return 0;
!     }
!     return -1;
  }
  
  /*
--- 877,887 ----
      BPTR      lock;
  
      lock = CreateDir(name);
!     if (lock == NULL)
!       return -1;
! 
!     UnLock(lock);
!     return 0;
  }
  
  /*
***************
*** 1173,1189 ****
      void
  mch_set_shellsize(void)
  {
!     if (term_console)
!     {
!       size_set = TRUE;
!       out_char(CSI);
!       out_num((long)Rows);
!       out_char('t');
!       out_char(CSI);
!       out_num((long)Columns);
!       out_char('u');
!       out_flush();
!     }
  }
  
  /*
--- 1172,1188 ----
      void
  mch_set_shellsize(void)
  {
!     if (!term_console)
!       return;
! 
!     size_set = TRUE;
!     out_char(CSI);
!     out_num((long)Rows);
!     out_char('t');
!     out_char(CSI);
!     out_num((long)Columns);
!     out_char('u');
!     out_flush();
  }
  
  /*
*** ../vim-9.0.1207/src/os_mac_conv.c   2022-09-17 21:07:52.099993159 +0100
--- src/os_mac_conv.c   2023-01-16 18:14:06.726813355 +0000
***************
*** 568,595 ****
      void
  mac_lang_init(void)
  {
!     if (mch_getenv((char_u *)"LANG") == NULL)
!     {
!       char    buf[50];
  
!       // $LANG is not set, either because it was unset or Vim was started
!       // from the Dock.  Query the system locale.
!       if (LocaleRefGetPartString(NULL,
!                   kLocaleLanguageMask | kLocaleLanguageVariantMask |
!                   kLocaleRegionMask | kLocaleRegionVariantMask,
!                   sizeof(buf) - 10, buf) == noErr && *buf)
!       {
!           if (strcasestr(buf, "utf-8") == NULL)
!               strcat(buf, ".UTF-8");
!           vim_setenv((char_u *)"LANG", (char_u *)buf);
  #   ifdef HAVE_LOCALE_H
!           setlocale(LC_ALL, "");
  #   endif
  #   if defined(LC_NUMERIC)
!           // Make sure strtod() uses a decimal point, not a comma.
!           setlocale(LC_NUMERIC, "C");
  #   endif
-       }
      }
  }
  #endif // MACOS_CONVERT
--- 568,595 ----
      void
  mac_lang_init(void)
  {
!     if (mch_getenv((char_u *)"LANG") != NULL)
!       return;
! 
!     char      buf[50];
  
!     // $LANG is not set, either because it was unset or Vim was started
!     // from the Dock.  Query the system locale.
!     if (LocaleRefGetPartString(NULL,
!               kLocaleLanguageMask | kLocaleLanguageVariantMask |
!               kLocaleRegionMask | kLocaleRegionVariantMask,
!               sizeof(buf) - 10, buf) == noErr && *buf)
!     {
!       if (strcasestr(buf, "utf-8") == NULL)
!           strcat(buf, ".UTF-8");
!       vim_setenv((char_u *)"LANG", (char_u *)buf);
  #   ifdef HAVE_LOCALE_H
!       setlocale(LC_ALL, "");
  #   endif
  #   if defined(LC_NUMERIC)
!       // Make sure strtod() uses a decimal point, not a comma.
!       setlocale(LC_NUMERIC, "C");
  #   endif
      }
  }
  #endif // MACOS_CONVERT
*** ../vim-9.0.1207/src/os_mswin.c      2022-09-18 12:24:30.542430902 +0100
--- src/os_mswin.c      2023-01-16 18:14:06.726813355 +0000
***************
*** 835,858 ****
      GetSystemInfo(&si);
  
      // get memory information
!     if (VirtualQuery(str, &mbi, sizeof(mbi)))
!     {
!       // pre cast these (typing savers)
!       long_u dwStr = (long_u)str;
!       long_u dwBaseAddress = (long_u)mbi.BaseAddress;
! 
!       // get start address of page that str is on
!       long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
! 
!       // get length from str to end of page
!       long_u pageLength = si.dwPageSize - (dwStr - strPage);
! 
!       for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
!                                 p += pageLength, pageLength = si.dwPageSize)
!           for (i = 0; i < pageLength; ++i, ++length)
!               if (p[i] == NUL)
!                   return length + 1;
!     }
  
      return 0;
  }
--- 835,858 ----
      GetSystemInfo(&si);
  
      // get memory information
!     if (!VirtualQuery(str, &mbi, sizeof(mbi)))
!       return 0;
! 
!     // pre cast these (typing savers)
!     long_u dwStr = (long_u)str;
!     long_u dwBaseAddress = (long_u)mbi.BaseAddress;
! 
!     // get start address of page that str is on
!     long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
! 
!     // get length from str to end of page
!     long_u pageLength = si.dwPageSize - (dwStr - strPage);
! 
!     for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
!           p += pageLength, pageLength = si.dwPageSize)
!       for (i = 0; i < pageLength; ++i, ++length)
!           if (p[i] == NUL)
!               return length + 1;
  
      return 0;
  }
***************
*** 1213,1255 ****
      RECT      rc, rcDlg, rcOwner;
      PRINTDLGW *pPD;
  
!     if (uiMsg == WM_INITDIALOG)
!     {
!       // Get the owner window and dialog box rectangles.
!       if ((hwndOwner = GetParent(hDlg)) == NULL)
!           hwndOwner = GetDesktopWindow();
! 
!       GetWindowRect(hwndOwner, &rcOwner);
!       GetWindowRect(hDlg, &rcDlg);
!       CopyRect(&rc, &rcOwner);
! 
!       // Offset the owner and dialog box rectangles so that
!       // right and bottom values represent the width and
!       // height, and then offset the owner again to discard
!       // space taken up by the dialog box.
! 
!       OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
!       OffsetRect(&rc, -rc.left, -rc.top);
!       OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
! 
!       // The new position is the sum of half the remaining
!       // space and the owner's original position.
! 
!       SetWindowPos(hDlg,
!               HWND_TOP,
!               rcOwner.left + (rc.right / 2),
!               rcOwner.top + (rc.bottom / 2),
!               0, 0,           // ignores size arguments
!               SWP_NOSIZE);
! 
!       //  tackle the printdlg copiesctrl problem
!       pPD = (PRINTDLGW *)lParam;
!       pPD->nCopies = (WORD)pPD->lCustData;
!       SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
!       //  Bring the window to top
!       BringWindowToTop(GetParent(hDlg));
!       SetForegroundWindow(hDlg);
!     }
  
      return FALSE;
  }
--- 1213,1255 ----
      RECT      rc, rcDlg, rcOwner;
      PRINTDLGW *pPD;
  
!     if (uiMsg != WM_INITDIALOG)
!       return FALSE;
! 
!     // Get the owner window and dialog box rectangles.
!     if ((hwndOwner = GetParent(hDlg)) == NULL)
!       hwndOwner = GetDesktopWindow();
! 
!     GetWindowRect(hwndOwner, &rcOwner);
!     GetWindowRect(hDlg, &rcDlg);
!     CopyRect(&rc, &rcOwner);
! 
!     // Offset the owner and dialog box rectangles so that
!     // right and bottom values represent the width and
!     // height, and then offset the owner again to discard
!     // space taken up by the dialog box.
! 
!     OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
!     OffsetRect(&rc, -rc.left, -rc.top);
!     OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
! 
!     // The new position is the sum of half the remaining
!     // space and the owner's original position.
! 
!     SetWindowPos(hDlg,
!           HWND_TOP,
!           rcOwner.left + (rc.right / 2),
!           rcOwner.top + (rc.bottom / 2),
!           0, 0,               // ignores size arguments
!           SWP_NOSIZE);
! 
!     //  tackle the printdlg copiesctrl problem
!     pPD = (PRINTDLGW *)lParam;
!     pPD->nCopies = (WORD)pPD->lCustData;
!     SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
!     //  Bring the window to top
!     BringWindowToTop(GetParent(hDlg));
!     SetForegroundWindow(hDlg);
  
      return FALSE;
  }
***************
*** 1571,1599 ****
      return TRUE;
  
  init_fail_dlg:
!     {
!       DWORD err = CommDlgExtendedError();
  
!       if (err)
!       {
!           char_u *buf;
! 
!           // I suspect FormatMessage() doesn't work for values returned by
!           // CommDlgExtendedError().  What does?
!           FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
!                         FORMAT_MESSAGE_FROM_SYSTEM |
!                         FORMAT_MESSAGE_IGNORE_INSERTS,
!                         NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
!           semsg(_(e_print_error_str),
!                                 buf == NULL ? (char_u *)_("Unknown") : buf);
!           LocalFree((LPVOID)(buf));
!       }
!       else
!           msg_clr_eos(); // Maybe canceled
  
!       mch_print_cleanup();
!       return FALSE;
      }
  }
  
  
--- 1571,1597 ----
      return TRUE;
  
  init_fail_dlg:
!     DWORD err = CommDlgExtendedError();
  
!     if (err)
!     {
!       char_u *buf;
  
!       // I suspect FormatMessage() doesn't work for values returned by
!       // CommDlgExtendedError().  What does?
!       FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
!               FORMAT_MESSAGE_FROM_SYSTEM |
!               FORMAT_MESSAGE_IGNORE_INSERTS,
!               NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
!       semsg(_(e_print_error_str),
!               buf == NULL ? (char_u *)_("Unknown") : buf);
!       LocalFree((LPVOID)(buf));
      }
+     else
+       msg_clr_eos(); // Maybe canceled
+ 
+     mch_print_cleanup();
+     return FALSE;
  }
  
  
***************
*** 1999,2009 ****
      static void
  CleanUpMessaging(void)
  {
!     if (message_window != 0)
!     {
!       DestroyWindow(message_window);
!       message_window = 0;
!     }
  }
  
  static int save_reply(HWND server, char_u *reply, int expr);
--- 1997,2007 ----
      static void
  CleanUpMessaging(void)
  {
!     if (message_window == 0)
!       return;
! 
!     DestroyWindow(message_window);
!     message_window = 0;
  }
  
  static int save_reply(HWND server, char_u *reply, int expr);
*** ../vim-9.0.1207/src/os_qnx.c        2019-12-05 19:18:17.000000000 +0000
--- src/os_qnx.c        2023-01-16 18:14:06.726813355 +0000
***************
*** 67,104 ****
      char_u        *clip_text = NULL;
  
      cbdata = PhClipboardPasteStart(PhInputGroup(NULL));
!     if (cbdata != NULL)
      {
!       // Look for the vim specific clip first
!       clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
!       if (clip_header != NULL && clip_header->data != NULL)
        {
!           switch(*(char *) clip_header->data)
!           {
!               default: // fallthrough to line type
!               case 'L': type = MLINE; break;
!               case 'C': type = MCHAR; break;
!               case 'B': type = MBLOCK; break;
!           }
!           is_type_set = TRUE;
        }
  
!       // Try for just normal text
!       clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
!       if (clip_header != NULL)
!       {
!           clip_text = clip_header->data;
!           clip_length  = clip_header->length - 1;
  
!           if (clip_text != NULL && is_type_set == FALSE)
!               type = MAUTO;
!       }
  
!       if ((clip_text != NULL) && (clip_length > 0))
!           clip_yank_selection(type, clip_text, clip_length, cbd);
  
!       PhClipboardPasteFinish(cbdata);
!     }
  }
  
  void
--- 67,104 ----
      char_u        *clip_text = NULL;
  
      cbdata = PhClipboardPasteStart(PhInputGroup(NULL));
!     if (cbdata == NULL)
!       return;
! 
!     // Look for the vim specific clip first
!     clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
!     if (clip_header != NULL && clip_header->data != NULL)
      {
!       switch(*(char *) clip_header->data)
        {
!           default: // fallthrough to line type
!           case 'L': type = MLINE; break;
!           case 'C': type = MCHAR; break;
!           case 'B': type = MBLOCK; break;
        }
+       is_type_set = TRUE;
+     }
  
!     // Try for just normal text
!     clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
!     if (clip_header != NULL)
!     {
!       clip_text = clip_header->data;
!       clip_length  = clip_header->length - 1;
  
!       if (clip_text != NULL && is_type_set == FALSE)
!           type = MAUTO;
!     }
  
!     if ((clip_text != NULL) && (clip_length > 0))
!       clip_yank_selection(type, clip_text, clip_length, cbd);
  
!     PhClipboardPasteFinish(cbdata);
  }
  
  void
*** ../vim-9.0.1207/src/os_unix.c       2023-01-10 12:37:33.253580676 +0000
--- src/os_unix.c       2023-01-16 18:14:06.726813355 +0000
***************
*** 780,795 ****
      int
  mch_stackcheck(char *p)
  {
!     if (stack_limit != NULL)
      {
!       if (stack_grows_downwards)
!       {
!           if (p < stack_limit)
!               return FAIL;
!       }
!       else if (p > stack_limit)
            return FAIL;
      }
      return OK;
  }
  #endif
--- 780,795 ----
      int
  mch_stackcheck(char *p)
  {
!     if (stack_limit == NULL)
!       return OK;
! 
!     if (stack_grows_downwards)
      {
!       if (p < stack_limit)
            return FAIL;
      }
+     else if (p > stack_limit)
+       return FAIL;
      return OK;
  }
  #endif
***************
*** 837,861 ****
      static void
  init_signal_stack(void)
  {
!     if (signal_stack != NULL)
!     {
  # ifdef HAVE_SIGALTSTACK
  #  ifdef HAVE_SS_BASE
!       sigstk.ss_base = signal_stack;
  #  else
!       sigstk.ss_sp = signal_stack;
  #  endif
!       sigstk.ss_size = get_signal_stack_size();
!       sigstk.ss_flags = 0;
!       (void)sigaltstack(&sigstk, NULL);
  # else
!       sigstk.ss_sp = signal_stack;
!       if (stack_grows_downwards)
!           sigstk.ss_sp += get_signal_stack_size() - 1;
!       sigstk.ss_onstack = 0;
!       (void)sigstack(&sigstk, NULL);
  # endif
-     }
  }
  #endif
  
--- 837,861 ----
      static void
  init_signal_stack(void)
  {
!     if (signal_stack == NULL)
!       return;
! 
  # ifdef HAVE_SIGALTSTACK
  #  ifdef HAVE_SS_BASE
!     sigstk.ss_base = signal_stack;
  #  else
!     sigstk.ss_sp = signal_stack;
  #  endif
!     sigstk.ss_size = get_signal_stack_size();
!     sigstk.ss_flags = 0;
!     (void)sigaltstack(&sigstk, NULL);
  # else
!     sigstk.ss_sp = signal_stack;
!     if (stack_grows_downwards)
!       sigstk.ss_sp += get_signal_stack_size() - 1;
!     sigstk.ss_onstack = 0;
!     (void)sigstack(&sigstk, NULL);
  # endif
  }
  #endif
  
***************
*** 2020,2110 ****
      int                       retval = FALSE;
      Status            status;
  
!     if (get_x11_windis() == OK)
      {
!       // Get window/icon name if any
        if (get_title)
!           status = XGetWMName(x11_display, x11_window, &text_prop);
        else
!           status = XGetWMIconName(x11_display, x11_window, &text_prop);
! 
!       /*
!        * If terminal is xterm, then x11_window may be a child window of the
!        * outer xterm window that actually contains the window/icon name, so
!        * keep traversing up the tree until a window with a title/icon is
!        * found.
!        */
!       // Previously this was only done for xterm and alike.  I don't see a
!       // reason why it would fail for other terminal emulators.
!       // if (term_is_xterm)
!       {
!           Window          root;
!           Window          parent;
!           Window          win = x11_window;
!           Window         *children;
!           unsigned int    num_children;
  
!           while (!status || text_prop.value == NULL)
            {
-               if (!XQueryTree(x11_display, win, &root, &parent, &children,
-                                                              &num_children))
-                   break;
-               if (children)
-                   XFree((void *)children);
-               if (parent == root || parent == 0)
-                   break;
- 
-               win = parent;
                if (get_title)
!                   status = XGetWMName(x11_display, win, &text_prop);
                else
!                   status = XGetWMIconName(x11_display, win, &text_prop);
            }
!       }
!       if (status && text_prop.value != NULL)
!       {
!           retval = TRUE;
!           if (!test_only)
            {
!               if (get_title)
!                   vim_free(oldtitle);
!               else
!                   vim_free(oldicon);
!               if (text_prop.encoding == XA_STRING && !has_mbyte)
                {
                    if (get_title)
!                       oldtitle = vim_strsave((char_u *)text_prop.value);
                    else
!                       oldicon = vim_strsave((char_u *)text_prop.value);
                }
                else
                {
!                   char    **cl;
!                   Status  transform_status;
!                   int     n = 0;
! 
!                   transform_status = XmbTextPropertyToTextList(x11_display,
!                                                                &text_prop,
!                                                                &cl, &n);
!                   if (transform_status >= Success && n > 0 && cl[0])
!                   {
!                       if (get_title)
!                           oldtitle = vim_strsave((char_u *) cl[0]);
!                       else
!                           oldicon = vim_strsave((char_u *) cl[0]);
!                       XFreeStringList(cl);
!                   }
                    else
!                   {
!                       if (get_title)
!                           oldtitle = vim_strsave((char_u *)text_prop.value);
!                       else
!                           oldicon = vim_strsave((char_u *)text_prop.value);
!                   }
                }
            }
-           XFree((void *)text_prop.value);
        }
      }
      return retval;
  }
--- 2020,2109 ----
      int                       retval = FALSE;
      Status            status;
  
!     if (get_x11_windis() != OK)
!       return FALSE;
! 
!     // Get window/icon name if any
!     if (get_title)
!       status = XGetWMName(x11_display, x11_window, &text_prop);
!     else
!       status = XGetWMIconName(x11_display, x11_window, &text_prop);
! 
!     /*
!      * If terminal is xterm, then x11_window may be a child window of the
!      * outer xterm window that actually contains the window/icon name, so
!      * keep traversing up the tree until a window with a title/icon is
!      * found.
!      */
!     // Previously this was only done for xterm and alike.  I don't see a
!     // reason why it would fail for other terminal emulators.
!     // if (term_is_xterm)
!     Window        root;
!     Window        parent;
!     Window        win = x11_window;
!     Window       *children;
!     unsigned int    num_children;
! 
!     while (!status || text_prop.value == NULL)
      {
!       if (!XQueryTree(x11_display, win, &root, &parent, &children,
!                   &num_children))
!           break;
!       if (children)
!           XFree((void *)children);
!       if (parent == root || parent == 0)
!           break;
! 
!       win = parent;
        if (get_title)
!           status = XGetWMName(x11_display, win, &text_prop);
        else
!           status = XGetWMIconName(x11_display, win, &text_prop);
!     }
  
!     if (status && text_prop.value != NULL)
!     {
!       retval = TRUE;
!       if (!test_only)
!       {
!           if (get_title)
!               vim_free(oldtitle);
!           else
!               vim_free(oldicon);
!           if (text_prop.encoding == XA_STRING && !has_mbyte)
            {
                if (get_title)
!                   oldtitle = vim_strsave((char_u *)text_prop.value);
                else
!                   oldicon = vim_strsave((char_u *)text_prop.value);
            }
!           else
            {
!               char    **cl;
!               Status  transform_status;
!               int         n = 0;
! 
!               transform_status = XmbTextPropertyToTextList(x11_display,
!                       &text_prop,
!                       &cl, &n);
!               if (transform_status >= Success && n > 0 && cl[0])
                {
                    if (get_title)
!                       oldtitle = vim_strsave((char_u *) cl[0]);
                    else
!                       oldicon = vim_strsave((char_u *) cl[0]);
!                   XFreeStringList(cl);
                }
                else
                {
!                   if (get_title)
!                       oldtitle = vim_strsave((char_u *)text_prop.value);
                    else
!                       oldicon = vim_strsave((char_u *)text_prop.value);
                }
            }
        }
+       XFree((void *)text_prop.value);
      }
      return retval;
  }
***************
*** 2772,2823 ****
      DIR               *dirp;
      struct dirent *dp;
  
!     if (mch_lstat((char *)name, &st) >= 0)
      {
!       // Open the directory where the file is located.
!       slash = vim_strrchr(name, '/');
!       if (slash == NULL)
!       {
!           dirp = opendir(".");
!           tail = name;
!       }
!       else
!       {
!           *slash = NUL;
!           dirp = opendir((char *)name);
!           *slash = '/';
!           tail = slash + 1;
!       }
  
!       if (dirp != NULL)
!       {
!           while ((dp = readdir(dirp)) != NULL)
!           {
!               // Only accept names that differ in case and are the same byte
!               // length. TODO: accept different length name.
!               if (STRICMP(tail, dp->d_name) == 0
!                       && STRLEN(tail) == STRLEN(dp->d_name))
!               {
!                   char_u      newname[MAXPATHL + 1];
!                   struct stat st2;
  
!                   // Verify the inode is equal.
!                   vim_strncpy(newname, name, MAXPATHL);
!                   vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
!                                                   MAXPATHL - (tail - name));
!                   if (mch_lstat((char *)newname, &st2) >= 0
!                           && st.st_ino == st2.st_ino
!                           && st.st_dev == st2.st_dev)
!                   {
!                       STRCPY(tail, dp->d_name);
!                       break;
!                   }
!               }
            }
- 
-           closedir(dirp);
        }
      }
  }
  #endif
  
--- 2771,2822 ----
      DIR               *dirp;
      struct dirent *dp;
  
!     if (mch_lstat((char *)name, &st) < 0)
!       return;
! 
!     // Open the directory where the file is located.
!     slash = vim_strrchr(name, '/');
!     if (slash == NULL)
      {
!       dirp = opendir(".");
!       tail = name;
!     }
!     else
!     {
!       *slash = NUL;
!       dirp = opendir((char *)name);
!       *slash = '/';
!       tail = slash + 1;
!     }
  
!     if (dirp == NULL)
!       return;
  
!     while ((dp = readdir(dirp)) != NULL)
!     {
!       // Only accept names that differ in case and are the same byte
!       // length. TODO: accept different length name.
!       if (STRICMP(tail, dp->d_name) == 0
!               && STRLEN(tail) == STRLEN(dp->d_name))
!       {
!           char_u      newname[MAXPATHL + 1];
!           struct stat st2;
! 
!           // Verify the inode is equal.
!           vim_strncpy(newname, name, MAXPATHL);
!           vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
!                   MAXPATHL - (tail - name));
!           if (mch_lstat((char *)newname, &st2) >= 0
!                   && st.st_ino == st2.st_ino
!                   && st.st_dev == st2.st_dev)
!           {
!               STRCPY(tail, dp->d_name);
!               break;
            }
        }
      }
+ 
+     closedir(dirp);
  }
  #endif
  
***************
*** 2902,2947 ****
      if (selinux_enabled == -1)
        selinux_enabled = is_selinux_enabled();
  
!     if (selinux_enabled > 0)
!     {
!       // Use "char *" instead of "security_context_t" to avoid a deprecation
!       // warning.
!       char *from_context = NULL;
!       char *to_context = NULL;
! 
!       if (getfilecon((char *)from_file, &from_context) < 0)
!       {
!           // If the filesystem doesn't support extended attributes,
!           // the original had no special security context and the
!           // target cannot have one either.
!           if (errno == EOPNOTSUPP)
!               return;
  
!           msg_puts(_("\nCould not get security context for "));
!           msg_outtrans(from_file);
!           msg_putchar('\n');
            return;
!       }
!       if (getfilecon((char *)to_file, &to_context) < 0)
        {
!           msg_puts(_("\nCould not get security context for "));
            msg_outtrans(to_file);
            msg_putchar('\n');
-           freecon (from_context);
-           return ;
-       }
-       if (strcmp(from_context, to_context) != 0)
-       {
-           if (setfilecon((char *)to_file, from_context) < 0)
-           {
-               msg_puts(_("\nCould not set security context for "));
-               msg_outtrans(to_file);
-               msg_putchar('\n');
-           }
        }
-       freecon(to_context);
-       freecon(from_context);
      }
  }
  #endif // HAVE_SELINUX
  
--- 2901,2946 ----
      if (selinux_enabled == -1)
        selinux_enabled = is_selinux_enabled();
  
!     if (selinux_enabled <= 0)
!       return;
  
!     // Use "char *" instead of "security_context_t" to avoid a deprecation
!     // warning.
!     char *from_context = NULL;
!     char *to_context = NULL;
! 
!     if (getfilecon((char *)from_file, &from_context) < 0)
!     {
!       // If the filesystem doesn't support extended attributes,
!       // the original had no special security context and the
!       // target cannot have one either.
!       if (errno == EOPNOTSUPP)
            return;
! 
!       msg_puts(_("\nCould not get security context for "));
!       msg_outtrans(from_file);
!       msg_putchar('\n');
!       return;
!     }
!     if (getfilecon((char *)to_file, &to_context) < 0)
!     {
!       msg_puts(_("\nCould not get security context for "));
!       msg_outtrans(to_file);
!       msg_putchar('\n');
!       freecon (from_context);
!       return ;
!     }
!     if (strcmp(from_context, to_context) != 0)
!     {
!       if (setfilecon((char *)to_file, from_context) < 0)
        {
!           msg_puts(_("\nCould not set security context for "));
            msg_outtrans(to_file);
            msg_putchar('\n');
        }
      }
+     freecon(to_context);
+     freecon(from_context);
  }
  #endif // HAVE_SELINUX
  
***************
*** 3549,3569 ****
      int               retval = -1;
  
      tty_fd = get_tty_fd(fd);
!     if (tty_fd >= 0)
!     {
  #ifdef NEW_TTY_SYSTEM
  # ifdef HAVE_TERMIOS_H
!       retval = tcgetattr(tty_fd, (struct termios *)term);
  # else
!       retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
  # endif
  #else
!       // for "old" tty systems
!       retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
  #endif
!       if (tty_fd != fd)
!           close(tty_fd);
!     }
      return retval;
  }
  
--- 3548,3568 ----
      int               retval = -1;
  
      tty_fd = get_tty_fd(fd);
!     if (tty_fd < 0)
!       return -1;
! 
  #ifdef NEW_TTY_SYSTEM
  # ifdef HAVE_TERMIOS_H
!     retval = tcgetattr(tty_fd, (struct termios *)term);
  # else
!     retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
  # endif
  #else
!     // for "old" tty systems
!     retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
  #endif
!     if (tty_fd != fd)
!       close(tty_fd);
      return retval;
  }
  
***************
*** 3682,3699 ****
      char_u    buf[2];
      char_u    *p;
  
!     if (get_tty_info(read_cmd_fd, &info) == OK)
!     {
!       intr_char = info.interrupt;
!       buf[0] = info.backspace;
!       buf[1] = NUL;
!       add_termcode((char_u *)"kb", buf, FALSE);
! 
!       // If <BS> and <DEL> are now the same, redefine <DEL>.
!       p = find_termcode((char_u *)"kD");
!       if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
!           do_fixdel(NULL);
!     }
  }
  
  /*
--- 3681,3698 ----
      char_u    buf[2];
      char_u    *p;
  
!     if (get_tty_info(read_cmd_fd, &info) != OK)
!       return;
! 
!     intr_char = info.interrupt;
!     buf[0] = info.backspace;
!     buf[1] = NUL;
!     add_termcode((char_u *)"kb", buf, FALSE);
! 
!     // If <BS> and <DEL> are now the same, redefine <DEL>.
!     p = find_termcode((char_u *)"kD");
!     if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
!       do_fixdel(NULL);
  }
  
  /*
***************
*** 4160,4189 ****
      int               retval = -1;
  
      tty_fd = get_tty_fd(fd);
!     if (tty_fd >= 0)
!     {
  # if defined(TIOCSWINSZ)
!       struct winsize ws;
  
!       ws.ws_col = cols;
!       ws.ws_row = rows;
!       ws.ws_xpixel = cols * 5;
!       ws.ws_ypixel = rows * 10;
!       retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
!       ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
!                                         retval == 0 ? "success" : "failed");
  # elif defined(TIOCSSIZE)
!       struct ttysize ts;
  
!       ts.ts_cols = cols;
!       ts.ts_lines = rows;
!       retval = ioctl(tty_fd, TIOCSSIZE, &ts);
!       ch_log(NULL, "ioctl(TIOCSSIZE) %s",
!                                         retval == 0 ? "success" : "failed");
  # endif
!       if (tty_fd != fd)
!           close(tty_fd);
!     }
      return retval == 0 ? OK : FAIL;
  }
  #endif
--- 4159,4188 ----
      int               retval = -1;
  
      tty_fd = get_tty_fd(fd);
!     if (tty_fd < 0)
!       return FAIL;
! 
  # if defined(TIOCSWINSZ)
!     struct winsize ws;
  
!     ws.ws_col = cols;
!     ws.ws_row = rows;
!     ws.ws_xpixel = cols * 5;
!     ws.ws_ypixel = rows * 10;
!     retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
!     ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
!           retval == 0 ? "success" : "failed");
  # elif defined(TIOCSSIZE)
!     struct ttysize ts;
  
!     ts.ts_cols = cols;
!     ts.ts_lines = rows;
!     retval = ioctl(tty_fd, TIOCSSIZE, &ts);
!     ch_log(NULL, "ioctl(TIOCSSIZE) %s",
!           retval == 0 ? "success" : "failed");
  # endif
!     if (tty_fd != fd)
!       close(tty_fd);
      return retval == 0 ? OK : FAIL;
  }
  #endif
***************
*** 4362,4389 ****
        *name2 = NULL;
  
      *pty_master_fd = mch_openpty(&tty_name);      // open pty
!     if (*pty_master_fd >= 0)
!     {
!       // Leaving out O_NOCTTY may lead to waitpid() always returning
!       // 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
!       // adding O_NOCTTY always works when defined.
  #ifdef O_NOCTTY
!       *pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
  #else
!       *pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
  #endif
!       if (*pty_slave_fd < 0)
!       {
!           close(*pty_master_fd);
!           *pty_master_fd = -1;
!       }
!       else
!       {
!           if (name1 != NULL)
!               *name1 = vim_strsave((char_u *)tty_name);
!           if (name2 != NULL)
!               *name2 = vim_strsave((char_u *)tty_name);
!       }
      }
  }
  #endif
--- 4361,4388 ----
        *name2 = NULL;
  
      *pty_master_fd = mch_openpty(&tty_name);      // open pty
!     if (*pty_master_fd < 0)
!       return;
! 
!     // Leaving out O_NOCTTY may lead to waitpid() always returning
!     // 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
!     // adding O_NOCTTY always works when defined.
  #ifdef O_NOCTTY
!     *pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
  #else
!     *pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
  #endif
!     if (*pty_slave_fd < 0)
!     {
!       close(*pty_master_fd);
!       *pty_master_fd = -1;
!     }
!     else
!     {
!       if (name1 != NULL)
!           *name1 = vim_strsave((char_u *)tty_name);
!       if (name2 != NULL)
!           *name2 = vim_strsave((char_u *)tty_name);
      }
  }
  #endif
***************
*** 7250,7278 ****
        return 0;
  #endif
  
!     if (!gpm_flag)
!     {
!       gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
!       gpm_connect.defaultMask = ~GPM_HARD;
!       // Default handling for mouse move
!       gpm_connect.minMod = 0; // Handle any modifier keys
!       gpm_connect.maxMod = 0xffff;
!       if (Gpm_Open(&gpm_connect, 0) > 0)
!       {
!           // gpm library tries to handling TSTP causes
!           // problems. Anyways, we close connection to Gpm whenever
!           // we are going to suspend or starting an external process
!           // so we shouldn't  have problem with this
  # ifdef SIGTSTP
!           signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
  # endif
!           return 1; // succeed
!       }
!       if (gpm_fd == -2)
!           Gpm_Close(); // We don't want to talk to xterm via gpm
!       return 0;
      }
!     return 1; // already open
  }
  
  /*
--- 7249,7276 ----
        return 0;
  #endif
  
!     if (gpm_flag)
!       return 1; // already open
! 
!     gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
!     gpm_connect.defaultMask = ~GPM_HARD;
!     // Default handling for mouse move
!     gpm_connect.minMod = 0; // Handle any modifier keys
!     gpm_connect.maxMod = 0xffff;
!     if (Gpm_Open(&gpm_connect, 0) > 0)
!     {
!       // gpm library tries to handling TSTP causes
!       // problems. Anyways, we close connection to Gpm whenever
!       // we are going to suspend or starting an external process
!       // so we shouldn't  have problem with this
  # ifdef SIGTSTP
!       signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
  # endif
!       return 1; // succeed
      }
!     if (gpm_fd == -2)
!       Gpm_Close(); // We don't want to talk to xterm via gpm
!     return 0;
  }
  
  /*
***************
*** 7395,7408 ****
      mouse.operation = MOUSE_MODE;
      mouse.u.mode.mode = 0;
      mouse.u.mode.signal = SIGUSR2;
!     if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
!     {
!       signal(SIGUSR2, (void (*)())sig_sysmouse);
!       mouse.operation = MOUSE_SHOW;
!       ioctl(1, CONS_MOUSECTL, &mouse);
!       return OK;
!     }
!     return FAIL;
  }
  
  /*
--- 7393,7405 ----
      mouse.operation = MOUSE_MODE;
      mouse.u.mode.mode = 0;
      mouse.u.mode.signal = SIGUSR2;
!     if (ioctl(1, CONS_MOUSECTL, &mouse) == -1)
!       return FAIL;
! 
!     signal(SIGUSR2, (void (*)())sig_sysmouse);
!     mouse.operation = MOUSE_SHOW;
!     ioctl(1, CONS_MOUSECTL, &mouse);
!     return OK;
  }
  
  /*
***************
*** 8243,8256 ****
      void
  xsmp_close(void)
  {
!     if (xsmp_icefd != -1)
!     {
!       SmcCloseConnection(xsmp.smcconn, 0, NULL);
!       if (xsmp.clientid != NULL)
!           free(xsmp.clientid);
!       xsmp.clientid = NULL;
!       xsmp_icefd = -1;
!     }
  }
  #endif // USE_XSMP
  
--- 8240,8253 ----
      void
  xsmp_close(void)
  {
!     if (xsmp_icefd == -1)
!       return;
! 
!     SmcCloseConnection(xsmp.smcconn, 0, NULL);
!     if (xsmp.clientid != NULL)
!       free(xsmp.clientid);
!     xsmp.clientid = NULL;
!     xsmp_icefd = -1;
  }
  #endif // USE_XSMP
  
***************
*** 8348,8358 ****
      void
  delete_timer(void)
  {
!     if (timer_created)
!     {
!       timer_delete(timer_id);
!       timer_created = FALSE;
!     }
  }
  
  # else // HAVE_TIMER_CREATE
--- 8345,8355 ----
      void
  delete_timer(void)
  {
!     if (!timer_created)
!       return;
! 
!     timer_delete(timer_id);
!     timer_created = FALSE;
  }
  
  # else // HAVE_TIMER_CREATE
*** ../vim-9.0.1207/src/os_win32.c      2023-01-10 13:42:59.722128350 +0000
--- src/os_win32.c      2023-01-16 18:14:06.726813355 +0000
***************
*** 278,292 ****
  
      osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
      hNtdll = GetModuleHandle("ntdll.dll");
!     if (hNtdll != NULL)
!     {
!       pRtlGetVersion =
!           (PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
!       pRtlGetVersion(&osver);
!       ver = MAKE_VER(min(osver.dwMajorVersion, 255),
!                      min(osver.dwMinorVersion, 255),
!                      min(osver.dwBuildNumber, 32767));
!     }
      return ver;
  }
  
--- 278,292 ----
  
      osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
      hNtdll = GetModuleHandle("ntdll.dll");
!     if (hNtdll == NULL)
!       return ver;
! 
!     pRtlGetVersion =
!       (PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
!     pRtlGetVersion(&osver);
!     ver = MAKE_VER(min(osver.dwMajorVersion, 255),
!           min(osver.dwMinorVersion, 255),
!           min(osver.dwBuildNumber, 32767));
      return ver;
  }
  
***************
*** 478,506 ****
            exe_name = FullName_save((char_u *)temp, FALSE);
      }
  
!     if (exe_path == NULL && exe_name != NULL)
      {
!       exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
!       if (exe_path != NULL)
        {
!           // Append our starting directory to $PATH, so that when doing
!           // "!xxd" it's found in our starting directory.  Needed because
!           // SearchPath() also looks there.
!           p = mch_getenv("PATH");
!           if (p == NULL
!                      || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
!           {
!               if (p == NULL || *p == NUL)
!                   temp[0] = NUL;
!               else
!               {
!                   STRCPY(temp, p);
!                   STRCAT(temp, ";");
!               }
!               STRCAT(temp, exe_path);
!               vim_setenv((char_u *)"PATH", (char_u *)temp);
!           }
        }
      }
  }
  
--- 478,506 ----
            exe_name = FullName_save((char_u *)temp, FALSE);
      }
  
!     if (exe_path != NULL || exe_name == NULL)
!       return;
! 
!     exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
!     if (exe_path == NULL)
!       return;
! 
!     // Append our starting directory to $PATH, so that when doing
!     // "!xxd" it's found in our starting directory.  Needed because
!     // SearchPath() also looks there.
!     p = mch_getenv("PATH");
!     if (p == NULL
!           || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
      {
!       if (p == NULL || *p == NUL)
!           temp[0] = NUL;
!       else
        {
!           STRCPY(temp, p);
!           STRCAT(temp, ";");
        }
+       STRCAT(temp, exe_path);
+       vim_setenv((char_u *)"PATH", (char_u *)temp);
      }
  }
  
***************
*** 533,559 ****
  
      // No need to load any library when registering OLE.
      if (found_register_arg)
!       return dll;
  
      // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
      // vimLoadLib() recursively, which causes a stack overflow.
      if (exe_path == NULL)
        get_exe_name();
-     if (exe_path != NULL)
-     {
-       WCHAR old_dirw[MAXPATHL];
  
!       if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
!       {
!           // Change directory to where the executable is, both to make
!           // sure we find a .dll there and to avoid looking for a .dll
!           // in the current directory.
!           SetCurrentDirectory((LPCSTR)exe_path);
!           dll = LoadLibrary(name);
!           SetCurrentDirectoryW(old_dirw);
!           return dll;
!       }
!     }
      return dll;
  }
  
--- 533,559 ----
  
      // No need to load any library when registering OLE.
      if (found_register_arg)
!       return NULL;
  
      // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
      // vimLoadLib() recursively, which causes a stack overflow.
      if (exe_path == NULL)
        get_exe_name();
  
!     if (exe_path == NULL)
!       return NULL;
! 
!     WCHAR old_dirw[MAXPATHL];
! 
!     if (GetCurrentDirectoryW(MAXPATHL, old_dirw) == 0)
!       return NULL;
! 
!     // Change directory to where the executable is, both to make
!     // sure we find a .dll there and to avoid looking for a .dll
!     // in the current directory.
!     SetCurrentDirectory((LPCSTR)exe_path);
!     dll = LoadLibrary(name);
!     SetCurrentDirectoryW(old_dirw);
      return dll;
  }
  
***************
*** 907,937 ****
  {
      static int done = FALSE;
  
!     if (!done)
!     {
!       OSVERSIONINFO ovi;
  
!       ovi.dwOSVersionInfoSize = sizeof(ovi);
!       GetVersionEx(&ovi);
  
  #ifdef FEAT_EVAL
!       vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
!               (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
  #endif
!       if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
!               || ovi.dwMajorVersion > 6)
!           win8_or_later = TRUE;
! 
!       if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
!               || ovi.dwMajorVersion > 10)
!           win10_22H2_or_later = TRUE;
  
  #ifdef HAVE_ACL
!       // Enable privilege for getting or setting SACLs.
!       win32_enable_privilege(SE_SECURITY_NAME, TRUE);
  #endif
!       done = TRUE;
!     }
  }
  #ifdef _MSC_VER
  # pragma warning(pop)
--- 907,937 ----
  {
      static int done = FALSE;
  
!     if (done)
!       return;
! 
!     OSVERSIONINFO ovi;
  
!     ovi.dwOSVersionInfoSize = sizeof(ovi);
!     GetVersionEx(&ovi);
  
  #ifdef FEAT_EVAL
!     vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
!           (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
  #endif
!     if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
!           || ovi.dwMajorVersion > 6)
!       win8_or_later = TRUE;
! 
!     if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
!           || ovi.dwMajorVersion > 10)
!       win10_22H2_or_later = TRUE;
  
  #ifdef HAVE_ACL
!     // Enable privilege for getting or setting SACLs.
!     win32_enable_privilege(SE_SECURITY_NAME, TRUE);
  #endif
!     done = TRUE;
  }
  #ifdef _MSC_VER
  # pragma warning(pop)
***************
*** 3051,3090 ****
      COORD dwWindowSize;
      BOOL NeedAdjust = FALSE;
  
!     if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
      {
!       /*
!        * A buffer resize will fail if the current console window does
!        * not lie completely within that buffer.  To avoid this, we might
!        * have to move and possibly shrink the window.
!        */
!       if (csbi.srWindow.Right >= dwBufferSize.X)
!       {
!           dwWindowSize.X = SRWIDTH(csbi.srWindow);
!           if (dwWindowSize.X > dwBufferSize.X)
!               dwWindowSize.X = dwBufferSize.X;
!           csbi.srWindow.Right = dwBufferSize.X - 1;
!           csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
!           NeedAdjust = TRUE;
!       }
!       if (csbi.srWindow.Bottom >= dwBufferSize.Y)
!       {
!           dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
!           if (dwWindowSize.Y > dwBufferSize.Y)
!               dwWindowSize.Y = dwBufferSize.Y;
!           csbi.srWindow.Bottom = dwBufferSize.Y - 1;
!           csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
!           NeedAdjust = TRUE;
!       }
!       if (NeedAdjust && WantAdjust)
!       {
!           if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
!               return FALSE;
!       }
!       return TRUE;
      }
! 
!     return FALSE;
  }
  
  typedef struct ConsoleBufferStruct
--- 3051,3088 ----
      COORD dwWindowSize;
      BOOL NeedAdjust = FALSE;
  
!     if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
!       return FALSE;
! 
!     /*
!      * A buffer resize will fail if the current console window does
!      * not lie completely within that buffer.  To avoid this, we might
!      * have to move and possibly shrink the window.
!      */
!     if (csbi.srWindow.Right >= dwBufferSize.X)
      {
!       dwWindowSize.X = SRWIDTH(csbi.srWindow);
!       if (dwWindowSize.X > dwBufferSize.X)
!           dwWindowSize.X = dwBufferSize.X;
!       csbi.srWindow.Right = dwBufferSize.X - 1;
!       csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
!       NeedAdjust = TRUE;
!     }
!     if (csbi.srWindow.Bottom >= dwBufferSize.Y)
!     {
!       dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
!       if (dwWindowSize.Y > dwBufferSize.Y)
!           dwWindowSize.Y = dwBufferSize.Y;
!       csbi.srWindow.Bottom = dwBufferSize.Y - 1;
!       csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
!       NeedAdjust = TRUE;
      }
!     if (NeedAdjust && WantAdjust)
!     {
!       if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
!           return FALSE;
!     }
!     return TRUE;
  }
  
  typedef struct ConsoleBufferStruct
***************
*** 3674,3690 ****
      WCHAR wszHostName[256 + 1];
      DWORD wcch = ARRAY_LENGTH(wszHostName);
  
!     if (GetComputerNameW(wszHostName, &wcch))
!     {
!       char_u  *p = utf16_to_enc(wszHostName, NULL);
  
!       if (p != NULL)
!       {
!           vim_strncpy(s, p, len - 1);
!           vim_free(p);
!           return;
!       }
!     }
  }
  
  
--- 3672,3686 ----
      WCHAR wszHostName[256 + 1];
      DWORD wcch = ARRAY_LENGTH(wszHostName);
  
!     if (!GetComputerNameW(wszHostName, &wcch))
!       return;
  
!     char_u  *p = utf16_to_enc(wszHostName, NULL);
!     if (p == NULL)
!       return;
! 
!     vim_strncpy(s, p, len - 1);
!     vim_free(p);
  }
  
  
***************
*** 3732,3763 ****
       * But the Win32s known bug list says that getcwd() doesn't work
       * so use the Win32 system call instead. <Negri>
       */
!     if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
!     {
!       WCHAR   wcbuf[_MAX_PATH + 1];
!       char_u  *p = NULL;
  
!       if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
!       {
!           p = utf16_to_enc(wcbuf, NULL);
!           if (STRLEN(p) >= (size_t)len)
!           {
!               // long path name is too long, fall back to short one
!               vim_free(p);
!               p = NULL;
!           }
!       }
!       if (p == NULL)
!           p = utf16_to_enc(wbuf, NULL);
  
!       if (p != NULL)
        {
!           vim_strncpy(buf, p, len - 1);
            vim_free(p);
!           return OK;
        }
      }
!     return FAIL;
  }
  
  /*
--- 3728,3758 ----
       * But the Win32s known bug list says that getcwd() doesn't work
       * so use the Win32 system call instead. <Negri>
       */
!     if (GetCurrentDirectoryW(_MAX_PATH, wbuf) == 0)
!       return FAIL;
  
!     WCHAR   wcbuf[_MAX_PATH + 1];
!     char_u  *p = NULL;
  
!     if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
!     {
!       p = utf16_to_enc(wcbuf, NULL);
!       if (STRLEN(p) >= (size_t)len)
        {
!           // long path name is too long, fall back to short one
            vim_free(p);
!           p = NULL;
        }
      }
!     if (p == NULL)
!       p = utf16_to_enc(wbuf, NULL);
! 
!     if (p == NULL)
!       return FAIL;
! 
!     vim_strncpy(buf, p, len - 1);
!     vim_free(p);
!     return OK;
  }
  
  /*
***************
*** 3974,3987 ****
            NULL);              // handle to template file
      vim_free(wn);
  
!     if (hFile != INVALID_HANDLE_VALUE)
!     {
!       if (GetFileInformationByHandle(hFile, info) != 0)
!           res = FILEINFO_OK;
!       else
!           res = FILEINFO_INFO_FAIL;
!       CloseHandle(hFile);
!     }
  
      return res;
  }
--- 3969,3982 ----
            NULL);              // handle to template file
      vim_free(wn);
  
!     if (hFile == INVALID_HANDLE_VALUE)
!       return FILEINFO_READ_FAIL;
! 
!     if (GetFileInformationByHandle(hFile, info) != 0)
!       res = FILEINFO_OK;
!     else
!       res = FILEINFO_INFO_FAIL;
!     CloseHandle(hFile);
  
      return res;
  }
***************
*** 6170,6181 ****
      void
  mch_clear_job(job_T *job)
  {
!     if (job->jv_status != JOB_FAILED)
!     {
!       if (job->jv_job_object != NULL)
!           CloseHandle(job->jv_job_object);
!       CloseHandle(job->jv_proc_info.hProcess);
!     }
  }
  #endif
  
--- 6165,6176 ----
      void
  mch_clear_job(job_T *job)
  {
!     if (job->jv_status == JOB_FAILED)
!       return;
! 
!     if (job->jv_job_object != NULL)
!       CloseHandle(job->jv_job_object);
!     CloseHandle(job->jv_proc_info.hProcess);
  }
  #endif
  
***************
*** 7988,8019 ****
  {
      static int        loaded = -1;
  
!     if (loaded == -1)
      {
!       HMODULE hNtdll = GetModuleHandle("ntdll.dll");
!       if (hNtdll != NULL)
!       {
!           pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
!           pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
!           pNtSetEaFile = (PfnNtSetEaFile)
!               GetProcAddress(hNtdll, "NtSetEaFile");
!           pNtQueryEaFile = (PfnNtQueryEaFile)
!               GetProcAddress(hNtdll, "NtQueryEaFile");
!           pNtQueryInformationFile = (PfnNtQueryInformationFile)
!               GetProcAddress(hNtdll, "NtQueryInformationFile");
!           pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
!               GetProcAddress(hNtdll, "RtlInitUnicodeString");
!       }
!       if (pNtOpenFile == NULL
!               || pNtClose == NULL
!               || pNtSetEaFile == NULL
!               || pNtQueryEaFile == NULL
!               || pNtQueryInformationFile == NULL
!               || pRtlInitUnicodeString == NULL)
!           loaded = FALSE;
!       else
!           loaded = TRUE;
!     }
      return (BOOL) loaded;
  }
  
--- 7983,8014 ----
  {
      static int        loaded = -1;
  
!     if (loaded != -1)
!       return (BOOL) loaded;
! 
!     HMODULE hNtdll = GetModuleHandle("ntdll.dll");
!     if (hNtdll != NULL)
      {
!       pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
!       pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
!       pNtSetEaFile = (PfnNtSetEaFile)
!           GetProcAddress(hNtdll, "NtSetEaFile");
!       pNtQueryEaFile = (PfnNtQueryEaFile)
!           GetProcAddress(hNtdll, "NtQueryEaFile");
!       pNtQueryInformationFile = (PfnNtQueryInformationFile)
!           GetProcAddress(hNtdll, "NtQueryInformationFile");
!       pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
!           GetProcAddress(hNtdll, "RtlInitUnicodeString");
!     }
!     if (pNtOpenFile == NULL
!           || pNtClose == NULL
!           || pNtSetEaFile == NULL
!           || pNtQueryEaFile == NULL
!           || pNtQueryInformationFile == NULL
!           || pRtlInitUnicodeString == NULL)
!       loaded = FALSE;
!     else
!       loaded = TRUE;
      return (BOOL) loaded;
  }
  
***************
*** 8190,8200 ****
      void
  free_cmd_argsW(void)
  {
!     if (ArglistW != NULL)
!     {
!       GlobalFree(ArglistW);
!       ArglistW = NULL;
!     }
  }
  
  /*
--- 8185,8195 ----
      void
  free_cmd_argsW(void)
  {
!     if (ArglistW == NULL)
!       return;
! 
!     GlobalFree(ArglistW);
!     ArglistW = NULL;
  }
  
  /*
***************
*** 8899,8918 ****
      COORD coord;
      SMALL_RECT newsize;
  
!     if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
!     {
!       coord.X = SRWIDTH(csbi.srWindow);
!       coord.Y = SRHEIGHT(csbi.srWindow);
!       SetConsoleScreenBufferSize(g_hConOut, coord);
! 
!       newsize.Left = 0;
!       newsize.Top = 0;
!       newsize.Right = coord.X - 1;
!       newsize.Bottom = coord.Y - 1;
!       SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
  
!       SetConsoleScreenBufferSize(g_hConOut, coord);
!     }
  }
  #endif
  
--- 8894,8913 ----
      COORD coord;
      SMALL_RECT newsize;
  
!     if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
!       return;
  
!     coord.X = SRWIDTH(csbi.srWindow);
!     coord.Y = SRHEIGHT(csbi.srWindow);
!     SetConsoleScreenBufferSize(g_hConOut, coord);
! 
!     newsize.Left = 0;
!     newsize.Top = 0;
!     newsize.Right = coord.X - 1;
!     newsize.Bottom = coord.Y - 1;
!     SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
! 
!     SetConsoleScreenBufferSize(g_hConOut, coord);
  }
  #endif
  
***************
*** 8926,8939 ****
            NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
      if (oldmsg != NULL)
        LocalFree(oldmsg);
!     if (msg != NULL)
!     {
!       // remove trailing \r\n
!       char *pcrlf = strstr(msg, "\r\n");
!       if (pcrlf != NULL)
!           *pcrlf = '\0';
!       oldmsg = msg;
!     }
      return msg;
  }
  
--- 8921,8934 ----
            NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
      if (oldmsg != NULL)
        LocalFree(oldmsg);
!     if (msg == NULL)
!       return NULL;
! 
!     // remove trailing \r\n
!     char *pcrlf = strstr(msg, "\r\n");
!     if (pcrlf != NULL)
!       *pcrlf = '\0';
!     oldmsg = msg;
      return msg;
  }
  
*** ../vim-9.0.1207/src/version.c       2023-01-16 16:39:33.495018026 +0000
--- src/version.c       2023-01-16 18:15:03.618924960 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1208,
  /**/

-- 
Far back in the mists of ancient time, in the great and glorious days of the
former Galactic Empire, life was wild, rich and largely tax free.
Mighty starships plied their way between exotic suns, seeking adventure and
reward among the furthest reaches of Galactic space.  In those days, spirits
were brave, the stakes were high, men were real men, women were real women
and small furry creatures from Alpha Centauri were real small furry creatures
from Alpha Centauri.  And all dared to brave unknown terrors, to do mighty
deeds, to boldly split infinitives that no man had split before -- and thus
was the Empire forged.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// 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/20230116181934.DCEF21C042F%40moolenaar.net.

Raspunde prin e-mail lui