Back to index

glibc  2.9
Defines | Functions | Variables
fnmatch.c File Reference
#include <assert.h>
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#include <strings.h>
#include "fnmatch_loop.c"

Go to the source code of this file.

Defines

#define _GNU_SOURCE   1
#define NO_LEADING_PERIOD(flags)   ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
#define ISASCII(c)   1
#define ISBLANK(c)   ((c) == ' ' || (c) == '\t')
#define ISGRAPH(c)   (ISASCII (c) && isprint (c) && !isspace (c))
#define ISPRINT(c)   (ISASCII (c) && isprint (c))
#define ISDIGIT(c)   (ISASCII (c) && isdigit (c))
#define ISALNUM(c)   (ISASCII (c) && isalnum (c))
#define ISALPHA(c)   (ISASCII (c) && isalpha (c))
#define ISCNTRL(c)   (ISASCII (c) && iscntrl (c))
#define ISLOWER(c)   (ISASCII (c) && islower (c))
#define ISPUNCT(c)   (ISASCII (c) && ispunct (c))
#define ISSPACE(c)   (ISASCII (c) && isspace (c))
#define ISUPPER(c)   (ISASCII (c) && isupper (c))
#define ISXDIGIT(c)   (ISASCII (c) && isxdigit (c))
#define STREQ(s1, s2)   ((strcmp (s1, s2) == 0))
#define CHAR_CLASS_MAX_LENGTH   6 /* Namely, `xdigit'. */
#define IS_CHAR_CLASS(string)
#define internal_function
#define FOLD(c)   ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
#define CHAR   char
#define UCHAR   unsigned char
#define INT   int
#define FCT   internal_fnmatch
#define EXT   ext_match
#define END   end_pattern
#define STRUCT   fnmatch_struct
#define L(CS)   CS
#define BTOWC(C)   btowc (C)
#define STRLEN(S)   strlen (S)
#define STRCAT(D, S)   strcat (D, S)
#define MEMPCPY(D, S, N)   __mempcpy (D, S, N)
#define MEMCHR(S, C, N)   memchr (S, C, N)
#define STRCOLL(S1, S2)   strcoll (S1, S2)

Functions

char * getenv ()
static char * __strchrnul (char *s, int c) const
int fnmatch (char *pattern, const char *string, int flags) const

Variables

int errno
static int posixly_correct

Define Documentation

#define _GNU_SOURCE   1

Definition at line 26 of file fnmatch.c.

#define BTOWC (   C)    btowc (C)

Definition at line 217 of file fnmatch.c.

#define CHAR   char

Definition at line 206 of file fnmatch.c.

#define CHAR_CLASS_MAX_LENGTH   6 /* Namely, `xdigit'. */

Definition at line 141 of file fnmatch.c.

#define END   end_pattern

Definition at line 211 of file fnmatch.c.

#define EXT   ext_match

Definition at line 210 of file fnmatch.c.

#define FCT   internal_fnmatch

Definition at line 209 of file fnmatch.c.

#define FOLD (   c)    ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))

Definition at line 204 of file fnmatch.c.

#define INT   int

Definition at line 208 of file fnmatch.c.

Definition at line 197 of file fnmatch.c.

#define IS_CHAR_CLASS (   string)
Value:
(STREQ (string, "alpha") || STREQ (string, "upper")                         \
    || STREQ (string, "lower") || STREQ (string, "digit")                   \
    || STREQ (string, "alnum") || STREQ (string, "xdigit")                  \
    || STREQ (string, "space") || STREQ (string, "print")                   \
    || STREQ (string, "punct") || STREQ (string, "graph")                   \
    || STREQ (string, "cntrl") || STREQ (string, "blank"))

Definition at line 143 of file fnmatch.c.

#define ISALNUM (   c)    (ISASCII (c) && isalnum (c))

Definition at line 101 of file fnmatch.c.

#define ISALPHA (   c)    (ISASCII (c) && isalpha (c))

Definition at line 102 of file fnmatch.c.

#define ISASCII (   c)    1

Definition at line 83 of file fnmatch.c.

#define ISBLANK (   c)    ((c) == ' ' || (c) == '\t')

Definition at line 91 of file fnmatch.c.

#define ISCNTRL (   c)    (ISASCII (c) && iscntrl (c))

Definition at line 103 of file fnmatch.c.

#define ISDIGIT (   c)    (ISASCII (c) && isdigit (c))

Definition at line 100 of file fnmatch.c.

#define ISGRAPH (   c)    (ISASCII (c) && isprint (c) && !isspace (c))

Definition at line 96 of file fnmatch.c.

#define ISLOWER (   c)    (ISASCII (c) && islower (c))

Definition at line 104 of file fnmatch.c.

#define ISPRINT (   c)    (ISASCII (c) && isprint (c))

Definition at line 99 of file fnmatch.c.

#define ISPUNCT (   c)    (ISASCII (c) && ispunct (c))

Definition at line 105 of file fnmatch.c.

#define ISSPACE (   c)    (ISASCII (c) && isspace (c))

Definition at line 106 of file fnmatch.c.

#define ISUPPER (   c)    (ISASCII (c) && isupper (c))

Definition at line 107 of file fnmatch.c.

#define ISXDIGIT (   c)    (ISASCII (c) && isxdigit (c))

Definition at line 108 of file fnmatch.c.

#define L (   CS)    CS

Definition at line 213 of file fnmatch.c.

#define MEMCHR (   S,
  C,
  N 
)    memchr (S, C, N)

Definition at line 222 of file fnmatch.c.

#define MEMPCPY (   D,
  S,
  N 
)    __mempcpy (D, S, N)

Definition at line 221 of file fnmatch.c.

Definition at line 68 of file fnmatch.c.

#define STRCAT (   D,
  S 
)    strcat (D, S)

Definition at line 220 of file fnmatch.c.

#define STRCOLL (   S1,
  S2 
)    strcoll (S1, S2)

Definition at line 223 of file fnmatch.c.

#define STREQ (   s1,
  s2 
)    ((strcmp (s1, s2) == 0))

Definition at line 110 of file fnmatch.c.

#define STRLEN (   S)    strlen (S)

Definition at line 219 of file fnmatch.c.

#define STRUCT   fnmatch_struct

Definition at line 212 of file fnmatch.c.

#define UCHAR   unsigned char

Definition at line 207 of file fnmatch.c.


Function Documentation

static char* __strchrnul ( char *  s,
int  c 
) const [static]

Definition at line 170 of file fnmatch.c.

{
  char *result = strchr (s, c);
  if (result == NULL)
    result = strchr (s, '\0');
  return result;
}
int fnmatch ( char *  pattern,
const char *  string,
int  flags 
) const

Definition at line 322 of file fnmatch.c.

{
# if HANDLE_MULTIBYTE
  if (__builtin_expect (MB_CUR_MAX, 1) != 1)
    {
      mbstate_t ps;
      size_t n;
      const char *p;
      wchar_t *wpattern;
      wchar_t *wstring;

      /* Convert the strings into wide characters.  */
      memset (&ps, '\0', sizeof (ps));
      p = pattern;
#ifdef _LIBC
      n = strnlen (pattern, 1024);
#else
      n = strlen (pattern);
#endif
      if (__builtin_expect (n < 1024, 1))
       {
         wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
         n = mbsrtowcs (wpattern, &p, n + 1, &ps);
         if (__builtin_expect (n == (size_t) -1, 0))
           /* Something wrong.
              XXX Do we have to set `errno' to something which mbsrtows hasn't
              already done?  */
           return -1;
         if (p)
           {
             memset (&ps, '\0', sizeof (ps));
             goto prepare_wpattern;
           }
       }
      else
       {
       prepare_wpattern:
         n = mbsrtowcs (NULL, &pattern, 0, &ps);
         if (__builtin_expect (n == (size_t) -1, 0))
           /* Something wrong.
              XXX Do we have to set `errno' to something which mbsrtows hasn't
              already done?  */
           return -1;
         wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
         assert (mbsinit (&ps));
         (void) mbsrtowcs (wpattern, &pattern, n + 1, &ps);
       }

      assert (mbsinit (&ps));
#ifdef _LIBC
      n = strnlen (string, 1024);
#else
      n = strlen (string);
#endif
      p = string;
      if (__builtin_expect (n < 1024, 1))
       {
         wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
         n = mbsrtowcs (wstring, &p, n + 1, &ps);
         if (__builtin_expect (n == (size_t) -1, 0))
           /* Something wrong.
              XXX Do we have to set `errno' to something which mbsrtows hasn't
              already done?  */
           return -1;
         if (p)
           {
             memset (&ps, '\0', sizeof (ps));
             goto prepare_wstring;
           }
       }
      else
       {
       prepare_wstring:
         n = mbsrtowcs (NULL, &string, 0, &ps);
         if (__builtin_expect (n == (size_t) -1, 0))
           /* Something wrong.
              XXX Do we have to set `errno' to something which mbsrtows hasn't
              already done?  */
           return -1;
         wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t));
         assert (mbsinit (&ps));
         (void) mbsrtowcs (wstring, &string, n + 1, &ps);
       }

      return internal_fnwmatch (wpattern, wstring, wstring + n,
                            flags & FNM_PERIOD, flags, NULL);
    }
# endif  /* mbstate_t and mbsrtowcs or _LIBC.  */

  return internal_fnmatch (pattern, string, string + strlen (string),
                        flags & FNM_PERIOD, flags, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getenv ( )

Here is the caller graph for this function:


Variable Documentation

Definition at line 22 of file sysdep.c.

int posixly_correct [static]

Definition at line 164 of file fnmatch.c.