1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Can't always find the file when using cscope.
12 Solution: Add the 'cscoperelative' option. (Raghavendra D Prabhu)
13 Files: runtime/doc/if_cscop.txt, runtime/doc/options.txt,
14 src/if_cscope.c, src/options.c, src/options.h
17 *** ../mercurial/vim73/runtime/doc/if_cscop.txt 2010-09-30 21:38:08.000000000 +0200
18 --- runtime/doc/if_cscop.txt 2011-06-12 19:54:26.000000000 +0200
25 + *cscoperelative* *csre*
26 + If 'cscoperelative' set, then in absence of a prefix given to cscope (prefx
27 + is the argument to -P option of cscope), basename of cscope.out location
28 + (usually the project root directory) will be used as the prefix to construt
29 + absolute path.The default is off. Note: This option is only effective when
30 + cscope (cscopeprg) is initialized without a prefix path (-P). Examples: >
34 *cscopetagorder* *csto*
35 The value of 'csto' determines the order in which |:cstag| performs a search.
36 If 'csto' is set to zero, cscope database(s) are searched first, followed
37 *** ../mercurial/vim73/runtime/doc/options.txt 2011-05-19 12:22:41.000000000 +0200
38 --- runtime/doc/options.txt 2011-06-12 20:00:10.000000000 +0200
42 Specifies whether to use quickfix window to show cscope results.
45 + *'cscoperelative'* *'csre'*
46 + 'cscoperelative' 'csre' boolean (default off)
48 + {not available when compiled without the |+cscope|
51 + In the absence of a prefix (-P) for cscope. setting this option enables
52 + to use the basename of cscope.out path as the prefix.
53 + See |cscoperelative|.
55 *'cscopetag'* *'cst'* *'nocscopetag'* *'nocst'*
56 'cscopetag' 'cst' boolean (default off)
58 *** ../mercurial/vim73/src/if_cscope.c 2011-05-05 16:41:19.000000000 +0200
59 --- src/if_cscope.c 2011-06-12 20:25:17.000000000 +0200
64 cs_resolve_file(i, name)
72 ! * ppath is freed when we destroy the cscope connection.
73 ! * fullname is freed after cs_make_vim_style_matches, after it's been
74 ! * copied into the tag buffer used by vim
76 len = (int)(strlen(name) + 2);
77 if (csinfo[i].ppath != NULL)
78 len += (int)strlen(csinfo[i].ppath);
80 if ((fullname = (char *)alloc(len)) == NULL)
84 ! * note/example: this won't work if the cscope output already starts
85 * "../.." and the prefix path is also "../..". if something like this
86 ! * happens, you are screwed up and need to fix how you're using cscope.
88 ! if (csinfo[i].ppath != NULL &&
89 ! (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) &&
92 ! && name[0] != '\\' && name[1] != ':'
95 (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
97 (void)sprintf(fullname, "%s", name);
100 ! } /* cs_resolve_file */
107 cs_resolve_file(i, name)
113 ! char_u *csdir = NULL;
116 ! * Ppath is freed when we destroy the cscope connection.
117 ! * Fullname is freed after cs_make_vim_style_matches, after it's been
118 ! * copied into the tag buffer used by Vim.
120 len = (int)(strlen(name) + 2);
121 if (csinfo[i].ppath != NULL)
122 len += (int)strlen(csinfo[i].ppath);
123 + else if (p_csre && csinfo[i].fname != NULL)
125 + /* If 'cscoperelative' is set and ppath is not set, use cscope.out
126 + * path in path resolution. */
127 + csdir = alloc(MAXPATHL);
130 + vim_strncpy(csdir, (char_u *)csinfo[i].fname,
131 + gettail((char_u *)csinfo[i].fname) - 1 - (char_u *)csinfo[i].fname);
132 + len += (int)STRLEN(csdir);
136 if ((fullname = (char *)alloc(len)) == NULL)
139 ! /* Note/example: this won't work if the cscope output already starts
140 * "../.." and the prefix path is also "../..". if something like this
141 ! * happens, you are screwed up and need to fix how you're using cscope. */
142 ! if (csinfo[i].ppath != NULL
143 ! && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
144 ! && (name[0] != '/')
146 ! && name[0] != '\\' && name[1] != ':'
149 (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name);
150 + else if (csdir != NULL && csinfo[i].fname != NULL && STRLEN(csdir) > 0)
152 + /* Check for csdir to be non empty to avoid empty path concatenated to
153 + * cscope output. TODO: avoid the unnecessary alloc/free of fullname. */
154 + vim_free(fullname);
155 + fullname = concat_fnames(csdir, (char_u *)name, TRUE);
158 (void)sprintf(fullname, "%s", name);
166 *** ../vim-7.3.209/src/version.c 2011-06-12 20:36:00.000000000 +0200
167 --- src/version.c 2011-06-12 20:37:48.000000000 +0200
171 { /* Add new patch number below this line */
177 Apathy Error: Don't bother striking any key.
179 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
180 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
181 \\\ an exciting new programming language -- http://www.Zimbu.org ///
182 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///