OSDN Git Service

Fix missed replacements.
[pf3gnuchains/gcc-fork.git] / libiberty / regex.c
index 555d3bb..66f1ef8 100644 (file)
@@ -2,7 +2,7 @@
    version 0.12.
    (Implements POSIX draft P1003.2/D11.2, except for some of the
    internationalization features.)
-   Copyright (C) 1993-1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1993-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    routines with an "x" prefix so they do not collide with the native regex
    routines or with other components regex routines. */
 /* AIX requires this to be the first thing in the file. */
-#if defined _AIX && !defined REGEX_MALLOC
+#if defined _AIX && !defined __GNUC__ && !defined REGEX_MALLOC
   #pragma alloca
 #endif
 
 #undef _GNU_SOURCE
 #define _GNU_SOURCE
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
+#ifndef INSIDE_RECURSION
+# ifdef HAVE_CONFIG_H
+#  include <config.h>
+# endif
 #endif
 
-#ifndef PARAMS
-# if defined __GNUC__ || (defined __STDC__ && __STDC__)
-#  define PARAMS(args) args
-# else
-#  define PARAMS(args) ()
-# endif  /* GCC.  */
-#endif  /* Not PARAMS.  */
+#include <ansidecl.h>
 
 #ifndef INSIDE_RECURSION
 
@@ -95,7 +91,7 @@
 # endif
 
 /* This is for other GNU distributions with internationalized messages.  */
-# if HAVE_LIBINTL_H || defined _LIBC
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
 #  include <libintl.h>
 #  ifdef _LIBC
 #   undef gettext
@@ -273,10 +269,10 @@ extern char *re_syntax_table;
 
 static char re_syntax_table[CHAR_SET_SIZE];
 
-static void init_syntax_once PARAMS ((void));
+static void init_syntax_once (void);
 
 static void
-init_syntax_once ()
+init_syntax_once (void)
 {
    register int c;
    static int done = 0;
@@ -301,7 +297,7 @@ init_syntax_once ()
 # endif /* emacs */
 \f
 /* Integer type for pointers.  */
-# if !defined _LIBC
+# if !defined _LIBC && !defined HAVE_UINTPTR_T
 typedef unsigned long int uintptr_t;
 # endif
 
@@ -407,44 +403,44 @@ typedef char boolean;
 # define false 0
 # define true 1
 
-static reg_errcode_t byte_regex_compile _RE_ARGS ((const char *pattern, size_t size,
-                                                   reg_syntax_t syntax,
-                                                   struct re_pattern_buffer *bufp));
-
-static int byte_re_match_2_internal PARAMS ((struct re_pattern_buffer *bufp,
-                                            const char *string1, int size1,
-                                            const char *string2, int size2,
-                                            int pos,
-                                            struct re_registers *regs,
-                                            int stop));
-static int byte_re_search_2 PARAMS ((struct re_pattern_buffer *bufp,
-                                    const char *string1, int size1,
-                                    const char *string2, int size2,
-                                    int startpos, int range,
-                                    struct re_registers *regs, int stop));
-static int byte_re_compile_fastmap PARAMS ((struct re_pattern_buffer *bufp));
+static reg_errcode_t byte_regex_compile (const char *pattern, size_t size,
+                                         reg_syntax_t syntax,
+                                         struct re_pattern_buffer *bufp);
+
+static int byte_re_match_2_internal (struct re_pattern_buffer *bufp,
+                                     const char *string1, int size1,
+                                     const char *string2, int size2,
+                                     int pos,
+                                     struct re_registers *regs,
+                                     int stop);
+static int byte_re_search_2 (struct re_pattern_buffer *bufp,
+                             const char *string1, int size1,
+                             const char *string2, int size2,
+                             int startpos, int range,
+                             struct re_registers *regs, int stop);
+static int byte_re_compile_fastmap (struct re_pattern_buffer *bufp);
 
 #ifdef MBS_SUPPORT
-static reg_errcode_t wcs_regex_compile _RE_ARGS ((const char *pattern, size_t size,
-                                                   reg_syntax_t syntax,
-                                                   struct re_pattern_buffer *bufp));
-
-
-static int wcs_re_match_2_internal PARAMS ((struct re_pattern_buffer *bufp,
-                                           const char *cstring1, int csize1,
-                                           const char *cstring2, int csize2,
-                                           int pos,
-                                           struct re_registers *regs,
-                                           int stop,
-                                           wchar_t *string1, int size1,
-                                           wchar_t *string2, int size2,
-                                           int *mbs_offset1, int *mbs_offset2));
-static int wcs_re_search_2 PARAMS ((struct re_pattern_buffer *bufp,
-                                   const char *string1, int size1,
-                                   const char *string2, int size2,
-                                   int startpos, int range,
-                                   struct re_registers *regs, int stop));
-static int wcs_re_compile_fastmap PARAMS ((struct re_pattern_buffer *bufp));
+static reg_errcode_t wcs_regex_compile (const char *pattern, size_t size,
+                                        reg_syntax_t syntax,
+                                        struct re_pattern_buffer *bufp);
+
+
+static int wcs_re_match_2_internal (struct re_pattern_buffer *bufp,
+                                    const char *cstring1, int csize1,
+                                    const char *cstring2, int csize2,
+                                    int pos,
+                                    struct re_registers *regs,
+                                    int stop,
+                                    wchar_t *string1, int size1,
+                                    wchar_t *string2, int size2,
+                                    int *mbs_offset1, int *mbs_offset2);
+static int wcs_re_search_2 (struct re_pattern_buffer *bufp,
+                            const char *string1, int size1,
+                            const char *string2, int size2,
+                            int startpos, int range,
+                            struct re_registers *regs, int stop);
+static int wcs_re_compile_fastmap (struct re_pattern_buffer *bufp);
 #endif
 \f
 /* These are the command codes that appear in compiled regular
@@ -690,11 +686,9 @@ typedef enum
 # endif
 
 # ifdef DEBUG
-static void PREFIX(extract_number) _RE_ARGS ((int *dest, UCHAR_T *source));
+static void PREFIX(extract_number) (int *dest, UCHAR_T *source);
 static void
-PREFIX(extract_number) (dest, source)
-    int *dest;
-    UCHAR_T *source;
+PREFIX(extract_number) (int *dest, UCHAR_T *source)
 {
 #  ifdef WCHAR
   *dest = *source;
@@ -722,12 +716,10 @@ PREFIX(extract_number) (dest, source)
   } while (0)
 
 # ifdef DEBUG
-static void PREFIX(extract_number_and_incr) _RE_ARGS ((int *destination,
-                                                      UCHAR_T **source));
+static void PREFIX(extract_number_and_incr) (int *destination,
+                                             UCHAR_T **source);
 static void
-PREFIX(extract_number_and_incr) (destination, source)
-    int *destination;
-    UCHAR_T **source;
+PREFIX(extract_number_and_incr) (int *destination, UCHAR_T **source)
 {
   PREFIX(extract_number) (destination, *source);
   *source += OFFSET_ADDRESS_SIZE;
@@ -778,8 +770,7 @@ static int debug;
 
 #  ifndef DEFINED_ONCE
 void
-print_fastmap (fastmap)
-    char *fastmap;
+print_fastmap (char *fastmap)
 {
   unsigned was_a_range = 0;
   unsigned i = 0;
@@ -811,9 +802,7 @@ print_fastmap (fastmap)
    the START pointer into it and ending just before the pointer END.  */
 
 void
-PREFIX(print_partial_compiled_pattern) (start, end)
-    UCHAR_T *start;
-    UCHAR_T *end;
+PREFIX(print_partial_compiled_pattern) (UCHAR_T *start, UCHAR_T *end)
 {
   int mcnt, mcnt2;
   UCHAR_T *p1;
@@ -1146,8 +1135,7 @@ PREFIX(print_partial_compiled_pattern) (start, end)
 
 
 void
-PREFIX(print_compiled_pattern) (bufp)
-    struct re_pattern_buffer *bufp;
+PREFIX(print_compiled_pattern) (struct re_pattern_buffer *bufp)
 {
   UCHAR_T *buffer = (UCHAR_T*) bufp->buffer;
 
@@ -1179,12 +1167,8 @@ PREFIX(print_compiled_pattern) (bufp)
 
 
 void
-PREFIX(print_double_string) (where, string1, size1, string2, size2)
-    const CHAR_T *where;
-    const CHAR_T *string1;
-    const CHAR_T *string2;
-    int size1;
-    int size2;
+PREFIX(print_double_string) (const CHAR_T *where, const CHAR_T *string1,
+                             int size1, const CHAR_T *string2, int size2)
 {
   int this_char;
 
@@ -1217,8 +1201,7 @@ PREFIX(print_double_string) (where, string1, size1, string2, size2)
 
 #  ifndef DEFINED_ONCE
 void
-printchar (c)
-     int c;
+printchar (int c)
 {
   putc (c, stderr);
 }
@@ -1255,11 +1238,8 @@ static size_t convert_mbs_to_wcs (CHAR_T *dest, const unsigned char* src,
                                  size_t len, int *offset_buffer,
                                  char *is_binary);
 static size_t
-convert_mbs_to_wcs (dest, src, len, offset_buffer, is_binary)
-     CHAR_T *dest;
-     const unsigned char* src;
-     size_t len; /* the length of multibyte string.  */
-
+convert_mbs_to_wcs (CHAR_T *dest, const unsigned char*src, size_t len,
+                    int *offset_buffer, char *is_binary)
      /* It hold correspondances between src(char string) and
        dest(wchar_t string) for optimization.
        e.g. src  = "xxxyzz"
@@ -1269,8 +1249,6 @@ convert_mbs_to_wcs (dest, src, len, offset_buffer, is_binary)
          offset_buffer = {0, 0+3("xxx"), 0+3+1("y"), 0+3+1+2("zz")}
                        = {0, 3, 4, 6}
      */
-     int *offset_buffer;
-     char *is_binary;
 {
   wchar_t *pdest = dest;
   const unsigned char *psrc = src;
@@ -1288,7 +1266,11 @@ convert_mbs_to_wcs (dest, src, len, offset_buffer, is_binary)
   for( ; mb_remain > 0 ; ++wc_count, ++pdest, mb_remain -= consumed,
         psrc += consumed)
     {
+#ifdef _LIBC
+      consumed = __mbrtowc (pdest, psrc, mb_remain, &mbs);
+#else
       consumed = mbrtowc (pdest, psrc, mb_remain, &mbs);
+#endif
 
       if (consumed <= 0)
        /* failed to convert. maybe src contains binary data.
@@ -1337,8 +1319,7 @@ reg_syntax_t re_syntax_options;
    defined in regex.h.  We return the old syntax.  */
 
 reg_syntax_t
-re_set_syntax (syntax)
-    reg_syntax_t syntax;
+re_set_syntax (reg_syntax_t syntax)
 {
   reg_syntax_t ret = re_syntax_options;
 
@@ -1360,80 +1341,26 @@ weak_alias (__re_set_syntax, re_set_syntax)
    POSIX doesn't require that we do anything for REG_NOERROR,
    but why not be nice?  */
 
-static const char re_error_msgid[] =
+static const char *re_error_msgid[] =
   {
-# define REG_NOERROR_IDX       0
-    gettext_noop ("Success")   /* REG_NOERROR */
-    "\0"
-# define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
-    gettext_noop ("No match")  /* REG_NOMATCH */
-    "\0"
-# define REG_BADPAT_IDX        (REG_NOMATCH_IDX + sizeof "No match")
-    gettext_noop ("Invalid regular expression") /* REG_BADPAT */
-    "\0"
-# define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
-    gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
-    "\0"
-# define REG_ECTYPE_IDX        (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
-    gettext_noop ("Invalid character class name") /* REG_ECTYPE */
-    "\0"
-# define REG_EESCAPE_IDX       (REG_ECTYPE_IDX + sizeof "Invalid character class name")
-    gettext_noop ("Trailing backslash") /* REG_EESCAPE */
-    "\0"
-# define REG_ESUBREG_IDX       (REG_EESCAPE_IDX + sizeof "Trailing backslash")
-    gettext_noop ("Invalid back reference") /* REG_ESUBREG */
-    "\0"
-# define REG_EBRACK_IDX        (REG_ESUBREG_IDX + sizeof "Invalid back reference")
-    gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
-    "\0"
-# define REG_EPAREN_IDX        (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
-    gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
-    "\0"
-# define REG_EBRACE_IDX        (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
-    gettext_noop ("Unmatched \\{") /* REG_EBRACE */
-    "\0"
-# define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
-    gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
-    "\0"
-# define REG_ERANGE_IDX        (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
-    gettext_noop ("Invalid range end") /* REG_ERANGE */
-    "\0"
-# define REG_ESPACE_IDX        (REG_ERANGE_IDX + sizeof "Invalid range end")
-    gettext_noop ("Memory exhausted") /* REG_ESPACE */
-    "\0"
-# define REG_BADRPT_IDX        (REG_ESPACE_IDX + sizeof "Memory exhausted")
-    gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
-    "\0"
-# define REG_EEND_IDX  (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
-    gettext_noop ("Premature end of regular expression") /* REG_EEND */
-    "\0"
-# define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
-    gettext_noop ("Regular expression too big") /* REG_ESIZE */
-    "\0"
-# define REG_ERPAREN_IDX       (REG_ESIZE_IDX + sizeof "Regular expression too big")
+    gettext_noop ("Success"),  /* REG_NOERROR */
+    gettext_noop ("No match"), /* REG_NOMATCH */
+    gettext_noop ("Invalid regular expression"), /* REG_BADPAT */
+    gettext_noop ("Invalid collation character"), /* REG_ECOLLATE */
+    gettext_noop ("Invalid character class name"), /* REG_ECTYPE */
+    gettext_noop ("Trailing backslash"), /* REG_EESCAPE */
+    gettext_noop ("Invalid back reference"), /* REG_ESUBREG */
+    gettext_noop ("Unmatched [ or [^"),        /* REG_EBRACK */
+    gettext_noop ("Unmatched ( or \\("), /* REG_EPAREN */
+    gettext_noop ("Unmatched \\{"), /* REG_EBRACE */
+    gettext_noop ("Invalid content of \\{\\}"), /* REG_BADBR */
+    gettext_noop ("Invalid range end"),        /* REG_ERANGE */
+    gettext_noop ("Memory exhausted"), /* REG_ESPACE */
+    gettext_noop ("Invalid preceding regular expression"), /* REG_BADRPT */
+    gettext_noop ("Premature end of regular expression"), /* REG_EEND */
+    gettext_noop ("Regular expression too big"), /* REG_ESIZE */
     gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
   };
-
-static const size_t re_error_msgid_idx[] =
-  {
-    REG_NOERROR_IDX,
-    REG_NOMATCH_IDX,
-    REG_BADPAT_IDX,
-    REG_ECOLLATE_IDX,
-    REG_ECTYPE_IDX,
-    REG_EESCAPE_IDX,
-    REG_ESUBREG_IDX,
-    REG_EBRACK_IDX,
-    REG_EPAREN_IDX,
-    REG_EBRACE_IDX,
-    REG_BADBR_IDX,
-    REG_ERANGE_IDX,
-    REG_ESPACE_IDX,
-    REG_BADRPT_IDX,
-    REG_EEND_IDX,
-    REG_ESIZE_IDX,
-    REG_ERPAREN_IDX
-  };
 \f
 #endif /* INSIDE_RECURSION */
 
@@ -1911,35 +1838,35 @@ static CHAR_T PREFIX(reg_unset_dummy);
 # define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
 
 /* Subroutine declarations and macros for regex_compile.  */
-static void PREFIX(store_op1) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc, int arg));
-static void PREFIX(store_op2) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
-                                int arg1, int arg2));
-static void PREFIX(insert_op1) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
-                                 int arg, UCHAR_T *end));
-static void PREFIX(insert_op2) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
-                                 int arg1, int arg2, UCHAR_T *end));
-static boolean PREFIX(at_begline_loc_p) _RE_ARGS ((const CHAR_T *pattern,
-                                          const CHAR_T *p,
-                                          reg_syntax_t syntax));
-static boolean PREFIX(at_endline_loc_p) _RE_ARGS ((const CHAR_T *p,
-                                          const CHAR_T *pend,
-                                          reg_syntax_t syntax));
+static void PREFIX(store_op1) (re_opcode_t op, UCHAR_T *loc, int arg);
+static void PREFIX(store_op2) (re_opcode_t op, UCHAR_T *loc,
+                               int arg1, int arg2);
+static void PREFIX(insert_op1) (re_opcode_t op, UCHAR_T *loc,
+                                int arg, UCHAR_T *end);
+static void PREFIX(insert_op2) (re_opcode_t op, UCHAR_T *loc,
+                                int arg1, int arg2, UCHAR_T *end);
+static boolean PREFIX(at_begline_loc_p) (const CHAR_T *pattern,
+                                         const CHAR_T *p,
+                                         reg_syntax_t syntax);
+static boolean PREFIX(at_endline_loc_p) (const CHAR_T *p,
+                                         const CHAR_T *pend,
+                                         reg_syntax_t syntax);
 # ifdef WCHAR
-static reg_errcode_t wcs_compile_range _RE_ARGS ((CHAR_T range_start,
-                                                 const CHAR_T **p_ptr,
-                                                 const CHAR_T *pend,
-                                                 char *translate,
-                                                 reg_syntax_t syntax,
-                                                 UCHAR_T *b,
-                                                 CHAR_T *char_set));
-static void insert_space _RE_ARGS ((int num, CHAR_T *loc, CHAR_T *end));
+static reg_errcode_t wcs_compile_range (CHAR_T range_start,
+                                        const CHAR_T **p_ptr,
+                                        const CHAR_T *pend,
+                                        char *translate,
+                                        reg_syntax_t syntax,
+                                        UCHAR_T *b,
+                                        CHAR_T *char_set);
+static void insert_space (int num, CHAR_T *loc, CHAR_T *end);
 # else /* BYTE */
-static reg_errcode_t byte_compile_range _RE_ARGS ((unsigned int range_start,
-                                                  const char **p_ptr,
-                                                  const char *pend,
-                                                  char *translate,
-                                                  reg_syntax_t syntax,
-                                                  unsigned char *b));
+static reg_errcode_t byte_compile_range (unsigned int range_start,
+                                         const char **p_ptr,
+                                         const char *pend,
+                                         char *translate,
+                                         reg_syntax_t syntax,
+                                         unsigned char *b);
 # endif /* WCHAR */
 
 /* Fetch the next character in the uncompiled pattern---translating it
@@ -2297,8 +2224,7 @@ static PREFIX(register_info_type) *PREFIX(reg_info_dummy);
    but don't make them smaller.  */
 
 static void
-PREFIX(regex_grow_registers) (num_regs)
-     int num_regs;
+PREFIX(regex_grow_registers) (int num_regs)
 {
   if (num_regs > regs_allocated_size)
     {
@@ -2319,9 +2245,8 @@ PREFIX(regex_grow_registers) (num_regs)
 # endif /* not MATCH_MAY_ALLOCATE */
 \f
 # ifndef DEFINED_ONCE
-static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type
-                                                compile_stack,
-                                                regnum_t regnum));
+static boolean group_in_compile_stack (compile_stack_type compile_stack,
+                                       regnum_t regnum);
 # endif /* not DEFINED_ONCE */
 
 /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
@@ -2352,11 +2277,9 @@ static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type
 # endif /* WCHAR */
 
 static reg_errcode_t
-PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
-     const char *ARG_PREFIX(pattern);
-     size_t ARG_PREFIX(size);
-     reg_syntax_t syntax;
-     struct re_pattern_buffer *bufp;
+PREFIX(regex_compile) (const char *ARG_PREFIX(pattern),
+                       size_t ARG_PREFIX(size), reg_syntax_t syntax,
+                       struct re_pattern_buffer *bufp)
 {
   /* We fetch characters from PATTERN here.  Even though PATTERN is
      `char *' (i.e., signed), we declare these variables as unsigned, so
@@ -3059,7 +2982,7 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
                                    /* First compare the hashing value.  */
                                    if (symb_table[2 * elem] == hash
                                        && c1 == extra[symb_table[2 * elem + 1]]
-                                       && memcmp (str,
+                                       && memcmp (char_str,
                                                   &extra[symb_table[2 * elem + 1]
                                                         + 1], c1) == 0)
                                      {
@@ -3079,7 +3002,7 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
                                       in the table.  */
                                    idx += 1 + extra[idx];
                                    /* Adjust for the alignment.  */
-                                   idx = (idx + 3) & ~4;
+                                   idx = (idx + 3) & ~3;
 
                                    str[0] = (wchar_t) idx + 4;
                                  }
@@ -4301,10 +4224,7 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
 /* ifdef WCHAR, integer parameter is 1 wchar_t.  */
 
 static void
-PREFIX(store_op1) (op, loc, arg)
-    re_opcode_t op;
-    UCHAR_T *loc;
-    int arg;
+PREFIX(store_op1) (re_opcode_t op, UCHAR_T *loc, int arg)
 {
   *loc = (UCHAR_T) op;
   STORE_NUMBER (loc + 1, arg);
@@ -4315,10 +4235,7 @@ PREFIX(store_op1) (op, loc, arg)
 /* ifdef WCHAR, integer parameter is 1 wchar_t.  */
 
 static void
-PREFIX(store_op2) (op, loc, arg1, arg2)
-    re_opcode_t op;
-    UCHAR_T *loc;
-    int arg1, arg2;
+PREFIX(store_op2) (re_opcode_t op, UCHAR_T *loc, int arg1, int arg2)
 {
   *loc = (UCHAR_T) op;
   STORE_NUMBER (loc + 1, arg1);
@@ -4331,11 +4248,7 @@ PREFIX(store_op2) (op, loc, arg1, arg2)
 /* ifdef WCHAR, integer parameter is 1 wchar_t.  */
 
 static void
-PREFIX(insert_op1) (op, loc, arg, end)
-    re_opcode_t op;
-    UCHAR_T *loc;
-    int arg;
-    UCHAR_T *end;
+PREFIX(insert_op1) (re_opcode_t op, UCHAR_T *loc, int arg, UCHAR_T *end)
 {
   register UCHAR_T *pfrom = end;
   register UCHAR_T *pto = end + 1 + OFFSET_ADDRESS_SIZE;
@@ -4351,11 +4264,8 @@ PREFIX(insert_op1) (op, loc, arg, end)
 /* ifdef WCHAR, integer parameter is 1 wchar_t.  */
 
 static void
-PREFIX(insert_op2) (op, loc, arg1, arg2, end)
-    re_opcode_t op;
-    UCHAR_T *loc;
-    int arg1, arg2;
-    UCHAR_T *end;
+PREFIX(insert_op2) (re_opcode_t op, UCHAR_T *loc, int arg1,
+                    int arg2, UCHAR_T *end)
 {
   register UCHAR_T *pfrom = end;
   register UCHAR_T *pto = end + 1 + 2 * OFFSET_ADDRESS_SIZE;
@@ -4372,9 +4282,8 @@ PREFIX(insert_op2) (op, loc, arg1, arg2, end)
    least one character before the ^.  */
 
 static boolean
-PREFIX(at_begline_loc_p) (pattern, p, syntax)
-    const CHAR_T *pattern, *p;
-    reg_syntax_t syntax;
+PREFIX(at_begline_loc_p) (const CHAR_T *pattern, const CHAR_T *p,
+                          reg_syntax_t syntax)
 {
   const CHAR_T *prev = p - 2;
   boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
@@ -4391,9 +4300,8 @@ PREFIX(at_begline_loc_p) (pattern, p, syntax)
    at least one character after the $, i.e., `P < PEND'.  */
 
 static boolean
-PREFIX(at_endline_loc_p) (p, pend, syntax)
-    const CHAR_T *p, *pend;
-    reg_syntax_t syntax;
+PREFIX(at_endline_loc_p) (const CHAR_T *p, const CHAR_T *pend,
+                          reg_syntax_t syntax)
 {
   const CHAR_T *next = p;
   boolean next_backslash = *next == '\\';
@@ -4414,9 +4322,7 @@ PREFIX(at_endline_loc_p) (p, pend, syntax)
    false if it's not.  */
 
 static boolean
-group_in_compile_stack (compile_stack, regnum)
-    compile_stack_type compile_stack;
-    regnum_t regnum;
+group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
 {
   int this_element;
 
@@ -4436,10 +4342,7 @@ group_in_compile_stack (compile_stack, regnum)
 /* This insert space, which size is "num", into the pattern at "loc".
    "end" must point the end of the allocated buffer.  */
 static void
-insert_space (num, loc, end)
-     int num;
-     CHAR_T *loc;
-     CHAR_T *end;
+insert_space (int num, CHAR_T *loc, CHAR_T *end)
 {
   register CHAR_T *pto = end;
   register CHAR_T *pfrom = end - num;
@@ -4451,13 +4354,9 @@ insert_space (num, loc, end)
 
 #ifdef WCHAR
 static reg_errcode_t
-wcs_compile_range (range_start_char, p_ptr, pend, translate, syntax, b,
-                  char_set)
-     CHAR_T range_start_char;
-     const CHAR_T **p_ptr, *pend;
-     CHAR_T *char_set, *b;
-     RE_TRANSLATE_TYPE translate;
-     reg_syntax_t syntax;
+wcs_compile_range (CHAR_T range_start_char, const CHAR_T **p_ptr,
+                   const CHAR_T *pend, RE_TRANSLATE_TYPE translate,
+                   reg_syntax_t syntax, CHAR_T *b, CHAR_T *char_set)
 {
   const CHAR_T *p = *p_ptr;
   CHAR_T range_start, range_end;
@@ -4538,12 +4437,9 @@ wcs_compile_range (range_start_char, p_ptr, pend, translate, syntax, b,
    `regex_compile' itself.  */
 
 static reg_errcode_t
-byte_compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
-     unsigned int range_start_char;
-     const char **p_ptr, *pend;
-     RE_TRANSLATE_TYPE translate;
-     reg_syntax_t syntax;
-     unsigned char *b;
+byte_compile_range (unsigned int range_start_char, const char **p_ptr,
+                    const char *pend, RE_TRANSLATE_TYPE translate,
+                    reg_syntax_t syntax, unsigned char *b)
 {
   unsigned this_char;
   const char *p = *p_ptr;
@@ -4624,18 +4520,23 @@ byte_compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
 static unsigned char truncate_wchar (CHAR_T c);
 
 static unsigned char
-truncate_wchar (c)
-     CHAR_T c;
+truncate_wchar (CHAR_T c)
 {
-  unsigned char buf[MB_LEN_MAX];
-  int retval = wctomb(buf, c);
-  return retval > 0 ? buf[0] : (unsigned char)c;
+  unsigned char buf[MB_CUR_MAX];
+  mbstate_t state;
+  int retval;
+  memset (&state, '\0', sizeof (state));
+# ifdef _LIBC
+  retval = __wcrtomb (buf, c, &state);
+# else
+  retval = wcrtomb (buf, c, &state);
+# endif
+  return retval > 0 ? buf[0] : (unsigned char) c;
 }
 #endif /* WCHAR */
 
 static int
-PREFIX(re_compile_fastmap) (bufp)
-     struct re_pattern_buffer *bufp;
+PREFIX(re_compile_fastmap) (struct re_pattern_buffer *bufp)
 {
   int j, k;
 #ifdef MATCH_MAY_ALLOCATE
@@ -4682,7 +4583,7 @@ PREFIX(re_compile_fastmap) (bufp)
 
   while (1)
     {
-      if (p == pend || *p == succeed)
+      if (p == pend || *p == (UCHAR_T) succeed)
        {
          /* We have reached the (effective) end of pattern.  */
          if (!FAIL_STACK_EMPTY ())
@@ -4954,8 +4855,7 @@ PREFIX(re_compile_fastmap) (bufp)
 #else /* not INSIDE_RECURSION */
 
 int
-re_compile_fastmap (bufp)
-     struct re_pattern_buffer *bufp;
+re_compile_fastmap (struct re_pattern_buffer *bufp)
 {
 # ifdef MBS_SUPPORT
   if (MB_CUR_MAX != 1)
@@ -4983,11 +4883,9 @@ weak_alias (__re_compile_fastmap, re_compile_fastmap)
    freeing the old data.  */
 
 void
-re_set_registers (bufp, regs, num_regs, starts, ends)
-    struct re_pattern_buffer *bufp;
-    struct re_registers *regs;
-    unsigned num_regs;
-    regoff_t *starts, *ends;
+re_set_registers (struct re_pattern_buffer *bufp,
+                  struct re_registers *regs, unsigned num_regs,
+                  regoff_t *starts, regoff_t *ends)
 {
   if (num_regs)
     {
@@ -5013,11 +4911,8 @@ weak_alias (__re_set_registers, re_set_registers)
    doesn't let you say where to stop matching.  */
 
 int
-re_search (bufp, string, size, startpos, range, regs)
-     struct re_pattern_buffer *bufp;
-     const char *string;
-     int size, startpos, range;
-     struct re_registers *regs;
+re_search (struct re_pattern_buffer *bufp, const char *string, int size,
+           int startpos, int range, struct re_registers *regs)
 {
   return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
                      regs, size);
@@ -5049,14 +4944,9 @@ weak_alias (__re_search, re_search)
    stack overflow).  */
 
 int
-re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
-     struct re_pattern_buffer *bufp;
-     const char *string1, *string2;
-     int size1, size2;
-     int startpos;
-     int range;
-     struct re_registers *regs;
-     int stop;
+re_search_2 (struct re_pattern_buffer *bufp, const char *string1, int size1,
+             const char *string2, int size2, int startpos, int range,
+             struct re_registers *regs, int stop)
 {
 # ifdef MBS_SUPPORT
   if (MB_CUR_MAX != 1)
@@ -5112,15 +5002,10 @@ weak_alias (__re_search_2, re_search_2)
 
 
 static int
-PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
-                    regs, stop)
-     struct re_pattern_buffer *bufp;
-     const char *string1, *string2;
-     int size1, size2;
-     int startpos;
-     int range;
-     struct re_registers *regs;
-     int stop;
+PREFIX(re_search_2) (struct re_pattern_buffer *bufp, const char *string1,
+                     int size1, const char *string2, int size2,
+                     int startpos, int range,
+                     struct re_registers *regs, int stop)
 {
   int val;
   register char *fastmap = bufp->fastmap;
@@ -5503,11 +5388,8 @@ PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
 /* re_match is like re_match_2 except it takes only a single string.  */
 
 int
-re_match (bufp, string, size, pos, regs)
-     struct re_pattern_buffer *bufp;
-     const char *string;
-     int size, pos;
-     struct re_registers *regs;
+re_match (struct re_pattern_buffer *bufp, const char *string,
+          int size, int pos, struct re_registers *regs)
 {
   int result;
 # ifdef MBS_SUPPORT
@@ -5534,17 +5416,17 @@ weak_alias (__re_match, re_match)
 #endif /* not INSIDE_RECURSION */
 
 #ifdef INSIDE_RECURSION
-static boolean PREFIX(group_match_null_string_p) _RE_ARGS ((UCHAR_T **p,
-                                                   UCHAR_T *end,
-                                       PREFIX(register_info_type) *reg_info));
-static boolean PREFIX(alt_match_null_string_p) _RE_ARGS ((UCHAR_T *p,
-                                                 UCHAR_T *end,
-                                       PREFIX(register_info_type) *reg_info));
-static boolean PREFIX(common_op_match_null_string_p) _RE_ARGS ((UCHAR_T **p,
-                                                       UCHAR_T *end,
-                                       PREFIX(register_info_type) *reg_info));
-static int PREFIX(bcmp_translate) _RE_ARGS ((const CHAR_T *s1, const CHAR_T *s2,
-                                    int len, char *translate));
+static boolean PREFIX(group_match_null_string_p) (UCHAR_T **p,
+                                                  UCHAR_T *end,
+                                       PREFIX(register_info_type) *reg_info);
+static boolean PREFIX(alt_match_null_string_p) (UCHAR_T *p,
+                                                UCHAR_T *end,
+                                       PREFIX(register_info_type) *reg_info);
+static boolean PREFIX(common_op_match_null_string_p) (UCHAR_T **p,
+                                                      UCHAR_T *end,
+                                       PREFIX(register_info_type) *reg_info);
+static int PREFIX(bcmp_translate) (const CHAR_T *s1, const CHAR_T *s2,
+                                   int len, char *translate);
 #else /* not INSIDE_RECURSION */
 
 /* re_match_2 matches the compiled pattern in BUFP against the
@@ -5561,13 +5443,9 @@ static int PREFIX(bcmp_translate) _RE_ARGS ((const CHAR_T *s1, const CHAR_T *s2,
    matched substring.  */
 
 int
-re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
-     struct re_pattern_buffer *bufp;
-     const char *string1, *string2;
-     int size1, size2;
-     int pos;
-     struct re_registers *regs;
-     int stop;
+re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1,
+            const char *string2, int size2, int pos,
+            struct re_registers *regs, int stop)
 {
   int result;
 # ifdef MBS_SUPPORT
@@ -5596,7 +5474,7 @@ weak_alias (__re_match_2, re_match_2)
 #ifdef INSIDE_RECURSION
 
 #ifdef WCHAR
-static int count_mbs_length PARAMS ((int *, int));
+static int count_mbs_length (int *, int);
 
 /* This check the substring (from 0, to length) of the multibyte string,
    to which offset_buffer correspond. And count how many wchar_t_characters
@@ -5604,9 +5482,7 @@ static int count_mbs_length PARAMS ((int *, int));
    See convert_mbs_to_wcs.  */
 
 static int
-count_mbs_length(offset_buffer, length)
-     int *offset_buffer;
-     int length;
+count_mbs_length(int *offset_buffer, int length)
 {
   int upper, lower;
 
@@ -5647,33 +5523,26 @@ count_mbs_length(offset_buffer, length)
    afterwards.  */
 #ifdef WCHAR
 static int
-wcs_re_match_2_internal (bufp, cstring1, csize1, cstring2, csize2, pos,
-                        regs, stop, string1, size1, string2, size2,
-                        mbs_offset1, mbs_offset2)
-     struct re_pattern_buffer *bufp;
-     const char *cstring1, *cstring2;
-     int csize1, csize2;
-     int pos;
-     struct re_registers *regs;
-     int stop;
+wcs_re_match_2_internal (struct re_pattern_buffer *bufp,
+                         const char *cstring1, int csize1,
+                         const char *cstring2, int csize2,
+                         int pos,
+                        struct re_registers *regs,
+                         int stop,
      /* string1 == string2 == NULL means string1/2, size1/2 and
        mbs_offset1/2 need seting up in this function.  */
      /* We need wchar_t* buffers correspond to cstring1, cstring2.  */
-     wchar_t *string1, *string2;
-     /* We need the size of wchar_t buffers correspond to csize1, csize2.  */
-     int size1, size2;
+                         wchar_t *string1, int size1,
+                         wchar_t *string2, int size2,
      /* offset buffer for optimizatoin. See convert_mbs_to_wc.  */
-     int *mbs_offset1, *mbs_offset2;
+                        int *mbs_offset1, int *mbs_offset2)
 #else /* BYTE */
 static int
-byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
-                         regs, stop)
-     struct re_pattern_buffer *bufp;
-     const char *string1, *string2;
-     int size1, size2;
-     int pos;
-     struct re_registers *regs;
-     int stop;
+byte_re_match_2_internal (struct re_pattern_buffer *bufp,
+                          const char *string1, int size1,
+                          const char *string2, int size2,
+                          int pos,
+                         struct re_registers *regs, int stop)
 #endif /* BYTE */
 {
   /* General temporaries.  */
@@ -6303,9 +6172,9 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            uint32_t nrules;
 # endif /* _LIBC */
 #endif /* WCHAR */
-           boolean not = (re_opcode_t) *(p - 1) == charset_not;
+           boolean negate = (re_opcode_t) *(p - 1) == charset_not;
 
-            DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
+            DEBUG_PRINT2 ("EXECUTING charset%s.\n", negate ? "_not" : "");
            PREFETCH ();
            c = TRANSLATE (*d); /* The character to match.  */
 #ifdef WCHAR
@@ -6337,8 +6206,13 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                                      & ~(uintptr_t)(__alignof__(wctype_t) - 1);
                wctype = *((wctype_t*)alignedp);
                workp += CHAR_CLASS_SIZE;
+# ifdef _LIBC
+               if (__iswctype((wint_t)c, wctype))
+                 goto char_set_matched;
+# else
                if (iswctype((wint_t)c, wctype))
                  goto char_set_matched;
+# endif
              }
 
             /* match with collating_symbol?  */
@@ -6374,12 +6248,20 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                for (workp2 = workp + coll_symbol_length ; workp < workp2 ;)
                  {
                    const CHAR_T *backup_d = d, *backup_dend = dend;
-                   length = wcslen(workp);
+# ifdef _LIBC
+                   length = __wcslen (workp);
+# else
+                   length = wcslen (workp);
+# endif
 
                    /* If wcscoll(the collating symbol, whole string) > 0,
                       any substring of the string never match with the
                       collating symbol.  */
-                   if (wcscoll(workp, d) > 0)
+# ifdef _LIBC
+                   if (__wcscoll (workp, d) > 0)
+# else
+                   if (wcscoll (workp, d) > 0)
+# endif
                      {
                        workp += length + 1;
                        continue;
@@ -6404,7 +6286,11 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                        str_buf[i] = TRANSLATE(*d);
                        str_buf[i+1] = '\0';
 
-                       match = wcscoll(workp, str_buf);
+# ifdef _LIBC
+                       match = __wcscoll (workp, str_buf);
+# else
+                       match = wcscoll (workp, str_buf);
+# endif
                        if (match == 0)
                          goto char_set_matched;
 
@@ -6515,12 +6401,20 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                for (workp2 = workp + equiv_class_length ; workp < workp2 ;)
                  {
                    const CHAR_T *backup_d = d, *backup_dend = dend;
-                   length = wcslen(workp);
+# ifdef _LIBC
+                   length = __wcslen (workp);
+# else
+                   length = wcslen (workp);
+# endif
 
                    /* If wcscoll(the collating symbol, whole string) > 0,
                       any substring of the string never match with the
                       collating symbol.  */
-                   if (wcscoll(workp, d) > 0)
+# ifdef _LIBC
+                   if (__wcscoll (workp, d) > 0)
+# else
+                   if (wcscoll (workp, d) > 0)
+# endif
                      {
                        workp += length + 1;
                        break;
@@ -6545,7 +6439,11 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                        str_buf[i] = TRANSLATE(*d);
                        str_buf[i+1] = '\0';
 
-                       match = wcscoll(workp, str_buf);
+# ifdef _LIBC
+                       match = __wcscoll (workp, str_buf);
+# else
+                       match = wcscoll (workp, str_buf);
+# endif
 
                        if (match == 0)
                          goto char_set_matched;
@@ -6568,7 +6466,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
              }
 
             /* match with char_range?  */
-#ifdef _LIBC
+# ifdef _LIBC
            if (nrules != 0)
              {
                uint32_t collseqval;
@@ -6591,7 +6489,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                  }
              }
            else
-#endif
+# endif
              {
                /* We set range_start_char at str_buf[0], range_end_char
                   at str_buf[4], and compared char at str_buf[2].  */
@@ -6627,9 +6525,13 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                        range_end_char = str_buf + 4;
                      }
 
-                   if (wcscoll(range_start_char, str_buf+2) <= 0 &&
-                       wcscoll(str_buf+2, range_end_char) <= 0)
-
+# ifdef _LIBC
+                   if (__wcscoll (range_start_char, str_buf+2) <= 0
+                       && __wcscoll (str_buf+2, range_end_char) <= 0)
+# else
+                   if (wcscoll (range_start_char, str_buf+2) <= 0
+                       && wcscoll (str_buf+2, range_end_char) <= 0)
+# endif
                      goto char_set_matched;
                  }
              }
@@ -6639,20 +6541,20 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
              if (c == *workp)
                goto char_set_matched;
 
-           not = !not;
+           negate = !negate;
 
          char_set_matched:
-           if (not) goto fail;
+           if (negate) goto fail;
 #else
             /* Cast to `unsigned' instead of `unsigned char' in case the
                bit list is a full 32 bytes long.  */
            if (c < (unsigned) (*p * BYTEWIDTH)
                && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-             not = !not;
+             negate = !negate;
 
            p += 1 + *p;
 
-           if (!not) goto fail;
+           if (!negate) goto fail;
 #undef WORK_BUFFER_SIZE
 #endif /* WCHAR */
            SET_REGS_MATCHED ();
@@ -7142,15 +7044,15 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                else if ((re_opcode_t) p1[3] == charset
                         || (re_opcode_t) p1[3] == charset_not)
                  {
-                   int not = (re_opcode_t) p1[3] == charset_not;
+                   int negate = (re_opcode_t) p1[3] == charset_not;
 
                    if (c < (unsigned) (p1[4] * BYTEWIDTH)
                        && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-                     not = !not;
+                     negate = !negate;
 
-                    /* `not' is equal to 1 if c would match, which means
+                    /* `negate' is equal to 1 if c would match, which means
                         that we can't change to pop_failure_jump.  */
-                   if (!not)
+                   if (!negate)
                       {
                        p[-3] = (unsigned char) pop_failure_jump;
                         DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
@@ -7590,9 +7492,8 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
    We don't handle duplicates properly (yet).  */
 
 static boolean
-PREFIX(group_match_null_string_p) (p, end, reg_info)
-    UCHAR_T **p, *end;
-    PREFIX(register_info_type) *reg_info;
+PREFIX(group_match_null_string_p) (UCHAR_T **p, UCHAR_T *end,
+                                   PREFIX(register_info_type) *reg_info)
 {
   int mcnt;
   /* Point to after the args to the start_memory.  */
@@ -7702,9 +7603,8 @@ PREFIX(group_match_null_string_p) (p, end, reg_info)
    byte past the last. The alternative can contain groups.  */
 
 static boolean
-PREFIX(alt_match_null_string_p) (p, end, reg_info)
-    UCHAR_T *p, *end;
-    PREFIX(register_info_type) *reg_info;
+PREFIX(alt_match_null_string_p) (UCHAR_T *p, UCHAR_T *end,
+                                 PREFIX(register_info_type) *reg_info)
 {
   int mcnt;
   UCHAR_T *p1 = p;
@@ -7739,9 +7639,8 @@ PREFIX(alt_match_null_string_p) (p, end, reg_info)
    Sets P to one after the op and its arguments, if any.  */
 
 static boolean
-PREFIX(common_op_match_null_string_p) (p, end, reg_info)
-    UCHAR_T **p, *end;
-    PREFIX(register_info_type) *reg_info;
+PREFIX(common_op_match_null_string_p) (UCHAR_T **p, UCHAR_T *end,
+                                       PREFIX(register_info_type) *reg_info)
 {
   int mcnt;
   boolean ret;
@@ -7827,10 +7726,8 @@ PREFIX(common_op_match_null_string_p) (p, end, reg_info)
    bytes; nonzero otherwise.  */
 
 static int
-PREFIX(bcmp_translate) (s1, s2, len, translate)
-     const CHAR_T *s1, *s2;
-     register int len;
-     RE_TRANSLATE_TYPE translate;
+PREFIX(bcmp_translate) (const CHAR_T *s1, const CHAR_T *s2, register int len,
+                        RE_TRANSLATE_TYPE translate)
 {
   register const UCHAR_T *p1 = (const UCHAR_T *) s1;
   register const UCHAR_T *p2 = (const UCHAR_T *) s2;
@@ -7863,10 +7760,8 @@ PREFIX(bcmp_translate) (s1, s2, len, translate)
    We call regex_compile to do the actual compilation.  */
 
 const char *
-re_compile_pattern (pattern, length, bufp)
-     const char *pattern;
-     size_t length;
-     struct re_pattern_buffer *bufp;
+re_compile_pattern (const char *pattern, size_t length,
+                    struct re_pattern_buffer *bufp)
 {
   reg_errcode_t ret;
 
@@ -7891,7 +7786,7 @@ re_compile_pattern (pattern, length, bufp)
 
   if (!ret)
     return NULL;
-  return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
+  return gettext (re_error_msgid[(int) ret]);
 }
 #ifdef _LIBC
 weak_alias (__re_compile_pattern, re_compile_pattern)
@@ -7912,8 +7807,7 @@ char *
    regcomp/regexec below without link errors.  */
 weak_function
 #endif
-re_comp (s)
-    const char *s;
+re_comp (const char *s)
 {
   reg_errcode_t ret;
 
@@ -7928,14 +7822,12 @@ re_comp (s)
     {
       re_comp_buf.buffer = (unsigned char *) malloc (200);
       if (re_comp_buf.buffer == NULL)
-        return (char *) gettext (re_error_msgid
-                                + re_error_msgid_idx[(int) REG_ESPACE]);
+        return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
       re_comp_buf.allocated = 200;
 
       re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
       if (re_comp_buf.fastmap == NULL)
-       return (char *) gettext (re_error_msgid
-                                + re_error_msgid_idx[(int) REG_ESPACE]);
+       return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
     }
 
   /* Since `re_exec' always passes NULL for the `regs' argument, we
@@ -7955,7 +7847,7 @@ re_comp (s)
     return NULL;
 
   /* Yes, we're discarding `const' here if !HAVE_LIBINTL.  */
-  return (char *) gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
+  return (char *) gettext (re_error_msgid[(int) ret]);
 }
 
 
@@ -7963,8 +7855,7 @@ int
 #ifdef _LIBC
 weak_function
 #endif
-re_exec (s)
-    const char *s;
+re_exec (const char *s)
 {
   const int len = strlen (s);
   return
@@ -8013,10 +7904,7 @@ re_exec (s)
    the return codes and their meanings.)  */
 
 int
-regcomp (preg, pattern, cflags)
-    regex_t *preg;
-    const char *pattern;
-    int cflags;
+regcomp (regex_t *preg, const char *pattern, int cflags)
 {
   reg_errcode_t ret;
   reg_syntax_t syntax
@@ -8043,7 +7931,7 @@ regcomp (preg, pattern, cflags)
 
       /* Map uppercase characters to corresponding lowercase ones.  */
       for (i = 0; i < CHAR_SET_SIZE; i++)
-        preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : i;
+        preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : (int) i;
     }
   else
     preg->translate = NULL;
@@ -8109,12 +7997,8 @@ weak_alias (__regcomp, regcomp)
    We return 0 if we find a match and REG_NOMATCH if not.  */
 
 int
-regexec (preg, string, nmatch, pmatch, eflags)
-    const regex_t *preg;
-    const char *string;
-    size_t nmatch;
-    regmatch_t pmatch[];
-    int eflags;
+regexec (const regex_t *preg, const char *string, size_t nmatch,
+         regmatch_t pmatch[], int eflags)
 {
   int ret;
   struct re_registers regs;
@@ -8176,25 +8060,22 @@ weak_alias (__regexec, regexec)
    from either regcomp or regexec.   We don't use PREG here.  */
 
 size_t
-regerror (errcode, preg, errbuf, errbuf_size)
-    int errcode;
-    const regex_t *preg;
-    char *errbuf;
-    size_t errbuf_size;
+regerror (int errcode, const regex_t *preg ATTRIBUTE_UNUSED,
+          char *errbuf, size_t errbuf_size)
 {
   const char *msg;
   size_t msg_size;
 
   if (errcode < 0
-      || errcode >= (int) (sizeof (re_error_msgid_idx)
-                          / sizeof (re_error_msgid_idx[0])))
+      || errcode >= (int) (sizeof (re_error_msgid)
+                          / sizeof (re_error_msgid[0])))
     /* Only error codes returned by the rest of the code should be passed
        to this routine.  If we are given anything else, or if other regex
        code generates an invalid error code, then the program has a bug.
        Dump core so we can fix it.  */
     abort ();
 
-  msg = gettext (re_error_msgid + re_error_msgid_idx[errcode]);
+  msg = gettext (re_error_msgid[errcode]);
 
   msg_size = strlen (msg) + 1; /* Includes the null.  */
 
@@ -8203,7 +8084,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
       if (msg_size > errbuf_size)
         {
 #if defined HAVE_MEMPCPY || defined _LIBC
-         *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
+         *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
 #else
           memcpy (errbuf, msg, errbuf_size - 1);
           errbuf[errbuf_size - 1] = 0;
@@ -8223,8 +8104,7 @@ weak_alias (__regerror, regerror)
 /* Free dynamically allocated space used by PREG.  */
 
 void
-regfree (preg)
-    regex_t *preg;
+regfree (regex_t *preg)
 {
   if (preg->buffer != NULL)
     free (preg->buffer);