4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: The tags listed for cscope are in the wrong order. (Johannes
13 Solution: Remove the reordering of tags for the current file. (Sergey
15 Files: src/if_cscope.c
18 *** ../vim-6.2.075/src/if_cscope.c Thu Jul 24 21:50:11 2003
19 --- src/if_cscope.c Wed Sep 10 21:35:19 2003
24 char *fname, *lno, *extra, *tbuf;
26 ! char_u *in_cur_file;
27 char *globalcntx = "GLOBAL";
28 char *cntxformat = " <<%s>>";
33 char *fname, *lno, *extra, *tbuf;
35 char *globalcntx = "GLOBAL";
36 char *cntxformat = " <<%s>>";
40 msg_advance(msg_col + 2);
41 MSG_PUTS_ATTR(_("filename / context / line\n"), hl_attr(HLF_T));
44 ! * for normal tags (non-cscope tags), vim sorts the tags before printing.
45 ! * hence, the output from 'matches' needs to be sorted as well (but we're
46 ! * not actually sorting the contents of 'matches'). for sorting, we simply
47 ! * print all tags in the current file before any other tags. this idea
48 ! * was suggested by Jeffrey George <jgeorge@texas.net>
50 ! in_cur_file = alloc_clear(num_matches);
51 ! if (in_cur_file != NULL)
53 ! if (curbuf->b_fname != NULL)
56 ! int fname_len, ffname_len;
58 ! fname_len = strlen((const char *)(curbuf->b_fname));
59 ! ffname_len = strlen((const char *)(curbuf->b_ffname));
61 ! for (i = 0; i < num_matches; i++)
63 ! if ((f = strchr(matches[i], '\t')) != NULL)
66 ! if (strncmp((const char *)(curbuf->b_fname), f, fname_len)
68 ! || strncmp((const char *)(curbuf->b_ffname), f,
70 ! in_cur_file[i] = TRUE;
77 ! * if we were able to allocate 'in_cur_file', then we make two passes
78 ! * through 'matches'. the first pass prints the tags in the current file,
79 ! * while the second prints all remaining tags. if we were unable to
80 ! * allocate 'in_cur_file', we'll just make one pass through 'matches' and
81 ! * print them unsorted.
84 ! for (j = (in_cur_file) ? 2 : 1; j > 0; j--)
86 ! for (i = 0; i < num_matches; i++)
90 ! if (((j == 2) && (in_cur_file[i] == TRUE))
91 ! || ((j == 1) && (in_cur_file[i] == FALSE)))
99 ! /* if we really wanted to, we could avoid this malloc and strcpy
100 ! * by parsing matches[i] on the fly and placing stuff into buf
101 ! * directly, but that's too much of a hassle
103 ! if ((tbuf = (char *)alloc(strlen(matches[idx]) + 1)) == NULL)
105 ! (void)strcpy(tbuf, matches[idx]);
107 ! if ((fname = strtok(tbuf, (const char *)"\t")) == NULL)
109 ! if ((fname = strtok(NULL, (const char *)"\t")) == NULL)
111 ! if ((lno = strtok(NULL, (const char *)"\t")) == NULL)
113 ! /* if NULL, then no "extra", although in cscope's case, there
114 ! * should always be "extra".
119 ! extra = lno + strlen(lno) + 1;
121 ! lno[strlen(lno)-2] = '\0'; /* ignore ;" at the end */
123 ! /* hopefully 'num' (num of matches) will be less than 10^16 */
124 ! newsize = strlen(csfmt_str) + 16 + strlen(lno);
125 ! if (bufsize < newsize)
127 ! buf = (char *)vim_realloc(buf, newsize);
135 ! /* csfmt_str = "%4d %6s "; */
136 ! (void)sprintf(buf, csfmt_str, num, lno);
137 ! MSG_PUTS_ATTR(buf, hl_attr(HLF_CM));
139 ! MSG_PUTS_LONG_ATTR(cs_pathcomponents(fname), hl_attr(HLF_CM));
141 ! /* compute the required space for the context */
142 ! if (cntxts[idx] != NULL)
143 ! context = cntxts[idx];
145 ! context = globalcntx;
146 ! newsize = strlen(context) + strlen(cntxformat);
148 ! if (bufsize < newsize)
150 ! buf = (char *)vim_realloc(buf, newsize);
158 ! (void)sprintf(buf, cntxformat, context);
160 ! /* print the context only if it fits on the same line */
161 ! if (msg_col + (int)strlen(buf) >= (int)Columns)
164 ! MSG_PUTS_LONG(buf);
170 ! MSG_PUTS_LONG(extra);
173 ! vim_free(tbuf); /* only after printing extra due to strtok use */
181 ! got_int = FALSE; /* don't print any more matches */
187 ! } /* for all matches */
188 ! } /* 1 or 2 passes through 'matches' */
190 - vim_free(in_cur_file);
192 } /* cs_print_tags_priv */
195 msg_advance(msg_col + 2);
196 MSG_PUTS_ATTR(_("filename / context / line\n"), hl_attr(HLF_T));
199 ! for (i = 0; i < num_matches; i++)
203 ! /* if we really wanted to, we could avoid this malloc and strcpy
204 ! * by parsing matches[i] on the fly and placing stuff into buf
205 ! * directly, but that's too much of a hassle
207 ! if ((tbuf = (char *)alloc(strlen(matches[idx]) + 1)) == NULL)
209 ! (void)strcpy(tbuf, matches[idx]);
211 ! if ((fname = strtok(tbuf, (const char *)"\t")) == NULL)
213 ! if ((fname = strtok(NULL, (const char *)"\t")) == NULL)
215 ! if ((lno = strtok(NULL, (const char *)"\t")) == NULL)
217 ! /* if NULL, then no "extra", although in cscope's case, there
218 ! * should always be "extra".
223 ! extra = lno + strlen(lno) + 1;
225 ! lno[strlen(lno)-2] = '\0'; /* ignore ;" at the end */
227 ! /* hopefully 'num' (num of matches) will be less than 10^16 */
228 ! newsize = strlen(csfmt_str) + 16 + strlen(lno);
229 ! if (bufsize < newsize)
231 ! buf = (char *)vim_realloc(buf, newsize);
239 ! /* csfmt_str = "%4d %6s "; */
240 ! (void)sprintf(buf, csfmt_str, num, lno);
241 ! MSG_PUTS_ATTR(buf, hl_attr(HLF_CM));
243 ! MSG_PUTS_LONG_ATTR(cs_pathcomponents(fname), hl_attr(HLF_CM));
245 ! /* compute the required space for the context */
246 ! if (cntxts[idx] != NULL)
247 ! context = cntxts[idx];
249 ! context = globalcntx;
250 ! newsize = strlen(context) + strlen(cntxformat);
252 ! if (bufsize < newsize)
254 ! buf = (char *)vim_realloc(buf, newsize);
262 ! (void)sprintf(buf, cntxformat, context);
264 ! /* print the context only if it fits on the same line */
265 ! if (msg_col + (int)strlen(buf) >= (int)Columns)
268 ! MSG_PUTS_LONG(buf);
274 ! MSG_PUTS_LONG(extra);
277 ! vim_free(tbuf); /* only after printing extra due to strtok use */
285 ! got_int = FALSE; /* don't print any more matches */
290 ! } /* for all matches */
293 } /* cs_print_tags_priv */
295 *** ../vim-6.2.075/src/version.c Tue Sep 9 22:48:37 2003
296 --- src/version.c Wed Sep 10 21:32:47 2003
300 { /* Add new patch number below this line */
306 ARTHUR: But if he was dying, he wouldn't bother to carve
307 "Aaaaarrrrrrggghhh". He'd just say it.
308 BROTHER MAYNARD: It's down there carved in stone.
309 GALAHAD: Perhaps he was dictating.
310 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
312 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
313 /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
314 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
315 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///