summaryrefslogtreecommitdiffstats
path: root/src/if_cscope.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-25 17:03:26 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-25 17:03:26 +0100
commitdc21552c9a83413a018a91e61649cc632929d6a1 (patch)
tree79f94e1c0409b24c18196449e2a0ec2ed4f0f3d3 /src/if_cscope.c
parentb9725bc7f6427654eb4e35874034b0ec1b6b96b3 (diff)
patch 9.0.0584: cscope test with wrong executable name failsv9.0.0584
Problem: Cscope test with wrong executable name fails. Solution: Use /bin/sh to execute the command. (Yegappan Lakshmanan)
Diffstat (limited to 'src/if_cscope.c')
-rw-r--r--src/if_cscope.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index 945b019a30..ad29fb9f50 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -799,7 +799,7 @@ cs_create_cmd(char *csoption, char *pattern)
return NULL;
}
- // Skip white space before the patter, except for text and pattern search,
+ // Skip white space before the pattern, except for text and pattern search,
// they may want to use the leading white space.
pat = pattern;
if (search != 4 && search != 6)
@@ -825,6 +825,7 @@ cs_create_connection(int i)
#ifdef UNIX
int to_cs[2], from_cs[2];
#endif
+ int cmdlen;
int len;
char *prog, *cmd, *ppath = NULL;
#ifdef MSWIN
@@ -917,7 +918,7 @@ err_closing:
expand_env(p_csprg, (char_u *)prog, MAXPATHL);
// alloc space to hold the cscope command
- len = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
+ cmdlen = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
if (csinfo[i].ppath)
{
// expand the prepend path for env var's
@@ -933,13 +934,13 @@ err_closing:
}
expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
- len += (int)strlen(ppath);
+ cmdlen += (int)strlen(ppath);
}
if (csinfo[i].flags)
- len += (int)strlen(csinfo[i].flags);
+ cmdlen += (int)strlen(csinfo[i].flags);
- if ((cmd = alloc(len)) == NULL)
+ if ((cmd = alloc(cmdlen)) == NULL)
{
vim_free(prog);
vim_free(ppath);
@@ -952,17 +953,21 @@ err_closing:
}
// run the cscope command
- (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
-
+#ifdef UNIX
+ vim_snprintf(cmd, cmdlen, "/bin/sh -c \"exec %s -dl -f %s\"",
+ prog, csinfo[i].fname);
+#else
+ vim_snprintf(cmd, cmdlen, "%s -dl -f %s", prog, csinfo[i].fname);
+#endif
if (csinfo[i].ppath != NULL)
{
- (void)strcat(cmd, " -P");
- (void)strcat(cmd, csinfo[i].ppath);
+ len = STRLEN(cmd);
+ vim_snprintf(cmd + len, cmdlen - len, " -P%s", csinfo[i].ppath);
}
if (csinfo[i].flags != NULL)
{
- (void)strcat(cmd, " ");
- (void)strcat(cmd, csinfo[i].flags);
+ len = STRLEN(cmd);
+ vim_snprintf(cmd + len, cmdlen - len, " %s", csinfo[i].flags);
}
# ifdef UNIX
// on Win32 we still need prog