Oops again: fix use of classpath.c.
[gnulib.git] / lib / regex.c
index 904b481..d715aa8 100644 (file)
@@ -4,7 +4,7 @@
    internationalization features.)
 
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004 Free Software Foundation, Inc.
+   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
@@ -18,7 +18,7 @@
 
    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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* AIX requires this to be the first thing in the file. */
 #if defined _AIX && !defined REGEX_MALLOC
@@ -41,6 +41,9 @@
 /* For platform which support the ISO C amendement 1 functionality we
    support user defined character classes.  */
 # if defined _LIBC || WIDE_CHAR_SUPPORT
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
+   before <wchar.h>. */
+#  include <stdio.h>
 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.  */
 #  include <wchar.h>
 #  include <wctype.h>
@@ -2079,7 +2082,8 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
     bufp->allocated <<= 1;                                             \
     if (bufp->allocated > MAX_BUF_SIZE)                                        \
       bufp->allocated = MAX_BUF_SIZE;                                  \
-    bufp->buffer = REALLOC (COMPILED_BUFFER_VAR, bufp->allocated);     \
+    bufp->buffer                                                       \
+      = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR, bufp->allocated);    \
     if (COMPILED_BUFFER_VAR == NULL)                                   \
       return REG_ESPACE;                                               \
     /* If the buffer moved, move all the pointers into it.  */         \
@@ -6010,19 +6014,22 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
             longest match, try backtracking.  */
          if (d != end_match_2)
            {
-             /* 1 if this match ends in the same string (string1 or string2)
-                as the best previous match.  */
-             boolean same_str_p = (FIRST_STRING_P (match_end)
-                                   == MATCHING_IN_FIRST_STRING);
              /* 1 if this match is the best seen so far.  */
              boolean best_match_p;
 
-             /* AIX compiler got confused when this was combined
-                with the previous declaration.  */
-             if (same_str_p)
-               best_match_p = d > match_end;
-             else
-               best_match_p = !MATCHING_IN_FIRST_STRING;
+             {
+               /* 1 if this match ends in the same string (string1 or string2)
+                  as the best previous match.  */
+               boolean same_str_p = (FIRST_STRING_P (match_end)
+                                     == MATCHING_IN_FIRST_STRING);
+
+               /* AIX compiler got confused when this was combined
+                  with the previous declaration.  */
+               if (same_str_p)
+                 best_match_p = d > match_end;
+               else
+                 best_match_p = !MATCHING_IN_FIRST_STRING;
+             }
 
              DEBUG_PRINT1 ("backtracking.\n");
 
@@ -8014,14 +8021,15 @@ regcomp (regex_t *preg, const char *pattern, int cflags)
   preg->used = 0;
 
   /* Try to allocate space for the fastmap.  */
-  preg->fastmap = malloc (1 << BYTEWIDTH);
+  preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
 
   if (cflags & REG_ICASE)
     {
       unsigned i;
 
-      preg->translate = malloc (CHAR_SET_SIZE
-                               * sizeof (*(RE_TRANSLATE_TYPE)0));
+      preg->translate =
+       (RE_TRANSLATE_TYPE)
+       malloc (CHAR_SET_SIZE * sizeof (*(RE_TRANSLATE_TYPE)0));
       if (preg->translate == NULL)
         return (int) REG_ESPACE;