Remove K&R cruft.
[gnulib.git] / lib / regex.c
index 753c261..ac70b90 100644 (file)
@@ -2,23 +2,23 @@
    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.
-   This file is part of the GNU C Library.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003 Free Software Foundation, Inc.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   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
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   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.  */
 
 /* AIX requires this to be the first thing in the file. */
 #if defined _AIX && !defined REGEX_MALLOC
 # include <config.h>
 #endif
 
-#ifndef PARAMS
-# if defined __GNUC__ || (defined __STDC__ && __STDC__)
-#  define PARAMS(args) args
-# else
-#  define PARAMS(args) ()
-# endif  /* GCC.  */
-#endif  /* Not PARAMS.  */
-
 #ifndef INSIDE_RECURSION
 
-# if defined STDC_HEADERS && !defined emacs
-#  include <stddef.h>
-# else
-/* We need this for `regex.h', and perhaps for the Emacs include files.  */
-#  include <sys/types.h>
-# endif
+# include <stddef.h>
 
 # define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
 
 #  define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
 
 #  define btowc __btowc
+#  define iswctype __iswctype
+#  define mbrtowc __mbrtowc
+#  define wcslen __wcslen
+#  define wcscoll __wcscoll
+#  define wcrtomb __wcrtomb
 
 /* We are also using some library internals.  */
 #  include <locale/localeinfo.h>
 #  include <locale/coll-lookup.h>
 # endif
 
-/* This is for other GNU distributions with internationalized messages.  */
-# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# ifdef _LIBC
 #  include <libintl.h>
-#  ifdef _LIBC
-#   undef gettext
-#   define gettext(msgid) __dcgettext ("libc", msgid, LC_MESSAGES)
-#  endif
+#  undef gettext
+#  define gettext(msgid) __dcgettext ("libc", msgid, LC_MESSAGES)
+   /* This define is so xgettext can find the internationalizable strings.  */
+#  define gettext_noop(msgid) msgid
 # else
-#  define gettext(msgid) (msgid)
+/* This is for other GNU distributions with internationalized messages.  */
+#  include "gettext.h"
 # endif
 
-# ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
-   strings.  */
-#  define gettext_noop(String) String
+/* Support for bounded pointers.  */
+# if !defined _LIBC && !defined __BOUNDED_POINTERS__
+#  define __bounded    /* nothing */
+#  define __unbounded  /* nothing */
+#  define __ptrvalue   /* nothing */
 # endif
 
 /* The `emacs' switch turns on certain matching commands
    even if config.h says that we can.  */
 #  undef REL_ALLOC
 
-#  if defined STDC_HEADERS || defined _LIBC
-#   include <stdlib.h>
-#  else
-char *malloc ();
-char *realloc ();
-#  endif
+#  include <stdlib.h>
 
 /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
    If nothing else has been done, use the method below.  */
@@ -143,22 +131,12 @@ char *realloc ();
    This is used in most programs--a few other programs avoid this
    by defining INHIBIT_STRING_HEADER.  */
 #  ifndef INHIBIT_STRING_HEADER
-#   if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
-#    include <string.h>
-#    ifndef bzero
-#     ifndef _LIBC
-#      define bzero(s, n)      (memset (s, '\0', n), (s))
-#     else
-#      define bzero(s, n)      __bzero (s, n)
-#     endif
-#    endif
-#   else
-#    include <strings.h>
-#    ifndef memcmp
-#     define memcmp(s1, s2, n) bcmp (s1, s2, n)
-#    endif
-#    ifndef memcpy
-#     define memcpy(d, s, n)   (bcopy (s, d, n), (d))
+#   include <string.h>
+#   ifndef bzero
+#    ifndef _LIBC
+#     define bzero(s, n)       (memset (s, '\0', n), (s))
+#    else
+#     define bzero(s, n)       __bzero (s, n)
 #    endif
 #   endif
 #  endif
@@ -179,9 +157,7 @@ char *realloc ();
 
 # endif /* not emacs */
 
-# if defined _LIBC || HAVE_LIMITS_H
-#  include <limits.h>
-# endif
+# include <limits.h>
 
 # ifndef MB_LEN_MAX
 #  define MB_LEN_MAX 1
@@ -239,22 +215,6 @@ char *realloc ();
 # else
 #  define TOLOWER(c) tolower(c)
 # endif
-
-# ifndef NULL
-#  define NULL (void *)0
-# endif
-
-/* We remove any previous definition of `SIGN_EXTEND_CHAR',
-   since ours (we hope) works properly with all combinations of
-   machines, compilers, `char' and `unsigned char' argument types.
-   (Per Bothner suggested the basic approach.)  */
-# undef SIGN_EXTEND_CHAR
-# if __STDC__
-#  define SIGN_EXTEND_CHAR(c) ((signed char) (c))
-# else  /* not __STDC__ */
-/* As in Harbison and Steele.  */
-#  define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
-# endif
 \f
 # ifndef emacs
 /* How many characters in the character set.  */
@@ -268,10 +228,8 @@ 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 ()
+init_syntax_once (void)
 {
    register int c;
    static int done = 0;
@@ -397,44 +355,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,
+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 startpos, int range,
-                                    struct re_registers *regs, int stop));
-static int byte_re_compile_fastmap PARAMS ((struct re_pattern_buffer *bufp));
+                                    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
@@ -631,6 +589,7 @@ typedef enum
 #  undef INSIDE_RECURSION
 # endif
 #endif
+#include "unlocked-io.h"
 
 #ifdef INSIDE_RECURSION
 /* Common operations on the compiled pattern.  */
@@ -675,21 +634,18 @@ typedef enum
 #  define EXTRACT_NUMBER(destination, source)                          \
   do {                                                                 \
     (destination) = *(source) & 0377;                                  \
-    (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8;          \
+    (destination) += (signed char) (*((source) + 1)) << 8;             \
   } while (0)
 # endif
 
 # ifdef DEBUG
-static void PREFIX(extract_number) _RE_ARGS ((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;
 #  else /* BYTE */
-  int temp = SIGN_EXTEND_CHAR (*(source + 1));
+  signed char temp = source[1];
   *dest = *source & 0377;
   *dest += temp << 8;
 #  endif
@@ -712,12 +668,8 @@ 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) (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;
@@ -768,8 +720,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;
@@ -801,9 +752,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;
@@ -1136,8 +1085,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;
 
@@ -1169,12 +1117,11 @@ 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,
+                            const CHAR_T *string2,
+                            int size1,
+                            int size2)
 {
   int this_char;
 
@@ -1241,26 +1188,26 @@ printchar (c)
    We assume offset_buffer and is_binary is already allocated
    enough space.  */
 
-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.  */
-
-     /* It hold correspondances between src(char string) and
-       dest(wchar_t string) for optimization.
-       e.g. src  = "xxxyzz"
-             dest = {'X', 'Y', 'Z'}
-             (each "xxx", "y" and "zz" represent one multibyte character
-              corresponding to 'X', 'Y' and 'Z'.)
-         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;
+convert_mbs_to_wcs (CHAR_T *dest,
+                   const unsigned char* src,
+
+                   /* The length of multibyte string.  */
+                   size_t len,
+
+                   /* Correspondences between src(char string) and
+                      dest(wchar_t string) for optimization.  E.g.:
+                      src  = "xxxyzz"
+                      dest = {'X', 'Y', 'Z'}
+                        (each "xxx", "y" and "zz" represent one
+                         multibyte character corresponding to 'X',
+                         'Y' and 'Z'.)
+                      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;
@@ -1327,8 +1274,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;
 
@@ -1901,35 +1847,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
@@ -2136,8 +2082,7 @@ static reg_errcode_t byte_compile_range _RE_ARGS ((unsigned int range_start,
     bufp->allocated <<= 1;                                             \
     if (bufp->allocated > MAX_BUF_SIZE)                                        \
       bufp->allocated = MAX_BUF_SIZE;                                  \
-    bufp->buffer = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR,           \
-                                               bufp->allocated);       \
+    bufp->buffer = REALLOC (COMPILED_BUFFER_VAR, bufp->allocated);     \
     if (COMPILED_BUFFER_VAR == NULL)                                   \
       return REG_ESPACE;                                               \
     /* If the buffer moved, move all the pointers into it.  */         \
@@ -2287,8 +2232,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)
     {
@@ -2309,9 +2253,9 @@ 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.
@@ -2342,11 +2286,10 @@ 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
@@ -3299,13 +3242,8 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
 
                         for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
                          {
-#  ifdef _LIBC
-                           if (__iswctype (__btowc (ch), wt))
-                             SET_LIST_BIT (ch);
-#  else
                            if (iswctype (btowc (ch), wt))
                              SET_LIST_BIT (ch);
-#  endif
 
                            if (translate && (is_upper || is_lower)
                                && (ISUPPER (ch) || ISLOWER (ch)))
@@ -4268,13 +4206,11 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
 # else /* not emacs */
        if (! fail_stack.stack)
          fail_stack.stack
-           = (PREFIX(fail_stack_elt_t) *) malloc (fail_stack.size
-                                  * sizeof (PREFIX(fail_stack_elt_t)));
+           = malloc (fail_stack.size * sizeof (PREFIX(fail_stack_elt_t)));
        else
          fail_stack.stack
-           = (PREFIX(fail_stack_elt_t) *) realloc (fail_stack.stack,
-                                           (fail_stack.size
-                                    * sizeof (PREFIX(fail_stack_elt_t))));
+           = realloc (fail_stack.stack,
+                      fail_stack.size * sizeof (PREFIX(fail_stack_elt_t)));
 # endif /* not emacs */
       }
 
@@ -4291,10 +4227,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);
@@ -4305,10 +4238,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);
@@ -4321,11 +4251,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;
@@ -4341,11 +4267,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;
@@ -4362,9 +4285,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] == '\\';
@@ -4381,9 +4303,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 == '\\';
@@ -4404,9 +4325,8 @@ 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;
 
@@ -4426,10 +4346,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;
@@ -4441,13 +4358,10 @@ 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;
@@ -4528,12 +4442,10 @@ 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;
@@ -4611,21 +4523,21 @@ byte_compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
 #ifdef WCHAR
 /* local function for re_compile_fastmap.
    truncate wchar_t character to char.  */
-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));
+  retval = wcrtomb (buf, c, &state);
+  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
@@ -4944,8 +4856,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)
@@ -4973,11 +4884,10 @@ 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 int num_regs,
+                 regoff_t *starts, regoff_t *ends)
 {
   if (num_regs)
     {
@@ -5003,11 +4913,10 @@ 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);
@@ -5039,14 +4948,12 @@ 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)
@@ -5102,15 +5009,12 @@ 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;
@@ -5493,11 +5397,10 @@ 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
@@ -5524,17 +5427,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,
+static boolean PREFIX(group_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) _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));
+                                       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
@@ -5551,13 +5454,11 @@ 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
@@ -5586,7 +5487,6 @@ weak_alias (__re_match_2, re_match_2)
 #ifdef INSIDE_RECURSION
 
 #ifdef WCHAR
-static int count_mbs_length PARAMS ((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
@@ -5594,9 +5494,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;
 
@@ -5637,33 +5535,31 @@ 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;
-     /* 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;
-     /* offset buffer for optimizatoin. See convert_mbs_to_wc.  */
-     int *mbs_offset1, *mbs_offset2;
+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
+                           setting up in this function.  */
+                        /* We need wchar_t * buffers corresponding to
+                           cstring1, cstring2.  */
+                        wchar_t *string1, int size1,
+                        wchar_t *string2, int size2,
+                        /* Offset buffer for optimization.  See
+                           convert_mbs_to_wc.  */
+                        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.  */
@@ -5797,6 +5693,88 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
   unsigned num_regs_pushed = 0;
 #endif
 
+  /* Definitions for state transitions.  More efficiently for gcc.  */
+#ifdef __GNUC__
+# if defined HAVE_SUBTRACT_LOCAL_LABELS && defined SHARED
+#  define NEXT \
+      do                                                                     \
+       {                                                                     \
+         int offset;                                                         \
+         const void *__unbounded ptr;                                        \
+         offset = (p == pend                                                 \
+                   ? 0 : jmptable[SWITCH_ENUM_CAST ((re_opcode_t) *p++)]);   \
+         ptr = &&end_of_pattern + offset;                                    \
+         goto *ptr;                                                          \
+       }                                                                     \
+      while (0)
+#  define REF(x) \
+  &&label_##x - &&end_of_pattern
+#  define JUMP_TABLE_TYPE const int
+# else
+#  define NEXT \
+      do                                                                     \
+       {                                                                     \
+         const void *__unbounded ptr;                                        \
+         ptr = (p == pend ? &&end_of_pattern                                 \
+                : jmptable[SWITCH_ENUM_CAST ((re_opcode_t) *p++)]);          \
+         goto *ptr;                                                          \
+       }                                                                     \
+      while (0)
+#  define REF(x) \
+  &&label_##x
+#  define JUMP_TABLE_TYPE const void *const
+# endif
+# define CASE(x) label_##x
+  static JUMP_TABLE_TYPE jmptable[] =
+    {
+    REF (no_op),
+    REF (succeed),
+    REF (exactn),
+# ifdef MBS_SUPPORT
+    REF (exactn_bin),
+# endif
+    REF (anychar),
+    REF (charset),
+    REF (charset_not),
+    REF (start_memory),
+    REF (stop_memory),
+    REF (duplicate),
+    REF (begline),
+    REF (endline),
+    REF (begbuf),
+    REF (endbuf),
+    REF (jump),
+    REF (jump_past_alt),
+    REF (on_failure_jump),
+    REF (on_failure_keep_string_jump),
+    REF (pop_failure_jump),
+    REF (maybe_pop_jump),
+    REF (dummy_failure_jump),
+    REF (push_dummy_failure),
+    REF (succeed_n),
+    REF (jump_n),
+    REF (set_number_at),
+    REF (wordchar),
+    REF (notwordchar),
+    REF (wordbeg),
+    REF (wordend),
+    REF (wordbound),
+    REF (notwordbound)
+# ifdef emacs
+    ,REF (before_dot),
+    REF (at_dot),
+    REF (after_dot),
+    REF (syntaxspec),
+    REF (notsyntaxspec)
+# endif
+    };
+#else
+# define NEXT \
+  break
+# define CASE(x) \
+  case x
+#endif
+
   DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
 
   INIT_FAIL_STACK ();
@@ -6019,13 +5997,21 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
       DEBUG_PRINT2 ("\n0x%x: ", p);
 #endif
 
+#ifdef __GNUC__
+      NEXT;
+#else
       if (p == pend)
-       { /* End of pattern means we might have succeeded.  */
-          DEBUG_PRINT1 ("end of pattern ... ");
+#endif
+       {
+#ifdef __GNUC__
+       end_of_pattern:
+#endif
+         /* End of pattern means we might have succeeded.  */
+         DEBUG_PRINT1 ("end of pattern ... ");
 
          /* If we haven't matched the entire string, and we want the
-             longest match, try backtracking.  */
-          if (d != end_match_2)
+            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.  */
@@ -6041,184 +6027,185 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
              else
                best_match_p = !MATCHING_IN_FIRST_STRING;
 
-              DEBUG_PRINT1 ("backtracking.\n");
+             DEBUG_PRINT1 ("backtracking.\n");
 
-              if (!FAIL_STACK_EMPTY ())
-                { /* More failure points to try.  */
+             if (!FAIL_STACK_EMPTY ())
+               { /* More failure points to try.  */
 
-                  /* If exceeds best match so far, save it.  */
-                  if (!best_regs_set || best_match_p)
-                    {
-                      best_regs_set = true;
-                      match_end = d;
+                 /* If exceeds best match so far, save it.  */
+                 if (!best_regs_set || best_match_p)
+                   {
+                     best_regs_set = true;
+                     match_end = d;
 
-                      DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
+                     DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
 
-                      for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
-                        {
-                          best_regstart[mcnt] = regstart[mcnt];
-                          best_regend[mcnt] = regend[mcnt];
-                        }
-                    }
-                  goto fail;
-                }
+                     for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
+                       {
+                         best_regstart[mcnt] = regstart[mcnt];
+                         best_regend[mcnt] = regend[mcnt];
+                       }
+                   }
+                 goto fail;
+               }
 
-              /* If no failure points, don't restore garbage.  And if
-                 last match is real best match, don't restore second
-                 best one. */
-              else if (best_regs_set && !best_match_p)
-                {
-               restore_best_regs:
-                  /* Restore best match.  It may happen that `dend ==
-                     end_match_1' while the restored d is in string2.
-                     For example, the pattern `x.*y.*z' against the
-                     strings `x-' and `y-z-', if the two strings are
-                     not consecutive in memory.  */
-                  DEBUG_PRINT1 ("Restoring best registers.\n");
-
-                  d = match_end;
-                  dend = ((d >= string1 && d <= end1)
-                          ? end_match_1 : end_match_2);
+             /* If no failure points, don't restore garbage.  And if
+                last match is real best match, don't restore second
+                best one. */
+             else if (best_regs_set && !best_match_p)
+               {
+               restore_best_regs:
+                 /* Restore best match.  It may happen that `dend ==
+                    end_match_1' while the restored d is in string2.
+                    For example, the pattern `x.*y.*z' against the
+                    strings `x-' and `y-z-', if the two strings are
+                    not consecutive in memory.  */
+                 DEBUG_PRINT1 ("Restoring best registers.\n");
+
+                 d = match_end;
+                 dend = ((d >= string1 && d <= end1)
+                         ? end_match_1 : end_match_2);
 
                  for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
                    {
                      regstart[mcnt] = best_regstart[mcnt];
                      regend[mcnt] = best_regend[mcnt];
                    }
-                }
-            } /* d != end_match_2 */
+               }
+           } /* d != end_match_2 */
 
        succeed_label:
-          DEBUG_PRINT1 ("Accepting match.\n");
-          /* If caller wants register contents data back, do it.  */
-          if (regs && !bufp->no_sub)
+         DEBUG_PRINT1 ("Accepting match.\n");
+         /* If caller wants register contents data back, do it.  */
+         if (regs && !bufp->no_sub)
            {
              /* Have the register data arrays been allocated?  */
-              if (bufp->regs_allocated == REGS_UNALLOCATED)
-                { /* No.  So allocate them with malloc.  We need one
-                     extra element beyond `num_regs' for the `-1' marker
-                     GNU code uses.  */
-                  regs->num_regs = MAX (RE_NREGS, num_regs + 1);
-                  regs->start = TALLOC (regs->num_regs, regoff_t);
-                  regs->end = TALLOC (regs->num_regs, regoff_t);
-                  if (regs->start == NULL || regs->end == NULL)
+             if (bufp->regs_allocated == REGS_UNALLOCATED)
+               { /* No.  So allocate them with malloc.  We need one
+                    extra element beyond `num_regs' for the `-1' marker
+                    GNU code uses.  */
+                 regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+                 regs->start = TALLOC (regs->num_regs, regoff_t);
+                 regs->end = TALLOC (regs->num_regs, regoff_t);
+                 if (regs->start == NULL || regs->end == NULL)
                    {
                      FREE_VARIABLES ();
                      return -2;
                    }
-                  bufp->regs_allocated = REGS_REALLOCATE;
-                }
-              else if (bufp->regs_allocated == REGS_REALLOCATE)
-                { /* Yes.  If we need more elements than were already
-                     allocated, reallocate them.  If we need fewer, just
-                     leave it alone.  */
-                  if (regs->num_regs < num_regs + 1)
-                    {
-                      regs->num_regs = num_regs + 1;
-                      RETALLOC (regs->start, regs->num_regs, regoff_t);
-                      RETALLOC (regs->end, regs->num_regs, regoff_t);
-                      if (regs->start == NULL || regs->end == NULL)
+                 bufp->regs_allocated = REGS_REALLOCATE;
+               }
+             else if (bufp->regs_allocated == REGS_REALLOCATE)
+               { /* Yes.  If we need more elements than were already
+                    allocated, reallocate them.  If we need fewer, just
+                    leave it alone.  */
+                 if (regs->num_regs < num_regs + 1)
+                   {
+                     regs->num_regs = num_regs + 1;
+                     RETALLOC (regs->start, regs->num_regs, regoff_t);
+                     RETALLOC (regs->end, regs->num_regs, regoff_t);
+                     if (regs->start == NULL || regs->end == NULL)
                        {
                          FREE_VARIABLES ();
                          return -2;
                        }
-                    }
-                }
-              else
+                   }
+               }
+             else
                {
                  /* These braces fend off a "empty body in an else-statement"
                     warning under GCC when assert expands to nothing.  */
                  assert (bufp->regs_allocated == REGS_FIXED);
                }
 
-              /* Convert the pointer data in `regstart' and `regend' to
-                 indices.  Register zero has to be set differently,
-                 since we haven't kept track of any info for it.  */
-              if (regs->num_regs > 0)
-                {
-                  regs->start[0] = pos;
+             /* Convert the pointer data in `regstart' and `regend' to
+                indices.  Register zero has to be set differently,
+                since we haven't kept track of any info for it.  */
+             if (regs->num_regs > 0)
+               {
+                 regs->start[0] = pos;
 #ifdef WCHAR
                  if (MATCHING_IN_FIRST_STRING)
-                   regs->end[0] = mbs_offset1 != NULL ?
-                                       mbs_offset1[d-string1] : 0;
+                   regs->end[0] = (mbs_offset1 != NULL ?
+                                   mbs_offset1[d-string1] : 0);
                  else
-                   regs->end[0] = csize1 + (mbs_offset2 != NULL ?
-                                            mbs_offset2[d-string2] : 0);
+                   regs->end[0] = csize1 + (mbs_offset2 != NULL
+                                            mbs_offset2[d-string2] : 0);
 #else
-                  regs->end[0] = (MATCHING_IN_FIRST_STRING
+                 regs->end[0] = (MATCHING_IN_FIRST_STRING
                                  ? ((regoff_t) (d - string1))
-                                 : ((regoff_t) (d - string2 + size1)));
+                                 : ((regoff_t) (d - string2 + size1)));
 #endif /* WCHAR */
-                }
+               }
 
-              /* Go through the first `min (num_regs, regs->num_regs)'
-                 registers, since that is all we initialized.  */
+             /* Go through the first `min (num_regs, regs->num_regs)'
+                registers, since that is all we initialized.  */
              for (mcnt = 1; (unsigned) mcnt < MIN (num_regs, regs->num_regs);
                   mcnt++)
                {
-                  if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
-                    regs->start[mcnt] = regs->end[mcnt] = -1;
-                  else
-                    {
+                 if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
+                   regs->start[mcnt] = regs->end[mcnt] = -1;
+                 else
+                   {
                      regs->start[mcnt]
                        = (regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
-                      regs->end[mcnt]
+                     regs->end[mcnt]
                        = (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
-                    }
+                   }
                }
 
-              /* If the regs structure we return has more elements than
-                 were in the pattern, set the extra elements to -1.  If
-                 we (re)allocated the registers, this is the case,
-                 because we always allocate enough to have at least one
-                 -1 at the end.  */
-              for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
-                regs->start[mcnt] = regs->end[mcnt] = -1;
+             /* If the regs structure we return has more elements than
+                were in the pattern, set the extra elements to -1.  If
+                we (re)allocated the registers, this is the case,
+                because we always allocate enough to have at least one
+                -1 at the end.  */
+             for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
+               regs->start[mcnt] = regs->end[mcnt] = -1;
            } /* regs && !bufp->no_sub */
 
-          DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
-                        nfailure_points_pushed, nfailure_points_popped,
-                        nfailure_points_pushed - nfailure_points_popped);
-          DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
+         DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
+                       nfailure_points_pushed, nfailure_points_popped,
+                       nfailure_points_pushed - nfailure_points_popped);
+         DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
 
 #ifdef WCHAR
          if (MATCHING_IN_FIRST_STRING)
            mcnt = mbs_offset1 != NULL ? mbs_offset1[d-string1] : 0;
          else
            mcnt = (mbs_offset2 != NULL ? mbs_offset2[d-string2] : 0) +
-                       csize1;
-          mcnt -= pos;
+             csize1;
+         mcnt -= pos;
 #else
-          mcnt = d - pos - (MATCHING_IN_FIRST_STRING
-                           ? string1
-                           : string2 - size1);
+         mcnt = d - pos - (MATCHING_IN_FIRST_STRING
+                           ? string1 : string2 - size1);
 #endif /* WCHAR */
 
-          DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
+         DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
 
-          FREE_VARIABLES ();
-          return mcnt;
-        }
+         FREE_VARIABLES ();
+         return mcnt;
+       }
 
+#ifndef __GNUC__
       /* Otherwise match next pattern command.  */
       switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
        {
+#endif
         /* Ignore these.  Used to ignore the n of succeed_n's which
            currently have n == 0.  */
-        case no_op:
+        CASE (no_op):
           DEBUG_PRINT1 ("EXECUTING no_op.\n");
-          break;
+          NEXT;
 
-       case succeed:
+       CASE (succeed):
           DEBUG_PRINT1 ("EXECUTING succeed.\n");
          goto succeed_label;
 
         /* Match the next n pattern characters exactly.  The following
            byte in the pattern defines n, and the n bytes after that
            are the characters to match.  */
-       case exactn:
+       CASE (exactn):
 #ifdef MBS_SUPPORT
-       case exactn_bin:
+       CASE (exactn_bin):
 #endif
          mcnt = *p++;
           DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
@@ -6260,11 +6247,11 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
              while (--mcnt);
            }
          SET_REGS_MATCHED ();
-          break;
+          NEXT;
 
 
         /* Match any character except possibly a newline or a null.  */
-       case anychar:
+       CASE (anychar):
           DEBUG_PRINT1 ("EXECUTING anychar.\n");
 
           PREFETCH ();
@@ -6276,11 +6263,11 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
           SET_REGS_MATCHED ();
           DEBUG_PRINT2 ("  Matched `%ld'.\n", (long int) *d);
           d++;
-         break;
+         NEXT;
 
 
-       case charset:
-       case charset_not:
+       CASE (charset):
+       CASE (charset_not):
          {
            register UCHAR_T c;
 #ifdef WCHAR
@@ -6364,12 +6351,12 @@ 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);
+                   length = wcslen (workp);
 
                    /* If wcscoll(the collating symbol, whole string) > 0,
                       any substring of the string never match with the
                       collating symbol.  */
-                   if (wcscoll(workp, d) > 0)
+                   if (wcscoll (workp, d) > 0)
                      {
                        workp += length + 1;
                        continue;
@@ -6394,7 +6381,7 @@ 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);
+                       match = wcscoll (workp, str_buf);
                        if (match == 0)
                          goto char_set_matched;
 
@@ -6505,12 +6492,12 @@ 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);
+                   length = wcslen (workp);
 
                    /* If wcscoll(the collating symbol, whole string) > 0,
                       any substring of the string never match with the
                       collating symbol.  */
-                   if (wcscoll(workp, d) > 0)
+                   if (wcscoll (workp, d) > 0)
                      {
                        workp += length + 1;
                        break;
@@ -6535,7 +6522,7 @@ 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);
+                       match = wcscoll (workp, str_buf);
 
                        if (match == 0)
                          goto char_set_matched;
@@ -6558,7 +6545,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;
@@ -6581,7 +6568,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].  */
@@ -6617,9 +6604,8 @@ 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)
-
+                   if (wcscoll (range_start_char, str_buf+2) <= 0
+                       && wcscoll (str_buf+2, range_end_char) <= 0)
                      goto char_set_matched;
                  }
              }
@@ -6647,7 +6633,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 #endif /* WCHAR */
            SET_REGS_MATCHED ();
             d++;
-           break;
+           NEXT;
          }
 
 
@@ -6656,7 +6642,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            number of groups inner to this one in the next.  The text
            matched within the group is recorded (in the internal
            registers data structure) under the register number.  */
-        case start_memory:
+        CASE (start_memory):
          DEBUG_PRINT3 ("EXECUTING start_memory %ld (%ld):\n",
                        (long int) *p, (long int) p[1]);
 
@@ -6699,13 +6685,13 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
           p += 2;
          just_past_start_mem = p;
 
-          break;
+          NEXT;
 
 
         /* The stop_memory opcode represents the end of a group.  Its
            arguments are the same as start_memory's: the register
            number, and the number of inner groups.  */
-       case stop_memory:
+       CASE (stop_memory):
          DEBUG_PRINT3 ("EXECUTING stop_memory %ld (%ld):\n",
                        (long int) *p, (long int) p[1]);
 
@@ -6838,12 +6824,12 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 
           /* Move past the register number and the inner group count.  */
           p += 2;
-          break;
+          NEXT;
 
 
        /* \<digit> has been turned into a `duplicate' command which is
            followed by the numeric value of <digit> as the register number.  */
-        case duplicate:
+        CASE (duplicate):
          {
            register const CHAR_T *d2, *dend2;
            int regno = *p++;   /* Get which register to match against.  */
@@ -6903,58 +6889,68 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
                SET_REGS_MATCHED ();
              }
          }
-         break;
+         NEXT;
 
 
         /* begline matches the empty string at the beginning of the string
            (unless `not_bol' is set in `bufp'), and, if
            `newline_anchor' is set, after newlines.  */
-       case begline:
+       CASE (begline):
           DEBUG_PRINT1 ("EXECUTING begline.\n");
 
           if (AT_STRINGS_BEG (d))
             {
-              if (!bufp->not_bol) break;
+              if (!bufp->not_bol)
+               {
+                 NEXT;
+               }
             }
           else if (d[-1] == '\n' && bufp->newline_anchor)
             {
-              break;
+              NEXT;
             }
           /* In all other cases, we fail.  */
           goto fail;
 
 
         /* endline is the dual of begline.  */
-       case endline:
+       CASE (endline):
           DEBUG_PRINT1 ("EXECUTING endline.\n");
 
           if (AT_STRINGS_END (d))
             {
-              if (!bufp->not_eol) break;
+              if (!bufp->not_eol)
+               {
+                 NEXT;
+               }
             }
 
           /* We have to ``prefetch'' the next character.  */
           else if ((d == end1 ? *string2 : *d) == '\n'
                    && bufp->newline_anchor)
             {
-              break;
+              NEXT;
             }
           goto fail;
 
 
        /* Match at the very beginning of the data.  */
-        case begbuf:
+        CASE (begbuf):
           DEBUG_PRINT1 ("EXECUTING begbuf.\n");
           if (AT_STRINGS_BEG (d))
-            break;
+           {
+             NEXT;
+           }
           goto fail;
 
 
        /* Match at the very end of the data.  */
-        case endbuf:
+        CASE (endbuf):
           DEBUG_PRINT1 ("EXECUTING endbuf.\n");
          if (AT_STRINGS_END (d))
-           break;
+           {
+             NEXT;
+           }
           goto fail;
 
 
@@ -6974,7 +6970,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            stack at all is that otherwise we would have to change
            `anychar's code to do something besides goto fail in this
            case; that seems worse than this.  */
-        case on_failure_keep_string_jump:
+        CASE (on_failure_keep_string_jump):
           DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
 
           EXTRACT_NUMBER_AND_INCR (mcnt, p);
@@ -6985,7 +6981,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 #endif
 
           PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
-          break;
+          NEXT;
 
 
        /* Uses of on_failure_jump:
@@ -7000,7 +6996,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            Repeats start with an on_failure_jump that points past both
            the repetition text and either the following jump or
            pop_failure_jump back to this on_failure_jump.  */
-       case on_failure_jump:
+       CASE (on_failure_jump):
         on_failure:
           DEBUG_PRINT1 ("EXECUTING on_failure_jump");
 
@@ -7042,12 +7038,12 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 
           DEBUG_PRINT1 (":\n");
           PUSH_FAILURE_POINT (p + mcnt, d, -2);
-          break;
+          NEXT;
 
 
         /* A smart repeat ends with `maybe_pop_jump'.
           We change it to either `pop_failure_jump' or `jump'.  */
-        case maybe_pop_jump:
+        CASE (maybe_pop_jump):
           EXTRACT_NUMBER_AND_INCR (mcnt, p);
           DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
           {
@@ -7215,7 +7211,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            points put on by this pop_failure_jump's matching
            on_failure_jump; we got through the pattern to here from the
            matching on_failure_jump, so didn't fail.  */
-        case pop_failure_jump:
+        CASE (pop_failure_jump):
           {
             /* We need to pass separate storage for the lowest and
                highest registers, even though we don't care about the
@@ -7242,7 +7238,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
           /* Note fall through.  */
 
         /* Unconditionally jump (without popping any failure points).  */
-        case jump:
+        CASE (jump):
          EXTRACT_NUMBER_AND_INCR (mcnt, p);    /* Get the amount to jump.  */
           DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
          p += mcnt;                            /* Do the jump.  */
@@ -7251,12 +7247,12 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 #else
           DEBUG_PRINT2 ("(to 0x%x).\n", p);
 #endif
-         break;
+         NEXT;
 
 
         /* We need this opcode so we can detect where alternatives end
            in `group_match_null_string_p' et al.  */
-        case jump_past_alt:
+        CASE (jump_past_alt):
           DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
           goto unconditional_jump;
 
@@ -7266,7 +7262,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            pop_failure_jump, also, and with a pattern of, say, `a+', we
            are skipping over the on_failure_jump, so we have to push
            something meaningless for pop_failure_jump to pop.  */
-        case dummy_failure_jump:
+        CASE (dummy_failure_jump):
           DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
           /* It doesn't matter what we push for the string here.  What
              the code at `fail' tests is the value for the pattern.  */
@@ -7279,16 +7275,16 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
            we don't want the failure point for the alternative to be
            popped.  For example, matching `(a|ab)*' against `aab'
            requires that we match the `ab' alternative.  */
-        case push_dummy_failure:
+        CASE (push_dummy_failure):
           DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
           /* See comments just above at `dummy_failure_jump' about the
              two zeroes.  */
           PUSH_FAILURE_POINT (NULL, NULL, -2);
-          break;
+          NEXT;
 
         /* Have to succeed matching what follows at least n times.
            After that, handle like `on_failure_jump'.  */
-        case succeed_n:
+        CASE (succeed_n):
           EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
           DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
 
@@ -7325,9 +7321,9 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
 #endif /* WCHAR */
               goto on_failure;
             }
-          break;
+          NEXT;
 
-        case jump_n:
+        CASE (jump_n):
           EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
           DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
 
@@ -7349,9 +7345,9 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
           /* If don't have to jump any more, skip over the rest of command.  */
          else
            p += 2 * OFFSET_ADDRESS_SIZE;
-          break;
+          NEXT;
 
-       case set_number_at:
+       CASE (set_number_at):
          {
             DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
 
@@ -7364,7 +7360,7 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
             DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p1, mcnt);
 #endif
            STORE_NUMBER (p1, mcnt);
-            break;
+            NEXT;
           }
 
 #if 0
@@ -7373,34 +7369,40 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
           AT_WORD_BOUNDARY, so this code is disabled.  Expanding the
           macro and introducing temporary variables works around the bug.  */
 
-       case wordbound:
+       CASE (wordbound):
          DEBUG_PRINT1 ("EXECUTING wordbound.\n");
          if (AT_WORD_BOUNDARY (d))
-           break;
+           {
+             NEXT;
+           }
          goto fail;
 
-       case notwordbound:
+       CASE (notwordbound):
          DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
          if (AT_WORD_BOUNDARY (d))
            goto fail;
-         break;
+         NEXT;
 #else
-       case wordbound:
+       CASE (wordbound):
        {
          boolean prevchar, thischar;
 
          DEBUG_PRINT1 ("EXECUTING wordbound.\n");
          if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
-           break;
+           {
+             NEXT;
+           }
 
          prevchar = WORDCHAR_P (d - 1);
          thischar = WORDCHAR_P (d);
          if (prevchar != thischar)
-           break;
+           {
+             NEXT;
+           }
          goto fail;
        }
 
-      case notwordbound:
+      CASE (notwordbound):
        {
          boolean prevchar, thischar;
 
@@ -7412,49 +7414,53 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
          thischar = WORDCHAR_P (d);
          if (prevchar != thischar)
            goto fail;
-         break;
+         NEXT;
        }
 #endif
 
-       case wordbeg:
+       CASE (wordbeg):
           DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
          if (!AT_STRINGS_END (d) && WORDCHAR_P (d)
              && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
-           break;
+           {
+             NEXT;
+           }
           goto fail;
 
-       case wordend:
+       CASE (wordend):
           DEBUG_PRINT1 ("EXECUTING wordend.\n");
          if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
               && (AT_STRINGS_END (d) || !WORDCHAR_P (d)))
-           break;
+           {
+             NEXT;
+           }
           goto fail;
 
 #ifdef emacs
-       case before_dot:
+       CASE (before_dot):
           DEBUG_PRINT1 ("EXECUTING before_dot.\n");
          if (PTR_CHAR_POS ((unsigned char *) d) >= point)
            goto fail;
-         break;
+         NEXT;
 
-       case at_dot:
+       CASE (at_dot):
           DEBUG_PRINT1 ("EXECUTING at_dot.\n");
          if (PTR_CHAR_POS ((unsigned char *) d) != point)
            goto fail;
-         break;
+         NEXT;
 
-       case after_dot:
+       CASE (after_dot):
           DEBUG_PRINT1 ("EXECUTING after_dot.\n");
           if (PTR_CHAR_POS ((unsigned char *) d) <= point)
            goto fail;
-         break;
+         NEXT;
 
-       case syntaxspec:
+       CASE (syntaxspec):
           DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
          mcnt = *p++;
          goto matchsyntax;
 
-        case wordchar:
+        CASE (wordchar):
           DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
          mcnt = (int) Sword;
         matchsyntax:
@@ -7464,14 +7470,14 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
          if (SYNTAX (d[-1]) != (enum syntaxcode) mcnt)
            goto fail;
           SET_REGS_MATCHED ();
-         break;
+         NEXT;
 
-       case notsyntaxspec:
+       CASE (notsyntaxspec):
           DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
          mcnt = *p++;
          goto matchnotsyntax;
 
-        case notwordchar:
+        CASE (notwordchar):
           DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
          mcnt = (int) Sword;
         matchnotsyntax:
@@ -7481,32 +7487,34 @@ byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
          if (SYNTAX (d[-1]) == (enum syntaxcode) mcnt)
            goto fail;
          SET_REGS_MATCHED ();
-          break;
+          NEXT;
 
 #else /* not emacs */
-       case wordchar:
+       CASE (wordchar):
           DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
          PREFETCH ();
           if (!WORDCHAR_P (d))
             goto fail;
          SET_REGS_MATCHED ();
           d++;
-         break;
+         NEXT;
 
-       case notwordchar:
+       CASE (notwordchar):
           DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
          PREFETCH ();
          if (WORDCHAR_P (d))
             goto fail;
           SET_REGS_MATCHED ();
           d++;
-         break;
+         NEXT;
 #endif /* not emacs */
 
+#ifndef __GNUC__
         default:
           abort ();
        }
       continue;  /* Successfully executed one pattern command; keep going.  */
+#endif
 
 
     /* We goto here if a matching operation fails. */
@@ -7580,9 +7588,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.  */
@@ -7692,9 +7699,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;
@@ -7729,9 +7735,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;
@@ -7817,10 +7822,9 @@ 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;
@@ -7853,10 +7857,9 @@ 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;
 
@@ -7902,8 +7905,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;
 
@@ -7916,13 +7918,13 @@ re_comp (s)
 
   if (!re_comp_buf.buffer)
     {
-      re_comp_buf.buffer = (unsigned char *) malloc (200);
+      re_comp_buf.buffer = malloc (200);
       if (re_comp_buf.buffer == NULL)
         return (char *) gettext (re_error_msgid
                                 + re_error_msgid_idx[(int) REG_ESPACE]);
       re_comp_buf.allocated = 200;
 
-      re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
+      re_comp_buf.fastmap = malloc (1 << BYTEWIDTH);
       if (re_comp_buf.fastmap == NULL)
        return (char *) gettext (re_error_msgid
                                 + re_error_msgid_idx[(int) REG_ESPACE]);
@@ -7953,12 +7955,11 @@ int
 #ifdef _LIBC
 weak_function
 #endif
-re_exec (s)
-    const char *s;
+re_exec (const char *s)
 {
   const int len = strlen (s);
   return
-    0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
+    0 <= re_search (&re_comp_buf, s, len, 0, len, 0);
 }
 
 #endif /* _REGEX_RE_COMP */
@@ -8003,10 +8004,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
@@ -8019,15 +8017,14 @@ regcomp (preg, pattern, cflags)
   preg->used = 0;
 
   /* Try to allocate space for the fastmap.  */
-  preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
+  preg->fastmap = malloc (1 << BYTEWIDTH);
 
   if (cflags & REG_ICASE)
     {
       unsigned i;
 
-      preg->translate
-       = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
-                                     * sizeof (*(RE_TRANSLATE_TYPE)0));
+      preg->translate = malloc (CHAR_SET_SIZE
+                               * sizeof (*(RE_TRANSLATE_TYPE)0));
       if (preg->translate == NULL)
         return (int) REG_ESPACE;
 
@@ -8099,12 +8096,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;
@@ -8134,7 +8127,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
   /* Perform the searching operation.  */
   ret = re_search (&private_preg, string, len,
                    /* start: */ 0, /* range: */ len,
-                   want_reg_info ? &regs : (struct re_registers *) 0);
+                   want_reg_info ? &regs : 0);
 
   /* Copy the register information to the POSIX structure.  */
   if (want_reg_info)
@@ -8166,11 +8159,7 @@ 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, char *errbuf, size_t errbuf_size)
 {
   const char *msg;
   size_t msg_size;
@@ -8213,8 +8202,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);