mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
Changes based on AI feedback
This commit is contained in:
parent
a50ecac2e6
commit
1a71d8d088
@ -1081,25 +1081,24 @@ ExpandOne(
|
|||||||
{
|
{
|
||||||
size_t ss_size = 0;
|
size_t ss_size = 0;
|
||||||
char *prefix = "";
|
char *prefix = "";
|
||||||
char *suffix;
|
char *suffix = (options & WILD_USE_NL) ? "\n" : " ";
|
||||||
int n = xp->xp_numfiles - 1;
|
int n = xp->xp_numfiles - 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (xp->xp_prefix == XP_PREFIX_NO)
|
if (xp->xp_prefix == XP_PREFIX_NO)
|
||||||
{
|
{
|
||||||
prefix = "no";
|
prefix = "no";
|
||||||
ss_size = 2 * n;
|
ss_size = STRLEN_LITERAL("no") * n;
|
||||||
}
|
}
|
||||||
else if (xp->xp_prefix == XP_PREFIX_INV)
|
else if (xp->xp_prefix == XP_PREFIX_INV)
|
||||||
{
|
{
|
||||||
prefix = "inv";
|
prefix = "inv";
|
||||||
ss_size = 3 * n;
|
ss_size = STRLEN_LITERAL("inv") * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
suffix = (options & WILD_USE_NL) ? "\n" : " ";
|
|
||||||
|
|
||||||
for (i = 0; i < xp->xp_numfiles; ++i)
|
for (i = 0; i < xp->xp_numfiles; ++i)
|
||||||
ss_size += STRLEN(xp->xp_files[i]) + 1;
|
ss_size += STRLEN(xp->xp_files[i]) + 1; // +1 for the suffix
|
||||||
|
++ss_size; // +1 for the NUL
|
||||||
|
|
||||||
ss = alloc(ss_size);
|
ss = alloc(ss_size);
|
||||||
if (ss != NULL)
|
if (ss != NULL)
|
||||||
@ -1113,7 +1112,7 @@ ExpandOne(
|
|||||||
ss_size - ss_len,
|
ss_size - ss_len,
|
||||||
"%s%s%s",
|
"%s%s%s",
|
||||||
(i > 0) ? prefix : "",
|
(i > 0) ? prefix : "",
|
||||||
xp->xp_files[i],
|
(char *)xp->xp_files[i],
|
||||||
(i < n) ? suffix : "");
|
(i < n) ? suffix : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3014,7 +3013,7 @@ expand_files_and_dirs(
|
|||||||
pat_end = pat + pat_len;
|
pat_end = pat + pat_len;
|
||||||
for (p = pat; *p != NUL; ++p)
|
for (p = pat; *p != NUL; ++p)
|
||||||
{
|
{
|
||||||
char_u *tmp;
|
char_u *from;
|
||||||
|
|
||||||
if (*p != '\\')
|
if (*p != '\\')
|
||||||
continue;
|
continue;
|
||||||
@ -3024,34 +3023,34 @@ expand_files_and_dirs(
|
|||||||
&& *(p + 2) == '\\'
|
&& *(p + 2) == '\\'
|
||||||
&& *(p + 3) == ' ')
|
&& *(p + 3) == ' ')
|
||||||
{
|
{
|
||||||
tmp = p + 3;
|
from = p + 3;
|
||||||
mch_memmove(p, tmp,
|
mch_memmove(p, from,
|
||||||
(size_t)(pat_end - tmp) + 1); // +1 for NUL
|
(size_t)(pat_end - from) + 1); // +1 for NUL
|
||||||
pat_end -= 3;
|
pat_end -= 3;
|
||||||
}
|
}
|
||||||
else if (xp->xp_backslash & XP_BS_ONE
|
else if (xp->xp_backslash & XP_BS_ONE
|
||||||
&& *(p + 1) == ' ')
|
&& *(p + 1) == ' ')
|
||||||
{
|
{
|
||||||
tmp = p + 1;
|
from = p + 1;
|
||||||
mch_memmove(p, tmp,
|
mch_memmove(p, from,
|
||||||
(size_t)(pat_end - tmp) + 1); // +1 for NUL
|
(size_t)(pat_end - from) + 1); // +1 for NUL
|
||||||
--pat_end;
|
--pat_end;
|
||||||
}
|
}
|
||||||
else if (xp->xp_backslash & XP_BS_COMMA)
|
else if (xp->xp_backslash & XP_BS_COMMA)
|
||||||
{
|
{
|
||||||
if (*(p + 1) == '\\' && *(p + 2) == ',')
|
if (*(p + 1) == '\\' && *(p + 2) == ',')
|
||||||
{
|
{
|
||||||
tmp = p + 2;
|
from = p + 2;
|
||||||
mch_memmove(p, tmp,
|
mch_memmove(p, from,
|
||||||
(size_t)(pat_end - tmp) + 1); // +1 for NUL
|
(size_t)(pat_end - from) + 1); // +1 for NUL
|
||||||
pat_end -= 2;
|
pat_end -= 2;
|
||||||
}
|
}
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
else if (*(p + 1) == ',')
|
else if (*(p + 1) == ',')
|
||||||
{
|
{
|
||||||
tmp = p + 1;
|
from = p + 1;
|
||||||
mch_memmove(p, tmp,
|
mch_memmove(p, from,
|
||||||
(size_t)(pat_end - tmp) + 1); // +1 for NUL
|
(size_t)(pat_end - from) + 1); // +1 for NUL
|
||||||
--pat_end;
|
--pat_end;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -4109,10 +4108,8 @@ globpath(
|
|||||||
|
|
||||||
if (ga_grow(ga, num_p) == OK)
|
if (ga_grow(ga, num_p) == OK)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
// take over the pointers and put them in "ga"
|
// take over the pointers and put them in "ga"
|
||||||
for (i = 0; i < num_p; ++i)
|
for (int i = 0; i < num_p; ++i)
|
||||||
{
|
{
|
||||||
((char_u **)ga->ga_data)[ga->ga_len] = p[i];
|
((char_u **)ga->ga_data)[ga->ga_len] = p[i];
|
||||||
++ga->ga_len;
|
++ga->ga_len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user