Patch 8.2.3542
Problem:    Too many comments are old style.
Solution:   Change comments to // style. (closes #9021)
Files:      src/buffer.c


*** ../vim-8.2.3541/src/buffer.c        2021-10-16 21:14:07.495196461 +0100
--- src/buffer.c        2021-10-19 20:46:24.163108515 +0100
***************
*** 94,104 ****
      int               retval = OK;
      linenr_T  line_count;
  
!     /*
!      * Read from the buffer which the text is already filled in and append at
!      * the end.  This makes it possible to retry when 'fileformat' or
!      * 'fileencoding' was guessed wrong.
!      */
      line_count = curbuf->b_ml.ml_line_count;
      retval = readfile(
            read_stdin ? NULL : curbuf->b_ffname,
--- 94,102 ----
      int               retval = OK;
      linenr_T  line_count;
  
!     // Read from the buffer which the text is already filled in and append at
!     // the end.  This makes it possible to retry when 'fileformat' or
!     // 'fileencoding' was guessed wrong.
      line_count = curbuf->b_ml.ml_line_count;
      retval = readfile(
            read_stdin ? NULL : curbuf->b_ffname,
***************
*** 178,206 ****
  #endif
      int               read_fifo = FALSE;
  
!     /*
!      * The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
!      * When re-entering the same buffer, it should not change, because the
!      * user may have reset the flag by hand.
!      */
      if (readonlymode && curbuf->b_ffname != NULL
                                        && (curbuf->b_flags & BF_NEVERLOADED))
        curbuf->b_p_ro = TRUE;
  
      if (ml_open(curbuf) == FAIL)
      {
!       /*
!        * There MUST be a memfile, otherwise we can't do anything
!        * If we can't create one for the current buffer, take another buffer
!        */
        close_buffer(NULL, curbuf, 0, FALSE, FALSE);
        FOR_ALL_BUFFERS(curbuf)
            if (curbuf->b_ml.ml_mfp != NULL)
                break;
!       /*
!        * If there is no memfile at all, exit.
!        * This is OK, since there are no changes to lose.
!        */
        if (curbuf == NULL)
        {
            emsg(_("E82: Cannot allocate any buffer, exiting..."));
--- 176,198 ----
  #endif
      int               read_fifo = FALSE;
  
!     // The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
!     // When re-entering the same buffer, it should not change, because the
!     // user may have reset the flag by hand.
      if (readonlymode && curbuf->b_ffname != NULL
                                        && (curbuf->b_flags & BF_NEVERLOADED))
        curbuf->b_p_ro = TRUE;
  
      if (ml_open(curbuf) == FAIL)
      {
!       // There MUST be a memfile, otherwise we can't do anything
!       // If we can't create one for the current buffer, take another buffer
        close_buffer(NULL, curbuf, 0, FALSE, FALSE);
        FOR_ALL_BUFFERS(curbuf)
            if (curbuf->b_ml.ml_mfp != NULL)
                break;
!       // If there is no memfile at all, exit.
!       // This is OK, since there are no changes to lose.
        if (curbuf == NULL)
        {
            emsg(_("E82: Cannot allocate any buffer, exiting..."));
***************
*** 281,292 ****
      {
        int     save_bin = curbuf->b_p_bin;
  
!       /*
!        * First read the text in binary mode into the buffer.
!        * Then read from that same buffer and append at the end.  This makes
!        * it possible to retry when 'fileformat' or 'fileencoding' was
!        * guessed wrong.
!        */
        curbuf->b_p_bin = TRUE;
        retval = readfile(NULL, NULL, (linenr_T)0,
                  (linenr_T)0, (linenr_T)MAXLNUM, NULL,
--- 273,282 ----
      {
        int     save_bin = curbuf->b_p_bin;
  
!       // First read the text in binary mode into the buffer.
!       // Then read from that same buffer and append at the end.  This makes
!       // it possible to retry when 'fileformat' or 'fileencoding' was
!       // guessed wrong.
        curbuf->b_p_bin = TRUE;
        retval = readfile(NULL, NULL, (linenr_T)0,
                  (linenr_T)0, (linenr_T)MAXLNUM, NULL,
***************
*** 305,315 ****
  #endif
      }
  
!     /*
!      * Set/reset the Changed flag first, autocmds may change the buffer.
!      * Apply the automatic commands, before processing the modelines.
!      * So the modelines have priority over autocommands.
!      */
      // When reading stdin, the buffer contents always needs writing, so set
      // the changed flag.  Unless in readonly mode: "ls | gview -".
      // When interrupted and 'cpoptions' contains 'i' set changed flag.
--- 295,304 ----
  #endif
      }
  
!     // Set/reset the Changed flag first, autocmds may change the buffer.
!     // Apply the automatic commands, before processing the modelines.
!     // So the modelines have priority over autocommands.
!     //
      // When reading stdin, the buffer contents always needs writing, so set
      // the changed flag.  Unless in readonly mode: "ls | gview -".
      // When interrupted and 'cpoptions' contains 'i' set changed flag.
***************
*** 360,369 ****
  
      if (retval == OK)
      {
!       /*
!        * The autocommands may have changed the current buffer.  Apply the
!        * modelines to the correct buffer, if it still exists and is loaded.
!        */
        if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL)
        {
            aco_save_T  aco;
--- 349,356 ----
  
      if (retval == OK)
      {
!       // The autocommands may have changed the current buffer.  Apply the
!       // modelines to the correct buffer, if it still exists and is loaded.
        if (bufref_valid(&old_curbuf) && old_curbuf.br_buf->b_ml.ml_mfp != NULL)
        {
            aco_save_T  aco;
***************
*** 521,531 ****
      int               del_buf = (action == DOBUF_DEL || wipe_buf);
  
      CHECK_CURBUF;
!     /*
!      * Force unloading or deleting when 'bufhidden' says so.
!      * The caller must take care of NOT deleting/freeing when 'bufhidden' is
!      * "hide" (otherwise we could never free or delete a buffer).
!      */
      if (buf->b_p_bh[0] == 'd')                // 'bufhidden' == "delete"
      {
        del_buf = TRUE;
--- 508,517 ----
      int               del_buf = (action == DOBUF_DEL || wipe_buf);
  
      CHECK_CURBUF;
! 
!     // Force unloading or deleting when 'bufhidden' says so.
!     // The caller must take care of NOT deleting/freeing when 'bufhidden' is
!     // "hide" (otherwise we could never free or delete a buffer).
      if (buf->b_p_bh[0] == 'd')                // 'bufhidden' == "delete"
      {
        del_buf = TRUE;
***************
*** 681,690 ****
            )
        end_visual_mode();
  
!     /*
!      * Free all things allocated for this buffer.
!      * Also calls the "BufDelete" autocommands when del_buf is TRUE.
!      */
      // Remember if we are closing the current buffer.  Restore the number of
      // windows, so that autocommands in buf_freeall() don't get confused.
      is_curbuf = (buf == curbuf);
--- 667,675 ----
            )
        end_visual_mode();
  
!     // Free all things allocated for this buffer.
!     // Also calls the "BufDelete" autocommands when del_buf is TRUE.
!     //
      // Remember if we are closing the current buffer.  Restore the number of
      // windows, so that autocommands in buf_freeall() don't get confused.
      is_curbuf = (buf == curbuf);
***************
*** 703,715 ****
        return FALSE;
  #endif
  
!     /*
!      * It's possible that autocommands change curbuf to the one being deleted.
!      * This might cause the previous curbuf to be deleted unexpectedly.  But
!      * in some cases it's OK to delete the curbuf, because a new one is
!      * obtained anyway.  Therefore only return if curbuf changed to the
!      * deleted buffer.
!      */
      if (buf == curbuf && !is_curbuf)
        return FALSE;
  
--- 688,698 ----
        return FALSE;
  #endif
  
!     // It's possible that autocommands change curbuf to the one being deleted.
!     // This might cause the previous curbuf to be deleted unexpectedly.  But
!     // in some cases it's OK to delete the curbuf, because a new one is
!     // obtained anyway.  Therefore only return if curbuf changed to the
!     // deleted buffer.
      if (buf == curbuf && !is_curbuf)
        return FALSE;
  
***************
*** 856,867 ****
        return;
  #endif
  
!     /*
!      * It's possible that autocommands change curbuf to the one being deleted.
!      * This might cause curbuf to be deleted unexpectedly.  But in some cases
!      * it's OK to delete the curbuf, because a new one is obtained anyway.
!      * Therefore only return if curbuf changed to the deleted buffer.
!      */
      if (buf == curbuf && !is_curbuf)
        return;
  #ifdef FEAT_DIFF
--- 839,848 ----
        return;
  #endif
  
!     // It's possible that autocommands change curbuf to the one being deleted.
!     // This might cause curbuf to be deleted unexpectedly.  But in some cases
!     // it's OK to delete the curbuf, because a new one is obtained anyway.
!     // Therefore only return if curbuf changed to the deleted buffer.
      if (buf == curbuf && !is_curbuf)
        return;
  #ifdef FEAT_DIFF
***************
*** 1215,1225 ****
      retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
                                          forceit ? ECMD_FORCEIT : 0, curwin);
  
!     /*
!      * do_ecmd() may create a new buffer, then we have to delete
!      * the old one.  But do_ecmd() may have done that already, check
!      * if the buffer still exists.
!      */
      if (buf != curbuf && bufref_valid(&bufref) && buf->b_nwindows == 0)
        close_buffer(NULL, buf, action, FALSE, FALSE);
      if (!close_others)
--- 1196,1204 ----
      retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
                                          forceit ? ECMD_FORCEIT : 0, curwin);
  
!     // do_ecmd() may create a new buffer, then we have to delete
!     // the old one.  But do_ecmd() may have done that already, check
!     // if the buffer still exists.
      if (buf != curbuf && bufref_valid(&bufref) && buf->b_nwindows == 0)
        close_buffer(NULL, buf, action, FALSE, FALSE);
      if (!close_others)
***************
*** 1350,1356 ****
  #endif
  
      /*
!      * delete buffer buf from memory and/or the list
       */
      if (unload)
      {
--- 1329,1335 ----
  #endif
  
      /*
!      * delete buffer "buf" from memory and/or the list
       */
      if (unload)
      {
***************
*** 1396,1416 ****
        if (buf == curbuf && VIsual_active)
            end_visual_mode();
  
!       /*
!        * If deleting the last (listed) buffer, make it empty.
!        * The last (listed) buffer cannot be unloaded.
!        */
        FOR_ALL_BUFFERS(bp)
            if (bp->b_p_bl && bp != buf)
                break;
        if (bp == NULL && buf == curbuf)
            return empty_curbuf(TRUE, (flags & DOBUF_FORCEIT), action);
  
!       /*
!        * If the deleted buffer is the current one, close the current window
!        * (unless it's the only window).  Repeat this so long as we end up in
!        * a window with this buffer.
!        */
        while (buf == curbuf
                   && !(curwin->w_closing || curwin->w_buffer->b_locked > 0)
                   && (!ONE_WINDOW || first_tabpage->tp_next != NULL))
--- 1375,1391 ----
        if (buf == curbuf && VIsual_active)
            end_visual_mode();
  
!       // If deleting the last (listed) buffer, make it empty.
!       // The last (listed) buffer cannot be unloaded.
        FOR_ALL_BUFFERS(bp)
            if (bp->b_p_bl && bp != buf)
                break;
        if (bp == NULL && buf == curbuf)
            return empty_curbuf(TRUE, (flags & DOBUF_FORCEIT), action);
  
!       // If the deleted buffer is the current one, close the current window
!       // (unless it's the only window).  Repeat this so long as we end up in
!       // a window with this buffer.
        while (buf == curbuf
                   && !(curwin->w_closing || curwin->w_buffer->b_locked > 0)
                   && (!ONE_WINDOW || first_tabpage->tp_next != NULL))
***************
*** 1419,1427 ****
                break;
        }
  
!       /*
!        * If the buffer to be deleted is not the current one, delete it here.
!        */
        if (buf != curbuf)
        {
            close_windows(buf, FALSE);
--- 1394,1400 ----
                break;
        }
  
!       // If the buffer to be deleted is not the current one, delete it here.
        if (buf != curbuf)
        {
            close_windows(buf, FALSE);
***************
*** 1535,1541 ****
      }
  
      /*
!      * make buf current buffer
       */
      if (action == DOBUF_SPLIT)            // split window first
      {
--- 1508,1514 ----
      }
  
      /*
!      * make "buf" the current buffer
       */
      if (action == DOBUF_SPLIT)            // split window first
      {
***************
*** 1555,1563 ****
      if (buf == curbuf)
        return OK;
  
!     /*
!      * Check if the current buffer may be abandoned.
!      */
      if (action == DOBUF_GOTO && !can_abandon(curbuf, (flags & DOBUF_FORCEIT)))
      {
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
--- 1528,1534 ----
      if (buf == curbuf)
        return OK;
  
!     // Check if the current buffer may be abandoned.
      if (action == DOBUF_GOTO && !can_abandon(curbuf, (flags & DOBUF_FORCEIT)))
      {
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
***************
*** 1650,1670 ****
  
        for ( ;!got_int; ui_breakcheck())
        {
!           /*
!            * Delete the current buffer last, otherwise when the
!            * current buffer is deleted, the next buffer becomes
!            * the current one and will be loaded, which may then
!            * also be deleted, etc.
!            */
            if (bnr == curbuf->b_fnum)
                do_current = bnr;
            else if (do_buffer_ext(command, DOBUF_FIRST, FORWARD, (int)bnr,
                          DOBUF_NOPOPUP | (forceit ? DOBUF_FORCEIT : 0)) == OK)
                ++deleted;
  
!           /*
!            * find next buffer number to delete/unload
!            */
            if (addr_count == 2)
            {
                if (++bnr > end_bnr)
--- 1621,1637 ----
  
        for ( ;!got_int; ui_breakcheck())
        {
!           // Delete the current buffer last, otherwise when the
!           // current buffer is deleted, the next buffer becomes
!           // the current one and will be loaded, which may then
!           // also be deleted, etc.
            if (bnr == curbuf->b_fnum)
                do_current = bnr;
            else if (do_buffer_ext(command, DOBUF_FIRST, FORWARD, (int)bnr,
                          DOBUF_NOPOPUP | (forceit ? DOBUF_FORCEIT : 0)) == OK)
                ++deleted;
  
!           // find next buffer number to delete/unload
            if (addr_count == 2)
            {
                if (++bnr > end_bnr)
***************
*** 2011,2017 ****
      fname_expand(curbuf, &ffname, &sfname);   // will allocate ffname
  
      /*
!      * If file name already exists in the list, update the entry.
       */
  #ifdef UNIX
      // On Unix we can use inode numbers when the file exists.  Works better
--- 1978,1984 ----
      fname_expand(curbuf, &ffname, &sfname);   // will allocate ffname
  
      /*
!      * If the file name already exists in the list, update the entry.
       */
  #ifdef UNIX
      // On Unix we can use inode numbers when the file exists.  Works better
***************
*** 2152,2160 ****
      }
      else
      {
!       /*
!        * put new buffer at the end of the buffer list
!        */
        buf->b_next = NULL;
        if (firstbuf == NULL)           // buffer list is empty
        {
--- 2119,2125 ----
      }
      else
      {
!       // put the new buffer at the end of the buffer list
        buf->b_next = NULL;
        if (firstbuf == NULL)           // buffer list is empty
        {
***************
*** 2209,2217 ****
        }
        buf_hashtab_add(buf);
  
!       /*
!        * Always copy the options from the current buffer.
!        */
        buf_copy_options(buf, BCO_ALWAYS);
      }
  
--- 2174,2180 ----
        }
        buf_hashtab_add(buf);
  
!       // Always copy the options from the current buffer.
        buf_copy_options(buf, BCO_ALWAYS);
      }
  
***************
*** 2759,2768 ****
      else
        patc = pat;
  
!     /*
!      * attempt == 0: try match with    '\<', match at start of word
!      * attempt == 1: try match without '\<', match anywhere
!      */
      for (attempt = 0; attempt <= 1; ++attempt)
      {
        regmatch_T      regmatch;
--- 2722,2729 ----
      else
        patc = pat;
  
!     // attempt == 0: try match with    '\<', match at start of word
!     // attempt == 1: try match without '\<', match anywhere
      for (attempt = 0; attempt <= 1; ++attempt)
      {
        regmatch_T      regmatch;
***************
*** 2777,2786 ****
            return FAIL;
        }
  
!       /*
!        * round == 1: Count the matches.
!        * round == 2: Build the array to keep the matches.
!        */
        for (round = 1; round <= 2; ++round)
        {
            count = 0;
--- 2738,2745 ----
            return FAIL;
        }
  
!       // round == 1: Count the matches.
!       // round == 2: Build the array to keep the matches.
        for (round = 1; round <= 2; ++round)
        {
            count = 0;
***************
*** 3383,3389 ****
            return FAIL;
  
        /*
!        * if the file name is already used in another buffer:
         * - if the buffer is loaded, fail
         * - if the buffer is not loaded, delete it from the list
         */
--- 3342,3348 ----
            return FAIL;
  
        /*
!        * If the file name is already used in another buffer:
         * - if the buffer is loaded, fail
         * - if the buffer is not loaded, delete it from the list
         */
*** ../vim-8.2.3541/src/version.c       2021-10-19 20:24:30.689798876 +0100
--- src/version.c       2021-10-19 20:47:31.439943063 +0100
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     3542,
  /**/

-- 
Spam seems to be something useful to novices.  Later you realize that
it's a bunch of indigestable junk that only clogs your system.
Applies to both the food and the e-mail!

 /// 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/20211019194921.C9DE9C80053%40moolenaar.net.

Raspunde prin e-mail lui