0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.0876: code is indented more than needed

Problem:    Code is indented more than needed.
Solution:   Split ExpandEscape() in two. (Yegappan Lakshmanan, closes #11539)
This commit is contained in:
Yegappan Lakshmanan
2022-11-13 22:38:10 +00:00
committed by Bram Moolenaar
parent 398a26f7fc
commit 68353e5270
2 changed files with 113 additions and 101 deletions

View File

@@ -92,24 +92,16 @@ sort_func_compare(const void *s1, const void *s2)
* Escape special characters in the cmdline completion matches. * Escape special characters in the cmdline completion matches.
*/ */
static void static void
ExpandEscape( wildescape(
expand_T *xp, expand_T *xp,
char_u *str, char_u *str,
int numfiles, int numfiles,
char_u **files, char_u **files)
int options)
{ {
int i;
char_u *p; char_u *p;
int vse_what = xp->xp_context == EXPAND_BUFFERS int vse_what = xp->xp_context == EXPAND_BUFFERS
? VSE_BUFFER : VSE_NONE; ? VSE_BUFFER : VSE_NONE;
// May change home directory back to "~"
if (options & WILD_HOME_REPLACE)
tilde_replace(str, numfiles, files);
if (options & WILD_ESCAPE)
{
if (xp->xp_context == EXPAND_FILES if (xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_FILES_IN_PATH || xp->xp_context == EXPAND_FILES_IN_PATH
|| xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_SHELLCMD
@@ -118,7 +110,7 @@ ExpandEscape(
{ {
// Insert a backslash into a file name before a space, \, %, # // Insert a backslash into a file name before a space, \, %, #
// and wildmatch characters, except '~'. // and wildmatch characters, except '~'.
for (i = 0; i < numfiles; ++i) for (int i = 0; i < numfiles; ++i)
{ {
// for ":set path=" we need to escape spaces twice // for ":set path=" we need to escape spaces twice
if (xp->xp_backslash == XP_BS_THREE) if (xp->xp_backslash == XP_BS_THREE)
@@ -166,7 +158,7 @@ ExpandEscape(
{ {
// Insert a backslash before characters in a tag name that // Insert a backslash before characters in a tag name that
// would terminate the ":tag" command. // would terminate the ":tag" command.
for (i = 0; i < numfiles; ++i) for (int i = 0; i < numfiles; ++i)
{ {
p = vim_strsave_escaped(files[i], (char_u *)"\\|\""); p = vim_strsave_escaped(files[i], (char_u *)"\\|\"");
if (p != NULL) if (p != NULL)
@@ -176,7 +168,25 @@ ExpandEscape(
} }
} }
} }
} }
/*
* Escape special characters in the cmdline completion matches.
*/
static void
ExpandEscape(
expand_T *xp,
char_u *str,
int numfiles,
char_u **files,
int options)
{
// May change home directory back to "~"
if (options & WILD_HOME_REPLACE)
tilde_replace(str, numfiles, files);
if (options & WILD_ESCAPE)
wildescape(xp, str, numfiles, files);
} }
/* /*
@@ -3238,7 +3248,6 @@ expand_shellcmd_onedir(
garray_T *gap) garray_T *gap)
{ {
int ret; int ret;
int i;
hash_T hash; hash_T hash;
hashitem_T *hi; hashitem_T *hi;
@@ -3249,13 +3258,16 @@ expand_shellcmd_onedir(
// Expand matches in one directory of $PATH. // Expand matches in one directory of $PATH.
ret = expand_wildcards(1, &buf, numMatches, matches, flags); ret = expand_wildcards(1, &buf, numMatches, matches, flags);
if (ret == OK) if (ret != OK)
{ return;
if (ga_grow(gap, *numMatches) == FAIL) if (ga_grow(gap, *numMatches) == FAIL)
FreeWild(*numMatches, *matches);
else
{ {
for (i = 0; i < *numMatches; ++i) FreeWild(*numMatches, *matches);
return;
}
for (int i = 0; i < *numMatches; ++i)
{ {
char_u *name = (*matches)[i]; char_u *name = (*matches)[i];
@@ -3276,8 +3288,6 @@ expand_shellcmd_onedir(
vim_free(name); vim_free(name);
} }
vim_free(*matches); vim_free(*matches);
}
}
} }
/* /*

View File

@@ -695,6 +695,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 */
/**/
876,
/**/ /**/
875, 875,
/**/ /**/