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