Patch 8.2.0132
Problem:    Script may be re-used when deleting and creating a new one.
Solution:   When the inode matches, also check the file name.
Files:      src/scriptfile.c, src/testdir/test_source.vim


*** ../vim-8.2.0131/src/scriptfile.c    2020-01-12 17:42:52.410413873 +0100
--- src/scriptfile.c    2020-01-19 20:13:45.487348527 +0100
***************
*** 1249,1266 ****
                                                         --current_sctx.sc_sid)
      {
        si = &SCRIPT_ITEM(current_sctx.sc_sid);
!       if (si->sn_name != NULL
!               && (
  # ifdef UNIX
!                   // Compare dev/ino when possible, it catches symbolic
!                   // links.  Also compare file names, the inode may change
!                   // when the file was edited.
!                   ((stat_ok && si->sn_dev_valid)
!                       && (si->sn_dev == st.st_dev
!                           && si->sn_ino == st.st_ino)) ||
  # endif
!               fnamecmp(si->sn_name, fname_exp) == 0))
!           break;
      }
      if (current_sctx.sc_sid == 0)
      {
--- 1249,1268 ----
                                                         --current_sctx.sc_sid)
      {
        si = &SCRIPT_ITEM(current_sctx.sc_sid);
!       if (si->sn_name != NULL)
!       {
  # ifdef UNIX
!           // Compare dev/ino when possible, it catches symbolic links.  Also
!           // compare file names, the inode may change when the file was
!           // edited or it may be re-used for another script (esp. in tests).
!           if ((stat_ok && si->sn_dev_valid)
!                      && (si->sn_dev != st.st_dev || si->sn_ino != st.st_ino))
!               continue;
  # endif
!           if (fnamecmp(si->sn_name, fname_exp) == 0)
!               // Found it!
!               break;
!       }
      }
      if (current_sctx.sc_sid == 0)
      {
*** ../vim-8.2.0131/src/testdir/test_source.vim 2019-06-03 22:39:43.000000000 
+0200
--- src/testdir/test_source.vim 2020-01-19 20:14:02.835278936 +0100
***************
*** 46,48 ****
--- 46,60 ----
    bwipe!
    call delete('Xsourcehello')
  endfunc
+ 
+ " When deleting a file and immediately creating a new one the inode may be
+ " recycled.  Vim should not recognize it as the same script.
+ func Test_different_script()
+   call ch_logfile('logfile', 'w')
+   call writefile(['let s:var = "asdf"'], 'XoneScript')
+   source XoneScript
+   call delete('XoneScript')
+   call writefile(['let g:var = s:var'], 'XtwoScript')
+   call assert_fails('source XtwoScript', 'E121:')
+   call delete('XtwoScript')
+ endfunc
*** ../vim-8.2.0131/src/version.c       2020-01-19 15:45:00.722541466 +0100
--- src/version.c       2020-01-19 20:15:16.930982041 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     132,
  /**/

-- 
"Lisp has all the visual appeal of oatmeal with nail clippings thrown in."
                                                         -- Larry Wall

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001191918.00JJIYDN027642%40masaka.moolenaar.net.

Raspunde prin e-mail lui