mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.2-228
This commit is contained in:
@@ -355,13 +355,8 @@ cscope version for Win32 see:
|
|||||||
The DJGPP-built version from http://cscope.sourceforge.net is known to not
|
The DJGPP-built version from http://cscope.sourceforge.net is known to not
|
||||||
work with Vim.
|
work with Vim.
|
||||||
|
|
||||||
There are a couple of hard-coded limitations:
|
Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files
|
||||||
|
is not configurable (e.g., you can't do a tselect instead).
|
||||||
1. The maximum number of cscope connections allowed is 8. Do you
|
|
||||||
really need more?
|
|
||||||
|
|
||||||
2. Doing a |:tjump| when |:cstag| searches the tag files is not
|
|
||||||
configurable (e.g., you can't do a tselect instead).
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. Suggested usage *cscope-suggestions*
|
6. Suggested usage *cscope-suggestions*
|
||||||
|
114
src/if_cscope.c
114
src/if_cscope.c
@@ -46,7 +46,6 @@ static void cs_fill_results __ARGS((char *, int , int *, char ***,
|
|||||||
static int cs_find __ARGS((exarg_T *eap));
|
static int cs_find __ARGS((exarg_T *eap));
|
||||||
static int cs_find_common __ARGS((char *opt, char *pat, int, int, int));
|
static int cs_find_common __ARGS((char *opt, char *pat, int, int, int));
|
||||||
static int cs_help __ARGS((exarg_T *eap));
|
static int cs_help __ARGS((exarg_T *eap));
|
||||||
static void cs_init __ARGS((void));
|
|
||||||
static void clear_csinfo __ARGS((int i));
|
static void clear_csinfo __ARGS((int i));
|
||||||
static int cs_insert_filelist __ARGS((char *, char *, char *,
|
static int cs_insert_filelist __ARGS((char *, char *, char *,
|
||||||
struct stat *));
|
struct stat *));
|
||||||
@@ -66,7 +65,10 @@ static char * cs_resolve_file __ARGS((int, char *));
|
|||||||
static int cs_show __ARGS((exarg_T *eap));
|
static int cs_show __ARGS((exarg_T *eap));
|
||||||
|
|
||||||
|
|
||||||
static csinfo_T csinfo[CSCOPE_MAX_CONNECTIONS];
|
static csinfo_T * csinfo = NULL;
|
||||||
|
static int csinfo_size = 0; /* number of items allocated in
|
||||||
|
csinfo[] */
|
||||||
|
|
||||||
static int eap_arg_len; /* length of eap->arg, set in
|
static int eap_arg_len; /* length of eap->arg, set in
|
||||||
cs_lookup_cmd() */
|
cs_lookup_cmd() */
|
||||||
static cscmd_T cs_cmds[] =
|
static cscmd_T cs_cmds[] =
|
||||||
@@ -144,23 +146,20 @@ get_cscope_name(xp, idx)
|
|||||||
}
|
}
|
||||||
case EXP_CSCOPE_KILL:
|
case EXP_CSCOPE_KILL:
|
||||||
{
|
{
|
||||||
static char_u connection[2];
|
static char connection[5];
|
||||||
|
|
||||||
/* ":cscope kill" accepts connection numbers or partial names of
|
/* ":cscope kill" accepts connection numbers or partial names of
|
||||||
* the pathname of the cscope database as argument. Only complete
|
* the pathname of the cscope database as argument. Only complete
|
||||||
* with connection numbers. -1 can also be used to kill all
|
* with connection numbers. -1 can also be used to kill all
|
||||||
* connections. */
|
* connections. */
|
||||||
for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0, current_idx = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname == NULL)
|
if (csinfo[i].fname == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (current_idx++ == idx)
|
if (current_idx++ == idx)
|
||||||
{
|
{
|
||||||
/* Connection number fits in one character since
|
vim_snprintf(connection, sizeof(connection), "%d", i);
|
||||||
* CSCOPE_MAX_CONNECTIONS is < 10 */
|
return (char_u *)connection;
|
||||||
connection[0] = i + '0';
|
|
||||||
connection[1] = NUL;
|
|
||||||
return connection;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
|
return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
|
||||||
@@ -223,7 +222,6 @@ do_cscope_general(eap, make_split)
|
|||||||
{
|
{
|
||||||
cscmd_T *cmdp;
|
cscmd_T *cmdp;
|
||||||
|
|
||||||
cs_init();
|
|
||||||
if ((cmdp = cs_lookup_cmd(eap)) == NULL)
|
if ((cmdp = cs_lookup_cmd(eap)) == NULL)
|
||||||
{
|
{
|
||||||
cs_help(eap);
|
cs_help(eap);
|
||||||
@@ -284,8 +282,6 @@ do_cstag(eap)
|
|||||||
{
|
{
|
||||||
int ret = FALSE;
|
int ret = FALSE;
|
||||||
|
|
||||||
cs_init();
|
|
||||||
|
|
||||||
if (*eap->arg == NUL)
|
if (*eap->arg == NUL)
|
||||||
{
|
{
|
||||||
(void)EMSG(_("E562: Usage: cstag <ident>"));
|
(void)EMSG(_("E562: Usage: cstag <ident>"));
|
||||||
@@ -441,7 +437,7 @@ cs_connection(num, dbpath, ppath)
|
|||||||
if (num < 0 || num > 4 || (num > 0 && !dbpath))
|
if (num < 0 || num > 4 || (num > 0 && !dbpath))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (!csinfo[i].fname)
|
if (!csinfo[i].fname)
|
||||||
continue;
|
continue;
|
||||||
@@ -684,7 +680,7 @@ cs_cnt_connections()
|
|||||||
short i;
|
short i;
|
||||||
short cnt = 0;
|
short cnt = 0;
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname != NULL)
|
if (csinfo[i].fname != NULL)
|
||||||
cnt++;
|
cnt++;
|
||||||
@@ -1112,7 +1108,8 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
int nummatches[CSCOPE_MAX_CONNECTIONS], totmatches;
|
int *nummatches;
|
||||||
|
int totmatches;
|
||||||
#ifdef FEAT_QUICKFIX
|
#ifdef FEAT_QUICKFIX
|
||||||
char cmdletter;
|
char cmdletter;
|
||||||
char *qfpos;
|
char *qfpos;
|
||||||
@@ -1123,13 +1120,17 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
nummatches = (int *)alloc(sizeof(int)*csinfo_size);
|
||||||
|
if (nummatches == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
/* send query to all open connections, then count the total number
|
/* send query to all open connections, then count the total number
|
||||||
* of matches so we can alloc matchesp all in one swell foop
|
* of matches so we can alloc matchesp all in one swell foop
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
nummatches[i] = 0;
|
nummatches[i] = 0;
|
||||||
totmatches = 0;
|
totmatches = 0;
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
|
if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -1154,7 +1155,10 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
|
{
|
||||||
|
vim_free(nummatches);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
|
buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
@@ -1165,6 +1169,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
(void)EMSG(buf);
|
(void)EMSG(buf);
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
}
|
}
|
||||||
|
vim_free(nummatches);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,6 +1222,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
(void)EMSG(buf);
|
(void)EMSG(buf);
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
}
|
}
|
||||||
|
vim_free(nummatches);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1264,6 +1270,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
}
|
}
|
||||||
mch_remove(tmp);
|
mch_remove(tmp);
|
||||||
vim_free(tmp);
|
vim_free(tmp);
|
||||||
|
vim_free(nummatches);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1275,6 +1282,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
|
|||||||
/* read output */
|
/* read output */
|
||||||
cs_fill_results((char *)pat, totmatches, nummatches, &matches,
|
cs_fill_results((char *)pat, totmatches, nummatches, &matches,
|
||||||
&contexts, &matched);
|
&contexts, &matched);
|
||||||
|
vim_free(nummatches);
|
||||||
if (matches == NULL)
|
if (matches == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -1328,26 +1336,6 @@ cs_help(eap)
|
|||||||
} /* cs_help */
|
} /* cs_help */
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PRIVATE: cs_init
|
|
||||||
*
|
|
||||||
* initialize cscope structure if not already
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
cs_init()
|
|
||||||
{
|
|
||||||
short i;
|
|
||||||
static int init_already = FALSE;
|
|
||||||
|
|
||||||
if (init_already)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
|
||||||
clear_csinfo(i);
|
|
||||||
|
|
||||||
init_already = TRUE;
|
|
||||||
} /* cs_init */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_csinfo(i)
|
clear_csinfo(i)
|
||||||
int i;
|
int i;
|
||||||
@@ -1444,7 +1432,7 @@ cs_insert_filelist(fname, ppath, flags, sb)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
i = -1; /* can be set to the index of an empty item in csinfo */
|
i = -1; /* can be set to the index of an empty item in csinfo */
|
||||||
for (j = 0; j < CSCOPE_MAX_CONNECTIONS; j++)
|
for (j = 0; j < csinfo_size; j++)
|
||||||
{
|
{
|
||||||
if (csinfo[j].fname != NULL
|
if (csinfo[j].fname != NULL
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
@@ -1471,9 +1459,25 @@ cs_insert_filelist(fname, ppath, flags, sb)
|
|||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
if (p_csverbose)
|
i = csinfo_size;
|
||||||
(void)EMSG(_("E569: maximum number of cscope connections reached"));
|
if (csinfo_size == 0)
|
||||||
|
{
|
||||||
|
/* First time allocation: allocate only 1 connection. It should
|
||||||
|
* be enough for most users. If more is needed, csinfo will be
|
||||||
|
* reallocated. */
|
||||||
|
csinfo_size = 1;
|
||||||
|
csinfo = (csinfo_T *)alloc_clear(sizeof(csinfo_T));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Reallocate space for more connections. */
|
||||||
|
csinfo_size *= 2;
|
||||||
|
csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
|
||||||
|
}
|
||||||
|
if (csinfo == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
for (j = csinfo_size/2; j < csinfo_size; j++)
|
||||||
|
clear_csinfo(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
|
if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
|
||||||
@@ -1580,15 +1584,14 @@ cs_kill(eap)
|
|||||||
/* It must be part of a name. We will try to find a match
|
/* It must be part of a name. We will try to find a match
|
||||||
* within all the names in the csinfo data structure
|
* within all the names in the csinfo data structure
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
|
if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i >= CSCOPE_MAX_CONNECTIONS || i < -1 || csinfo[i].fname == NULL)
|
if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL))
|
||||||
&& i != -1)
|
|
||||||
{
|
{
|
||||||
if (p_csverbose)
|
if (p_csverbose)
|
||||||
(void)EMSG2(_("E261: cscope connection %s not found"), stok);
|
(void)EMSG2(_("E261: cscope connection %s not found"), stok);
|
||||||
@@ -1597,7 +1600,7 @@ cs_kill(eap)
|
|||||||
{
|
{
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname)
|
if (csinfo[i].fname)
|
||||||
cs_kill_execute(i, csinfo[i].fname);
|
cs_kill_execute(i, csinfo[i].fname);
|
||||||
@@ -1857,7 +1860,7 @@ cs_file_results(f, nummatches_a)
|
|||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (nummatches_a[i] < 1)
|
if (nummatches_a[i] < 1)
|
||||||
continue;
|
continue;
|
||||||
@@ -1929,7 +1932,7 @@ cs_fill_results(tagstr, totmatches, nummatches_a, matches_p, cntxts_p, matched)
|
|||||||
if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
|
if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
|
||||||
goto parse_out;
|
goto parse_out;
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (nummatches_a[i] < 1)
|
if (nummatches_a[i] < 1)
|
||||||
continue;
|
continue;
|
||||||
@@ -2383,10 +2386,13 @@ cs_reset(eap)
|
|||||||
int i;
|
int i;
|
||||||
char buf[20]; /* for sprintf " (#%d)" */
|
char buf[20]; /* for sprintf " (#%d)" */
|
||||||
|
|
||||||
|
if (csinfo_size == 0)
|
||||||
|
return CSCOPE_SUCCESS;
|
||||||
|
|
||||||
/* malloc our db and ppath list */
|
/* malloc our db and ppath list */
|
||||||
dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
|
dblist = (char **)alloc(csinfo_size * sizeof(char *));
|
||||||
pplist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
|
pplist = (char **)alloc(csinfo_size * sizeof(char *));
|
||||||
fllist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
|
fllist = (char **)alloc(csinfo_size * sizeof(char *));
|
||||||
if (dblist == NULL || pplist == NULL || fllist == NULL)
|
if (dblist == NULL || pplist == NULL || fllist == NULL)
|
||||||
{
|
{
|
||||||
vim_free(dblist);
|
vim_free(dblist);
|
||||||
@@ -2395,7 +2401,7 @@ cs_reset(eap)
|
|||||||
return CSCOPE_FAILURE;
|
return CSCOPE_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
dblist[i] = csinfo[i].fname;
|
dblist[i] = csinfo[i].fname;
|
||||||
pplist[i] = csinfo[i].ppath;
|
pplist[i] = csinfo[i].ppath;
|
||||||
@@ -2405,7 +2411,7 @@ cs_reset(eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* rebuild the cscope connection list */
|
/* rebuild the cscope connection list */
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (dblist[i] != NULL)
|
if (dblist[i] != NULL)
|
||||||
{
|
{
|
||||||
@@ -2502,7 +2508,7 @@ cs_show(eap)
|
|||||||
MSG_PUTS_ATTR(
|
MSG_PUTS_ATTR(
|
||||||
_(" # pid database name prepend path\n"),
|
_(" # pid database name prepend path\n"),
|
||||||
hl_attr(HLF_T));
|
hl_attr(HLF_T));
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
{
|
{
|
||||||
if (csinfo[i].fname == NULL)
|
if (csinfo[i].fname == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -2531,8 +2537,10 @@ cs_end()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
|
for (i = 0; i < csinfo_size; i++)
|
||||||
cs_release_csp(i, TRUE);
|
cs_release_csp(i, TRUE);
|
||||||
|
vim_free(csinfo);
|
||||||
|
csinfo_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FEAT_CSCOPE */
|
#endif /* FEAT_CSCOPE */
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#define CSCOPE_SUCCESS 0
|
#define CSCOPE_SUCCESS 0
|
||||||
#define CSCOPE_FAILURE -1
|
#define CSCOPE_FAILURE -1
|
||||||
#define CSCOPE_MAX_CONNECTIONS 8 /* you actually need more? */
|
|
||||||
|
|
||||||
#define CSCOPE_DBFILE "cscope.out"
|
#define CSCOPE_DBFILE "cscope.out"
|
||||||
#define CSCOPE_PROMPT ">> "
|
#define CSCOPE_PROMPT ">> "
|
||||||
|
@@ -676,6 +676,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
228,
|
||||||
/**/
|
/**/
|
||||||
227,
|
227,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user