Karsten Hopp 642e85
To: vim_dev@googlegroups.com
Karsten Hopp 642e85
Subject: Patch 7.3.210
Karsten Hopp 642e85
Fcc: outbox
Karsten Hopp 642e85
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 642e85
Mime-Version: 1.0
Karsten Hopp 642e85
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 642e85
Content-Transfer-Encoding: 8bit
Karsten Hopp 642e85
------------
Karsten Hopp 642e85
Karsten Hopp 642e85
Patch 7.3.210
Karsten Hopp 642e85
Problem:    Can't always find the file when using cscope.
Karsten Hopp 642e85
Solution:   Add the 'cscoperelative' option. (Raghavendra D Prabhu)
Karsten Hopp 642e85
Files:      runtime/doc/if_cscop.txt, runtime/doc/options.txt,
Karsten Hopp 642e85
            src/if_cscope.c, src/options.c, src/options.h
Karsten Hopp 642e85
Karsten Hopp 642e85
Karsten Hopp 642e85
*** ../mercurial/vim73/runtime/doc/if_cscop.txt	2010-09-30 21:38:08.000000000 +0200
Karsten Hopp 642e85
--- runtime/doc/if_cscop.txt	2011-06-12 19:54:26.000000000 +0200
Karsten Hopp 642e85
***************
Karsten Hopp 642e85
*** 271,276 ****
Karsten Hopp 642e85
--- 271,285 ----
Karsten Hopp 642e85
  	:set cst
Karsten Hopp 642e85
  	:set nocst
Karsten Hopp 642e85
  <
Karsten Hopp 642e85
+ 							*cscoperelative* *csre*
Karsten Hopp 642e85
+ If 'cscoperelative' set, then in absence of a prefix given to cscope (prefx
Karsten Hopp 642e85
+ is the argument to -P option of cscope), basename of cscope.out location
Karsten Hopp 642e85
+ (usually the project root directory) will be used as the prefix to construt
Karsten Hopp 642e85
+ absolute path.The default is off. Note: This option is only effective when
Karsten Hopp 642e85
+ cscope (cscopeprg) is initialized without a prefix path (-P). Examples: >
Karsten Hopp 642e85
+ 	:set csre
Karsten Hopp 642e85
+ 	:set nocsre
Karsten Hopp 642e85
+ <
Karsten Hopp 642e85
  							*cscopetagorder* *csto*
Karsten Hopp 642e85
  The value of 'csto' determines the order in which |:cstag| performs a search.
Karsten Hopp 642e85
  If 'csto' is set to zero, cscope database(s) are searched first, followed
Karsten Hopp 642e85
*** ../mercurial/vim73/runtime/doc/options.txt	2011-05-19 12:22:41.000000000 +0200
Karsten Hopp 642e85
--- runtime/doc/options.txt	2011-06-12 20:00:10.000000000 +0200
Karsten Hopp 642e85
***************
Karsten Hopp 642e85
*** 2209,2214 ****
Karsten Hopp 642e85
--- 2209,2224 ----
Karsten Hopp 642e85
  	Specifies whether to use quickfix window to show cscope results.
Karsten Hopp 642e85
  	See |cscopequickfix|.
Karsten Hopp 642e85
  
Karsten Hopp 642e85
+ 						*'cscoperelative'* *'csre'*
Karsten Hopp 642e85
+ 'cscoperelative' 'csre' boolean (default off)
Karsten Hopp 642e85
+ 			global
Karsten Hopp 642e85
+ 			{not available when compiled without the |+cscope|
Karsten Hopp 642e85
+ 			feature}
Karsten Hopp 642e85
+ 			{not in Vi}
Karsten Hopp 642e85
+ 	In the absence of a prefix (-P) for cscope. setting this option enables
Karsten Hopp 642e85
+ 	to use the basename of cscope.out path as the prefix.
Karsten Hopp 642e85
+ 	See |cscoperelative|.
Karsten Hopp 642e85
+ 
Karsten Hopp 642e85
  				*'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'*
Karsten Hopp 642e85
  'cscopetag' 'cst'	boolean (default off)
Karsten Hopp 642e85
  			global
Karsten Hopp 642e85
*** ../mercurial/vim73/src/if_cscope.c	2011-05-05 16:41:19.000000000 +0200
Karsten Hopp 642e85
--- src/if_cscope.c	2011-06-12 20:25:17.000000000 +0200
Karsten Hopp 642e85
***************
Karsten Hopp 642e85
*** 2471,2512 ****
Karsten Hopp 642e85
   */
Karsten Hopp 642e85
      static char *
Karsten Hopp 642e85
  cs_resolve_file(i, name)
Karsten Hopp 642e85
!     int i;
Karsten Hopp 642e85
      char *name;
Karsten Hopp 642e85
  {
Karsten Hopp 642e85
!     char *fullname;
Karsten Hopp 642e85
!     int len;
Karsten Hopp 642e85
  
Karsten Hopp 642e85
      /*
Karsten Hopp 642e85
!      * ppath is freed when we destroy the cscope connection.
Karsten Hopp 642e85
!      * fullname is freed after cs_make_vim_style_matches, after it's been
Karsten Hopp 642e85
!      * copied into the tag buffer used by vim
Karsten Hopp 642e85
       */
Karsten Hopp 642e85
      len = (int)(strlen(name) + 2);
Karsten Hopp 642e85
      if (csinfo[i].ppath != NULL)
Karsten Hopp 642e85
  	len += (int)strlen(csinfo[i].ppath);
Karsten Hopp 642e85
  
Karsten Hopp 642e85
      if ((fullname = (char *)alloc(len)) == NULL)
Karsten Hopp 642e85
  	return NULL;
Karsten Hopp 642e85
  
Karsten Hopp 642e85
!     /*
Karsten Hopp 642e85
!      * note/example: this won't work if the cscope output already starts
Karsten Hopp 642e85
       * "../.." and the prefix path is also "../..".  if something like this
Karsten Hopp 642e85
!      * happens, you are screwed up and need to fix how you're using cscope.
Karsten Hopp 642e85
!      */
Karsten Hopp 642e85
!     if (csinfo[i].ppath != NULL &&
Karsten Hopp 642e85
! 	(strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) &&
Karsten Hopp 642e85
! 	(name[0] != '/')
Karsten Hopp 642e85
  #ifdef WIN32
Karsten Hopp 642e85
! 	&& name[0] != '\\' && name[1] != ':'
Karsten Hopp 642e85
  #endif
Karsten Hopp 642e85
! 	)
Karsten Hopp 642e85
  	(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
Karsten Hopp 642e85
      else
Karsten Hopp 642e85
  	(void)sprintf(fullname, "%s", name);
Karsten Hopp 642e85
  
Karsten Hopp 642e85
      return fullname;
Karsten Hopp 642e85
! } /* cs_resolve_file */
Karsten Hopp 642e85
  
Karsten Hopp 642e85
  
Karsten Hopp 642e85
  /*
Karsten Hopp 642e85
--- 2471,2531 ----
Karsten Hopp 642e85
   */
Karsten Hopp 642e85
      static char *
Karsten Hopp 642e85
  cs_resolve_file(i, name)
Karsten Hopp 642e85
!     int  i;
Karsten Hopp 642e85
      char *name;
Karsten Hopp 642e85
  {
Karsten Hopp 642e85
!     char	*fullname;
Karsten Hopp 642e85
!     int		len;
Karsten Hopp 642e85
!     char_u	*csdir = NULL;
Karsten Hopp 642e85
  
Karsten Hopp 642e85
      /*
Karsten Hopp 642e85
!      * Ppath is freed when we destroy the cscope connection.
Karsten Hopp 642e85
!      * Fullname is freed after cs_make_vim_style_matches, after it's been
Karsten Hopp 642e85
!      * copied into the tag buffer used by Vim.
Karsten Hopp 642e85
       */
Karsten Hopp 642e85
      len = (int)(strlen(name) + 2);
Karsten Hopp 642e85
      if (csinfo[i].ppath != NULL)
Karsten Hopp 642e85
  	len += (int)strlen(csinfo[i].ppath);
Karsten Hopp 642e85
+     else if (p_csre && csinfo[i].fname != NULL)
Karsten Hopp 642e85
+     {
Karsten Hopp 642e85
+ 	/* If 'cscoperelative' is set and ppath is not set, use cscope.out
Karsten Hopp 642e85
+ 	 * path in path resolution. */
Karsten Hopp 642e85
+ 	csdir = alloc(MAXPATHL);
Karsten Hopp 642e85
+ 	if (csdir != NULL)
Karsten Hopp 642e85
+ 	{
Karsten Hopp 642e85
+ 	    vim_strncpy(csdir, (char_u *)csinfo[i].fname,
Karsten Hopp 642e85
+ 		    gettail((char_u *)csinfo[i].fname) - 1 - (char_u *)csinfo[i].fname);
Karsten Hopp 642e85
+ 	    len += (int)STRLEN(csdir);
Karsten Hopp 642e85
+ 	}
Karsten Hopp 642e85
+     }
Karsten Hopp 642e85
  
Karsten Hopp 642e85
      if ((fullname = (char *)alloc(len)) == NULL)
Karsten Hopp 642e85
  	return NULL;
Karsten Hopp 642e85
  
Karsten Hopp 642e85
!     /* Note/example: this won't work if the cscope output already starts
Karsten Hopp 642e85
       * "../.." and the prefix path is also "../..".  if something like this
Karsten Hopp 642e85
!      * happens, you are screwed up and need to fix how you're using cscope. */
Karsten Hopp 642e85
!     if (csinfo[i].ppath != NULL
Karsten Hopp 642e85
! 	    && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
Karsten Hopp 642e85
! 	    && (name[0] != '/')
Karsten Hopp 642e85
  #ifdef WIN32
Karsten Hopp 642e85
! 	    && name[0] != '\\' && name[1] != ':'
Karsten Hopp 642e85
  #endif
Karsten Hopp 642e85
!        )
Karsten Hopp 642e85
  	(void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
Karsten Hopp 642e85
+     else if (csdir != NULL && csinfo[i].fname != NULL && STRLEN(csdir) > 0)
Karsten Hopp 642e85
+     {
Karsten Hopp 642e85
+ 	/* Check for csdir to be non empty to avoid empty path concatenated to
Karsten Hopp 642e85
+ 	 * cscope output. TODO: avoid the unnecessary alloc/free of fullname. */
Karsten Hopp 642e85
+ 	vim_free(fullname);
Karsten Hopp 642e85
+ 	fullname = concat_fnames(csdir, (char_u *)name, TRUE);
Karsten Hopp 642e85
+     }
Karsten Hopp 642e85
      else
Karsten Hopp 642e85
  	(void)sprintf(fullname, "%s", name);
Karsten Hopp 642e85
  
Karsten Hopp 642e85
+     vim_free(csdir);
Karsten Hopp 642e85
      return fullname;
Karsten Hopp 642e85
! }
Karsten Hopp 642e85
  
Karsten Hopp 642e85
  
Karsten Hopp 642e85
  /*
Karsten Hopp 642e85
*** ../vim-7.3.209/src/version.c	2011-06-12 20:36:00.000000000 +0200
Karsten Hopp 642e85
--- src/version.c	2011-06-12 20:37:48.000000000 +0200
Karsten Hopp 642e85
***************
Karsten Hopp 642e85
*** 711,712 ****
Karsten Hopp 642e85
--- 711,714 ----
Karsten Hopp 642e85
  {   /* Add new patch number below this line */
Karsten Hopp 642e85
+ /**/
Karsten Hopp 642e85
+     210,
Karsten Hopp 642e85
  /**/
Karsten Hopp 642e85
Karsten Hopp 642e85
-- 
Karsten Hopp 642e85
Apathy Error: Don't bother striking any key.
Karsten Hopp 642e85
Karsten Hopp 642e85
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 642e85
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 642e85
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 642e85
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///