Karsten Hopp 60c122
To: vim-dev@vim.org
Karsten Hopp 60c122
Subject: patch 7.1.100
Karsten Hopp 60c122
Fcc: outbox
Karsten Hopp 60c122
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 60c122
Mime-Version: 1.0
Karsten Hopp 60c122
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 60c122
Content-Transfer-Encoding: 8bit
Karsten Hopp 60c122
------------
Karsten Hopp 60c122
Karsten Hopp 60c122
Patch 7.1.100
Karsten Hopp 60c122
Problem:    Win32: Executing cscope doesn't always work properly.
Karsten Hopp 60c122
Solution:   Use another way to invoke cscope. (Mike Williams)
Karsten Hopp 60c122
Files:	    src/if_cscope.c, src/if_cscope.h, src/main.c,
Karsten Hopp 60c122
	    src/proto/if_cscope.pro
Karsten Hopp 60c122
Karsten Hopp 60c122
Karsten Hopp 60c122
*** ../vim-7.1.099/src/if_cscope.c	Tue Aug 21 18:02:58 2007
Karsten Hopp 60c122
--- src/if_cscope.c	Sun Sep  2 16:50:50 2007
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 24,34 ****
Karsten Hopp 60c122
      /* not UNIX, must be WIN32 */
Karsten Hopp 60c122
  # include "vimio.h"
Karsten Hopp 60c122
  # include <fcntl.h>
Karsten Hopp 60c122
- # include <process.h>
Karsten Hopp 60c122
- # define STDIN_FILENO    0
Karsten Hopp 60c122
- # define STDOUT_FILENO   1
Karsten Hopp 60c122
- # define STDERR_FILENO   2
Karsten Hopp 60c122
- # define pipe(fds) _pipe(fds, 256, O_TEXT|O_NOINHERIT)
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  #include "if_cscope.h"
Karsten Hopp 60c122
  
Karsten Hopp 60c122
--- 24,29 ----
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 65,71 ****
Karsten Hopp 60c122
  static char *	    cs_parse_results __ARGS((int cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search));
Karsten Hopp 60c122
  static char *	    cs_pathcomponents __ARGS((char *path));
Karsten Hopp 60c122
  static void	    cs_print_tags_priv __ARGS((char **, char **, int));
Karsten Hopp 60c122
! static int	    cs_read_prompt __ARGS((int ));
Karsten Hopp 60c122
  static void	    cs_release_csp __ARGS((int, int freefnpp));
Karsten Hopp 60c122
  static int	    cs_reset __ARGS((exarg_T *eap));
Karsten Hopp 60c122
  static char *	    cs_resolve_file __ARGS((int, char *));
Karsten Hopp 60c122
--- 60,66 ----
Karsten Hopp 60c122
  static char *	    cs_parse_results __ARGS((int cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search));
Karsten Hopp 60c122
  static char *	    cs_pathcomponents __ARGS((char *path));
Karsten Hopp 60c122
  static void	    cs_print_tags_priv __ARGS((char **, char **, int));
Karsten Hopp 60c122
! static int	    cs_read_prompt __ARGS((int));
Karsten Hopp 60c122
  static void	    cs_release_csp __ARGS((int, int freefnpp));
Karsten Hopp 60c122
  static int	    cs_reset __ARGS((exarg_T *eap));
Karsten Hopp 60c122
  static char *	    cs_resolve_file __ARGS((int, char *));
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 504,510 ****
Karsten Hopp 60c122
  #if defined(UNIX)
Karsten Hopp 60c122
      else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
! 	/* substitute define S_ISREG from os_unix.h */
Karsten Hopp 60c122
      else if (((statbuf.st_mode) & S_IFMT) == S_IFREG)
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
      {
Karsten Hopp 60c122
--- 499,505 ----
Karsten Hopp 60c122
  #if defined(UNIX)
Karsten Hopp 60c122
      else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
! 	/* WIN32 - substitute define S_ISREG from os_unix.h */
Karsten Hopp 60c122
      else if (((statbuf.st_mode) & S_IFMT) == S_IFREG)
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
      {
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 717,733 ****
Karsten Hopp 60c122
  cs_create_connection(i)
Karsten Hopp 60c122
      int i;
Karsten Hopp 60c122
  {
Karsten Hopp 60c122
!     int to_cs[2], from_cs[2], len;
Karsten Hopp 60c122
!     char *prog, *cmd, *ppath = NULL;
Karsten Hopp 60c122
! #ifndef UNIX
Karsten Hopp 60c122
!     int in_save, out_save, err_save;
Karsten Hopp 60c122
!     long_i ph;
Karsten Hopp 60c122
! # ifdef FEAT_GUI
Karsten Hopp 60c122
!     HWND activewnd = NULL;
Karsten Hopp 60c122
!     HWND consolewnd = NULL;
Karsten Hopp 60c122
! # endif
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  
Karsten Hopp 60c122
      /*
Karsten Hopp 60c122
       * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
Karsten Hopp 60c122
       * from_cs[0] and writes to to_cs[1].
Karsten Hopp 60c122
--- 712,734 ----
Karsten Hopp 60c122
  cs_create_connection(i)
Karsten Hopp 60c122
      int i;
Karsten Hopp 60c122
  {
Karsten Hopp 60c122
! #ifdef UNIX
Karsten Hopp 60c122
!     int		to_cs[2], from_cs[2];
Karsten Hopp 60c122
! #endif
Karsten Hopp 60c122
!     int		len;
Karsten Hopp 60c122
!     char	*prog, *cmd, *ppath = NULL;
Karsten Hopp 60c122
! #ifdef WIN32
Karsten Hopp 60c122
!     int		fd;
Karsten Hopp 60c122
!     SECURITY_ATTRIBUTES sa;
Karsten Hopp 60c122
!     PROCESS_INFORMATION pi;
Karsten Hopp 60c122
!     STARTUPINFO si;
Karsten Hopp 60c122
!     BOOL	pipe_stdin = FALSE, pipe_stdout = FALSE;
Karsten Hopp 60c122
!     HANDLE	stdin_rd, stdout_rd;
Karsten Hopp 60c122
!     HANDLE	stdout_wr, stdin_wr;
Karsten Hopp 60c122
!     BOOL	created;
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  
Karsten Hopp 60c122
+ #if defined(UNIX)
Karsten Hopp 60c122
      /*
Karsten Hopp 60c122
       * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
Karsten Hopp 60c122
       * from_cs[0] and writes to to_cs[1].
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 748,765 ****
Karsten Hopp 60c122
  	return CSCOPE_FAILURE;
Karsten Hopp 60c122
      }
Karsten Hopp 60c122
  
Karsten Hopp 60c122
- #if defined(UNIX)
Karsten Hopp 60c122
      switch (csinfo[i].pid = fork())
Karsten Hopp 60c122
      {
Karsten Hopp 60c122
      case -1:
Karsten Hopp 60c122
  	(void)EMSG(_("E622: Could not fork for cscope"));
Karsten Hopp 60c122
  	goto err_closing;
Karsten Hopp 60c122
      case 0:				/* child: run cscope. */
Karsten Hopp 60c122
- #else
Karsten Hopp 60c122
- 	in_save = dup(STDIN_FILENO);
Karsten Hopp 60c122
- 	out_save = dup(STDOUT_FILENO);
Karsten Hopp 60c122
- 	err_save = dup(STDERR_FILENO);
Karsten Hopp 60c122
- #endif
Karsten Hopp 60c122
  	if (dup2(to_cs[0], STDIN_FILENO) == -1)
Karsten Hopp 60c122
  	    PERROR("cs_create_connection 1");
Karsten Hopp 60c122
  	if (dup2(from_cs[1], STDOUT_FILENO) == -1)
Karsten Hopp 60c122
--- 749,760 ----
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 768,782 ****
Karsten Hopp 60c122
  	    PERROR("cs_create_connection 3");
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  	/* close unused */
Karsten Hopp 60c122
- #if defined(UNIX)
Karsten Hopp 60c122
  	(void)close(to_cs[1]);
Karsten Hopp 60c122
  	(void)close(from_cs[0]);
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
! 	/* On win32 we must close opposite ends because we are the parent */
Karsten Hopp 60c122
! 	(void)close(to_cs[0]);
Karsten Hopp 60c122
! 	to_cs[0] = -1;
Karsten Hopp 60c122
! 	(void)close(from_cs[1]);
Karsten Hopp 60c122
! 	from_cs[1] = -1;
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	/* expand the cscope exec for env var's */
Karsten Hopp 60c122
  	if ((prog = (char *)alloc(MAXPATHL + 1)) == NULL)
Karsten Hopp 60c122
--- 763,794 ----
Karsten Hopp 60c122
  	    PERROR("cs_create_connection 3");
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  	/* close unused */
Karsten Hopp 60c122
  	(void)close(to_cs[1]);
Karsten Hopp 60c122
  	(void)close(from_cs[0]);
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
! 	/* WIN32 */
Karsten Hopp 60c122
! 	/* Create pipes to communicate with cscope */
Karsten Hopp 60c122
! 	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
Karsten Hopp 60c122
! 	sa.bInheritHandle = TRUE;
Karsten Hopp 60c122
! 	sa.lpSecurityDescriptor = NULL;
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
! 	if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0))
Karsten Hopp 60c122
! 		|| !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0)))
Karsten Hopp 60c122
! 	{
Karsten Hopp 60c122
! 	    (void)EMSG(_("E566: Could not create cscope pipes"));
Karsten Hopp 60c122
! err_closing:
Karsten Hopp 60c122
! 	    if (pipe_stdin)
Karsten Hopp 60c122
! 	    {
Karsten Hopp 60c122
! 		CloseHandle(stdin_rd);
Karsten Hopp 60c122
! 		CloseHandle(stdin_wr);
Karsten Hopp 60c122
! 	    }
Karsten Hopp 60c122
! 	    if (pipe_stdout)
Karsten Hopp 60c122
! 	    {
Karsten Hopp 60c122
! 		CloseHandle(stdout_rd);
Karsten Hopp 60c122
! 		CloseHandle(stdout_wr);
Karsten Hopp 60c122
! 	    }
Karsten Hopp 60c122
! 	    return CSCOPE_FAILURE;
Karsten Hopp 60c122
! 	}
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	/* expand the cscope exec for env var's */
Karsten Hopp 60c122
  	if ((prog = (char *)alloc(MAXPATHL + 1)) == NULL)
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 784,789 ****
Karsten Hopp 60c122
--- 796,802 ----
Karsten Hopp 60c122
  #ifdef UNIX
Karsten Hopp 60c122
  	    return CSCOPE_FAILURE;
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
+ 	    /* WIN32 */
Karsten Hopp 60c122
  	    goto err_closing;
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	}
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 800,805 ****
Karsten Hopp 60c122
--- 813,819 ----
Karsten Hopp 60c122
  #ifdef UNIX
Karsten Hopp 60c122
  		return CSCOPE_FAILURE;
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
+ 		/* WIN32 */
Karsten Hopp 60c122
  		goto err_closing;
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	    }
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 818,823 ****
Karsten Hopp 60c122
--- 832,838 ----
Karsten Hopp 60c122
  #ifdef UNIX
Karsten Hopp 60c122
  	    return CSCOPE_FAILURE;
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
+ 	    /* WIN32 */
Karsten Hopp 60c122
  	    goto err_closing;
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	}
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 826,831 ****
Karsten Hopp 60c122
--- 841,847 ----
Karsten Hopp 60c122
  #if defined(UNIX)
Karsten Hopp 60c122
  	(void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
+ 	/* WIN32 */
Karsten Hopp 60c122
  	(void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  	if (csinfo[i].ppath != NULL)
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 851,910 ****
Karsten Hopp 60c122
  	exit(127);
Karsten Hopp 60c122
  	/* NOTREACHED */
Karsten Hopp 60c122
      default:	/* parent. */
Karsten Hopp 60c122
- #else
Karsten Hopp 60c122
- # ifdef FEAT_GUI
Karsten Hopp 60c122
- 	activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
Karsten Hopp 60c122
- 	/* Dirty hack to hide annoying console window */
Karsten Hopp 60c122
- 	if (AllocConsole())
Karsten Hopp 60c122
- 	{
Karsten Hopp 60c122
- 	    char *title;
Karsten Hopp 60c122
- 	    title = (char *)alloc(1024);
Karsten Hopp 60c122
- 	    if (title == NULL)
Karsten Hopp 60c122
- 		FreeConsole();
Karsten Hopp 60c122
- 	    else
Karsten Hopp 60c122
- 	    {
Karsten Hopp 60c122
- 		GetConsoleTitle(title, 1024); /* save for future restore */
Karsten Hopp 60c122
- 		SetConsoleTitle(
Karsten Hopp 60c122
- 		    "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
Karsten Hopp 60c122
- 		Sleep(40); /* as stated in MS KB we must wait 40 ms */
Karsten Hopp 60c122
- 		consolewnd = FindWindow(NULL,
Karsten Hopp 60c122
- 			"GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
Karsten Hopp 60c122
- 		if (consolewnd != NULL)
Karsten Hopp 60c122
- 		    ShowWindow(consolewnd, SW_HIDE);
Karsten Hopp 60c122
- 		SetConsoleTitle(title);
Karsten Hopp 60c122
- 		vim_free(title);
Karsten Hopp 60c122
- 	    }
Karsten Hopp 60c122
- 	}
Karsten Hopp 60c122
- # endif
Karsten Hopp 60c122
- 	/* May be use &shell, &shellquote etc */
Karsten Hopp 60c122
- # ifdef __BORLANDC__
Karsten Hopp 60c122
- 	/* BCC 5.5 uses a different function name for spawnlp */
Karsten Hopp 60c122
- 	ph = (long_i)spawnlp(P_NOWAIT, prog, cmd, NULL);
Karsten Hopp 60c122
- # else
Karsten Hopp 60c122
- 	ph = (long_i)_spawnlp(_P_NOWAIT, prog, cmd, NULL);
Karsten Hopp 60c122
- # endif
Karsten Hopp 60c122
- 	vim_free(prog);
Karsten Hopp 60c122
- 	vim_free(cmd);
Karsten Hopp 60c122
- # ifdef FEAT_GUI
Karsten Hopp 60c122
- 	/* Dirty hack part two */
Karsten Hopp 60c122
- 	if (activewnd != NULL)
Karsten Hopp 60c122
- 	    /* restoring focus */
Karsten Hopp 60c122
- 	    SetForegroundWindow(activewnd);
Karsten Hopp 60c122
- 	if (consolewnd != NULL)
Karsten Hopp 60c122
- 	    FreeConsole();
Karsten Hopp 60c122
- 
Karsten Hopp 60c122
- # endif
Karsten Hopp 60c122
- 	if (ph == -1)
Karsten Hopp 60c122
- 	{
Karsten Hopp 60c122
- 	    PERROR(_("cs_create_connection exec failed"));
Karsten Hopp 60c122
- 	    (void)EMSG(_("E623: Could not spawn cscope process"));
Karsten Hopp 60c122
- 	    goto err_closing;
Karsten Hopp 60c122
- 	}
Karsten Hopp 60c122
- 	/* else */
Karsten Hopp 60c122
- 	csinfo[i].pid = 0;
Karsten Hopp 60c122
- 	csinfo[i].hProc = (HANDLE)ph;
Karsten Hopp 60c122
- 
Karsten Hopp 60c122
- #endif /* !UNIX */
Karsten Hopp 60c122
  	/*
Karsten Hopp 60c122
  	 * Save the file descriptors for later duplication, and
Karsten Hopp 60c122
  	 * reopen as streams.
Karsten Hopp 60c122
--- 867,872 ----
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 914,935 ****
Karsten Hopp 60c122
  	if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
Karsten Hopp 60c122
  	    PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
Karsten Hopp 60c122
  
Karsten Hopp 60c122
- #if defined(UNIX)
Karsten Hopp 60c122
  	/* close unused */
Karsten Hopp 60c122
  	(void)close(to_cs[0]);
Karsten Hopp 60c122
  	(void)close(from_cs[1]);
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  	break;
Karsten Hopp 60c122
      }
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
! 	/* restore stdhandles */
Karsten Hopp 60c122
!     dup2(in_save, STDIN_FILENO);
Karsten Hopp 60c122
!     dup2(out_save, STDOUT_FILENO);
Karsten Hopp 60c122
!     dup2(err_save, STDERR_FILENO);
Karsten Hopp 60c122
!     close(in_save);
Karsten Hopp 60c122
!     close(out_save);
Karsten Hopp 60c122
!     close(err_save);
Karsten Hopp 60c122
! #endif
Karsten Hopp 60c122
      return CSCOPE_SUCCESS;
Karsten Hopp 60c122
  } /* cs_create_connection */
Karsten Hopp 60c122
  
Karsten Hopp 60c122
--- 876,927 ----
Karsten Hopp 60c122
  	if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
Karsten Hopp 60c122
  	    PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  	/* close unused */
Karsten Hopp 60c122
  	(void)close(to_cs[0]);
Karsten Hopp 60c122
  	(void)close(from_cs[1]);
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  	break;
Karsten Hopp 60c122
      }
Karsten Hopp 60c122
+ 
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
!     /* WIN32 */
Karsten Hopp 60c122
!     /* Create a new process to run cscope and use pipes to talk with it */
Karsten Hopp 60c122
!     GetStartupInfo(&si);
Karsten Hopp 60c122
!     si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
Karsten Hopp 60c122
!     si.wShowWindow = SW_HIDE;  /* Hide child application window */
Karsten Hopp 60c122
!     si.hStdOutput = stdout_wr;
Karsten Hopp 60c122
!     si.hStdError  = stdout_wr;
Karsten Hopp 60c122
!     si.hStdInput  = stdin_rd;
Karsten Hopp 60c122
!     created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE,
Karsten Hopp 60c122
! 							NULL, NULL, &si, &pi);
Karsten Hopp 60c122
!     vim_free(prog);
Karsten Hopp 60c122
!     vim_free(cmd);
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
!     if (!created)
Karsten Hopp 60c122
!     {
Karsten Hopp 60c122
! 	PERROR(_("cs_create_connection exec failed"));
Karsten Hopp 60c122
! 	(void)EMSG(_("E623: Could not spawn cscope process"));
Karsten Hopp 60c122
! 	goto err_closing;
Karsten Hopp 60c122
!     }
Karsten Hopp 60c122
!     /* else */
Karsten Hopp 60c122
!     csinfo[i].pid = pi.dwProcessId;
Karsten Hopp 60c122
!     csinfo[i].hProc = pi.hProcess;
Karsten Hopp 60c122
!     CloseHandle(pi.hThread);
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
!     /* TODO - tidy up after failure to create files on pipe handles. */
Karsten Hopp 60c122
!     if (((fd = _open_osfhandle((intptr_t)stdin_wr, _O_TEXT|_O_APPEND)) < 0)
Karsten Hopp 60c122
! 	    || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL))
Karsten Hopp 60c122
! 	PERROR(_("cs_create_connection: fdopen for to_fp failed"));
Karsten Hopp 60c122
!     if (((fd = _open_osfhandle((intptr_t)stdout_rd, _O_TEXT|_O_RDONLY)) < 0)
Karsten Hopp 60c122
! 	    || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL))
Karsten Hopp 60c122
! 	PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
!     /* Close handles for file descriptors inherited by the cscope process */
Karsten Hopp 60c122
!     CloseHandle(stdin_rd);
Karsten Hopp 60c122
!     CloseHandle(stdout_wr);
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
! #endif /* !UNIX */
Karsten Hopp 60c122
! 
Karsten Hopp 60c122
      return CSCOPE_SUCCESS;
Karsten Hopp 60c122
  } /* cs_create_connection */
Karsten Hopp 60c122
  
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 2097,2104 ****
Karsten Hopp 60c122
  /*
Karsten Hopp 60c122
   * PRIVATE: cs_release_csp
Karsten Hopp 60c122
   *
Karsten Hopp 60c122
!  * does the actual free'ing for the cs ptr with an optional flag of whether
Karsten Hopp 60c122
!  * or not to free the filename.  called by cs_kill and cs_reset.
Karsten Hopp 60c122
   */
Karsten Hopp 60c122
      static void
Karsten Hopp 60c122
  cs_release_csp(i, freefnpp)
Karsten Hopp 60c122
--- 2089,2096 ----
Karsten Hopp 60c122
  /*
Karsten Hopp 60c122
   * PRIVATE: cs_release_csp
Karsten Hopp 60c122
   *
Karsten Hopp 60c122
!  * Does the actual free'ing for the cs ptr with an optional flag of whether
Karsten Hopp 60c122
!  * or not to free the filename.  Called by cs_kill and cs_reset.
Karsten Hopp 60c122
   */
Karsten Hopp 60c122
      static void
Karsten Hopp 60c122
  cs_release_csp(i, freefnpp)
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 2116,2125 ****
Karsten Hopp 60c122
  	(void)fputs("q\n", csinfo[i].to_fp);
Karsten Hopp 60c122
  	(void)fflush(csinfo[i].to_fp);
Karsten Hopp 60c122
      }
Karsten Hopp 60c122
!     /* give cscope chance to exit normally */
Karsten Hopp 60c122
!     if (csinfo[i].hProc != NULL
Karsten Hopp 60c122
! 	    && WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
Karsten Hopp 60c122
! 	TerminateProcess(csinfo[i].hProc, 0);
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  
Karsten Hopp 60c122
      if (csinfo[i].fr_fp != NULL)
Karsten Hopp 60c122
--- 2108,2120 ----
Karsten Hopp 60c122
  	(void)fputs("q\n", csinfo[i].to_fp);
Karsten Hopp 60c122
  	(void)fflush(csinfo[i].to_fp);
Karsten Hopp 60c122
      }
Karsten Hopp 60c122
!     if (csinfo[i].hProc != NULL)
Karsten Hopp 60c122
!     {
Karsten Hopp 60c122
! 	/* Give cscope a chance to exit normally */
Karsten Hopp 60c122
! 	if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
Karsten Hopp 60c122
! 	    TerminateProcess(csinfo[i].hProc, 0);
Karsten Hopp 60c122
! 	CloseHandle(csinfo[i].hProc);
Karsten Hopp 60c122
!     }
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
  
Karsten Hopp 60c122
      if (csinfo[i].fr_fp != NULL)
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 2301,2306 ****
Karsten Hopp 60c122
--- 2296,2316 ----
Karsten Hopp 60c122
      wait_return(TRUE);
Karsten Hopp 60c122
      return CSCOPE_SUCCESS;
Karsten Hopp 60c122
  } /* cs_show */
Karsten Hopp 60c122
+ 
Karsten Hopp 60c122
+ 
Karsten Hopp 60c122
+ /*
Karsten Hopp 60c122
+  * PUBLIC: cs_end
Karsten Hopp 60c122
+  *
Karsten Hopp 60c122
+  * Only called when VIM exits to quit any cscope sessions.
Karsten Hopp 60c122
+  */
Karsten Hopp 60c122
+     void
Karsten Hopp 60c122
+ cs_end()
Karsten Hopp 60c122
+ {
Karsten Hopp 60c122
+     int i;
Karsten Hopp 60c122
+ 
Karsten Hopp 60c122
+     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 60c122
+ 	cs_release_csp(i, TRUE);
Karsten Hopp 60c122
+ }
Karsten Hopp 60c122
  
Karsten Hopp 60c122
  #endif	/* FEAT_CSCOPE */
Karsten Hopp 60c122
  
Karsten Hopp 60c122
*** ../vim-7.1.099/src/if_cscope.h	Thu Jun 30 23:59:58 2005
Karsten Hopp 60c122
--- src/if_cscope.h	Sun Sep  2 16:51:08 2007
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 72,78 ****
Karsten Hopp 60c122
      ino_t	    st_ino;	/* inode number of cscope db */
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
  # if defined(WIN32)
Karsten Hopp 60c122
!     int	    pid;	/* Can't get pid so set it to 0 ;) */
Karsten Hopp 60c122
      HANDLE	    hProc;	/* cscope process handle */
Karsten Hopp 60c122
      DWORD	    nVolume;	/* Volume serial number, instead of st_dev */
Karsten Hopp 60c122
      DWORD	    nIndexHigh;	/* st_ino has no meaning in the Windows */
Karsten Hopp 60c122
--- 72,78 ----
Karsten Hopp 60c122
      ino_t	    st_ino;	/* inode number of cscope db */
Karsten Hopp 60c122
  #else
Karsten Hopp 60c122
  # if defined(WIN32)
Karsten Hopp 60c122
!     DWORD	    pid;	/* PID of the connected cscope process. */
Karsten Hopp 60c122
      HANDLE	    hProc;	/* cscope process handle */
Karsten Hopp 60c122
      DWORD	    nVolume;	/* Volume serial number, instead of st_dev */
Karsten Hopp 60c122
      DWORD	    nIndexHigh;	/* st_ino has no meaning in the Windows */
Karsten Hopp 60c122
*** ../vim-7.1.099/src/main.c	Thu Aug 30 12:24:21 2007
Karsten Hopp 60c122
--- src/main.c	Sun Sep  2 16:44:36 2007
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 1331,1336 ****
Karsten Hopp 60c122
--- 1331,1339 ----
Karsten Hopp 60c122
  #ifdef FEAT_NETBEANS_INTG
Karsten Hopp 60c122
      netbeans_end();
Karsten Hopp 60c122
  #endif
Karsten Hopp 60c122
+ #ifdef FEAT_CSCOPE
Karsten Hopp 60c122
+     cs_end();
Karsten Hopp 60c122
+ #endif
Karsten Hopp 60c122
  
Karsten Hopp 60c122
      mch_exit(exitval);
Karsten Hopp 60c122
  }
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 3671,3677 ****
Karsten Hopp 60c122
  	mainerr_arg_missing((char_u *)filev[-1]);
Karsten Hopp 60c122
      if (mch_dirname(cwd, MAXPATHL) != OK)
Karsten Hopp 60c122
  	return NULL;
Karsten Hopp 60c122
!     if ((p = vim_strsave_escaped_ext(cwd, PATH_ESC_CHARS, '\\', TRUE)) == NULL)
Karsten Hopp 60c122
  	return NULL;
Karsten Hopp 60c122
      ga_init2(&ga, 1, 100);
Karsten Hopp 60c122
      ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
Karsten Hopp 60c122
--- 3674,3686 ----
Karsten Hopp 60c122
  	mainerr_arg_missing((char_u *)filev[-1]);
Karsten Hopp 60c122
      if (mch_dirname(cwd, MAXPATHL) != OK)
Karsten Hopp 60c122
  	return NULL;
Karsten Hopp 60c122
!     if ((p = vim_strsave_escaped_ext(cwd,
Karsten Hopp 60c122
! #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp 60c122
! 		    "",  /* rem_backslash() will tell what chars to escape */
Karsten Hopp 60c122
! #else
Karsten Hopp 60c122
! 		    PATH_ESC_CHARS,
Karsten Hopp 60c122
! #endif
Karsten Hopp 60c122
! 		    '\\', TRUE)) == NULL)
Karsten Hopp 60c122
  	return NULL;
Karsten Hopp 60c122
      ga_init2(&ga, 1, 100);
Karsten Hopp 60c122
      ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
Karsten Hopp 60c122
*** ../vim-7.1.099/src/proto/if_cscope.pro	Sat May  5 19:15:39 2007
Karsten Hopp 60c122
--- src/proto/if_cscope.pro	Sun Sep  2 16:51:34 2007
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 6,9 ****
Karsten Hopp 60c122
--- 6,10 ----
Karsten Hopp 60c122
  void cs_free_tags __ARGS((void));
Karsten Hopp 60c122
  void cs_print_tags __ARGS((void));
Karsten Hopp 60c122
  int cs_connection __ARGS((int num, char_u *dbpath, char_u *ppath));
Karsten Hopp 60c122
+ void cs_end __ARGS((void));
Karsten Hopp 60c122
  /* vim: set ft=c : */
Karsten Hopp 60c122
*** ../vim-7.1.099/src/version.c	Thu Sep  6 16:33:47 2007
Karsten Hopp 60c122
--- src/version.c	Thu Sep  6 17:27:51 2007
Karsten Hopp 60c122
***************
Karsten Hopp 60c122
*** 668,669 ****
Karsten Hopp 60c122
--- 668,671 ----
Karsten Hopp 60c122
  {   /* Add new patch number below this line */
Karsten Hopp 60c122
+ /**/
Karsten Hopp 60c122
+     100,
Karsten Hopp 60c122
  /**/
Karsten Hopp 60c122
Karsten Hopp 60c122
-- 
Karsten Hopp 60c122
I have to exercise early in the morning before my brain
Karsten Hopp 60c122
figures out what I'm doing.
Karsten Hopp 60c122
Karsten Hopp 60c122
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 60c122
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 60c122
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 60c122
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///