components/vim/vim72-patches/7.2.300
changeset 198 172fc01ce997
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/vim/vim72-patches/7.2.300	Thu Apr 07 16:25:07 2011 -0700
@@ -0,0 +1,201 @@
+To: [email protected]
+Subject: Patch 7.2.300
+Fcc: outbox
+From: Bram Moolenaar <[email protected]>
+Mime-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+------------
+
+Patch 7.2.300
+Problem:    Vim doesn't close file descriptors when forking and executing
+	    another command, e.g., ":shell".
+Solution:   Use FD_CLOEXEC when available. (James Vega)
+Files:	    src/auto/configure, src/config.h.in, src/configure.in,
+	    src/ex_cmdds2.c, src/fileio.c, src/memfile.c, src/memline.c
+
+
+*** ../vim-7.2.299/src/auto/configure	2009-11-17 12:08:48.000000000 +0100
+--- src/auto/configure	2009-11-17 13:09:03.000000000 +0100
+***************
+*** 15174,15179 ****
+--- 15174,15231 ----
+  $as_echo "yes" >&6; }
+  fi
+  
++ { $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
++ $as_echo_n "checking for FD_CLOEXEC... " >&6; }
++ cat >conftest.$ac_ext <<_ACEOF
++ /* confdefs.h.  */
++ _ACEOF
++ cat confdefs.h >>conftest.$ac_ext
++ cat >>conftest.$ac_ext <<_ACEOF
++ /* end confdefs.h.  */
++ #if HAVE_FCNTL_H
++ # include <fcntl.h>
++ #endif
++ int
++ main ()
++ {
++ 	int flag = FD_CLOEXEC;
++   ;
++   return 0;
++ }
++ _ACEOF
++ rm -f conftest.$ac_objext
++ if { (ac_try="$ac_compile"
++ case "(($ac_try" in
++   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++   *) ac_try_echo=$ac_try;;
++ esac
++ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
++ $as_echo "$ac_try_echo") >&5
++   (eval "$ac_compile") 2>conftest.er1
++   ac_status=$?
++   grep -v '^ *+' conftest.er1 >conftest.err
++   rm -f conftest.er1
++   cat conftest.err >&5
++   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); } && {
++ 	 test -z "$ac_c_werror_flag" ||
++ 	 test ! -s conftest.err
++        } && test -s conftest.$ac_objext; then
++   { $as_echo "$as_me:$LINENO: result: yes" >&5
++ $as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
++ #define HAVE_FD_CLOEXEC 1
++ _ACEOF
++ 
++ else
++   $as_echo "$as_me: failed program was:" >&5
++ sed 's/^/| /' conftest.$ac_ext >&5
++ 
++ 	{ $as_echo "$as_me:$LINENO: result: not usable" >&5
++ $as_echo "not usable" >&6; }
++ fi
++ 
++ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ 
+  { $as_echo "$as_me:$LINENO: checking for rename" >&5
+  $as_echo_n "checking for rename... " >&6; }
+  cat >conftest.$ac_ext <<_ACEOF
+*** ../vim-7.2.299/src/config.h.in	2009-11-17 12:08:48.000000000 +0100
+--- src/config.h.in	2009-11-17 13:01:36.000000000 +0100
+***************
+*** 388,390 ****
+--- 388,393 ----
+  
+  /* Define if you want XSMP interaction as well as vanilla swapfile safety */
+  #undef USE_XSMP_INTERACT
++ 
++ /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
++ #undef HAVE_FD_CLOEXEC
+*** ../vim-7.2.299/src/configure.in	2009-11-17 12:08:48.000000000 +0100
+--- src/configure.in	2009-11-17 13:01:36.000000000 +0100
+***************
+*** 2855,2860 ****
+--- 2855,2870 ----
+    AC_MSG_RESULT(yes)
+  fi
+  
++ dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
++ AC_MSG_CHECKING(for FD_CLOEXEC)
++ AC_TRY_COMPILE(
++ [#if HAVE_FCNTL_H
++ # include <fcntl.h>
++ #endif],
++ [	int flag = FD_CLOEXEC;],
++ 	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
++ 	AC_MSG_RESULT(not usable))
++ 
+  dnl rename needs to be checked separately to work on Nextstep with cc
+  AC_MSG_CHECKING(for rename)
+  AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
+*** ../vim-7.2.299/src/fileio.c	2009-11-17 14:57:19.000000000 +0100
+--- src/fileio.c	2009-11-17 13:22:06.000000000 +0100
+***************
+*** 2254,2259 ****
+--- 2254,2267 ----
+  
+      if (!read_buffer && !read_stdin)
+  	close(fd);				/* errors are ignored */
++ #ifdef HAVE_FD_CLOEXEC
++     else
++     {
++ 	int fdflags = fcntl(fd, F_GETFD);
++ 	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
++ 	    fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
++     }
++ #endif
+      vim_free(buffer);
+  
+  #ifdef HAVE_DUP
+*** ../vim-7.2.299/src/memfile.c	2008-07-13 19:39:39.000000000 +0200
+--- src/memfile.c	2009-11-17 13:22:15.000000000 +0100
+***************
+*** 1343,1348 ****
+--- 1343,1353 ----
+      }
+      else
+      {
++ #ifdef HAVE_FD_CLOEXEC
++ 	int fdflags = fcntl(mfp->mf_fd, F_GETFD);
++ 	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
++ 	    fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
++ #endif
+  #ifdef HAVE_SELINUX
+  	mch_copy_sec(fname, mfp->mf_fname);
+  #endif
+*** ../vim-7.2.299/src/memline.c	2009-11-03 15:32:58.000000000 +0100
+--- src/memline.c	2009-11-17 13:21:40.000000000 +0100
+***************
+*** 382,388 ****
+      dp->db_index[0] = --dp->db_txt_start;	/* at end of block */
+      dp->db_free -= 1 + INDEX_SIZE;
+      dp->db_line_count = 1;
+!     *((char_u *)dp + dp->db_txt_start) = NUL;	/* emtpy line */
+  
+      return OK;
+  
+--- 382,388 ----
+      dp->db_index[0] = --dp->db_txt_start;	/* at end of block */
+      dp->db_free -= 1 + INDEX_SIZE;
+      dp->db_line_count = 1;
+!     *((char_u *)dp + dp->db_txt_start) = NUL;	/* empty line */
+  
+      return OK;
+  
+***************
+*** 490,495 ****
+--- 490,502 ----
+  	    EMSG(_("E301: Oops, lost the swap file!!!"));
+  	    return;
+  	}
++ #ifdef HAVE_FD_CLOEXEC
++ 	{
++ 	    int fdflags = fcntl(mfp->mf_fd, F_GETFD);
++ 	    if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
++ 		fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
++ 	}
++ #endif
+      }
+      if (!success)
+  	EMSG(_("E302: Could not rename swap file"));
+*** ../vim-7.2.299/src/version.c	2009-11-17 16:08:12.000000000 +0100
+--- src/version.c	2009-11-17 17:09:43.000000000 +0100
+***************
+*** 683,684 ****
+--- 683,686 ----
+  {   /* Add new patch number below this line */
++ /**/
++     300,
+  /**/
+
+-- 
+            |
+
+Ceci n'est pas une pipe.
+
+ /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
+///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
+\\\        download, build and distribute -- http://www.A-A-P.org        ///
+ \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///