81c2858
To: vim-dev@vim.org
81c2858
Subject: Patch 7.2.170
81c2858
Fcc: outbox
81c2858
From: Bram Moolenaar <Bram@moolenaar.net>
81c2858
Mime-Version: 1.0
81c2858
Content-Type: text/plain; charset=UTF-8
81c2858
Content-Transfer-Encoding: 8bit
81c2858
------------
81c2858
81c2858
Patch 7.2.170
81c2858
Problem:    Using b_dev while it was not set. (Dominique Pelle)
81c2858
Solution:   Add the b_dev_valid flag.
81c2858
Files:	    src/buffer.c, src/fileio.c, src/structs.h
81c2858
81c2858
81c2858
*** ../vim-7.2.169/src/buffer.c	2009-05-13 12:46:36.000000000 +0200
81c2858
--- src/buffer.c	2009-05-13 20:23:51.000000000 +0200
81c2858
***************
81c2858
*** 1678,1686 ****
81c2858
      buf->b_fname = buf->b_sfname;
81c2858
  #ifdef UNIX
81c2858
      if (st.st_dev == (dev_T)-1)
81c2858
! 	buf->b_dev = -1;
81c2858
      else
81c2858
      {
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
--- 1678,1687 ----
81c2858
      buf->b_fname = buf->b_sfname;
81c2858
  #ifdef UNIX
81c2858
      if (st.st_dev == (dev_T)-1)
81c2858
! 	buf->b_dev_valid = FALSE;
81c2858
      else
81c2858
      {
81c2858
+ 	buf->b_dev_valid = TRUE;
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
***************
81c2858
*** 2693,2701 ****
81c2858
      buf->b_fname = buf->b_sfname;
81c2858
  #ifdef UNIX
81c2858
      if (st.st_dev == (dev_T)-1)
81c2858
! 	buf->b_dev = -1;
81c2858
      else
81c2858
      {
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
--- 2694,2703 ----
81c2858
      buf->b_fname = buf->b_sfname;
81c2858
  #ifdef UNIX
81c2858
      if (st.st_dev == (dev_T)-1)
81c2858
! 	buf->b_dev_valid = FALSE;
81c2858
      else
81c2858
      {
81c2858
+ 	buf->b_dev_valid = TRUE;
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
***************
81c2858
*** 2889,2895 ****
81c2858
  	/* If no struct stat given, get it now */
81c2858
  	if (stp == NULL)
81c2858
  	{
81c2858
! 	    if (buf->b_dev < 0 || mch_stat((char *)ffname, &st) < 0)
81c2858
  		st.st_dev = (dev_T)-1;
81c2858
  	    stp = &st;
81c2858
  	}
81c2858
--- 2891,2897 ----
81c2858
  	/* If no struct stat given, get it now */
81c2858
  	if (stp == NULL)
81c2858
  	{
81c2858
! 	    if (!buf->b_dev_valid || mch_stat((char *)ffname, &st) < 0)
81c2858
  		st.st_dev = (dev_T)-1;
81c2858
  	    stp = &st;
81c2858
  	}
81c2858
***************
81c2858
*** 2926,2936 ****
81c2858
  
81c2858
      if (buf->b_fname != NULL && mch_stat((char *)buf->b_fname, &st) >= 0)
81c2858
      {
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
      else
81c2858
! 	buf->b_dev = -1;
81c2858
  }
81c2858
  
81c2858
  /*
81c2858
--- 2928,2939 ----
81c2858
  
81c2858
      if (buf->b_fname != NULL && mch_stat((char *)buf->b_fname, &st) >= 0)
81c2858
      {
81c2858
+ 	buf->b_dev_valid = TRUE;
81c2858
  	buf->b_dev = st.st_dev;
81c2858
  	buf->b_ino = st.st_ino;
81c2858
      }
81c2858
      else
81c2858
! 	buf->b_dev_valid = FALSE;
81c2858
  }
81c2858
  
81c2858
  /*
81c2858
***************
81c2858
*** 2941,2947 ****
81c2858
      buf_T	*buf;
81c2858
      struct stat *stp;
81c2858
  {
81c2858
!     return (buf->b_dev >= 0
81c2858
  	    && stp->st_dev == buf->b_dev
81c2858
  	    && stp->st_ino == buf->b_ino);
81c2858
  }
81c2858
--- 2944,2950 ----
81c2858
      buf_T	*buf;
81c2858
      struct stat *stp;
81c2858
  {
81c2858
!     return (buf->b_dev_valid
81c2858
  	    && stp->st_dev == buf->b_dev
81c2858
  	    && stp->st_ino == buf->b_ino);
81c2858
  }
81c2858
*** ../vim-7.2.169/src/fileio.c	2009-04-29 18:01:23.000000000 +0200
81c2858
--- src/fileio.c	2009-05-13 20:24:08.000000000 +0200
81c2858
***************
81c2858
*** 4416,4422 ****
81c2858
  # endif
81c2858
  	buf_setino(buf);
81c2858
      }
81c2858
!     else if (buf->b_dev < 0)
81c2858
  	/* Set the inode when creating a new file. */
81c2858
  	buf_setino(buf);
81c2858
  #endif
81c2858
--- 4416,4422 ----
81c2858
  # endif
81c2858
  	buf_setino(buf);
81c2858
      }
81c2858
!     else if (!buf->b_dev_valid)
81c2858
  	/* Set the inode when creating a new file. */
81c2858
  	buf_setino(buf);
81c2858
  #endif
81c2858
*** ../vim-7.2.169/src/structs.h	2009-05-13 18:54:14.000000000 +0200
81c2858
--- src/structs.h	2009-05-13 20:24:54.000000000 +0200
81c2858
***************
81c2858
*** 1166,1172 ****
81c2858
      char_u	*b_fname;	/* current file name */
81c2858
  
81c2858
  #ifdef UNIX
81c2858
!     dev_t	b_dev;		/* device number (-1 if not set) */
81c2858
      ino_t	b_ino;		/* inode number */
81c2858
  #endif
81c2858
  #ifdef FEAT_CW_EDITOR
81c2858
--- 1166,1173 ----
81c2858
      char_u	*b_fname;	/* current file name */
81c2858
  
81c2858
  #ifdef UNIX
81c2858
!     int		b_dev_valid;	/* TRUE when b_dev has a valid number */
81c2858
!     dev_t	b_dev;		/* device number */
81c2858
      ino_t	b_ino;		/* inode number */
81c2858
  #endif
81c2858
  #ifdef FEAT_CW_EDITOR
81c2858
*** ../vim-7.2.169/src/version.c	2009-05-13 18:54:14.000000000 +0200
81c2858
--- src/version.c	2009-05-13 20:43:22.000000000 +0200
81c2858
***************
81c2858
*** 678,679 ****
81c2858
--- 678,681 ----
81c2858
  {   /* Add new patch number below this line */
81c2858
+ /**/
81c2858
+     170,
81c2858
  /**/
81c2858
81c2858
-- 
81c2858
A special cleaning ordinance bans housewives from hiding dirt and dust under a
81c2858
rug in a dwelling.
81c2858
		[real standing law in Pennsylvania, United States of America]
81c2858
81c2858
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
81c2858
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
81c2858
\\\        download, build and distribute -- http://www.A-A-P.org        ///
81c2858
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///