]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1570: Copilot suggested some improvements in cmdexpand.c v9.1.1570
authorJohn Marriott <basilisk@internode.on.net>
Sun, 20 Jul 2025 08:28:26 +0000 (10:28 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Jul 2025 08:28:26 +0000 (10:28 +0200)
Problem:  Copilot suggested some improvements in cmdexpand.c
          (after v9.1.1556)
Solution: Use better variable names and comments
          (John Marriott).

closes: #17795

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/version.c

index 449636f736a031c2173a8749f3f9933525b854fe..a7a5acf95ff131d3c660f5e81ee691d812fbd8d7 100644 (file)
@@ -3718,8 +3718,9 @@ ExpandGenericExt(
  */
     static void
 expand_shellcmd_onedir(
-       char_u          *pat,
-       size_t          pathlen,        // length of the path portion of pat.
+       char_u          *pathed_pattern,    // fully pathed pattern
+       size_t          pathlen,            // length of the path portion of pathed_pattern
+                                           // (0 if no path).
        char_u          ***matches,
        int             *numMatches,
        int             flags,
@@ -3727,7 +3728,7 @@ expand_shellcmd_onedir(
        garray_T        *gap)
 {
     // Expand matches in one directory of $PATH.
-    if (expand_wildcards(1, &pat, numMatches, matches, flags) != OK)
+    if (expand_wildcards(1, &pathed_pattern, numMatches, matches, flags) != OK)
        return;
 
     if (ga_grow(gap, *numMatches) == FAIL)
@@ -3878,6 +3879,9 @@ expand_shellcmd(
            seplen = !after_pathsep(s, e) ? STRLEN_LITERAL(PATHSEPSTR) : 0;
        }
 
+       // Make sure that the pathed pattern (ie the path and pattern concatenated
+       // together) will fit inside the buffer. If not skip it and move on to the
+       // next path.
        if (pathlen + seplen + patlen + 1 <= MAXPATHL)
        {
            if (pathlen > 0)
index 7297bc8cc2304afe714d70eab26bc9bdc55dd61e..c7027a68eace58e6a37802f3e12a25468fbb9ef9 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1570,
 /**/
     1569,
 /**/