diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-20 19:26:14 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-20 19:26:14 +0100 |
commit | 57e95179abdd851cb2d0c06d4f973575a768e3bb (patch) | |
tree | b46e223a591e688becbc9bc46c28194205c006ea | |
parent | 2984ed31d92f7da19b3dc86b37764c55669dd7c2 (diff) | |
download | vim-git-57e95179abdd851cb2d0c06d4f973575a768e3bb.tar.gz |
patch 9.0.0231: expanding "**" may loop forever with directory linksv9.0.0231
Problem: Expanding "**" may loop forever with directory links.
Solution: Check for being interrupted. (closes #10946)
-rw-r--r-- | src/cmdexpand.c | 5 | ||||
-rw-r--r-- | src/filepath.c | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c index ff6aa0d03..fb329a57d 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -722,8 +722,9 @@ ExpandOne( findex = -1; // next p_wc gets first one } - // Concatenate all matching names - if (mode == WILD_ALL && xp->xp_numfiles > 0) + // Concatenate all matching names. Unless interrupted, this can be slow + // and the result probably won't be used. + if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) { len = 0; for (i = 0; i < xp->xp_numfiles; ++i) diff --git a/src/filepath.c b/src/filepath.c index 0867a5181..ecee8db8b 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -3180,8 +3180,9 @@ expand_wildcards( /* * Move the names where 'suffixes' match to the end. + * Skip when interrupted, the result probably won't be used. */ - if (*num_files > 1) + if (*num_files > 1 && !got_int) { non_suf_match = 0; for (i = 0; i < *num_files; ++i) @@ -3719,7 +3720,7 @@ unix_expandpath( // Find all matching entries if (dirp != NULL) { - for (;;) + while (!got_int) { dp = readdir(dirp); if (dp == NULL) @@ -3789,8 +3790,10 @@ unix_expandpath( vim_free(buf); vim_regfree(regmatch.regprog); + // When interrupted the matches probably won't be used and sorting can be + // slow, thus skip it. matches = gap->ga_len - start_len; - if (matches > 0) + if (matches > 0 && !got_int) qsort(((char_u **)gap->ga_data) + start_len, matches, sizeof(char_u *), pstrcmp); return matches; @@ -3918,7 +3921,7 @@ gen_expand_wildcards( */ ga_init2(&ga, sizeof(char_u *), 30); - for (i = 0; i < num_pat; ++i) + for (i = 0; i < num_pat && !got_int; ++i) { add_pat = -1; p = pat[i]; diff --git a/src/version.c b/src/version.c index 9ce33cdbc..9b98edcc6 100644 --- a/src/version.c +++ b/src/version.c @@ -732,6 +732,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 231, +/**/ 230, /**/ 229, |