mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
refactor(cmdexpand): prefer memmove over strmove
This commit is contained in:
parent
4881211097
commit
e8b1fbf47d
@ -2462,26 +2462,27 @@ static int expand_files_and_dirs(expand_T *xp, char *pat, char ***matches, int *
|
||||
|
||||
// for ":set path=" and ":set tags=" halve backslashes for escaped space
|
||||
if (xp->xp_backslash != XP_BS_NONE) {
|
||||
char *pat_e = pat + strlen(pat);
|
||||
free_pat = true;
|
||||
pat = xstrdup(pat);
|
||||
pat = xmemdupz(pat, (size_t)(pat_e - pat));
|
||||
for (int i = 0; pat[i]; i++) {
|
||||
if (pat[i] == '\\') {
|
||||
if (xp->xp_backslash & XP_BS_THREE
|
||||
&& pat[i + 1] == '\\'
|
||||
&& pat[i + 2] == '\\'
|
||||
&& pat[i + 3] == ' ') {
|
||||
STRMOVE(pat + i, pat + i + 3);
|
||||
memmove(pat + i, pat + i + 3, (size_t)(pat_e - (pat + i + 3) + 1));
|
||||
} else if (xp->xp_backslash & XP_BS_ONE
|
||||
&& pat[i + 1] == ' ') {
|
||||
STRMOVE(pat + i, pat + i + 1);
|
||||
memmove(pat + i, pat + i + 1, (size_t)(pat_e - (pat + i + 1) + 1));
|
||||
} else if ((xp->xp_backslash & XP_BS_COMMA)
|
||||
&& pat[i + 1] == '\\'
|
||||
&& pat[i + 2] == ',') {
|
||||
STRMOVE(pat + i, pat + i + 2);
|
||||
memmove(pat + i, pat + i + 2, (size_t)(pat_e - (pat + i + 2) + 1));
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
} else if ((xp->xp_backslash & XP_BS_COMMA)
|
||||
&& pat[i + 1] == ',') {
|
||||
STRMOVE(pat + i, pat + i + 1);
|
||||
memmove(pat + i, pat + i + 1, (size_t)(pat_e - (pat + i + 1) + 1));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user