return 1;
}
-
-/*
- * collapse()
- * Collapse a pattern string into minimal components.
- * This particular version is "in place", so that it changes the pattern
- * which is to be reduced to a "minimal" size.
- *
- * (C) Carlo Wood - 6 Oct 1998
- * Speedup rewrite by Andrea Cocito, December 1998.
- * Note that this new optimized algorithm can *only* work in place.
- */
-
-/*! \brief Collapse a mask string to remove redundancies.
- * Specifically, it replaces a sequence of '*' followed by additional
- * '*' or '?' with the same number of '?'s as the input, followed by
- * one '*'. This minimizes useless backtracking when matching later.
- * \param mask Mask string to collapse.
- * \return Pointer to the start of the string.
- */
-char *
-collapse(char *mask)
-{
- unsigned int star = 0;
- char *m = mask;
- char *b = NULL;
-
- if (m)
- {
- do
- {
- if ((*m == '*') && (*(m + 1) == '*' || *(m + 1) == '?'))
- {
- b = m;
-
- do
- {
- if (*m == '*')
- star = 1;
- else
- {
- if (star && (*m != '?'))
- {
- *b++ = '*';
- star = 0;
- }
-
- *b++ = *m;
-
- if ((*m == '\\') && (*(m + 1) == '*' || *(m + 1) == '?'))
- *b++ = *++m;
- }
- } while (*m++);
-
- break;
- }
- else
- {
- if ((*m == '\\') && (*(m + 1) == '*' || *(m + 1) == '?'))
- ++m;
- }
- } while (*m++);
- }
-
- return mask;
-}
#define EmptyString(x) (!(x) || (*(x) == '\0'))
extern int match(const char *, const char *);
-extern char *collapse(char *);
#endif