Loading ...
Sorry, an error occurred while loading the content.

Patch 7.3.880

Expand Messages
  • Bram Moolenaar
    Patch 7.3.880 Problem: When writing viminfo, old history lines may replace lines written more recently by another Vim instance. Solution: Mark history
    Message 1 of 6 , Apr 5 9:59 AM
    • 0 Attachment
      Patch 7.3.880
      Problem: When writing viminfo, old history lines may replace lines written
      more recently by another Vim instance.
      Solution: Mark history entries that were read from viminfo and overwrite
      them when merging with the current viminfo.
      Files: src/ex_getln.c


      *** ../vim-7.3.879/src/ex_getln.c 2013-03-19 16:46:59.000000000 +0100
      --- src/ex_getln.c 2013-04-05 18:56:08.000000000 +0200
      ***************
      *** 56,61 ****
      --- 56,62 ----
      typedef struct hist_entry
      {
      int hisnum; /* identifying number */
      + int viminfo; /* when TRUE hisstr comes from viminfo */
      char_u *hisstr; /* actual entry, separator char after the NUL */
      } histentry_T;

      ***************
      *** 113,118 ****
      --- 114,120 ----
      static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
      # ifdef FEAT_CMDHIST
      static char_u *get_history_arg __ARGS((expand_T *xp, int idx));
      + static void clear_hist_entry __ARGS((histentry_T *hisptr));
      # endif
      # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
      static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
      ***************
      *** 5343,5352 ****
      if (hisidx[type] < 0) /* there are no entries yet */
      {
      for (i = 0; i < newlen; ++i)
      ! {
      ! temp[i].hisnum = 0;
      ! temp[i].hisstr = NULL;
      ! }
      }
      else if (newlen > hislen) /* array becomes bigger */
      {
      --- 5345,5351 ----
      if (hisidx[type] < 0) /* there are no entries yet */
      {
      for (i = 0; i < newlen; ++i)
      ! clear_hist_entry(&temp[i]);
      }
      else if (newlen > hislen) /* array becomes bigger */
      {
      ***************
      *** 5354,5363 ****
      temp[i] = history[type][i];
      j = i;
      for ( ; i <= newlen - (hislen - hisidx[type]); ++i)
      ! {
      ! temp[i].hisnum = 0;
      ! temp[i].hisstr = NULL;
      ! }
      for ( ; j < hislen; ++i, ++j)
      temp[i] = history[type][j];
      }
      --- 5353,5359 ----
      temp[i] = history[type][i];
      j = i;
      for ( ; i <= newlen - (hislen - hisidx[type]); ++i)
      ! clear_hist_entry(&temp[i]);
      for ( ; j < hislen; ++i, ++j)
      temp[i] = history[type][j];
      }
      ***************
      *** 5385,5390 ****
      --- 5381,5395 ----
      }
      }

      + static void
      + clear_hist_entry(hisptr)
      + histentry_T *hisptr;
      + {
      + hisptr->hisnum = 0;
      + hisptr->viminfo = FALSE;
      + hisptr->hisstr = NULL;
      + }
      +
      /*
      * Check if command line 'str' is already in history.
      * If 'move_to_front' is TRUE, matching entry is moved to end of history.
      ***************
      *** 5433,5440 ****
      history[type][last_i] = history[type][i];
      last_i = i;
      }
      - history[type][i].hisstr = str;
      history[type][i].hisnum = ++hisnum[type];
      return TRUE;
      }
      return FALSE;
      --- 5438,5446 ----
      history[type][last_i] = history[type][i];
      last_i = i;
      }
      history[type][i].hisnum = ++hisnum[type];
      + history[type][i].viminfo = FALSE;
      + history[type][i].hisstr = str;
      return TRUE;
      }
      return FALSE;
      ***************
      *** 5498,5505 ****
      /* Current line is from the same mapping, remove it */
      hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];
      vim_free(hisptr->hisstr);
      ! hisptr->hisstr = NULL;
      ! hisptr->hisnum = 0;
      --hisnum[histype];
      if (--hisidx[HIST_SEARCH] < 0)
      hisidx[HIST_SEARCH] = hislen - 1;
      --- 5504,5510 ----
      /* Current line is from the same mapping, remove it */
      hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];
      vim_free(hisptr->hisstr);
      ! clear_hist_entry(hisptr);
      --hisnum[histype];
      if (--hisidx[HIST_SEARCH] < 0)
      hisidx[HIST_SEARCH] = hislen - 1;
      ***************
      *** 5520,5525 ****
      --- 5525,5531 ----
      hisptr->hisstr[len + 1] = sep;

      hisptr->hisnum = ++hisnum[histype];
      + hisptr->viminfo = FALSE;
      if (histype == HIST_SEARCH && in_map)
      last_maptick = maptick;
      }
      ***************
      *** 5709,5716 ****
      for (i = hislen; i--;)
      {
      vim_free(hisptr->hisstr);
      ! hisptr->hisnum = 0;
      ! hisptr++->hisstr = NULL;
      }
      hisidx[histype] = -1; /* mark history as cleared */
      hisnum[histype] = 0; /* reset identifier counter */
      --- 5715,5721 ----
      for (i = hislen; i--;)
      {
      vim_free(hisptr->hisstr);
      ! clear_hist_entry(hisptr);
      }
      hisidx[histype] = -1; /* mark history as cleared */
      hisnum[histype] = 0; /* reset identifier counter */
      ***************
      *** 5755,5770 ****
      {
      found = TRUE;
      vim_free(hisptr->hisstr);
      ! hisptr->hisstr = NULL;
      ! hisptr->hisnum = 0;
      }
      else
      {
      if (i != last)
      {
      history[histype][last] = *hisptr;
      ! hisptr->hisstr = NULL;
      ! hisptr->hisnum = 0;
      }
      if (--last < 0)
      last += hislen;
      --- 5760,5773 ----
      {
      found = TRUE;
      vim_free(hisptr->hisstr);
      ! clear_hist_entry(hisptr);
      }
      else
      {
      if (i != last)
      {
      history[histype][last] = *hisptr;
      ! clear_hist_entry(hisptr);
      }
      if (--last < 0)
      last += hislen;
      ***************
      *** 5808,5815 ****
      history[histype][i] = history[histype][j];
      i = j;
      }
      ! history[histype][i].hisstr = NULL;
      ! history[histype][i].hisnum = 0;
      if (--i < 0)
      i += hislen;
      hisidx[histype] = i;
      --- 5811,5817 ----
      history[histype][i] = history[histype][j];
      i = j;
      }
      ! clear_hist_entry(&history[histype][i]);
      if (--i < 0)
      i += hislen;
      hisidx[histype] = i;
      ***************
      *** 6043,6054 ****

      for (type = 0; type < HIST_COUNT; ++type)
      {
      ! /*
      ! * Count the number of empty spaces in the history list. If there are
      ! * more spaces available than we request, then fill them up.
      ! */
      for (i = 0, num = 0; i < hislen; i++)
      ! if (history[type][i].hisstr == NULL)
      num++;
      len = asklen;
      if (num > len)
      --- 6045,6055 ----

      for (type = 0; type < HIST_COUNT; ++type)
      {
      ! /* Count the number of empty spaces in the history list. Entries read
      ! * from viminfo previously are also considered empty. If there are
      ! * more spaces available than we request, then fill them up. */
      for (i = 0, num = 0; i < hislen; i++)
      ! if (history[type][i].hisstr == NULL || history[type][i].viminfo)
      num++;
      len = asklen;
      if (num > len)
      ***************
      *** 6141,6147 ****
      hisidx[type] = hislen - 1;
      do
      {
      ! if (history[type][idx].hisstr != NULL)
      break;
      if (++idx == hislen)
      idx = 0;
      --- 6142,6149 ----
      hisidx[type] = hislen - 1;
      do
      {
      ! if (history[type][idx].hisstr != NULL
      ! || history[type][idx].viminfo)
      break;
      if (++idx == hislen)
      idx = 0;
      ***************
      *** 6153,6158 ****
      --- 6155,6161 ----
      {
      vim_free(history[type][idx].hisstr);
      history[type][idx].hisstr = viminfo_history[type][i];
      + history[type][idx].viminfo = TRUE;
      if (--idx < 0)
      idx = hislen - 1;
      }
      *** ../vim-7.3.879/src/version.c 2013-04-05 17:43:10.000000000 +0200
      --- src/version.c 2013-04-05 18:54:11.000000000 +0200
      ***************
      *** 730,731 ****
      --- 730,733 ----
      { /* Add new patch number below this line */
      + /**/
      + 880,
      /**/

      --
      hundred-and-one symptoms of being an internet addict:
      122. You ask if the Netaholics Anonymous t-shirt you ordered can be
      sent to you via e-mail.

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

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

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ben Fritz
      ... This sounds like it s referring to command-line history and the like. Could this also be done for marks and registers? Those are more frequently annoying
      Message 2 of 6 , Apr 5 11:54 AM
      • 0 Attachment
        On Friday, April 5, 2013 11:59:09 AM UTC-5, Bram Moolenaar wrote:
        > Patch 7.3.880
        >
        > Problem: When writing viminfo, old history lines may replace lines written
        >
        > more recently by another Vim instance.
        >
        > Solution: Mark history entries that were read from viminfo and overwrite
        >
        > them when merging with the current viminfo.
        >

        This sounds like it's referring to command-line history and the like.

        Could this also be done for marks and registers? Those are more frequently annoying to me.

        --
        --
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... That s a completely different part of the viminfo implementation. I suppose for registers something similar could be done. I m not sure about marks. What
        Message 3 of 6 , Apr 5 1:16 PM
        • 0 Attachment
          Ben Fritz wrote:

          > On Friday, April 5, 2013 11:59:09 AM UTC-5, Bram Moolenaar wrote:
          > > Patch 7.3.880
          > >
          > > Problem: When writing viminfo, old history lines may replace lines written
          > >
          > > more recently by another Vim instance.
          > >
          > > Solution: Mark history entries that were read from viminfo and overwrite
          > >
          > > them when merging with the current viminfo.
          > >
          >
          > This sounds like it's referring to command-line history and the like.
          >
          > Could this also be done for marks and registers? Those are more
          > frequently annoying to me.

          That's a completely different part of the viminfo implementation.
          I suppose for registers something similar could be done. I'm not sure
          about marks. What marks are you thinking about?

          --
          "Microsoft is like Coke. It's a secret formula, all the money is from
          distribution, and their goal is to get Coke everywhere. Open source is like
          selling water. There are water companies like Perrier and Poland Spring, but
          you're competing with something that's free." -- Carl Howe


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

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Erik Falor
          ... This patch breaks the build on linux x86_64 when configured --with-features=small. --with-features=tiny, --with-features=normal, --with-features=big, and
          Message 4 of 6 , Apr 5 1:48 PM
          • 0 Attachment
            On Fri, Apr 05, 2013 at 06:59:09PM +0200, Bram Moolenaar wrote:
            >
            > Patch 7.3.880
            > Problem: When writing viminfo, old history lines may replace lines written
            > more recently by another Vim instance.
            > Solution: Mark history entries that were read from viminfo and overwrite
            > them when merging with the current viminfo.
            > Files: src/ex_getln.c

            This patch breaks the build on linux x86_64 when configured
            --with-features=small.

            --with-features=tiny, --with-features=normal, --with-features=big, and
            --with-features=huge, all build successfully.

            GCC gives this error:

            ex_getln.c:5385:1: warning: conflicting types for ‘clear_hist_entry’ [enabled by default]
            ex_getln.c:5385:1: error: static declaration of ‘clear_hist_entry’ follows non-static declaration
            ex_getln.c:5348:4: note: previous implicit declaration of ‘clear_hist_entry’ was here


            --
            Erik Falor http://unnovative.net
            Registered Linux User #445632 http://linuxcounter.net
          • Ben Fritz
            ... I was thinking about a, b, etc. included with the item in viminfo, but also file marks. I don t like that these can be overwritten by old data.
            Message 5 of 6 , Apr 5 2:38 PM
            • 0 Attachment
              On Friday, April 5, 2013 3:16:54 PM UTC-5, Bram Moolenaar wrote:
              > Ben Fritz wrote:
              >
              >
              >
              > > On Friday, April 5, 2013 11:59:09 AM UTC-5, Bram Moolenaar wrote:
              >
              > > > Patch 7.3.880
              >
              > > >
              >
              > > > Problem: When writing viminfo, old history lines may replace lines written
              >
              > > >
              >
              > > > more recently by another Vim instance.
              >
              > > >
              >
              > > > Solution: Mark history entries that were read from viminfo and overwrite
              >
              > > >
              >
              > > > them when merging with the current viminfo.
              >
              > > >
              >
              > >
              >
              > > This sounds like it's referring to command-line history and the like.
              >
              > >
              >
              > > Could this also be done for marks and registers? Those are more
              >
              > > frequently annoying to me.
              >
              >
              >
              > That's a completely different part of the viminfo implementation.
              >
              > I suppose for registers something similar could be done. I'm not sure
              >
              > about marks. What marks are you thinking about?
              >

              I was thinking about 'a, 'b, etc. included with the ' item in viminfo, but also file marks. I don't like that these can be overwritten by old data.

              Actually the same can apply to any data in .viminfo, including global variables and the buffer list.

              I'm sure all of these are annoying to some people. For me, the most annoying is when I lose modified register content due to exiting open Vim sessions in the wrong order. I don't care as much about marks. I hardly care at all about history or global variables or the buffer list.

              --
              --
              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 vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Bram Moolenaar
              ... Yes, I see it now too. I l make a fix. -- hundred-and-one symptoms of being an internet addict: 127. You bring your laptop and cellular phone to church.
              Message 6 of 6 , Apr 6 4:57 AM
              • 0 Attachment
                Erik Falor wrote:

                > On Fri, Apr 05, 2013 at 06:59:09PM +0200, Bram Moolenaar wrote:
                > >
                > > Patch 7.3.880
                > > Problem: When writing viminfo, old history lines may replace lines written
                > > more recently by another Vim instance.
                > > Solution: Mark history entries that were read from viminfo and overwrite
                > > them when merging with the current viminfo.
                > > Files: src/ex_getln.c
                >
                > This patch breaks the build on linux x86_64 when configured
                > --with-features=small.
                >
                > --with-features=tiny, --with-features=normal, --with-features=big, and
                > --with-features=huge, all build successfully.
                >
                > GCC gives this error:
                >
                > ex_getln.c:5385:1: warning: conflicting types for ‘clear_hist_entry’ [enabled by default]
                > ex_getln.c:5385:1: error: static declaration of ‘clear_hist_entry’ follows non-static declaration
                > ex_getln.c:5348:4: note: previous implicit declaration of ‘clear_hist_entry’ was here

                Yes, I see it now too. I'l make a fix.

                --
                hundred-and-one symptoms of being an internet addict:
                127. You bring your laptop and cellular phone to church.

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

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

                ---
                You received this message because you are subscribed to the Google Groups "vim_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.