Karsten Hopp 3b1279
To: vim_dev@googlegroups.com
Karsten Hopp 3b1279
Subject: Patch 7.4.876
Karsten Hopp 3b1279
Fcc: outbox
Karsten Hopp 3b1279
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 3b1279
Mime-Version: 1.0
Karsten Hopp 3b1279
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 3b1279
Content-Transfer-Encoding: 8bit
Karsten Hopp 3b1279
------------
Karsten Hopp 3b1279
Karsten Hopp 3b1279
Patch 7.4.876
Karsten Hopp 3b1279
Problem:    Windows7: when using vim.exe with msys or msys2, conhost.exe
Karsten Hopp 3b1279
            (console window provider on Windows7) will freeze or crash.
Karsten Hopp 3b1279
Solution:   Make original screen buffer active, before executing external
Karsten Hopp 3b1279
            program.  And when the program is finished, revert to vim's one.
Karsten Hopp 3b1279
            (Taro Muraoka)
Karsten Hopp 3b1279
Files:      src/os_win32.c
Karsten Hopp 3b1279
Karsten Hopp 3b1279
Karsten Hopp 3b1279
*** ../vim-7.4.875/src/os_win32.c	2015-09-01 20:31:16.307776163 +0200
Karsten Hopp 3b1279
--- src/os_win32.c	2015-09-25 15:27:22.772877421 +0200
Karsten Hopp 3b1279
***************
Karsten Hopp 3b1279
*** 234,239 ****
Karsten Hopp 3b1279
--- 234,240 ----
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  static char_u *exe_path = NULL;
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
+ static BOOL is_win7 = FALSE;
Karsten Hopp 3b1279
  static BOOL win8_or_later = FALSE;
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  /*
Karsten Hopp 3b1279
***************
Karsten Hopp 3b1279
*** 680,685 ****
Karsten Hopp 3b1279
--- 681,689 ----
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  	g_PlatformId = ovi.dwPlatformId;
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
+ 	if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion == 1))
Karsten Hopp 3b1279
+ 	    is_win7 = TRUE;
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
  	if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
Karsten Hopp 3b1279
  		|| ovi.dwMajorVersion > 6)
Karsten Hopp 3b1279
  	    win8_or_later = TRUE;
Karsten Hopp 3b1279
***************
Karsten Hopp 3b1279
*** 4581,4591 ****
Karsten Hopp 3b1279
      else
Karsten Hopp 3b1279
  	return mch_system_classic(cmd, options);
Karsten Hopp 3b1279
  }
Karsten Hopp 3b1279
  #else
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  # ifdef FEAT_MBYTE
Karsten Hopp 3b1279
      static int
Karsten Hopp 3b1279
! mch_system(char *cmd, int options)
Karsten Hopp 3b1279
  {
Karsten Hopp 3b1279
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 3b1279
      {
Karsten Hopp 3b1279
--- 4585,4596 ----
Karsten Hopp 3b1279
      else
Karsten Hopp 3b1279
  	return mch_system_classic(cmd, options);
Karsten Hopp 3b1279
  }
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
  #else
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  # ifdef FEAT_MBYTE
Karsten Hopp 3b1279
      static int
Karsten Hopp 3b1279
! mch_system1(char *cmd, int options)
Karsten Hopp 3b1279
  {
Karsten Hopp 3b1279
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 3b1279
      {
Karsten Hopp 3b1279
***************
Karsten Hopp 3b1279
*** 4600,4608 ****
Karsten Hopp 3b1279
      return system(cmd);
Karsten Hopp 3b1279
  }
Karsten Hopp 3b1279
  # else
Karsten Hopp 3b1279
! #  define mch_system(c, o) system(c)
Karsten Hopp 3b1279
  # endif
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  #endif
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  /*
Karsten Hopp 3b1279
--- 4605,4635 ----
Karsten Hopp 3b1279
      return system(cmd);
Karsten Hopp 3b1279
  }
Karsten Hopp 3b1279
  # else
Karsten Hopp 3b1279
! #  define mch_system1(c, o) system(c)
Karsten Hopp 3b1279
  # endif
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
+     static int
Karsten Hopp 3b1279
+ mch_system(char *cmd, int options)
Karsten Hopp 3b1279
+ {
Karsten Hopp 3b1279
+     int ret;
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
+     /*
Karsten Hopp 3b1279
+      * Restore non-termcap screen buffer before execute external program, and
Karsten Hopp 3b1279
+      * revert it after.  Because msys and msys2's programs will cause freeze
Karsten Hopp 3b1279
+      * or crash conhost.exe (Windows's console window provider) and vim.exe,
Karsten Hopp 3b1279
+      * if active screen buffer is vim's one on Windows7.
Karsten Hopp 3b1279
+      */
Karsten Hopp 3b1279
+     if (is_win7 && g_fTermcapMode)
Karsten Hopp 3b1279
+ 	SetConsoleActiveScreenBuffer(g_cbNonTermcap.handle);
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
+     ret = mch_system1(cmd, options);
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
+     if (is_win7 && g_fTermcapMode)
Karsten Hopp 3b1279
+ 	SetConsoleActiveScreenBuffer(g_cbTermcap.handle);
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
+     return ret;
Karsten Hopp 3b1279
+ }
Karsten Hopp 3b1279
+ 
Karsten Hopp 3b1279
  #endif
Karsten Hopp 3b1279
  
Karsten Hopp 3b1279
  /*
Karsten Hopp 3b1279
*** ../vim-7.4.875/src/version.c	2015-09-25 15:00:53.537813204 +0200
Karsten Hopp 3b1279
--- src/version.c	2015-09-25 15:23:09.863577538 +0200
Karsten Hopp 3b1279
***************
Karsten Hopp 3b1279
*** 743,744 ****
Karsten Hopp 3b1279
--- 743,746 ----
Karsten Hopp 3b1279
  {   /* Add new patch number below this line */
Karsten Hopp 3b1279
+ /**/
Karsten Hopp 3b1279
+     876,
Karsten Hopp 3b1279
  /**/
Karsten Hopp 3b1279
Karsten Hopp 3b1279
Karsten Hopp 3b1279
-- 
Karsten Hopp 3b1279
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 3b1279
5. You find yourself brainstorming for new subjects to search.
Karsten Hopp 3b1279
Karsten Hopp 3b1279
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 3b1279
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 3b1279
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 3b1279
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///