Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bacula.h"
-
-
-/* Enable GNU extensions in fnmatch.h. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
#include "fnmatch.h"
switch (c)
{
- case '?':
- if (*n == '\0')
+ case '?':
+ if (*n == '\0')
return FNM_NOMATCH;
- else if ((flags & FNM_FILE_NAME) && *n == '/')
+ else if ((flags & FNM_FILE_NAME) && *n == '/')
return FNM_NOMATCH;
- else if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ else if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
break;
- case '\\':
+ case '\\':
if (!(flags & FNM_NOESCAPE))
{
c = *p++;
- if (c == '\0')
- /* Trailing \ loses. */
+ if (c == '\0')
+ /* Trailing \ loses. */
return FNM_NOMATCH;
c = FOLD (c);
}
return FNM_NOMATCH;
break;
- case '*':
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ case '*':
+ if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
- for (c = *p++; c == '?' || c == '*'; c = *p++)
+ for (c = *p++; c == '?' || c == '*'; c = *p++)
{
- if ((flags & FNM_FILE_NAME) && *n == '/')
+ if ((flags & FNM_FILE_NAME) && *n == '/')
/* A slash does not match a wildcard under FNM_FILE_NAME. */
return FNM_NOMATCH;
- else if (c == '?')
+ else if (c == '?')
{
/* A ? needs to match one character. */
- if (*n == '\0')
- /* There isn't another character; no match. */
+ if (*n == '\0')
+ /* There isn't another character; no match. */
return FNM_NOMATCH;
else
/* One character of the string is consumed in matching
- this ? wildcard, so *??? won't match if there are
+ this ? wildcard, so *??? won't match if there are
less than three characters. */
++n;
}
}
- if (c == '\0')
+ if (c == '\0')
return 0;
{
- char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
+ char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
c1 = FOLD (c1);
- for (--p; *n != '\0'; ++n)
- if ((c == '[' || FOLD (*n) == c1) &&
+ for (--p; *n != '\0'; ++n)
+ if ((c == '[' || FOLD (*n) == c1) &&
fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
return 0;
return FNM_NOMATCH;
}
- case '[':
+ case '[':
{
/* Nonzero if the sense of the character class is inverted. */
register int nnot;
- if (*n == '\0')
+ if (*n == '\0')
return FNM_NOMATCH;
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+ if ((flags & FNM_PERIOD) && *n == '.' &&
+ (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
- nnot = (*p == '!' || *p == '^');
+ nnot = (*p == '!' || *p == '^');
if (nnot)
++p;
{
register char cstart = c, cend = c;
- if (!(flags & FNM_NOESCAPE) && c == '\\')
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
{
- if (*p == '\0')
+ if (*p == '\0')
return FNM_NOMATCH;
cstart = cend = *p++;
}
cstart = cend = FOLD (cstart);
- if (c == '\0')
+ if (c == '\0')
/* [ (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
c = FOLD (c);
- if ((flags & FNM_FILE_NAME) && c == '/')
+ if ((flags & FNM_FILE_NAME) && c == '/')
/* [/] can never match. */
return FNM_NOMATCH;
- if (c == '-' && *p != ']')
+ if (c == '-' && *p != ']')
{
cend = *p++;
- if (!(flags & FNM_NOESCAPE) && cend == '\\')
+ if (!(flags & FNM_NOESCAPE) && cend == '\\')
cend = *p++;
- if (cend == '\0')
+ if (cend == '\0')
return FNM_NOMATCH;
cend = FOLD (cend);
if (FOLD (*n) >= cstart && FOLD (*n) <= cend)
goto matched;
- if (c == ']')
+ if (c == ']')
break;
}
if (!nnot)
matched:;
/* Skip the rest of the [...] that already matched. */
- while (c != ']')
+ while (c != ']')
{
- if (c == '\0')
+ if (c == '\0')
/* [... (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
- if (!(flags & FNM_NOESCAPE) && c == '\\')
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
{
- if (*p == '\0')
+ if (*p == '\0')
return FNM_NOMATCH;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
-Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#ifndef _FNMATCH_H
+#ifndef _FNMATCH_H
-#define _FNMATCH_H 1
+#define _FNMATCH_H 1
#ifdef __cplusplus
extern "C" {
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
#undef __P
-#define __P(protos) protos
+#define __P(protos) protos
#else /* Not C++ or ANSI C. */
#undef __P
-#define __P(protos) ()
+#define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
#undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
-#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
-#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
-#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
-
-#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
-#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
-#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
-#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
-#endif
+#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
+#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
+
+/* #if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) */
+#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
+#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+/* #endif -- kes 12Jan05 */
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
-#define FNM_NOMATCH 1
+#define FNM_NOMATCH 1
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */