changeset 4673:8135c02e42f8

Remove K&R cruft.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 10 Sep 2003 06:18:22 +0000
parents 55a4d3c67ca7
children 092d9a2797a7
files config/srclist.txt lib/regex.c lib/regex.h m4/regex.m4
diffstat 4 files changed, 265 insertions(+), 412 deletions(-) [+]
line wrap: on
line diff
--- a/config/srclist.txt
+++ b/config/srclist.txt
@@ -1,4 +1,4 @@
-# $Id: srclist.txt,v 1.24 2003-09-09 18:36:53 eggert Exp $
+# $Id: srclist.txt,v 1.25 2003-09-10 06:18:22 eggert Exp $
 # Files for which we are not the source.  See ./srclistvars.sh for the
 # variable definitions.
 
@@ -74,7 +74,6 @@
 $LIBCSRC/argp/argp-pvh.c		lib gpl
 $LIBCSRC/argp/argp-xinl.c		lib gpl
 $LIBCSRC/argp/argp.h			lib gpl
-$LIBCSRC/posix/regex.h			lib gpl
 $LIBCSRC/string/strdup.c		lib gpl
 $LIBCSRC/sysdeps/generic/strtoll.c	lib gpl
 $LIBCSRC/sysdeps/generic/strtoul.c	lib gpl
@@ -96,6 +95,7 @@
 #$LIBCSRC/posix/getopt.c		lib gpl
 #$LIBCSRC/posix/getopt.h		lib gpl
 #$LIBCSRC/posix/getopt1.c		lib gpl
+#$LIBCSRC/posix/regex.h			lib gpl
 #$LIBCSRC/posix/tempname.c		lib gpl
 #$LIBCSRC/stdlib/rpmatch.c		lib gpl
 #$LIBCSRC/string/strndup.c		lib gpl
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -2,8 +2,9 @@
    version 0.12.
    (Implements POSIX draft P1003.2/D11.2, except for some of the
    internationalization features.)
-   Copyright (C) 1993-1999, 2000-2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
+
+   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -31,22 +32,9 @@
 # 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)
 
@@ -127,12 +115,7 @@
    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.  */
@@ -148,22 +131,12 @@
    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
@@ -184,9 +157,7 @@
 
 # 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
@@ -244,22 +215,6 @@
 # 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
 
 # ifndef emacs
 /* How many characters in the character set.  */
@@ -273,10 +228,8 @@
 
 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;
@@ -402,44 +355,44 @@
 # 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
 
 /* These are the command codes that appear in compiled regular
@@ -681,21 +634,18 @@
 #  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
@@ -718,12 +668,8 @@
   } 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;
@@ -774,8 +720,7 @@
 
 #  ifndef DEFINED_ONCE
 void
-print_fastmap (fastmap)
-    char *fastmap;
+print_fastmap (char *fastmap)
 {
   unsigned was_a_range = 0;
   unsigned i = 0;
@@ -807,9 +752,7 @@
    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;
@@ -1142,8 +1085,7 @@
 
 
 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;
 
@@ -1175,12 +1117,11 @@
 
 
 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;
 
@@ -1247,26 +1188,26 @@
    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;
@@ -1333,8 +1274,7 @@
    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;
 
@@ -1907,35 +1847,35 @@
 # 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
@@ -2142,8 +2082,7 @@
     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.  */		\
@@ -2293,8 +2232,7 @@
    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)
     {
@@ -2315,9 +2253,9 @@
 # endif /* not MATCH_MAY_ALLOCATE */
 
 # 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.
@@ -2348,11 +2286,10 @@
 # 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
@@ -4269,13 +4206,11 @@
 # 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 */
       }
 
@@ -4292,10 +4227,7 @@
 /* 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);
@@ -4306,10 +4238,7 @@
 /* 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);
@@ -4322,11 +4251,7 @@
 /* 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;
@@ -4342,11 +4267,8 @@
 /* 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;
@@ -4363,9 +4285,8 @@
    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] == '\\';
@@ -4382,9 +4303,8 @@
    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 == '\\';
@@ -4405,9 +4325,8 @@
    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;
 
@@ -4427,10 +4346,7 @@
 /* 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;
@@ -4442,13 +4358,10 @@
 
 #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;
@@ -4529,12 +4442,10 @@
    `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;
@@ -4612,11 +4523,9 @@
 #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_CUR_MAX];
   mbstate_t state;
@@ -4628,8 +4537,7 @@
 #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
@@ -4948,8 +4856,7 @@
 #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)
@@ -4977,11 +4884,10 @@
    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)
     {
@@ -5007,11 +4913,10 @@
    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);
@@ -5043,14 +4948,12 @@
    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)
@@ -5106,15 +5009,12 @@
 
 
 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;
@@ -5497,11 +5397,10 @@
 /* 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
@@ -5528,17 +5427,17 @@
 #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
@@ -5555,13 +5454,11 @@
    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
@@ -5590,7 +5487,6 @@
 #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
@@ -5598,9 +5494,7 @@
    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;
 
@@ -5641,33 +5535,31 @@
    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.  */
@@ -7696,9 +7588,8 @@
    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.  */
@@ -7808,9 +7699,8 @@
    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;
@@ -7845,9 +7735,8 @@
    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;
@@ -7933,10 +7822,9 @@
    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;
@@ -7969,10 +7857,9 @@
    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;
 
@@ -8018,8 +7905,7 @@
    regcomp/regexec below without link errors.  */
 weak_function
 #endif
-re_comp (s)
-    const char *s;
+re_comp (const char *s)
 {
   reg_errcode_t ret;
 
@@ -8032,13 +7918,13 @@
 
   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]);
@@ -8069,12 +7955,11 @@
 #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 */
@@ -8119,10 +8004,7 @@
    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
@@ -8135,15 +8017,14 @@
   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;
 
@@ -8215,12 +8096,8 @@
    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;
@@ -8250,7 +8127,7 @@
   /* 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)
@@ -8282,11 +8159,7 @@
    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;
@@ -8329,8 +8202,7 @@
 /* Free dynamically allocated space used by PREG.  */
 
 void
-regfree (preg)
-    regex_t *preg;
+regfree (regex_t *preg)
 {
   if (preg->buffer != NULL)
     free (preg->buffer);
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -434,38 +434,21 @@
 
 /* Declarations for routines.  */
 
-/* To avoid duplicating every routine declaration -- once with a
-   prototype (if we are ANSI), and once without (if we aren't) -- we
-   use the following macro to declare argument types.  This
-   unfortunately clutters up the declarations a bit, but I think it's
-   worth it.  */
-
-#if __STDC__
-
-# define _RE_ARGS(args) args
-
-#else /* not __STDC__ */
-
-# define _RE_ARGS(args) ()
-
-#endif /* not __STDC__ */
-
 /* Sets the current default syntax to SYNTAX, and return the old syntax.
    You can also simply assign to the `re_syntax_options' variable.  */
-extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
+extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
 
 /* Compile the regular expression PATTERN, with length LENGTH
    and syntax given by the global `re_syntax_options', into the buffer
    BUFFER.  Return NULL if successful, and an error string if not.  */
-extern const char *re_compile_pattern
-  _RE_ARGS ((const char *pattern, size_t length,
-             struct re_pattern_buffer *buffer));
+extern const char *re_compile_pattern (const char *pattern, size_t length,
+				       struct re_pattern_buffer *buffer);
 
 
 /* Compile a fastmap for the compiled pattern in BUFFER; used to
    accelerate searches.  Return 0 if successful and -2 if was an
    internal error.  */
-extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
+extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
 
 
 /* Search in the string STRING (with length LENGTH) for the pattern
@@ -473,31 +456,29 @@
    characters.  Return the starting position of the match, -1 for no
    match, or -2 for an internal error.  Also return register
    information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
-extern int re_search
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
-            int length, int start, int range, struct re_registers *regs));
+extern int re_search (struct re_pattern_buffer *buffer, const char *string,
+		      int length, int start, int range,
+		      struct re_registers *regs);
 
 
 /* Like `re_search', but search in the concatenation of STRING1 and
    STRING2.  Also, stop searching at index START + STOP.  */
-extern int re_search_2
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
-             int length1, const char *string2, int length2,
-             int start, int range, struct re_registers *regs, int stop));
+extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1,
+			int length1, const char *string2, int length2,
+			int start, int range, struct re_registers *regs,
+			int stop);
 
 
 /* Like `re_search', but return how many characters in STRING the regexp
    in BUFFER matched, starting at position START.  */
-extern int re_match
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
-             int length, int start, struct re_registers *regs));
+extern int re_match (struct re_pattern_buffer *buffer, const char *string,
+		     int length, int start, struct re_registers *regs);
 
 
 /* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
-extern int re_match_2
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
-             int length1, const char *string2, int length2,
-             int start, struct re_registers *regs, int stop));
+extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1,
+		       int length1, const char *string2, int length2,
+		       int start, struct re_registers *regs, int stop);
 
 
 /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -512,15 +493,15 @@
    Unless this function is called, the first search or match using
    PATTERN_BUFFER will allocate its own register data, without
    freeing the old data.  */
-extern void re_set_registers
-  _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
-             unsigned num_regs, regoff_t *starts, regoff_t *ends));
+extern void re_set_registers (struct re_pattern_buffer *buffer,
+			      struct re_registers *regs, unsigned num_regs,
+			      regoff_t *starts, regoff_t *ends);
 
 #if defined _REGEX_RE_COMP || defined _LIBC
 # ifndef _CRAY
 /* 4.2 bsd compatibility.  */
-extern char *re_comp _RE_ARGS ((const char *));
-extern int re_exec _RE_ARGS ((const char *));
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
 # endif
 #endif
 
@@ -545,19 +526,19 @@
 #endif
 
 /* POSIX compatibility.  */
-extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
-			      const char *__restrict __pattern,
-			      int __cflags));
+extern int regcomp (regex_t *__restrict __preg,
+		    const char *__restrict __pattern,
+		    int __cflags);
 
-extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
-			      const char *__restrict __string, size_t __nmatch,
-			      regmatch_t __pmatch[__restrict_arr],
-			      int __eflags));
+extern int regexec (const regex_t *__restrict __preg,
+		    const char *__restrict __string, size_t __nmatch,
+		    regmatch_t __pmatch[__restrict_arr],
+		    int __eflags);
 
-extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
-				  char *__errbuf, size_t __errbuf_size));
+extern size_t regerror (int __errcode, const regex_t *__preg,
+			char *__errbuf, size_t __errbuf_size);
 
-extern void regfree _RE_ARGS ((regex_t *__preg));
+extern void regfree (regex_t *__preg);
 
 
 #ifdef __cplusplus
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,4 +1,4 @@
-#serial 19
+#serial 20
 
 dnl Initially derived from code in GNU grep.
 dnl Mostly written by Jim Meyering.
@@ -113,7 +113,7 @@
   AC_REQUIRE([gl_C_RESTRICT])
   AC_REQUIRE([AC_FUNC_ALLOCA])
   AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS_ONCE(limits.h string.h wchar.h wctype.h)
+  AC_CHECK_HEADERS_ONCE(wchar.h wctype.h)
   AC_CHECK_FUNCS_ONCE(isascii mempcpy)
   AC_CHECK_FUNCS(btowc)
 ])