7e0a4d
diff -up unzip60/match.c.recmatch unzip60/match.c
7e0a4d
--- unzip60/match.c.recmatch	2005-08-14 13:00:36.000000000 -0400
7e0a4d
+++ unzip60/match.c	2013-05-28 10:29:57.949077543 -0400
7e0a4d
@@ -27,16 +27,14 @@
7e0a4d
 
7e0a4d
   ---------------------------------------------------------------------------
7e0a4d
 
7e0a4d
-  Copyright on recmatch() from Zip's util.c (although recmatch() was almost
7e0a4d
-  certainly written by Mark Adler...ask me how I can tell :-) ):
7e0a4d
+  Copyright on recmatch() from Zip's util.c
7e0a4d
+	 Copyright (c) 1990-2005 Info-ZIP.  All rights reserved.
7e0a4d
 
7e0a4d
-     Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
7e0a4d
-     Kai Uwe Rommel and Igor Mandrichenko.
7e0a4d
+	 See the accompanying file LICENSE, version 2004-May-22 or later
7e0a4d
+	 for terms of use.
7e0a4d
+	 If, for some reason, both of these files are missing, the Info-ZIP license
7e0a4d
+	 also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html  
7e0a4d
 
7e0a4d
-     Permission is granted to any individual or institution to use, copy,
7e0a4d
-     or redistribute this software so long as all of the original files are
7e0a4d
-     included unmodified, that it is not sold for profit, and that this copy-
7e0a4d
-     right notice is retained.
7e0a4d
 
7e0a4d
   ---------------------------------------------------------------------------
7e0a4d
 
7e0a4d
@@ -53,7 +51,7 @@
7e0a4d
 
7e0a4d
   A set is composed of characters or ranges; a range looks like ``character
7e0a4d
   hyphen character'' (as in 0-9 or A-Z).  [0-9a-zA-Z_] is the minimal set of
7e0a4d
-  characters allowed in the [..] pattern construct.  Other characters are
7e0a4d
+  characters ALlowed in the [..] pattern construct.  Other characters are
7e0a4d
   allowed (i.e., 8-bit characters) if your system will support them.
7e0a4d
 
7e0a4d
   To suppress the special syntactic significance of any of ``[]*?!^-\'', in-
7e0a4d
@@ -101,8 +99,32 @@
7e0a4d
 #  define WILDCHAR   '?'
7e0a4d
 #  define BEG_RANGE  '['
7e0a4d
 #  define END_RANGE  ']'
7e0a4d
+#  define WILDCHR_SINGLE '?'
7e0a4d
+#  define DIRSEP_CHR '/'
7e0a4d
+#  define WILDCHR_MULTI '*'
7e0a4d
 #endif
7e0a4d
 
7e0a4d
+#ifdef WILD_STOP_AT_DIR
7e0a4d
+   int wild_stop_at_dir = 1; /* default wildcards do not include / in matches */
7e0a4d
+#else
7e0a4d
+   int wild_stop_at_dir = 0; /* default wildcards do include / in matches */
7e0a4d
+#endif
7e0a4d
+
7e0a4d
+
7e0a4d
+
7e0a4d
+/*
7e0a4d
+ * case mapping functions. case_map is used to ignore case in comparisons,
7e0a4d
+ * to_up is used to force upper case even on Unix (for dosify option).
7e0a4d
+ */
7e0a4d
+#ifdef USE_CASE_MAP
7e0a4d
+#  define case_map(c) upper[(c) & 0xff]
7e0a4d
+#  define to_up(c)    upper[(c) & 0xff]
7e0a4d
+#else
7e0a4d
+#  define case_map(c) (c)
7e0a4d
+#  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
7e0a4d
+#endif /* USE_CASE_MAP */
7e0a4d
+
7e0a4d
+
7e0a4d
 #if 0                /* GRR:  add this to unzip.h someday... */
7e0a4d
 #if !(defined(MSDOS) && defined(DOSWILD))
7e0a4d
 #ifdef WILD_STOP_AT_DIR
7e0a4d
@@ -114,8 +136,8 @@ int recmatch OF((ZCONST uch *pattern, ZC
7e0a4d
                  int ignore_case __WDLPRO));
7e0a4d
 #endif
7e0a4d
 #endif /* 0 */
7e0a4d
-static int recmatch OF((ZCONST uch *pattern, ZCONST uch *string,
7e0a4d
-                        int ignore_case __WDLPRO));
7e0a4d
+static int recmatch OF((ZCONST char *, ZCONST char *, 
7e0a4d
+                        int));
7e0a4d
 static char *isshexp OF((ZCONST char *p));
7e0a4d
 static int namecmp OF((ZCONST char *s1, ZCONST char *s2));
7e0a4d
 
7e0a4d
@@ -154,192 +176,240 @@ int match(string, pattern, ignore_case _
7e0a4d
             }
7e0a4d
             dospattern[j-1] = '\0';                    /* nuke the end "." */
7e0a4d
         }
7e0a4d
-        j = recmatch((uch *)dospattern, (uch *)string, ignore_case __WDL);
7e0a4d
+        j = recmatch(dospattern, string, ignore_case);
7e0a4d
         free(dospattern);
7e0a4d
         return j == 1;
7e0a4d
     } else
7e0a4d
 #endif /* MSDOS && DOSWILD */
7e0a4d
-    return recmatch((uch *)pattern, (uch *)string, ignore_case __WDL) == 1;
7e0a4d
+    return recmatch(pattern, string, ignore_case) == 1;
7e0a4d
 }
7e0a4d
 
7e0a4d
+#ifdef _MBCS
7e0a4d
+
7e0a4d
+char *___tmp_ptr;
7e0a4d
 
7e0a4d
+#endif
7e0a4d
 
7e0a4d
-static int recmatch(p, s, ic __WDL)
7e0a4d
-    ZCONST uch *p;        /* sh pattern to match */
7e0a4d
-    ZCONST uch *s;        /* string to which to match it */
7e0a4d
-    int ic;               /* true for case insensitivity */
7e0a4d
-    __WDLDEF              /* directory sepchar for WildStopAtDir mode, or 0 */
7e0a4d
+static int recmatch(p, s, cs)
7e0a4d
+ZCONST char *p;         /* sh pattern to match */
7e0a4d
+ZCONST char *s;         /* string to match it to */
7e0a4d
+int cs;                 /* flag: force case-sensitive matching */
7e0a4d
 /* Recursively compare the sh pattern p with the string s and return 1 if
7e0a4d
- * they match, and 0 or 2 if they don't or if there is a syntax error in the
7e0a4d
- * pattern.  This routine recurses on itself no more deeply than the number
7e0a4d
- * of characters in the pattern. */
7e0a4d
+   they match, and 0 or 2 if they don't or if there is a syntax error in the
7e0a4d
+   pattern.  This routine recurses on itself no deeper than the number of
7e0a4d
+   characters in the pattern. */
7e0a4d
 {
7e0a4d
-    unsigned int c;       /* pattern char or start of range in [-] loop */
7e0a4d
+  int c;                /* pattern char or start of range in [-] loop */
7e0a4d
+  /* Get first character, the pattern for new recmatch calls follows */
7e0a4d
+ /* borrowed from Zip's global.c */
7e0a4d
+ int no_wild = 0; 
7e0a4d
+ int allow_regex=1;
7e0a4d
+  /* This fix provided by akt@m5.dion.ne.jp for Japanese.
7e0a4d
+     See 21 July 2006 mail.
7e0a4d
+     It only applies when p is pointing to a doublebyte character and
7e0a4d
+     things like / and wildcards are not doublebyte.  This probably
7e0a4d
+     should not be needed. */
7e0a4d
 
7e0a4d
-    /* Get first character, the pattern for new recmatch calls follows */
7e0a4d
-    c = *p; INCSTR(p);
7e0a4d
+#ifdef _MBCS
7e0a4d
+  if (CLEN(p) == 2) {
7e0a4d
+    if (CLEN(s) == 2) {
7e0a4d
+      return (*p == *s && *(p+1) == *(s+1)) ?
7e0a4d
+        recmatch(p + 2, s + 2, cs) : 0;
7e0a4d
+    } else {
7e0a4d
+      return 0;
7e0a4d
+    }
7e0a4d
+  }
7e0a4d
+#endif /* ?_MBCS */
7e0a4d
 
7e0a4d
-    /* If that was the end of the pattern, match if string empty too */
7e0a4d
-    if (c == 0)
7e0a4d
-        return *s == 0;
7e0a4d
+  c = *POSTINCSTR(p);
7e0a4d
 
7e0a4d
-    /* '?' (or '%') matches any character (but not an empty string). */
7e0a4d
-    if (c == WILDCHAR)
7e0a4d
-#ifdef WILD_STOP_AT_DIR
7e0a4d
-        /* If uO.W_flag is non-zero, it won't match '/' */
7e0a4d
-        return (*s && (!sepc || *s != (uch)sepc))
7e0a4d
-               ? recmatch(p, s + CLEN(s), ic, sepc) : 0;
7e0a4d
-#else
7e0a4d
-        return *s ? recmatch(p, s + CLEN(s), ic) : 0;
7e0a4d
-#endif
7e0a4d
+  /* If that was the end of the pattern, match if string empty too */
7e0a4d
+  if (c == 0)
7e0a4d
+    return *s == 0;
7e0a4d
+
7e0a4d
+  /* '?' (or '%' or '#') matches any character (but not an empty string) */
7e0a4d
+  if (c == WILDCHR_SINGLE) {
7e0a4d
+    if (wild_stop_at_dir)
7e0a4d
+      return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
7e0a4d
+    else
7e0a4d
+      return *s ? recmatch(p, s + CLEN(s), cs) : 0;
7e0a4d
+  }
7e0a4d
 
7e0a4d
-    /* '*' matches any number of characters, including zero */
7e0a4d
+  /* WILDCHR_MULTI ('*') matches any number of characters, including zero */
7e0a4d
 #ifdef AMIGA
7e0a4d
-    if (c == '#' && *p == '?')     /* "#?" is Amiga-ese for "*" */
7e0a4d
-        c = '*', p++;
7e0a4d
+  if (!no_wild && c == '#' && *p == '?')            /* "#?" is Amiga-ese for "*" */
7e0a4d
+    c = WILDCHR_MULTI, p++;
7e0a4d
 #endif /* AMIGA */
7e0a4d
-    if (c == '*') {
7e0a4d
-#ifdef WILD_STOP_AT_DIR
7e0a4d
-        if (sepc) {
7e0a4d
-          /* check for single "*" or double "**" */
7e0a4d
-#  ifdef AMIGA
7e0a4d
-          if ((c = p[0]) == '#' && p[1] == '?') /* "#?" is Amiga-ese for "*" */
7e0a4d
-            c = '*', p++;
7e0a4d
-          if (c != '*') {
7e0a4d
-#  else /* !AMIGA */
7e0a4d
-          if (*p != '*') {
7e0a4d
-#  endif /* ?AMIGA */
7e0a4d
-            /* single "*": this doesn't match the dirsep character */
7e0a4d
-            for (; *s && *s != (uch)sepc; INCSTR(s))
7e0a4d
-                if ((c = recmatch(p, s, ic, sepc)) != 0)
7e0a4d
-                    return (int)c;
7e0a4d
-            /* end of pattern: matched if at end of string, else continue */
7e0a4d
-            if (*p == '\0')
7e0a4d
-                return (*s == 0);
7e0a4d
-            /* continue to match if at sepc in pattern, else give up */
7e0a4d
-            return (*p == (uch)sepc || (*p == '\\' && p[1] == (uch)sepc))
7e0a4d
-                   ? recmatch(p, s, ic, sepc) : 2;
7e0a4d
-          }
7e0a4d
-          /* "**": this matches slashes */
7e0a4d
-          ++p;        /* move p behind the second '*' */
7e0a4d
-          /* and continue with the non-W_flag code variant */
7e0a4d
-        }
7e0a4d
-#endif /* WILD_STOP_AT_DIR */
7e0a4d
+  if (!no_wild && c == WILDCHR_MULTI)
7e0a4d
+  {
7e0a4d
+    if (wild_stop_at_dir) {
7e0a4d
+      /* Check for an immediately following WILDCHR_MULTI */
7e0a4d
+# ifdef AMIGA
7e0a4d
+      if ((c = p[0]) == '#' && p[1] == '?') /* "#?" is Amiga-ese for "*" */
7e0a4d
+        c = WILDCHR_MULTI, p++;
7e0a4d
+      if (c != WILDCHR_MULTI) {
7e0a4d
+# else /* !AMIGA */
7e0a4d
+      if (*p != WILDCHR_MULTI) {
7e0a4d
+# endif /* ?AMIGA */
7e0a4d
+        /* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
7e0a4d
+        for (; *s && *s != DIRSEP_CHR; INCSTR(s))
7e0a4d
+          if ((c = recmatch(p, s, cs)) != 0)
7e0a4d
+            return c;
7e0a4d
+        /* end of pattern: matched if at end of string, else continue */
7e0a4d
         if (*p == 0)
7e0a4d
-            return 1;
7e0a4d
-        if (isshexp((ZCONST char *)p) == NULL) {
7e0a4d
-            /* Optimization for rest of pattern being a literal string:
7e0a4d
-             * If there are no other shell expression chars in the rest
7e0a4d
-             * of the pattern behind the multi-char wildcard, then just
7e0a4d
-             * compare the literal string tail.
7e0a4d
-             */
7e0a4d
-            ZCONST uch *srest;
7e0a4d
-
7e0a4d
-            srest = s + (strlen((ZCONST char *)s) - strlen((ZCONST char *)p));
7e0a4d
-            if (srest - s < 0)
7e0a4d
-                /* remaining literal string from pattern is longer than rest
7e0a4d
-                 * of test string, there can't be a match
7e0a4d
-                 */
7e0a4d
-                return 0;
7e0a4d
-            else
7e0a4d
-              /* compare the remaining literal pattern string with the last
7e0a4d
-               * bytes of the test string to check for a match
7e0a4d
-               */
7e0a4d
+          return (*s == 0);
7e0a4d
+        /* continue to match if at DIRSEP_CHR in pattern, else give up */
7e0a4d
+        return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
7e0a4d
+               ? recmatch(p, s, cs) : 2;
7e0a4d
+      }
7e0a4d
+      /* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
7e0a4d
+      p++;        /* move p past the second WILDCHR_MULTI */
7e0a4d
+      /* continue with the normal non-WILD_STOP_AT_DIR code */
7e0a4d
+    } /* wild_stop_at_dir */
7e0a4d
+
7e0a4d
+    /* Not wild_stop_at_dir */
7e0a4d
+    if (*p == 0)
7e0a4d
+      return 1;
7e0a4d
+    if (!isshexp((char *)p))
7e0a4d
+    {
7e0a4d
+      /* optimization for rest of pattern being a literal string */
7e0a4d
+
7e0a4d
+      /* optimization to handle patterns like *.txt */
7e0a4d
+      /* if the first char in the pattern is '*' and there */
7e0a4d
+      /* are no other shell expression chars, i.e. a literal string */
7e0a4d
+      /* then just compare the literal string at the end */
7e0a4d
+
7e0a4d
+      ZCONST char *srest;
7e0a4d
+
7e0a4d
+      srest = s + (strlen(s) - strlen(p));
7e0a4d
+      if (srest - s < 0)
7e0a4d
+        /* remaining literal string from pattern is longer than rest of
7e0a4d
+           test string, there can't be a match
7e0a4d
+         */
7e0a4d
+        return 0;
7e0a4d
+      else
7e0a4d
+        /* compare the remaining literal pattern string with the last bytes
7e0a4d
+           of the test string to check for a match */
7e0a4d
 #ifdef _MBCS
7e0a4d
-            {
7e0a4d
-                ZCONST uch *q = s;
7e0a4d
+      {
7e0a4d
+        ZCONST char *q = s;
7e0a4d
 
7e0a4d
-                /* MBCS-aware code must not scan backwards into a string from
7e0a4d
-                 * the end.
7e0a4d
-                 * So, we have to move forward by character from our well-known
7e0a4d
-                 * character position s in the test string until we have
7e0a4d
-                 * advanced to the srest position.
7e0a4d
-                 */
7e0a4d
-                while (q < srest)
7e0a4d
-                  INCSTR(q);
7e0a4d
-                /* In case the byte *srest is a trailing byte of a multibyte
7e0a4d
-                 * character in the test string s, we have actually advanced
7e0a4d
-                 * past the position (srest).
7e0a4d
-                 * For this case, the match has failed!
7e0a4d
-                 */
7e0a4d
-                if (q != srest)
7e0a4d
-                    return 0;
7e0a4d
-                return ((ic
7e0a4d
-                         ? namecmp((ZCONST char *)p, (ZCONST char *)q)
7e0a4d
-                         : strcmp((ZCONST char *)p, (ZCONST char *)q)
7e0a4d
-                        ) == 0);
7e0a4d
-            }
7e0a4d
+        /* MBCS-aware code must not scan backwards into a string from
7e0a4d
+         * the end.
7e0a4d
+         * So, we have to move forward by character from our well-known
7e0a4d
+         * character position s in the test string until we have advanced
7e0a4d
+         * to the srest position.
7e0a4d
+         */
7e0a4d
+        while (q < srest)
7e0a4d
+          INCSTR(q);
7e0a4d
+        /* In case the byte *srest is a trailing byte of a multibyte
7e0a4d
+         * character, we have actually advanced past the position (srest).
7e0a4d
+         * For this case, the match has failed!
7e0a4d
+         */
7e0a4d
+        if (q != srest)
7e0a4d
+          return 0;
7e0a4d
+        return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
7e0a4d
+      }
7e0a4d
 #else /* !_MBCS */
7e0a4d
-                return ((ic
7e0a4d
-                         ? namecmp((ZCONST char *)p, (ZCONST char *)srest)
7e0a4d
-                         : strcmp((ZCONST char *)p, (ZCONST char *)srest)
7e0a4d
-                        ) == 0);
7e0a4d
+        return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
7e0a4d
 #endif /* ?_MBCS */
7e0a4d
-        } else {
7e0a4d
-            /* pattern contains more wildcards, continue with recursion... */
7e0a4d
-            for (; *s; INCSTR(s))
7e0a4d
-                if ((c = recmatch(p, s, ic __WDL)) != 0)
7e0a4d
-                    return (int)c;
7e0a4d
-            return 2;  /* 2 means give up--match will return false */
7e0a4d
-        }
7e0a4d
     }
7e0a4d
-
7e0a4d
-    /* Parse and process the list of characters and ranges in brackets */
7e0a4d
-    if (c == BEG_RANGE) {
7e0a4d
-        int e;          /* flag true if next char to be taken literally */
7e0a4d
-        ZCONST uch *q;  /* pointer to end of [-] group */
7e0a4d
-        int r;          /* flag true to match anything but the range */
7e0a4d
-
7e0a4d
-        if (*s == 0)                            /* need a character to match */
7e0a4d
-            return 0;
7e0a4d
-        p += (r = (*p == '!' || *p == '^'));    /* see if reverse */
7e0a4d
-        for (q = p, e = 0; *q; INCSTR(q))       /* find closing bracket */
7e0a4d
-            if (e)
7e0a4d
-                e = 0;
7e0a4d
-            else
7e0a4d
-                if (*q == '\\')      /* GRR:  change to ^ for MS-DOS, OS/2? */
7e0a4d
-                    e = 1;
7e0a4d
-                else if (*q == END_RANGE)
7e0a4d
-                    break;
7e0a4d
-        if (*q != END_RANGE)         /* nothing matches if bad syntax */
7e0a4d
-            return 0;
7e0a4d
-        for (c = 0, e = (*p == '-'); p < q; INCSTR(p)) {
7e0a4d
-            /* go through the list */
7e0a4d
-            if (!e && *p == '\\')               /* set escape flag if \ */
7e0a4d
-                e = 1;
7e0a4d
-            else if (!e && *p == '-')           /* set start of range if - */
7e0a4d
-                c = *(p-1);
7e0a4d
-            else {
7e0a4d
-                unsigned int cc = Case(*s);
7e0a4d
-
7e0a4d
-                if (*(p+1) != '-')
7e0a4d
-                    for (c = c ? c : *p; c <= *p; c++)  /* compare range */
7e0a4d
-                        if ((unsigned)Case(c) == cc) /* typecast for MSC bug */
7e0a4d
-                            return r ? 0 : recmatch(q + 1, s + 1, ic __WDL);
7e0a4d
-                c = e = 0;   /* clear range, escape flags */
7e0a4d
-            }
7e0a4d
-        }
7e0a4d
-        return r ? recmatch(q + CLEN(q), s + CLEN(s), ic __WDL) : 0;
7e0a4d
-                                        /* bracket match failed */
7e0a4d
+    else
7e0a4d
+    {
7e0a4d
+      /* pattern contains more wildcards, continue with recursion... */
7e0a4d
+      for (; *s; INCSTR(s))
7e0a4d
+        if ((c = recmatch(p, s, cs)) != 0)
7e0a4d
+          return c;
7e0a4d
+      return 2;           /* 2 means give up--shmatch will return false */
7e0a4d
     }
7e0a4d
+  }
7e0a4d
 
7e0a4d
-    /* if escape ('\\'), just compare next character */
7e0a4d
-    if (c == '\\' && (c = *p++) == 0)     /* if \ at end, then syntax error */
7e0a4d
-        return 0;
7e0a4d
+#ifndef VMS             /* No bracket matching in VMS */
7e0a4d
+  /* Parse and process the list of characters and ranges in brackets */
7e0a4d
+  if (!no_wild && allow_regex && c == '[')
7e0a4d
+  {
7e0a4d
+    int e;              /* flag true if next char to be taken literally */
7e0a4d
+    ZCONST char *q;     /* pointer to end of [-] group */
7e0a4d
+    int r;              /* flag true to match anything but the range */
7e0a4d
+
7e0a4d
+    if (*s == 0)                        /* need a character to match */
7e0a4d
+      return 0;
7e0a4d
+    p += (r = (*p == '!' || *p == '^')); /* see if reverse */
7e0a4d
+    for (q = p, e = 0; *q; q++)         /* find closing bracket */
7e0a4d
+      if (e)
7e0a4d
+        e = 0;
7e0a4d
+      else
7e0a4d
+        if (*q == '\\')
7e0a4d
+          e = 1;
7e0a4d
+        else if (*q == ']')
7e0a4d
+          break;
7e0a4d
+    if (*q != ']')                      /* nothing matches if bad syntax */
7e0a4d
+      return 0;
7e0a4d
+    for (c = 0, e = *p == '-'; p < q; p++)      /* go through the list */
7e0a4d
+    {
7e0a4d
+      if (e == 0 && *p == '\\')         /* set escape flag if \ */
7e0a4d
+        e = 1;
7e0a4d
+      else if (e == 0 && *p == '-')     /* set start of range if - */
7e0a4d
+        c = *(p-1);
7e0a4d
+      else
7e0a4d
+      {
7e0a4d
+        uch cc = (cs ? (uch)*s : case_map((uch)*s));
7e0a4d
+        uch uc = (uch) c;
7e0a4d
+        if (*(p+1) != '-')
7e0a4d
+          for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
7e0a4d
+            /* compare range */
7e0a4d
+            if ((cs ? uc : case_map(uc)) == cc)
7e0a4d
+              return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
7e0a4d
+        c = e = 0;                      /* clear range, escape flags */
7e0a4d
+      }
7e0a4d
+    }
7e0a4d
+    return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
7e0a4d
+                                        /* bracket match failed */
7e0a4d
+  }
7e0a4d
+#endif /* !VMS */
7e0a4d
 
7e0a4d
-    /* just a character--compare it */
7e0a4d
-#ifdef QDOS
7e0a4d
-    return QMatch(Case((uch)c), Case(*s)) ?
7e0a4d
-           recmatch(p, s + CLEN(s), ic __WDL) : 0;
7e0a4d
-#else
7e0a4d
-    return Case((uch)c) == Case(*s) ?
7e0a4d
-           recmatch(p, s + CLEN(s), ic __WDL) : 0;
7e0a4d
-#endif
7e0a4d
+  /* If escape ('\'), just compare next character */
7e0a4d
+  if (!no_wild && c == '\\')
7e0a4d
+    if ((c = *p++) == '\0')             /* if \ at end, then syntax error */
7e0a4d
+      return 0;
7e0a4d
+
7e0a4d
+#ifdef VMS
7e0a4d
+  /* 2005-11-06 SMS.
7e0a4d
+     Handle "..." wildcard in p with "." or "]" in s.
7e0a4d
+  */
7e0a4d
+  if ((c == '.') && (*p == '.') && (*(p+ CLEN( p)) == '.') &&
7e0a4d
+   ((*s == '.') || (*s == ']')))
7e0a4d
+  {
7e0a4d
+    /* Match "...]" with "]".  Continue after "]" in both. */
7e0a4d
+    if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
7e0a4d
+      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
7e0a4d
+
7e0a4d
+    /* Else, look for a reduced match in s, until "]" in or end of s. */
7e0a4d
+    for (; *s && (*s != ']'); INCSTR(s))
7e0a4d
+      if (*s == '.')
7e0a4d
+        /* If reduced match, then continue after "..." in p, "." in s. */
7e0a4d
+        if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
7e0a4d
+          return (int)c;
7e0a4d
+
7e0a4d
+    /* Match "...]" with "]".  Continue after "]" in both. */
7e0a4d
+    if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
7e0a4d
+      return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
7e0a4d
+
7e0a4d
+    /* No reduced match.  Quit. */
7e0a4d
+    return 2;
7e0a4d
+  }
7e0a4d
+
7e0a4d
+#endif /* def VMS */
7e0a4d
+
7e0a4d
+  /* Just a character--compare it */
7e0a4d
+  return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
7e0a4d
+          recmatch(p, s + CLEN(s), cs) : 0;
7e0a4d
+}
7e0a4d
 
7e0a4d
-} /* end function recmatch() */
7e0a4d
 
7e0a4d
 
7e0a4d
 
7e0a4d
+/*************************************************************************************************/
7e0a4d
 static char *isshexp(p)
7e0a4d
 ZCONST char *p;
7e0a4d
 /* If p is a sh expression, a pointer to the first special character is