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