Explorar o código

Fixes for corner cases (thanks, Bradley!)

Ryan C. Gordon %!s(int64=23) %!d(string=hai) anos
pai
achega
33be461bcb
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      extras/globbing.c

+ 8 - 2
extras/globbing.c

@@ -39,7 +39,11 @@ static int matchesPattern(const char *fname, const char *wildcard,
         y = *wildptr;
         if (y == '*')
         {
-            wildptr++;
+            do
+            {
+                wildptr++;  /* skip multiple '*' in a row... */
+            } while (*wildptr == '*');
+
             y = (caseSensitive) ? *wildptr : (char) tolower(*wildptr);
 
             while (1)
@@ -74,9 +78,11 @@ static int matchesPattern(const char *fname, const char *wildcard,
             if (x != y)
                 return(0);
         } /* else */
-
     } /* while */
 
+    while (*wildptr == '*')
+        wildptr++;
+
     return(*fnameptr == *wildptr);
 } /* matchesPattern */