Преглед на файлове

Fixes for corner cases (thanks, Bradley!)

Ryan C. Gordon преди 23 години
родител
ревизия
33be461bcb
променени са 1 файла, в които са добавени 8 реда и са изтрити 2 реда
  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;
         y = *wildptr;
         if (y == '*')
         if (y == '*')
         {
         {
-            wildptr++;
+            do
+            {
+                wildptr++;  /* skip multiple '*' in a row... */
+            } while (*wildptr == '*');
+
             y = (caseSensitive) ? *wildptr : (char) tolower(*wildptr);
             y = (caseSensitive) ? *wildptr : (char) tolower(*wildptr);
 
 
             while (1)
             while (1)
@@ -74,9 +78,11 @@ static int matchesPattern(const char *fname, const char *wildcard,
             if (x != y)
             if (x != y)
                 return(0);
                 return(0);
         } /* else */
         } /* else */
-
     } /* while */
     } /* while */
 
 
+    while (*wildptr == '*')
+        wildptr++;
+
     return(*fnameptr == *wildptr);
     return(*fnameptr == *wildptr);
 } /* matchesPattern */
 } /* matchesPattern */