To: vim_dev@googlegroups.com Subject: Patch 9.0.0231 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0231 Problem: Expanding "**" may loop forever with directory links. Solution: Check for being interrupted. (closes #10946) Files: src/filepath.c, src/cmdexpand.c *** ../vim-9.0.0230/src/filepath.c 2022-07-23 09:52:00.337814264 +0100 --- src/filepath.c 2022-08-20 19:20:27.569695133 +0100 *************** *** 3180,3187 **** /* * Move the names where 'suffixes' match to the end. */ ! if (*num_files > 1) { non_suf_match = 0; for (i = 0; i < *num_files; ++i) --- 3180,3188 ---- /* * Move the names where 'suffixes' match to the end. + * Skip when interrupted, the result probably won't be used. */ ! if (*num_files > 1 && !got_int) { non_suf_match = 0; for (i = 0; i < *num_files; ++i) *************** *** 3719,3725 **** // Find all matching entries if (dirp != NULL) { ! for (;;) { dp = readdir(dirp); if (dp == NULL) --- 3720,3726 ---- // Find all matching entries if (dirp != NULL) { ! while (!got_int) { dp = readdir(dirp); if (dp == NULL) *************** *** 3789,3796 **** vim_free(buf); vim_regfree(regmatch.regprog); matches = gap->ga_len - start_len; ! if (matches > 0) qsort(((char_u **)gap->ga_data) + start_len, matches, sizeof(char_u *), pstrcmp); return matches; --- 3790,3799 ---- 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 && !got_int) qsort(((char_u **)gap->ga_data) + start_len, matches, sizeof(char_u *), pstrcmp); return matches; *************** *** 3918,3924 **** */ ga_init2(&ga, sizeof(char_u *), 30); ! for (i = 0; i < num_pat; ++i) { add_pat = -1; p = pat[i]; --- 3921,3927 ---- */ ga_init2(&ga, sizeof(char_u *), 30); ! for (i = 0; i < num_pat && !got_int; ++i) { add_pat = -1; p = pat[i]; *** ../vim-9.0.0230/src/cmdexpand.c 2022-08-14 14:16:07.983582313 +0100 --- src/cmdexpand.c 2022-08-20 19:18:16.196840577 +0100 *************** *** 722,729 **** findex = -1; // next p_wc gets first one } ! // Concatenate all matching names ! if (mode == WILD_ALL && xp->xp_numfiles > 0) { len = 0; for (i = 0; i < xp->xp_numfiles; ++i) --- 722,730 ---- findex = -1; // next p_wc gets first one } ! // 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) *** ../vim-9.0.0230/src/version.c 2022-08-20 14:51:13.814510144 +0100 --- src/version.c 2022-08-20 19:08:01.803977580 +0100 *************** *** 733,734 **** --- 733,736 ---- { /* Add new patch number below this line */ + /**/ + 231, /**/ -- There are 10 kinds of people: Those who understand binary and those who don't. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///