4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Cscope is limited to 8 connections.
12 Solution: Allocated the connection array to handle any number of
13 connections. (Dominique Pelle)
14 Files: runtime/doc/if_cscop.txt, src/if_cscope.h, src/if_cscope.c
17 *** ../vim-7.2.227/runtime/doc/if_cscop.txt 2009-03-18 14:30:46.000000000 +0100
18 --- runtime/doc/if_cscop.txt 2009-07-09 15:40:48.000000000 +0200
21 The DJGPP-built version from http://cscope.sourceforge.net is known to not
24 ! There are a couple of hard-coded limitations:
26 ! 1. The maximum number of cscope connections allowed is 8. Do you
29 ! 2. Doing a |:tjump| when |:cstag| searches the tag files is not
30 ! configurable (e.g., you can't do a tselect instead).
32 ==============================================================================
33 6. Suggested usage *cscope-suggestions*
35 The DJGPP-built version from http://cscope.sourceforge.net is known to not
38 ! Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files
39 ! is not configurable (e.g., you can't do a tselect instead).
41 ==============================================================================
42 6. Suggested usage *cscope-suggestions*
43 *** ../vim-7.2.227/src/if_cscope.h 2008-08-25 04:35:13.000000000 +0200
44 --- src/if_cscope.h 2009-07-09 15:39:32.000000000 +0200
48 #define CSCOPE_SUCCESS 0
49 #define CSCOPE_FAILURE -1
50 - #define CSCOPE_MAX_CONNECTIONS 8 /* you actually need more? */
52 #define CSCOPE_DBFILE "cscope.out"
53 #define CSCOPE_PROMPT ">> "
55 *** ../vim-7.2.227/src/if_cscope.c 2009-05-16 17:29:37.000000000 +0200
56 --- src/if_cscope.c 2009-07-09 15:39:32.000000000 +0200
59 static int cs_find __ARGS((exarg_T *eap));
60 static int cs_find_common __ARGS((char *opt, char *pat, int, int, int));
61 static int cs_help __ARGS((exarg_T *eap));
62 - static void cs_init __ARGS((void));
63 static void clear_csinfo __ARGS((int i));
64 static int cs_insert_filelist __ARGS((char *, char *, char *,
69 static int cs_show __ARGS((exarg_T *eap));
72 ! static csinfo_T csinfo[CSCOPE_MAX_CONNECTIONS];
73 static int eap_arg_len; /* length of eap->arg, set in
75 static cscmd_T cs_cmds[] =
77 static int cs_show __ARGS((exarg_T *eap));
80 ! static csinfo_T * csinfo = NULL;
81 ! static int csinfo_size = 0; /* number of items allocated in
84 static int eap_arg_len; /* length of eap->arg, set in
86 static cscmd_T cs_cmds[] =
92 ! static char_u connection[2];
94 /* ":cscope kill" accepts connection numbers or partial names of
95 * the pathname of the cscope database as argument. Only complete
96 * with connection numbers. -1 can also be used to kill all
98 ! for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
100 if (csinfo[i].fname == NULL)
102 if (current_idx++ == idx)
104 ! /* Connection number fits in one character since
105 ! * CSCOPE_MAX_CONNECTIONS is < 10 */
106 ! connection[0] = i + '0';
107 ! connection[1] = NUL;
111 return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
114 case EXP_CSCOPE_KILL:
116 ! static char connection[5];
118 /* ":cscope kill" accepts connection numbers or partial names of
119 * the pathname of the cscope database as argument. Only complete
120 * with connection numbers. -1 can also be used to kill all
122 ! for (i = 0, current_idx = 0; i < csinfo_size; i++)
124 if (csinfo[i].fname == NULL)
126 if (current_idx++ == idx)
128 ! vim_snprintf(connection, sizeof(connection), "%d", i);
129 ! return (char_u *)connection;
132 return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
139 if ((cmdp = cs_lookup_cmd(eap)) == NULL)
150 if (*eap->arg == NUL)
152 (void)EMSG(_("E562: Usage: cstag <ident>"));
156 if (num < 0 || num > 4 || (num > 0 && !dbpath))
159 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
161 if (!csinfo[i].fname)
164 if (num < 0 || num > 4 || (num > 0 && !dbpath))
167 ! for (i = 0; i < csinfo_size; i++)
169 if (!csinfo[i].fname)
176 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
178 if (csinfo[i].fname != NULL)
184 ! for (i = 0; i < csinfo_size; i++)
186 if (csinfo[i].fname != NULL)
193 ! int nummatches[CSCOPE_MAX_CONNECTIONS], totmatches;
211 /* send query to all open connections, then count the total number
212 * of matches so we can alloc matchesp all in one swell foop
214 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
217 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
219 if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
225 + nummatches = (int *)alloc(sizeof(int)*csinfo_size);
226 + if (nummatches == NULL)
229 /* send query to all open connections, then count the total number
230 * of matches so we can alloc matchesp all in one swell foop
232 ! for (i = 0; i < csinfo_size; i++)
235 ! for (i = 0; i < csinfo_size; i++)
237 if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
246 + vim_free(nummatches);
250 buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
258 + vim_free(nummatches);
268 + vim_free(nummatches);
278 + vim_free(nummatches);
286 cs_fill_results((char *)pat, totmatches, nummatches, &matches,
287 &contexts, &matched);
288 + vim_free(nummatches);
300 - * initialize cscope structure if not already
306 - static int init_already = FALSE;
311 - for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
314 - init_already = TRUE;
325 i = -1; /* can be set to the index of an empty item in csinfo */
326 ! for (j = 0; j < CSCOPE_MAX_CONNECTIONS; j++)
328 if (csinfo[j].fname != NULL
333 i = -1; /* can be set to the index of an empty item in csinfo */
334 ! for (j = 0; j < csinfo_size; j++)
336 if (csinfo[j].fname != NULL
344 ! (void)EMSG(_("E569: maximum number of cscope connections reached"));
348 if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
354 ! if (csinfo_size == 0)
356 ! /* First time allocation: allocate only 1 connection. It should
357 ! * be enough for most users. If more is needed, csinfo will be
360 ! csinfo = (csinfo_T *)alloc_clear(sizeof(csinfo_T));
364 ! /* Reallocate space for more connections. */
366 ! csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
368 ! if (csinfo == NULL)
370 ! for (j = csinfo_size/2; j < csinfo_size; j++)
374 if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
377 /* It must be part of a name. We will try to find a match
378 * within all the names in the csinfo data structure
380 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
382 if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
387 ! if ((i >= CSCOPE_MAX_CONNECTIONS || i < -1 || csinfo[i].fname == NULL)
391 (void)EMSG2(_("E261: cscope connection %s not found"), stok);
393 /* It must be part of a name. We will try to find a match
394 * within all the names in the csinfo data structure
396 ! for (i = 0; i < csinfo_size; i++)
398 if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
403 ! if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL))
406 (void)EMSG2(_("E261: cscope connection %s not found"), stok);
412 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
415 cs_kill_execute(i, csinfo[i].fname);
420 ! for (i = 0; i < csinfo_size; i++)
423 cs_kill_execute(i, csinfo[i].fname);
429 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
431 if (nummatches_a[i] < 1)
437 ! for (i = 0; i < csinfo_size; i++)
439 if (nummatches_a[i] < 1)
443 if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
446 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
448 if (nummatches_a[i] < 1)
451 if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
454 ! for (i = 0; i < csinfo_size; i++)
456 if (nummatches_a[i] < 1)
461 char buf[20]; /* for sprintf " (#%d)" */
463 /* malloc our db and ppath list */
464 ! dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
465 ! pplist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
466 ! fllist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
467 if (dblist == NULL || pplist == NULL || fllist == NULL)
472 char buf[20]; /* for sprintf " (#%d)" */
474 + if (csinfo_size == 0)
475 + return CSCOPE_SUCCESS;
477 /* malloc our db and ppath list */
478 ! dblist = (char **)alloc(csinfo_size * sizeof(char *));
479 ! pplist = (char **)alloc(csinfo_size * sizeof(char *));
480 ! fllist = (char **)alloc(csinfo_size * sizeof(char *));
481 if (dblist == NULL || pplist == NULL || fllist == NULL)
486 return CSCOPE_FAILURE;
489 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
491 dblist[i] = csinfo[i].fname;
492 pplist[i] = csinfo[i].ppath;
494 return CSCOPE_FAILURE;
497 ! for (i = 0; i < csinfo_size; i++)
499 dblist[i] = csinfo[i].fname;
500 pplist[i] = csinfo[i].ppath;
505 /* rebuild the cscope connection list */
506 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
508 if (dblist[i] != NULL)
513 /* rebuild the cscope connection list */
514 ! for (i = 0; i < csinfo_size; i++)
516 if (dblist[i] != NULL)
521 _(" # pid database name prepend path\n"),
523 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
525 if (csinfo[i].fname == NULL)
529 _(" # pid database name prepend path\n"),
531 ! for (i = 0; i < csinfo_size; i++)
533 if (csinfo[i].fname == NULL)
540 ! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
541 cs_release_csp(i, TRUE);
544 #endif /* FEAT_CSCOPE */
549 ! for (i = 0; i < csinfo_size; i++)
550 cs_release_csp(i, TRUE);
555 #endif /* FEAT_CSCOPE */
556 *** ../vim-7.2.227/src/version.c 2009-07-09 20:13:59.000000000 +0200
557 --- src/version.c 2009-07-09 21:21:48.000000000 +0200
561 { /* Add new patch number below this line */
567 hundred-and-one symptoms of being an internet addict:
568 84. Books in your bookcase bear the names Bongo, WinSock and Inside OLE
570 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
571 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
572 \\\ download, build and distribute -- http://www.A-A-P.org ///
573 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///