Blame SOURCES/unzip-6.0-caseinsensitive.patch

6c1878
diff --git a/match.c b/match.c
6c1878
index 6cd656f..4e569f5 100644
6c1878
--- a/match.c
6c1878
+++ b/match.c
6c1878
@@ -190,10 +190,10 @@ char *___tmp_ptr;
6c1878
 
6c1878
 #endif
6c1878
 
6c1878
-static int recmatch(p, s, cs)
6c1878
+static int recmatch(p, s, ci)
6c1878
 ZCONST char *p;         /* sh pattern to match */
6c1878
 ZCONST char *s;         /* string to match it to */
6c1878
-int cs;                 /* flag: force case-sensitive matching */
6c1878
+int ci;                 /* flag: force case-insensitive matching */
6c1878
 /* Recursively compare the sh pattern p with the string s and return 1 if
6c1878
    they match, and 0 or 2 if they don't or if there is a syntax error in the
6c1878
    pattern.  This routine recurses on itself no deeper than the number of
6c1878
@@ -214,7 +214,7 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
   if (CLEN(p) == 2) {
6c1878
     if (CLEN(s) == 2) {
6c1878
       return (*p == *s && *(p+1) == *(s+1)) ?
6c1878
-        recmatch(p + 2, s + 2, cs) : 0;
6c1878
+        recmatch(p + 2, s + 2, ci) : 0;
6c1878
     } else {
6c1878
       return 0;
6c1878
     }
6c1878
@@ -230,9 +230,9 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
   /* '?' (or '%' or '#') matches any character (but not an empty string) */
6c1878
   if (c == WILDCHR_SINGLE) {
6c1878
     if (wild_stop_at_dir)
6c1878
-      return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
6c1878
+      return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), ci) : 0;
6c1878
     else
6c1878
-      return *s ? recmatch(p, s + CLEN(s), cs) : 0;
6c1878
+      return *s ? recmatch(p, s + CLEN(s), ci) : 0;
6c1878
   }
6c1878
 
6c1878
   /* WILDCHR_MULTI ('*') matches any number of characters, including zero */
6c1878
@@ -253,14 +253,14 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
 # endif /* ?AMIGA */
6c1878
         /* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
6c1878
         for (; *s && *s != DIRSEP_CHR; INCSTR(s))
6c1878
-          if ((c = recmatch(p, s, cs)) != 0)
6c1878
+          if ((c = recmatch(p, s, ci)) != 0)
6c1878
             return c;
6c1878
         /* end of pattern: matched if at end of string, else continue */
6c1878
         if (*p == 0)
6c1878
           return (*s == 0);
6c1878
         /* continue to match if at DIRSEP_CHR in pattern, else give up */
6c1878
         return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
6c1878
-               ? recmatch(p, s, cs) : 2;
6c1878
+               ? recmatch(p, s, ci) : 2;
6c1878
       }
6c1878
       /* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
6c1878
       p++;        /* move p past the second WILDCHR_MULTI */
6c1878
@@ -308,17 +308,17 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
          */
6c1878
         if (q != srest)
6c1878
           return 0;
6c1878
-        return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
6c1878
+        return ((!ci ? strcmp(p, q) : namecmp(p, q)) == 0);
6c1878
       }
6c1878
 #else /* !_MBCS */
6c1878
-        return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
6c1878
+        return ((!ci ? strcmp(p, srest) : namecmp(p, srest)) == 0);
6c1878
 #endif /* ?_MBCS */
6c1878
     }
6c1878
     else
6c1878
     {
6c1878
       /* pattern contains more wildcards, continue with recursion... */
6c1878
       for (; *s; INCSTR(s))
6c1878
-        if ((c = recmatch(p, s, cs)) != 0)
6c1878
+        if ((c = recmatch(p, s, ci)) != 0)
6c1878
           return c;
6c1878
       return 2;           /* 2 means give up--shmatch will return false */
6c1878
     }
6c1878
@@ -353,17 +353,17 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
         c = *(p-1);
6c1878
       else
6c1878
       {
6c1878
-        uch cc = (cs ? (uch)*s : case_map((uch)*s));
6c1878
+        uch cc = (!ci ? (uch)*s : to_up((uch)*s));
6c1878
         uch uc = (uch) c;
6c1878
         if (*(p+1) != '-')
6c1878
           for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
6c1878
             /* compare range */
6c1878
-            if ((cs ? uc : case_map(uc)) == cc)
6c1878
-              return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
6c1878
+            if ((!ci ? uc : to_up(uc)) == cc)
6c1878
+              return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), ci);
6c1878
         c = e = 0;                      /* clear range, escape flags */
6c1878
       }
6c1878
     }
6c1878
-    return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
6c1878
+    return r ? recmatch(q + CLEN(q), s + CLEN(s), ci) : 0;
6c1878
                                         /* bracket match failed */
6c1878
   }
6c1878
 #endif /* !VMS */
6c1878
@@ -382,18 +382,18 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
   {
6c1878
     /* Match "...]" with "]".  Continue after "]" in both. */
6c1878
     if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
6c1878
-      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
6c1878
+      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
6c1878
 
6c1878
     /* Else, look for a reduced match in s, until "]" in or end of s. */
6c1878
     for (; *s && (*s != ']'); INCSTR(s))
6c1878
       if (*s == '.')
6c1878
         /* If reduced match, then continue after "..." in p, "." in s. */
6c1878
-        if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
6c1878
+        if ((c = recmatch( (p+ CLEN( p)), s, ci)) != 0)
6c1878
           return (int)c;
6c1878
 
6c1878
     /* Match "...]" with "]".  Continue after "]" in both. */
6c1878
     if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
6c1878
-      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
6c1878
+      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
6c1878
 
6c1878
     /* No reduced match.  Quit. */
6c1878
     return 2;
6c1878
@@ -402,8 +402,8 @@ int cs;                 /* flag: force case-sensitive matching */
6c1878
 #endif /* def VMS */
6c1878
 
6c1878
   /* Just a character--compare it */
6c1878
-  return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
6c1878
-          recmatch(p, s + CLEN(s), cs) : 0;
6c1878
+  return (!ci ? c == *s : to_up((uch)c) == to_up((uch)*s)) ?
6c1878
+          recmatch(p, s + CLEN(s), ci) : 0;
6c1878
 }
6c1878
 
6c1878