]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update from gnulib.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Jul 2006 14:52:39 +0000 (14:52 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:39 +0000 (12:13 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/fnmatch.c
gettext-tools/lib/fnmatch_.h
gettext-tools/lib/fnmatch_loop.c
gettext-tools/lib/full-write.c
gettext-tools/lib/fwriteerror.c
gettext-tools/m4/ChangeLog
gettext-tools/m4/fnmatch.m4

index f9f6a4d72ba52d1de4a0a4ce46f842ce5a161e67..1224069cb339f929aa90f3388fb7fe3e20a9237e 100644 (file)
@@ -1,5 +1,7 @@
 2006-07-22  Bruno Haible  <bruno@clisp.org>
 
+       * fwriteerror.c: Update from gnulib.
+
        * fnmatch_.h: Update from gnulib.
        * fnmatch.c: Likewise.
        * fnmatch_loop.c: Likewise.
index 81e3002dca4d9e6dd0fd271467fdaf6f7445e9c5..bd413588526dde66bf048e7cb76eb4d7557c17c7 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-1993,1996-1999,2000-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
+       Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -85,12 +86,9 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
 #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
 
 
-# ifndef isblank
+# if ! (defined isblank || HAVE_DECL_ISBLANK)
 #  define isblank(c) ((c) == ' ' || (c) == '\t')
 # endif
-# ifndef isgraph
-#  define isgraph(c) (isprint (c) && !isspace (c))
-# endif
 
 # define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
 
@@ -147,18 +145,14 @@ static int posixly_correct;
 # endif
 
 /* Note that this evaluates C many times.  */
-# ifdef _LIBC
-#  define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
-# else
-#  define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
-# endif
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? 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 L(CS) CS
+# define L_(CS)        CS
 # ifdef _LIBC
 #  define BTOWC(C)     __btowc (C)
 # else
@@ -188,7 +182,7 @@ static int posixly_correct;
 #  define FCT  internal_fnwmatch
 #  define EXT  ext_wmatch
 #  define END  end_wpattern
-#  define L(CS)        L##CS
+#  define L_(CS)       L##CS
 #  define BTOWC(C)     (C)
 #  ifdef _LIBC
 #   define STRLEN(S) __wcslen (S)
@@ -297,54 +291,51 @@ fnmatch (const char *pattern, const char *string, int flags)
         wide characters.  */
       memset (&ps, '\0', sizeof (ps));
       patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
-      if (__builtin_expect (patsize == 0, 0))
-       /* Something wrong.
-          XXX Do we have to set `errno' to something which mbsrtows hasn't
-          already done?  */
-       return -1;
-      assert (mbsinit (&ps));
-      strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
-      if (__builtin_expect (strsize == 0, 0))
-       /* Something wrong.
-          XXX Do we have to set `errno' to something which mbsrtows hasn't
-          already done?  */
-       return -1;
-      assert (mbsinit (&ps));
-      totsize = patsize + strsize;
-      if (__builtin_expect (! (patsize <= totsize
-                              && totsize <= SIZE_MAX / sizeof (wchar_t)),
-                           0))
+      if (__builtin_expect (patsize != 0, 1))
        {
-         errno = ENOMEM;
-         return -1;
-       }
-
-      /* Allocate room for the wide characters.  */
-      if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
-       wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
-      else
-       {
-         wpattern = malloc (totsize * sizeof (wchar_t));
-         if (__builtin_expect (! wpattern, 0))
+         assert (mbsinit (&ps));
+         strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
+         if (__builtin_expect (strsize != 0, 1))
            {
-             errno = ENOMEM;
-             return -1;
+             assert (mbsinit (&ps));
+             totsize = patsize + strsize;
+             if (__builtin_expect (! (patsize <= totsize
+                                      && totsize <= SIZE_MAX / sizeof (wchar_t)),
+                                   0))
+               {
+                 errno = ENOMEM;
+                 return -1;
+               }
+
+             /* Allocate room for the wide characters.  */
+             if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
+               wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
+             else
+               {
+                 wpattern = malloc (totsize * sizeof (wchar_t));
+                 if (__builtin_expect (! wpattern, 0))
+                   {
+                     errno = ENOMEM;
+                     return -1;
+                   }
+               }
+             wstring = wpattern + patsize;
+
+             /* Convert the strings into wide characters.  */
+             mbsrtowcs (wpattern, &pattern, patsize, &ps);
+             assert (mbsinit (&ps));
+             mbsrtowcs (wstring, &string, strsize, &ps);
+
+             res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
+                                      flags & FNM_PERIOD, flags);
+
+             if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
+               free (wpattern);
+             return res;
            }
        }
-      wstring = wpattern + patsize;
-
-      /* Convert the strings into wide characters.  */
-      mbsrtowcs (wpattern, &pattern, patsize, &ps);
-      assert (mbsinit (&ps));
-      mbsrtowcs (wstring, &string, strsize, &ps);
-
-      res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
-                              flags & FNM_PERIOD, flags);
-
-      if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
-       free (wpattern);
-      return res;
     }
+
 # endif /* HANDLE_MULTIBYTE */
 
   return internal_fnmatch (pattern, string, string + strlen (string),
index a88d323a3fddb5a1483b0604796c12f065246e71..fecada57fbde5945a2d666676ef515240488c059 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003
-   Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
+   2005 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ extern "C" {
 #  define FNM_NOSYS    (-1)
 # endif
 
-/* Match NAME against the filename pattern PATTERN,
+/* Match NAME against the file name pattern PATTERN,
    returning zero if it matches, FNM_NOMATCH if not.  */
 extern int fnmatch (const char *__pattern, const char *__name,
                    int __flags);
index e6f0ef39f5e2da38d730edae47e8aa72526a9fd4..308d311f9f8366aaa82b7ff30776e907f22b439f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993,1996-1999,2000-2004,2006
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
        Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-/* Match STRING against the filename pattern PATTERN, returning zero if
+/* Match STRING against the file name pattern PATTERN, returning zero if
    it matches, nonzero if not.  */
 static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
                const CHAR *string_end, bool no_leading_period, int flags)
@@ -39,14 +39,14 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 # endif
 #endif
 
-  while ((c = *p++) != L('\0'))
+  while ((c = *p++) != L_('\0'))
     {
       bool new_no_leading_period = false;
       c = FOLD (c);
 
       switch (c)
        {
-       case L('?'):
+       case L_('?'):
          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
            {
              int res;
@@ -59,17 +59,17 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 
          if (n == string_end)
            return FNM_NOMATCH;
-         else if (*n == L('/') && (flags & FNM_FILE_NAME))
+         else if (*n == L_('/') && (flags & FNM_FILE_NAME))
            return FNM_NOMATCH;
-         else if (*n == L('.') && no_leading_period)
+         else if (*n == L_('.') && no_leading_period)
            return FNM_NOMATCH;
          break;
 
-       case L('\\'):
+       case L_('\\'):
          if (!(flags & FNM_NOESCAPE))
            {
              c = *p++;
-             if (c == L('\0'))
+             if (c == L_('\0'))
                /* Trailing \ loses.  */
                return FNM_NOMATCH;
              c = FOLD (c);
@@ -78,7 +78,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            return FNM_NOMATCH;
          break;
 
-       case L('*'):
+       case L_('*'):
          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
            {
              int res;
@@ -89,12 +89,12 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                return res;
            }
 
-         if (n != string_end && *n == L('.') && no_leading_period)
+         if (n != string_end && *n == L_('.') && no_leading_period)
            return FNM_NOMATCH;
 
-         for (c = *p++; c == L('?') || c == L('*'); c = *p++)
+         for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
            {
-             if (*p == L('(') && (flags & FNM_EXTMATCH) != 0)
+             if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
                {
                  const CHAR *endp = END (p);
                  if (endp != p)
@@ -105,13 +105,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    }
                }
 
-             if (c == L('?'))
+             if (c == L_('?'))
                {
                  /* A ? needs to match one character.  */
                  if (n == string_end)
                    /* There isn't another character; no match.  */
                    return FNM_NOMATCH;
-                 else if (*n == L('/')
+                 else if (*n == L_('/')
                           && __builtin_expect (flags & FNM_FILE_NAME, 0))
                    /* A slash does not match a wildcard under
                       FNM_FILE_NAME.  */
@@ -124,7 +124,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                }
            }
 
-         if (c == L('\0'))
+         if (c == L_('\0'))
            /* The wildcard(s) is/are the last element of the pattern.
               If the name is a file name and contains another slash
               this means it cannot match, unless the FNM_LEADING_DIR
@@ -138,7 +138,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    result = 0;
                  else
                    {
-                     if (MEMCHR (n, L('/'), string_end - n) == NULL)
+                     if (MEMCHR (n, L_('/'), string_end - n) == NULL)
                        result = 0;
                    }
                }
@@ -149,15 +149,15 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            {
              const CHAR *endp;
 
-             endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L('/') : L('\0'),
+             endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
                             string_end - n);
              if (endp == NULL)
                endp = string_end;
 
-             if (c == L('[')
+             if (c == L_('[')
                  || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
-                     && (c == L('@') || c == L('+') || c == L('!'))
-                     && *p == L('(')))
+                     && (c == L_('@') || c == L_('+') || c == L_('!'))
+                     && *p == L_('(')))
                {
                  int flags2 = ((flags & FNM_FILE_NAME)
                                ? flags : (flags & ~FNM_PERIOD));
@@ -168,11 +168,11 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        == 0)
                      return 0;
                }
-             else if (c == L('/') && (flags & FNM_FILE_NAME))
+             else if (c == L_('/') && (flags & FNM_FILE_NAME))
                {
-                 while (n < string_end && *n != L('/'))
+                 while (n < string_end && *n != L_('/'))
                    ++n;
-                 if (n < string_end && *n == L('/')
+                 if (n < string_end && *n == L_('/')
                      && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
                          == 0))
                    return 0;
@@ -183,7 +183,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                                ? flags : (flags & ~FNM_PERIOD));
                  int no_leading_period2 = no_leading_period;
 
-                 if (c == L('\\') && !(flags & FNM_NOESCAPE))
+                 if (c == L_('\\') && !(flags & FNM_NOESCAPE))
                    c = *p;
                  c = FOLD (c);
                  for (--p; n < endp; ++n, no_leading_period2 = false)
@@ -197,7 +197,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
          /* If we come here no match is possible with the wildcard.  */
          return FNM_NOMATCH;
 
-       case L('['):
+       case L_('['):
          {
            /* Nonzero if the sense of the character class is inverted.  */
            register bool not;
@@ -210,14 +210,14 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            if (n == string_end)
              return FNM_NOMATCH;
 
-           if (*n == L('.') && no_leading_period)
+           if (*n == L_('.') && no_leading_period)
              return FNM_NOMATCH;
 
-           if (*n == L('/') && (flags & FNM_FILE_NAME))
+           if (*n == L_('/') && (flags & FNM_FILE_NAME))
              /* `/' cannot be matched.  */
              return FNM_NOMATCH;
 
-           not = (*p == L('!') || (posixly_correct < 0 && *p == L('^')));
+           not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
            if (not)
              ++p;
 
@@ -226,9 +226,9 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            c = *p++;
            for (;;)
              {
-               if (!(flags & FNM_NOESCAPE) && c == L('\\'))
+               if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
                  {
-                   if (*p == L('\0'))
+                   if (*p == L_('\0'))
                      return FNM_NOMATCH;
                    c = FOLD ((UCHAR) *p);
                    ++p;
@@ -236,7 +236,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    if (c == fn)
                      goto matched;
                  }
-               else if (c == L('[') && *p == L(':'))
+               else if (c == L_('[') && *p == L_(':'))
                  {
                    /* Leave room for the null.  */
                    CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
@@ -254,22 +254,22 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                          return FNM_NOMATCH;
 
                        c = *++p;
-                       if (c == L(':') && p[1] == L(']'))
+                       if (c == L_(':') && p[1] == L_(']'))
                          {
                            p += 2;
                            break;
                          }
-                       if (c < L('a') || c >= L('z'))
+                       if (c < L_('a') || c >= L_('z'))
                          {
                            /* This cannot possibly be a character class name.
                               Match it as a normal range.  */
                            p = startp;
-                           c = L('[');
+                           c = L_('[');
                            goto normal_bracket;
                          }
                        str[c1++] = c;
                      }
-                   str[c1] = L('\0');
+                   str[c1] = L_('\0');
 
 #if defined _LIBC || WIDE_CHAR_SUPPORT
                    wt = IS_CHAR_CLASS (str);
@@ -288,24 +288,24 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                      goto matched;
 # endif
 #else
-                   if ((STREQ (str, L("alnum")) && isalnum ((UCHAR) *n))
-                       || (STREQ (str, L("alpha")) && isalpha ((UCHAR) *n))
-                       || (STREQ (str, L("blank")) && isblank ((UCHAR) *n))
-                       || (STREQ (str, L("cntrl")) && iscntrl ((UCHAR) *n))
-                       || (STREQ (str, L("digit")) && isdigit ((UCHAR) *n))
-                       || (STREQ (str, L("graph")) && isgraph ((UCHAR) *n))
-                       || (STREQ (str, L("lower")) && islower ((UCHAR) *n))
-                       || (STREQ (str, L("print")) && isprint ((UCHAR) *n))
-                       || (STREQ (str, L("punct")) && ispunct ((UCHAR) *n))
-                       || (STREQ (str, L("space")) && isspace ((UCHAR) *n))
-                       || (STREQ (str, L("upper")) && isupper ((UCHAR) *n))
-                       || (STREQ (str, L("xdigit")) && isxdigit ((UCHAR) *n)))
+                   if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
+                       || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
+                       || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
+                       || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
+                       || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
+                       || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
+                       || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
+                       || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
+                       || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
+                       || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
+                       || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
+                       || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
                      goto matched;
 #endif
                    c = *p++;
                  }
 #ifdef _LIBC
-               else if (c == L('[') && *p == L('='))
+               else if (c == L_('[') && *p == L_('='))
                  {
                    UCHAR str[1];
                    uint32_t nrules =
@@ -313,19 +313,19 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    const CHAR *startp = p;
 
                    c = *++p;
-                   if (c == L('\0'))
+                   if (c == L_('\0'))
                      {
                        p = startp;
-                       c = L('[');
+                       c = L_('[');
                        goto normal_bracket;
                      }
                    str[0] = c;
 
                    c = *++p;
-                   if (c != L('=') || p[1] != L(']'))
+                   if (c != L_('=') || p[1] != L_(']'))
                      {
                        p = startp;
-                       c = L('[');
+                       c = L_('[');
                        goto normal_bracket;
                      }
                    p += 2;
@@ -405,7 +405,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    c = *p++;
                  }
 #endif
-               else if (c == L('\0'))
+               else if (c == L_('\0'))
                  /* [ (unterminated) loses.  */
                  return FNM_NOMATCH;
                else
@@ -415,7 +415,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 #ifdef _LIBC
                    bool is_seqval = false;
 
-                   if (c == L('[') && *p == L('.'))
+                   if (c == L_('[') && *p == L_('.'))
                      {
                        uint32_t nrules =
                          _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -425,7 +425,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        while (1)
                          {
                            c = *++p;
-                           if (c == L('.') && p[1] == L(']'))
+                           if (c == L_('.') && p[1] == L_(']'))
                              {
                                p += 2;
                                break;
@@ -438,7 +438,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        /* We have to handling the symbols differently in
                           ranges since then the collation sequence is
                           important.  */
-                       is_range = *p == L('-') && p[1] != L('\0');
+                       is_range = *p == L_('-') && p[1] != L_('\0');
 
                        if (nrules == 0)
                          {
@@ -586,8 +586,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        /* We have to handling the symbols differently in
                           ranges since then the collation sequence is
                           important.  */
-                       is_range = (*p == L('-') && p[1] != L('\0')
-                                   && p[1] != L(']'));
+                       is_range = (*p == L_('-') && p[1] != L_('\0')
+                                   && p[1] != L_(']'));
 
                        if (!is_range && c == fn)
                          goto matched;
@@ -596,7 +596,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        c = *p++;
                      }
 
-                   if (c == L('-') && *p != L(']'))
+                   if (c == L_('-') && *p != L_(']'))
                      {
 #if _LIBC
                        /* We have to find the collation sequence
@@ -630,7 +630,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 # endif
 
                        is_seqval = false;
-                       if (cend == L('[') && *p == L('.'))
+                       if (cend == L_('[') && *p == L_('.'))
                          {
                            uint32_t nrules =
                              _NL_CURRENT_WORD (LC_COLLATE,
@@ -641,7 +641,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                            while (1)
                              {
                                c = *++p;
-                               if (c == L('.') && p[1] == L(']'))
+                               if (c == L_('.') && p[1] == L_(']'))
                                  {
                                    p += 2;
                                    break;
@@ -760,9 +760,9 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                          }
                        else
                          {
-                           if (!(flags & FNM_NOESCAPE) && cend == L('\\'))
+                           if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
                              cend = *p++;
-                           if (cend == L('\0'))
+                           if (cend == L_('\0'))
                              return FNM_NOMATCH;
                            cend = FOLD (cend);
                          }
@@ -814,9 +814,9 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                           and sometimes fatal consequences.  */
                        UCHAR cend = *p++;
 
-                       if (!(flags & FNM_NOESCAPE) && cend == L('\\'))
+                       if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
                          cend = *p++;
-                       if (cend == L('\0'))
+                       if (cend == L_('\0'))
                          return FNM_NOMATCH;
 
                        /* It is a range.  */
@@ -828,7 +828,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                      }
                  }
 
-               if (c == L(']'))
+               if (c == L_(']'))
                  break;
              }
 
@@ -843,18 +843,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
              ignore_next:
                c = *p++;
 
-               if (c == L('\0'))
+               if (c == L_('\0'))
                  /* [... (unterminated) loses.  */
                  return FNM_NOMATCH;
 
-               if (!(flags & FNM_NOESCAPE) && c == L('\\'))
+               if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
                  {
-                   if (*p == L('\0'))
+                   if (*p == L_('\0'))
                      return FNM_NOMATCH;
                    /* XXX 1003.2d11 is unclear if this is right.  */
                    ++p;
                  }
-               else if (c == L('[') && *p == L(':'))
+               else if (c == L_('[') && *p == L_(':'))
                  {
                    int c1 = 0;
                    const CHAR *startp = p;
@@ -865,10 +865,10 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        if (++c1 == CHAR_CLASS_MAX_LENGTH)
                          return FNM_NOMATCH;
 
-                       if (*p == L(':') && p[1] == L(']'))
+                       if (*p == L_(':') && p[1] == L_(']'))
                          break;
 
-                       if (c < L('a') || c >= L('z'))
+                       if (c < L_('a') || c >= L_('z'))
                          {
                            p = startp;
                            goto ignore_next;
@@ -877,18 +877,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                    p += 2;
                    c = *p++;
                  }
-               else if (c == L('[') && *p == L('='))
+               else if (c == L_('[') && *p == L_('='))
                  {
                    c = *++p;
-                   if (c == L('\0'))
+                   if (c == L_('\0'))
                      return FNM_NOMATCH;
                    c = *++p;
-                   if (c != L('=') || p[1] != L(']'))
+                   if (c != L_('=') || p[1] != L_(']'))
                      return FNM_NOMATCH;
                    p += 2;
                    c = *p++;
                  }
-               else if (c == L('[') && *p == L('.'))
+               else if (c == L_('[') && *p == L_('.'))
                  {
                    ++p;
                    while (1)
@@ -897,22 +897,22 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                        if (c == '\0')
                          return FNM_NOMATCH;
 
-                       if (*p == L('.') && p[1] == L(']'))
+                       if (*p == L_('.') && p[1] == L_(']'))
                          break;
                      }
                    p += 2;
                    c = *p++;
                  }
              }
-           while (c != L(']'));
+           while (c != L_(']'));
            if (not)
              return FNM_NOMATCH;
          }
          break;
 
-       case L('+'):
-       case L('@'):
-       case L('!'):
+       case L_('+'):
+       case L_('@'):
+       case L_('!'):
          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
            {
              int res;
@@ -923,7 +923,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            }
          goto normal_match;
 
-       case L('/'):
+       case L_('/'):
          if (NO_LEADING_PERIOD (flags))
            {
              if (n == string_end || c != (UCHAR) *n)
@@ -946,7 +946,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
   if (n == string_end)
     return 0;
 
-  if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L('/'))
+  if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/'))
     /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
     return 0;
 
@@ -961,10 +961,10 @@ END (const CHAR *pattern)
   const CHAR *p = pattern;
 
   while (1)
-    if (*++p == L('\0'))
+    if (*++p == L_('\0'))
       /* This is an invalid pattern.  */
       return pattern;
-    else if (*p == L('['))
+    else if (*p == L_('['))
       {
        /* Handle brackets special.  */
        if (posixly_correct == 0)
@@ -972,21 +972,21 @@ END (const CHAR *pattern)
 
        /* Skip the not sign.  We have to recognize it because of a possibly
           following ']'.  */
-       if (*++p == L('!') || (posixly_correct < 0 && *p == L('^')))
+       if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
          ++p;
        /* A leading ']' is recognized as such.  */
-       if (*p == L(']'))
+       if (*p == L_(']'))
          ++p;
        /* Skip over all characters of the list.  */
-       while (*p != L(']'))
-         if (*p++ == L('\0'))
+       while (*p != L_(']'))
+         if (*p++ == L_('\0'))
            /* This is no valid pattern.  */
            return pattern;
       }
-    else if ((*p == L('?') || *p == L('*') || *p == L('+') || *p == L('@')
-             || *p == L('!')) && p[1] == L('('))
+    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+             || *p == L_('!')) && p[1] == L_('('))
       p = END (p + 1);
-    else if (*p == L(')'))
+    else if (*p == L_(')'))
       break;
 
   return p + 1;
@@ -1014,10 +1014,10 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
   /* Parse the pattern.  Store the individual parts in the list.  */
   level = 0;
   for (startp = p = pattern + 1; ; ++p)
-    if (*p == L('\0'))
+    if (*p == L_('\0'))
       /* This is an invalid pattern.  */
       return -1;
-    else if (*p == L('['))
+    else if (*p == L_('['))
       {
        /* Handle brackets special.  */
        if (posixly_correct == 0)
@@ -1025,22 +1025,22 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 
        /* Skip the not sign.  We have to recognize it because of a possibly
           following ']'.  */
-       if (*++p == L('!') || (posixly_correct < 0 && *p == L('^')))
+       if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
          ++p;
        /* A leading ']' is recognized as such.  */
-       if (*p == L(']'))
+       if (*p == L_(']'))
          ++p;
        /* Skip over all characters of the list.  */
-       while (*p != L(']'))
-         if (*p++ == L('\0'))
+       while (*p != L_(']'))
+         if (*p++ == L_('\0'))
            /* This is no valid pattern.  */
            return -1;
       }
-    else if ((*p == L('?') || *p == L('*') || *p == L('+') || *p == L('@')
-             || *p == L('!')) && p[1] == L('('))
+    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+             || *p == L_('!')) && p[1] == L_('('))
       /* Remember the nesting level.  */
       ++level;
-    else if (*p == L(')'))
+    else if (*p == L_(')'))
       {
        if (level-- == 0)
          {
@@ -1051,7 +1051,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            size_t plensize;                                                  \
            size_t newpsize;                                                  \
                                                                              \
-           plen = (opt == L('?') || opt == L('@')                            \
+           plen = (opt == L_('?') || opt == L_('@')                          \
                    ? pattern_len                                             \
                    : p - startp + 1);                                        \
            plensize = plen * sizeof (CHAR);                                  \
@@ -1061,7 +1061,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
                || ALLOCA_LIMIT <= newpsize)                                  \
              return -1;                                                      \
            newp = (struct patternlist *) alloca (newpsize);                  \
-           *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0');    \
+           *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0');    \
            newp->next = NULL;                                                \
            *lastp = newp;                                                    \
            lastp = &newp->next
@@ -1069,7 +1069,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
            break;
          }
       }
-    else if (*p == L('|'))
+    else if (*p == L_('|'))
       {
        if (level == 0)
          {
@@ -1078,17 +1078,17 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
          }
       }
   assert (list != NULL);
-  assert (p[-1] == L(')'));
+  assert (p[-1] == L_(')'));
 #undef NEW_PATTERN
 
   switch (opt)
     {
-    case L('*'):
+    case L_('*'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
        return 0;
       /* FALLTHROUGH */
 
-    case L('+'):
+    case L_('+'):
       do
        {
          for (rs = string; rs <= string_end; ++rs)
@@ -1120,12 +1120,12 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
       /* None of the patterns lead to a match.  */
       return FNM_NOMATCH;
 
-    case L('?'):
+    case L_('?'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
        return 0;
       /* FALLTHROUGH */
 
-    case L('@'):
+    case L_('@'):
       do
        /* I cannot believe it but `strcat' is actually acceptable
           here.  Match the entire string with the prefix from the
@@ -1141,7 +1141,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
       /* None of the patterns lead to a match.  */
       return FNM_NOMATCH;
 
-    case L('!'):
+    case L_('!'):
       for (rs = string; rs <= string_end; ++rs)
        {
          struct patternlist *runp;
@@ -1188,5 +1188,5 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 #undef STRCOLL
 #undef STRLEN
 #undef STRCAT
-#undef L
+#undef L_
 #undef BTOWC
index 660e92e63cc0e4bf4d9f3d2a035a57ec76da3bbf..c4624e5dc6639a73a5dc14a44e88246db7986e87 100644 (file)
@@ -1,6 +1,7 @@
 /* An interface to read and write that retries (if necessary) until complete.
 
-   Copyright (C) 1993, 1994, 1997-1999, 2000-2005 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
index a88c8e1c3965db0d5d36bf9cb1d7320ae3090c57..f010674ba43a5d95a0fab48eb2efeb6ef45d094b 100644 (file)
@@ -1,5 +1,5 @@
 /* Detect write error on a stream.
-   Copyright (C) 2003-2005 Free Software Foundation, Inc.
+   Copyright (C) 2003-2006 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -47,18 +47,26 @@ fwriteerror (FILE *fp)
   if (ferror (fp))
     {
       if (fflush (fp))
-       return -1; /* errno is set here */
+       goto close_preserving_errno; /* errno is set here */
       /* The stream had an error earlier, but its errno was lost.  If the
         error was not temporary, we can get the same errno by writing and
         flushing one more byte.  We can do so because at this point the
         stream's contents is garbage anyway.  */
       if (fputc ('\0', fp) == EOF)
-       return -1; /* errno is set here */
+       goto close_preserving_errno; /* errno is set here */
       if (fflush (fp))
-       return -1; /* errno is set here */
+       goto close_preserving_errno; /* errno is set here */
       /* Give up on errno.  */
       errno = 0;
-      return -1;
+     close_preserving_errno:
+      /* There's an error.  Nevertheless call fclose(fp), for consistency
+        with the other cases.  */
+      {
+       int saved_errno = errno;
+       fclose (fp);
+       errno = saved_errno;
+       return -1;
+      }
     }
 
   /* If we are closing stdout, don't attempt to do it later again.  */
index 25d97e73e804d633bfd274ae89812b0d566d75dd..b0c025bb29ef3c03e1d15e8fa4c11a68bfc55ae5 100644 (file)
@@ -1,6 +1,9 @@
 2006-07-22  Bruno Haible  <bruno@clisp.org>
 
+       * fnmatch.m4: Update from gnulib.
+
        * error.m4: Update from gnulib.
+       * extensions.m4: Update from gnulib.
 
 2006-07-21  Bruno Haible  <bruno@clisp.org>
 
index f469451bade36c2531f54b3fa24d0b0219f45cb4..ce94c84a701505889fdd58420b7574fa54ab3540 100644 (file)
@@ -3,10 +3,11 @@
 # This is a modified version of autoconf's AC_FUNC_FNMATCH.
 # This file should be simplified after Autoconf 2.57 is required.
 
-dnl Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+# Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
 # -------------------------------------------------------------------------
@@ -27,9 +28,15 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF],
 #         include <fnmatch.h>
 #         define y(a, b, c) (fnmatch (a, b, c) == 0)
 #         define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
+          static int
+          fnm (char const *pattern, char const *string, int flags)
+          {
+            return fnmatch (pattern, string, flags);
+          }
          ],
         [exit
-          (!(y ("a*", "abc", 0)
+          (!((fnm ? fnm : fnmatch) ("a*", "", 0) == FNM_NOMATCH
+             && y ("a*", "abc", 0)
              && n ("d*/*1", "d/s/1", FNM_PATHNAME)
              && y ("a\\\\bc", "abc", 0)
              && n ("a\\\\bc", "abc", FNM_NOESCAPE)
@@ -56,7 +63,7 @@ AS_IF([test $$2 = yes], [$3], [$4])
 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
 [AC_REQUIRE([AC_FUNC_ALLOCA])dnl
 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
-AC_CHECK_DECLS([getenv])
+AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
 AC_CHECK_HEADERS([wchar.h wctype.h])
 AC_LIBOBJ([fnmatch])