Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.228
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.228
Karsten Hopp 81c285
Problem:    Cscope is limited to 8 connections.
Karsten Hopp 81c285
Solution:   Allocated the connection array to handle any number of
Karsten Hopp 81c285
	    connections. (Dominique Pelle)
Karsten Hopp 81c285
Files:	    runtime/doc/if_cscop.txt, src/if_cscope.h, src/if_cscope.c
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.227/runtime/doc/if_cscop.txt	2009-03-18 14:30:46.000000000 +0100
Karsten Hopp 81c285
--- runtime/doc/if_cscop.txt	2009-07-09 15:40:48.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 355,367 ****
Karsten Hopp 81c285
  The DJGPP-built version from http://cscope.sourceforge.net is known to not
Karsten Hopp 81c285
  work with Vim.
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! There are a couple of hard-coded limitations:
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     1. The maximum number of cscope connections allowed is 8.  Do you
Karsten Hopp 81c285
!     really need more?
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     2. Doing a |:tjump| when |:cstag| searches the tag files is not
Karsten Hopp 81c285
!     configurable (e.g., you can't do a tselect instead).
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  ==============================================================================
Karsten Hopp 81c285
  6. Suggested usage					*cscope-suggestions*
Karsten Hopp 81c285
--- 355,362 ----
Karsten Hopp 81c285
  The DJGPP-built version from http://cscope.sourceforge.net is known to not
Karsten Hopp 81c285
  work with Vim.
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files
Karsten Hopp 81c285
! is not configurable (e.g., you can't do a tselect instead).
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  ==============================================================================
Karsten Hopp 81c285
  6. Suggested usage					*cscope-suggestions*
Karsten Hopp 81c285
*** ../vim-7.2.227/src/if_cscope.h	2008-08-25 04:35:13.000000000 +0200
Karsten Hopp 81c285
--- src/if_cscope.h	2009-07-09 15:39:32.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 25,31 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #define CSCOPE_SUCCESS		0
Karsten Hopp 81c285
  #define CSCOPE_FAILURE		-1
Karsten Hopp 81c285
- #define CSCOPE_MAX_CONNECTIONS	8   /* you actually need more? */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #define	CSCOPE_DBFILE		"cscope.out"
Karsten Hopp 81c285
  #define	CSCOPE_PROMPT		">> "
Karsten Hopp 81c285
--- 25,30 ----
Karsten Hopp 81c285
*** ../vim-7.2.227/src/if_cscope.c	2009-05-16 17:29:37.000000000 +0200
Karsten Hopp 81c285
--- src/if_cscope.c	2009-07-09 15:39:32.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 46,52 ****
Karsten Hopp 81c285
  static int	    cs_find __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  static int	    cs_find_common __ARGS((char *opt, char *pat, int, int, int));
Karsten Hopp 81c285
  static int	    cs_help __ARGS((exarg_T *eap));
Karsten Hopp 81c285
- static void	    cs_init __ARGS((void));
Karsten Hopp 81c285
  static void	    clear_csinfo __ARGS((int i));
Karsten Hopp 81c285
  static int	    cs_insert_filelist __ARGS((char *, char *, char *,
Karsten Hopp 81c285
  			struct stat *));
Karsten Hopp 81c285
--- 46,51 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 66,72 ****
Karsten Hopp 81c285
  static int	    cs_show __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static csinfo_T	    csinfo[CSCOPE_MAX_CONNECTIONS];
Karsten Hopp 81c285
  static int	    eap_arg_len;    /* length of eap->arg, set in
Karsten Hopp 81c285
  				       cs_lookup_cmd() */
Karsten Hopp 81c285
  static cscmd_T	    cs_cmds[] =
Karsten Hopp 81c285
--- 65,74 ----
Karsten Hopp 81c285
  static int	    cs_show __ARGS((exarg_T *eap));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static csinfo_T *   csinfo = NULL;
Karsten Hopp 81c285
! static int	    csinfo_size = 0;	/* number of items allocated in
Karsten Hopp 81c285
! 					   csinfo[] */
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
  static int	    eap_arg_len;    /* length of eap->arg, set in
Karsten Hopp 81c285
  				       cs_lookup_cmd() */
Karsten Hopp 81c285
  static cscmd_T	    cs_cmds[] =
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 144,166 ****
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      case EXP_CSCOPE_KILL:
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    static char_u	connection[2];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* ":cscope kill" accepts connection numbers or partial names of
Karsten Hopp 81c285
  	     * the pathname of the cscope database as argument.  Only complete
Karsten Hopp 81c285
  	     * with connection numbers. -1 can also be used to kill all
Karsten Hopp 81c285
  	     * connections. */
Karsten Hopp 81c285
! 	    for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		    continue;
Karsten Hopp 81c285
  		if (current_idx++ == idx)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 		    /* Connection number fits in one character since
Karsten Hopp 81c285
! 		     * CSCOPE_MAX_CONNECTIONS is < 10 */
Karsten Hopp 81c285
! 		    connection[0] = i + '0';
Karsten Hopp 81c285
! 		    connection[1] = NUL;
Karsten Hopp 81c285
! 		    return connection;
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
  	    return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
Karsten Hopp 81c285
--- 146,165 ----
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      case EXP_CSCOPE_KILL:
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    static char	connection[5];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* ":cscope kill" accepts connection numbers or partial names of
Karsten Hopp 81c285
  	     * the pathname of the cscope database as argument.  Only complete
Karsten Hopp 81c285
  	     * with connection numbers. -1 can also be used to kill all
Karsten Hopp 81c285
  	     * connections. */
Karsten Hopp 81c285
! 	    for (i = 0, current_idx = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		    continue;
Karsten Hopp 81c285
  		if (current_idx++ == idx)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 		    vim_snprintf(connection, sizeof(connection), "%d", i);
Karsten Hopp 81c285
! 		    return (char_u *)connection;
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
  	    return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 223,229 ****
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      cscmd_T *cmdp;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
-     cs_init();
Karsten Hopp 81c285
      if ((cmdp = cs_lookup_cmd(eap)) == NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	cs_help(eap);
Karsten Hopp 81c285
--- 222,227 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 284,291 ****
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int ret = FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
-     cs_init();
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
      if (*eap->arg == NUL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	(void)EMSG(_("E562: Usage: cstag <ident>"));
Karsten Hopp 81c285
--- 282,287 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 441,447 ****
Karsten Hopp 81c285
      if (num < 0 || num > 4 || (num > 0 && !dbpath))
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (!csinfo[i].fname)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
--- 437,443 ----
Karsten Hopp 81c285
      if (num < 0 || num > 4 || (num > 0 && !dbpath))
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (!csinfo[i].fname)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 684,690 ****
Karsten Hopp 81c285
      short i;
Karsten Hopp 81c285
      short cnt = 0;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[i].fname != NULL)
Karsten Hopp 81c285
  	    cnt++;
Karsten Hopp 81c285
--- 680,686 ----
Karsten Hopp 81c285
      short i;
Karsten Hopp 81c285
      short cnt = 0;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[i].fname != NULL)
Karsten Hopp 81c285
  	    cnt++;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1112,1118 ****
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int i;
Karsten Hopp 81c285
      char *cmd;
Karsten Hopp 81c285
!     int nummatches[CSCOPE_MAX_CONNECTIONS], totmatches;
Karsten Hopp 81c285
  #ifdef FEAT_QUICKFIX
Karsten Hopp 81c285
      char cmdletter;
Karsten Hopp 81c285
      char *qfpos;
Karsten Hopp 81c285
--- 1108,1115 ----
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int i;
Karsten Hopp 81c285
      char *cmd;
Karsten Hopp 81c285
!     int *nummatches;
Karsten Hopp 81c285
!     int totmatches;
Karsten Hopp 81c285
  #ifdef FEAT_QUICKFIX
Karsten Hopp 81c285
      char cmdletter;
Karsten Hopp 81c285
      char *qfpos;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1123,1135 ****
Karsten Hopp 81c285
      if (cmd == NULL)
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* send query to all open connections, then count the total number
Karsten Hopp 81c285
       * of matches so we can alloc matchesp all in one swell foop
Karsten Hopp 81c285
       */
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	nummatches[i] = 0;
Karsten Hopp 81c285
      totmatches = 0;
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
--- 1120,1136 ----
Karsten Hopp 81c285
      if (cmd == NULL)
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+     nummatches = (int *)alloc(sizeof(int)*csinfo_size);
Karsten Hopp 81c285
+     if (nummatches == NULL)
Karsten Hopp 81c285
+ 	return FALSE;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      /* send query to all open connections, then count the total number
Karsten Hopp 81c285
       * of matches so we can alloc matchesp all in one swell foop
Karsten Hopp 81c285
       */
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	nummatches[i] = 0;
Karsten Hopp 81c285
      totmatches = 0;
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1154,1160 ****
Karsten Hopp 81c285
--- 1155,1164 ----
Karsten Hopp 81c285
  	char *buf;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (!verbose)
Karsten Hopp 81c285
+ 	{
Karsten Hopp 81c285
+ 	    vim_free(nummatches);
Karsten Hopp 81c285
  	    return FALSE;
Karsten Hopp 81c285
+ 	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
Karsten Hopp 81c285
  	if (buf == NULL)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1165,1170 ****
Karsten Hopp 81c285
--- 1169,1175 ----
Karsten Hopp 81c285
  	    (void)EMSG(buf);
Karsten Hopp 81c285
  	    vim_free(buf);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
+ 	vim_free(nummatches);
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1217,1222 ****
Karsten Hopp 81c285
--- 1222,1228 ----
Karsten Hopp 81c285
  		(void)EMSG(buf);
Karsten Hopp 81c285
  		vim_free(buf);
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
+ 	    vim_free(nummatches);
Karsten Hopp 81c285
  	    return FALSE;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1264,1269 ****
Karsten Hopp 81c285
--- 1270,1276 ----
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  	mch_remove(tmp);
Karsten Hopp 81c285
  	vim_free(tmp);
Karsten Hopp 81c285
+ 	vim_free(nummatches);
Karsten Hopp 81c285
  	return TRUE;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1275,1280 ****
Karsten Hopp 81c285
--- 1282,1288 ----
Karsten Hopp 81c285
  	/* read output */
Karsten Hopp 81c285
  	cs_fill_results((char *)pat, totmatches, nummatches, &matches,
Karsten Hopp 81c285
  							 &contexts, &matched);
Karsten Hopp 81c285
+ 	vim_free(nummatches);
Karsten Hopp 81c285
  	if (matches == NULL)
Karsten Hopp 81c285
  	    return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1328,1353 ****
Karsten Hopp 81c285
  } /* cs_help */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
- /*
Karsten Hopp 81c285
-  * PRIVATE: cs_init
Karsten Hopp 81c285
-  *
Karsten Hopp 81c285
-  * initialize cscope structure if not already
Karsten Hopp 81c285
-  */
Karsten Hopp 81c285
-     static void
Karsten Hopp 81c285
- cs_init()
Karsten Hopp 81c285
- {
Karsten Hopp 81c285
-     short i;
Karsten Hopp 81c285
-     static int init_already = FALSE;
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
-     if (init_already)
Karsten Hopp 81c285
- 	return;
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
-     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
- 	clear_csinfo(i);
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
-     init_already = TRUE;
Karsten Hopp 81c285
- } /* cs_init */
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
  clear_csinfo(i)
Karsten Hopp 81c285
      int	    i;
Karsten Hopp 81c285
--- 1336,1341 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1444,1450 ****
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      i = -1; /* can be set to the index of an empty item in csinfo */
Karsten Hopp 81c285
!     for (j = 0; j < CSCOPE_MAX_CONNECTIONS; j++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[j].fname != NULL
Karsten Hopp 81c285
  #if defined(UNIX)
Karsten Hopp 81c285
--- 1432,1438 ----
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      i = -1; /* can be set to the index of an empty item in csinfo */
Karsten Hopp 81c285
!     for (j = 0; j < csinfo_size; j++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (csinfo[j].fname != NULL
Karsten Hopp 81c285
  #if defined(UNIX)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1471,1479 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (i == -1)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	if (p_csverbose)
Karsten Hopp 81c285
! 	    (void)EMSG(_("E569: maximum number of cscope connections reached"));
Karsten Hopp 81c285
! 	return -1;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
Karsten Hopp 81c285
--- 1459,1483 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (i == -1)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	i = csinfo_size;
Karsten Hopp 81c285
! 	if (csinfo_size == 0)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    /* First time allocation: allocate only 1 connection. It should
Karsten Hopp 81c285
! 	     * be enough for most users.  If more is needed, csinfo will be
Karsten Hopp 81c285
! 	     * reallocated. */
Karsten Hopp 81c285
! 	    csinfo_size = 1;
Karsten Hopp 81c285
! 	    csinfo = (csinfo_T *)alloc_clear(sizeof(csinfo_T));
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! 	else
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    /* Reallocate space for more connections. */
Karsten Hopp 81c285
! 	    csinfo_size *= 2;
Karsten Hopp 81c285
! 	    csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! 	if (csinfo == NULL)
Karsten Hopp 81c285
! 	    return -1;
Karsten Hopp 81c285
! 	for (j = csinfo_size/2; j < csinfo_size; j++)
Karsten Hopp 81c285
! 	    clear_csinfo(j);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1580,1594 ****
Karsten Hopp 81c285
  	/* It must be part of a name.  We will try to find a match
Karsten Hopp 81c285
  	 * within all the names in the csinfo data structure
Karsten Hopp 81c285
  	 */
Karsten Hopp 81c285
! 	for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
Karsten Hopp 81c285
  		break;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if ((i >= CSCOPE_MAX_CONNECTIONS || i < -1 || csinfo[i].fname == NULL)
Karsten Hopp 81c285
! 	    && i != -1)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (p_csverbose)
Karsten Hopp 81c285
  	    (void)EMSG2(_("E261: cscope connection %s not found"), stok);
Karsten Hopp 81c285
--- 1584,1597 ----
Karsten Hopp 81c285
  	/* It must be part of a name.  We will try to find a match
Karsten Hopp 81c285
  	 * within all the names in the csinfo data structure
Karsten Hopp 81c285
  	 */
Karsten Hopp 81c285
! 	for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
Karsten Hopp 81c285
  		break;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL))
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (p_csverbose)
Karsten Hopp 81c285
  	    (void)EMSG2(_("E261: cscope connection %s not found"), stok);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1597,1603 ****
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (i == -1)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname)
Karsten Hopp 81c285
  		    cs_kill_execute(i, csinfo[i].fname);
Karsten Hopp 81c285
--- 1600,1606 ----
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (i == -1)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		if (csinfo[i].fname)
Karsten Hopp 81c285
  		    cs_kill_execute(i, csinfo[i].fname);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1857,1863 ****
Karsten Hopp 81c285
      if (buf == NULL)
Karsten Hopp 81c285
  	return;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (nummatches_a[i] < 1)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
--- 1860,1866 ----
Karsten Hopp 81c285
      if (buf == NULL)
Karsten Hopp 81c285
  	return;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (nummatches_a[i] < 1)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1929,1935 ****
Karsten Hopp 81c285
      if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
Karsten Hopp 81c285
  	goto parse_out;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (nummatches_a[i] < 1)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
--- 1932,1938 ----
Karsten Hopp 81c285
      if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
Karsten Hopp 81c285
  	goto parse_out;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (nummatches_a[i] < 1)
Karsten Hopp 81c285
  	    continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2383,2392 ****
Karsten Hopp 81c285
      int	i;
Karsten Hopp 81c285
      char buf[20]; /* for sprintf " (#%d)" */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* malloc our db and ppath list */
Karsten Hopp 81c285
!     dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
Karsten Hopp 81c285
!     pplist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
Karsten Hopp 81c285
!     fllist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
Karsten Hopp 81c285
      if (dblist == NULL || pplist == NULL || fllist == NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	vim_free(dblist);
Karsten Hopp 81c285
--- 2386,2398 ----
Karsten Hopp 81c285
      int	i;
Karsten Hopp 81c285
      char buf[20]; /* for sprintf " (#%d)" */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+     if (csinfo_size == 0)
Karsten Hopp 81c285
+ 	return CSCOPE_SUCCESS;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      /* malloc our db and ppath list */
Karsten Hopp 81c285
!     dblist = (char **)alloc(csinfo_size * sizeof(char *));
Karsten Hopp 81c285
!     pplist = (char **)alloc(csinfo_size * sizeof(char *));
Karsten Hopp 81c285
!     fllist = (char **)alloc(csinfo_size * sizeof(char *));
Karsten Hopp 81c285
      if (dblist == NULL || pplist == NULL || fllist == NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	vim_free(dblist);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2395,2401 ****
Karsten Hopp 81c285
  	return CSCOPE_FAILURE;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	dblist[i] = csinfo[i].fname;
Karsten Hopp 81c285
  	pplist[i] = csinfo[i].ppath;
Karsten Hopp 81c285
--- 2401,2407 ----
Karsten Hopp 81c285
  	return CSCOPE_FAILURE;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	dblist[i] = csinfo[i].fname;
Karsten Hopp 81c285
  	pplist[i] = csinfo[i].ppath;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2405,2411 ****
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* rebuild the cscope connection list */
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (dblist[i] != NULL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
--- 2411,2417 ----
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* rebuild the cscope connection list */
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (dblist[i] != NULL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2502,2508 ****
Karsten Hopp 81c285
  	MSG_PUTS_ATTR(
Karsten Hopp 81c285
  	    _(" # pid    database name                       prepend path\n"),
Karsten Hopp 81c285
  	    hl_attr(HLF_T));
Karsten Hopp 81c285
! 	for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		continue;
Karsten Hopp 81c285
--- 2508,2514 ----
Karsten Hopp 81c285
  	MSG_PUTS_ATTR(
Karsten Hopp 81c285
  	    _(" # pid    database name                       prepend path\n"),
Karsten Hopp 81c285
  	    hl_attr(HLF_T));
Karsten Hopp 81c285
! 	for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  	    if (csinfo[i].fname == NULL)
Karsten Hopp 81c285
  		continue;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2531,2538 ****
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int i;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
Karsten Hopp 81c285
  	cs_release_csp(i, TRUE);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif	/* FEAT_CSCOPE */
Karsten Hopp 81c285
--- 2537,2546 ----
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int i;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     for (i = 0; i < csinfo_size; i++)
Karsten Hopp 81c285
  	cs_release_csp(i, TRUE);
Karsten Hopp 81c285
+     vim_free(csinfo);
Karsten Hopp 81c285
+     csinfo_size = 0;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif	/* FEAT_CSCOPE */
Karsten Hopp 81c285
*** ../vim-7.2.227/src/version.c	2009-07-09 20:13:59.000000000 +0200
Karsten Hopp 81c285
--- src/version.c	2009-07-09 21:21:48.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     228,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 81c285
84. Books in your bookcase bear the names Bongo, WinSock and Inside OLE
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///