Explorar o código

regex.h: sync with glibc, making it more POSIX-like

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Peter S. Mazinger %!s(int64=13) %!d(string=hai) anos
pai
achega
1a6e3c3f8f
Modificáronse 1 ficheiros con 73 adicións e 65 borrados
  1. 73 65
      include/regex.h

+ 73 - 65
include/regex.h

@@ -1,6 +1,6 @@
 /* Definitions for data structures and routines for the regular
 /* Definitions for data structures and routines for the regular
    expression library.
    expression library.
-   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005
+   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
    Free Software Foundation, Inc.
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    This file is part of the GNU C Library.
 
 
@@ -22,21 +22,10 @@
 #ifndef _REGEX_H
 #ifndef _REGEX_H
 #define _REGEX_H 1
 #define _REGEX_H 1
 
 
-#include <features.h>
-
 #include <sys/types.h>
 #include <sys/types.h>
 
 
 __BEGIN_DECLS
 __BEGIN_DECLS
 
 
-/* POSIX says that <sys/types.h> must be included (by the caller) before
-   <regex.h>.  */
-
-#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
-/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
-   should be there.  */
-# include <stddef.h>
-#endif
-
 /* The following two types have to be signed and unsigned integer type
 /* The following two types have to be signed and unsigned integer type
    wide enough to hold a value of a pointer.  For most ANSI compilers
    wide enough to hold a value of a pointer.  For most ANSI compilers
    ptrdiff_t and size_t should be likely OK.  Still size of these two
    ptrdiff_t and size_t should be likely OK.  Still size of these two
@@ -51,20 +40,21 @@ typedef unsigned long int active_reg_t;
    add or remove a bit, only one other definition need change.  */
    add or remove a bit, only one other definition need change.  */
 typedef unsigned long int reg_syntax_t;
 typedef unsigned long int reg_syntax_t;
 
 
+#ifdef __USE_GNU
 /* If this bit is not set, then \ inside a bracket expression is literal.
 /* If this bit is not set, then \ inside a bracket expression is literal.
    If set, then such a \ quotes the following character.  */
    If set, then such a \ quotes the following character.  */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
 
 
 /* If this bit is not set, then + and ? are operators, and \+ and \? are
 /* If this bit is not set, then + and ? are operators, and \+ and \? are
      literals.
      literals.
    If set, then \+ and \? are operators and + and ? are literals.  */
    If set, then \+ and \? are operators and + and ? are literals.  */
-#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
 
 
 /* If this bit is set, then character classes are supported.  They are:
 /* If this bit is set, then character classes are supported.  They are:
      [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
      [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
    If not set, then character classes are not supported.  */
    If not set, then character classes are not supported.  */
-#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
 
 
 /* If this bit is set, then ^ and $ are always anchors (outside bracket
 /* If this bit is set, then ^ and $ are always anchors (outside bracket
      expressions, of course).
      expressions, of course).
@@ -78,7 +68,7 @@ typedef unsigned long int reg_syntax_t;
    POSIX draft 11.2 says that * etc. in leading positions is undefined.
    POSIX draft 11.2 says that * etc. in leading positions is undefined.
    We already implemented a previous draft which made those constructs
    We already implemented a previous draft which made those constructs
    invalid, though, so we haven't changed the code back.  */
    invalid, though, so we haven't changed the code back.  */
-#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
 
 
 /* If this bit is set, then special characters are always special
 /* If this bit is set, then special characters are always special
      regardless of where they are in the pattern.
      regardless of where they are in the pattern.
@@ -86,71 +76,71 @@ typedef unsigned long int reg_syntax_t;
      some contexts; otherwise they are ordinary.  Specifically,
      some contexts; otherwise they are ordinary.  Specifically,
      * + ? and intervals are only special when not after the beginning,
      * + ? and intervals are only special when not after the beginning,
      open-group, or alternation operator.  */
      open-group, or alternation operator.  */
-#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
 
 
 /* If this bit is set, then *, +, ?, and { cannot be first in an re or
 /* If this bit is set, then *, +, ?, and { cannot be first in an re or
      immediately after an alternation or begin-group operator.  */
      immediately after an alternation or begin-group operator.  */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
 
 
 /* If this bit is set, then . matches newline.
 /* If this bit is set, then . matches newline.
    If not set, then it doesn't.  */
    If not set, then it doesn't.  */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
 
 
 /* If this bit is set, then . doesn't match NUL.
 /* If this bit is set, then . doesn't match NUL.
    If not set, then it does.  */
    If not set, then it does.  */
-#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
 
 
 /* If this bit is set, nonmatching lists [^...] do not match newline.
 /* If this bit is set, nonmatching lists [^...] do not match newline.
    If not set, they do.  */
    If not set, they do.  */
-#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
 
 
 /* If this bit is set, either \{...\} or {...} defines an
 /* If this bit is set, either \{...\} or {...} defines an
      interval, depending on RE_NO_BK_BRACES.
      interval, depending on RE_NO_BK_BRACES.
    If not set, \{, \}, {, and } are literals.  */
    If not set, \{, \}, {, and } are literals.  */
-#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
 
 
 /* If this bit is set, +, ? and | aren't recognized as operators.
 /* If this bit is set, +, ? and | aren't recognized as operators.
    If not set, they are.  */
    If not set, they are.  */
-#define RE_LIMITED_OPS (RE_INTERVALS << 1)
+# define RE_LIMITED_OPS (RE_INTERVALS << 1)
 
 
 /* If this bit is set, newline is an alternation operator.
 /* If this bit is set, newline is an alternation operator.
    If not set, newline is literal.  */
    If not set, newline is literal.  */
-#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
 
 
 /* If this bit is set, then `{...}' defines an interval, and \{ and \}
 /* If this bit is set, then `{...}' defines an interval, and \{ and \}
      are literals.
      are literals.
   If not set, then `\{...\}' defines an interval.  */
   If not set, then `\{...\}' defines an interval.  */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
 
 
 /* If this bit is set, (...) defines a group, and \( and \) are literals.
 /* If this bit is set, (...) defines a group, and \( and \) are literals.
    If not set, \(...\) defines a group, and ( and ) are literals.  */
    If not set, \(...\) defines a group, and ( and ) are literals.  */
-#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
 
 
 /* If this bit is set, then \<digit> matches <digit>.
 /* If this bit is set, then \<digit> matches <digit>.
    If not set, then \<digit> is a back-reference.  */
    If not set, then \<digit> is a back-reference.  */
-#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
 
 
 /* If this bit is set, then | is an alternation operator, and \| is literal.
 /* If this bit is set, then | is an alternation operator, and \| is literal.
    If not set, then \| is an alternation operator, and | is literal.  */
    If not set, then \| is an alternation operator, and | is literal.  */
-#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
 
 
 /* If this bit is set, then an ending range point collating higher
 /* If this bit is set, then an ending range point collating higher
      than the starting range point, as in [z-a], is invalid.
      than the starting range point, as in [z-a], is invalid.
    If not set, then when ending range point collates higher than the
    If not set, then when ending range point collates higher than the
      starting range point, the range is ignored.  */
      starting range point, the range is ignored.  */
-#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
 
 
 /* If this bit is set, then an unmatched ) is ordinary.
 /* If this bit is set, then an unmatched ) is ordinary.
    If not set, then an unmatched ) is invalid.  */
    If not set, then an unmatched ) is invalid.  */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
 
 
 /* If this bit is set, succeed as soon as we match the whole pattern,
 /* If this bit is set, succeed as soon as we match the whole pattern,
    without further backtracking.  */
    without further backtracking.  */
-#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
 
 
 /* If this bit is set, do not process the GNU regex operators.
 /* If this bit is set, do not process the GNU regex operators.
    If not set, then the GNU regex operators are recognized. */
    If not set, then the GNU regex operators are recognized. */
-#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
 
 
 /* If this bit is set, turn on internal regex debugging.
 /* If this bit is set, turn on internal regex debugging.
    If not set, and debugging was on, turn it off.
    If not set, and debugging was on, turn it off.
@@ -158,29 +148,30 @@ typedef unsigned long int reg_syntax_t;
    We define this bit always, so that all that's needed to turn on
    We define this bit always, so that all that's needed to turn on
    debugging is to recompile regex.c; the calling code can always have
    debugging is to recompile regex.c; the calling code can always have
    this bit set, and it won't affect anything in the normal case. */
    this bit set, and it won't affect anything in the normal case. */
-#define RE_DEBUG (RE_NO_GNU_OPS << 1)
+# define RE_DEBUG (RE_NO_GNU_OPS << 1)
 
 
 /* If this bit is set, a syntactically invalid interval is treated as
 /* If this bit is set, a syntactically invalid interval is treated as
    a string of ordinary characters.  For example, the ERE 'a{1' is
    a string of ordinary characters.  For example, the ERE 'a{1' is
    treated as 'a\{1'.  */
    treated as 'a\{1'.  */
-#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
 
 
 /* If this bit is set, then ignore case when matching.
 /* If this bit is set, then ignore case when matching.
    If not set, then case is significant.  */
    If not set, then case is significant.  */
-#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
+# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
 
 
 /* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
 /* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
    for ^, because it is difficult to scan the regex backwards to find
    for ^, because it is difficult to scan the regex backwards to find
    whether ^ should be special.  */
    whether ^ should be special.  */
-#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
+# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
 
 
 /* If this bit is set, then \{ cannot be first in an bre or
 /* If this bit is set, then \{ cannot be first in an bre or
    immediately after an alternation or begin-group operator.  */
    immediately after an alternation or begin-group operator.  */
-#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
+# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
 
 
 /* If this bit is set, then no_sub will be set to 1 during
 /* If this bit is set, then no_sub will be set to 1 during
    re_compile_pattern.  */
    re_compile_pattern.  */
-#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+#endif
 
 
 /* This global variable defines the particular regexp syntax to use (for
 /* This global variable defines the particular regexp syntax to use (for
    some interfaces).  When a regexp is compiled, the syntax used is
    some interfaces).  When a regexp is compiled, the syntax used is
@@ -188,6 +179,7 @@ typedef unsigned long int reg_syntax_t;
    already-compiled regexps.  */
    already-compiled regexps.  */
 extern reg_syntax_t re_syntax_options;
 extern reg_syntax_t re_syntax_options;
 
 
+#ifdef __USE_GNU
 /* Define combinations of the above bits for the standard possibilities.
 /* Define combinations of the above bits for the standard possibilities.
    (The [[[ comments delimit what gets put into the Texinfo file, so
    (The [[[ comments delimit what gets put into the Texinfo file, so
    don't delete them!)  */
    don't delete them!)  */
@@ -262,11 +254,12 @@ extern reg_syntax_t re_syntax_options;
 /* Maximum number of duplicates an interval can allow.  Some systems
 /* Maximum number of duplicates an interval can allow.  Some systems
    (erroneously) define this in other header files, but we want our
    (erroneously) define this in other header files, but we want our
    value, so remove any previous define.  */
    value, so remove any previous define.  */
-#ifdef RE_DUP_MAX
-# undef RE_DUP_MAX
-#endif
+# ifdef RE_DUP_MAX
+#  undef RE_DUP_MAX
+# endif
 /* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
 /* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
-#define RE_DUP_MAX (0x7fff)
+# define RE_DUP_MAX (0x7fff)
+#endif
 
 
 
 
 /* POSIX `cflags' bits (i.e., information for `regcomp').  */
 /* POSIX `cflags' bits (i.e., information for `regcomp').  */
@@ -310,7 +303,7 @@ extern reg_syntax_t re_syntax_options;
    `re_error_msg' table in regex.c.  */
    `re_error_msg' table in regex.c.  */
 typedef enum
 typedef enum
 {
 {
-#ifdef _XOPEN_SOURCE
+#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
   REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
   REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
 #endif
 #endif
 
 
@@ -345,7 +338,16 @@ typedef enum
    private to the regex routines.  */
    private to the regex routines.  */
 
 
 #ifndef RE_TRANSLATE_TYPE
 #ifndef RE_TRANSLATE_TYPE
-# define RE_TRANSLATE_TYPE unsigned char *
+# define __RE_TRANSLATE_TYPE unsigned char *
+# ifdef __USE_GNU
+#  define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
+# endif
+#endif
+
+#ifdef __USE_GNU
+# define __REPB_PREFIX(name) name
+#else
+# define __REPB_PREFIX(name) __##name
 #endif
 #endif
 
 
 struct re_pattern_buffer
 struct re_pattern_buffer
@@ -353,27 +355,27 @@ struct re_pattern_buffer
   /* Space that holds the compiled pattern.  It is declared as
   /* Space that holds the compiled pattern.  It is declared as
      `unsigned char *' because its elements are sometimes used as
      `unsigned char *' because its elements are sometimes used as
      array indexes.  */
      array indexes.  */
-  unsigned char *buffer;
+  unsigned char *__REPB_PREFIX(buffer);
 
 
   /* Number of bytes to which `buffer' points.  */
   /* Number of bytes to which `buffer' points.  */
-  unsigned long int allocated;
+  unsigned long int __REPB_PREFIX(allocated);
 
 
   /* Number of bytes actually used in `buffer'.  */
   /* Number of bytes actually used in `buffer'.  */
-  unsigned long int used;
+  unsigned long int __REPB_PREFIX(used);
 
 
   /* Syntax setting with which the pattern was compiled.  */
   /* Syntax setting with which the pattern was compiled.  */
-  reg_syntax_t syntax;
+  reg_syntax_t __REPB_PREFIX(syntax);
 
 
   /* Pointer to a fastmap, if any, otherwise zero.  re_search uses the
   /* Pointer to a fastmap, if any, otherwise zero.  re_search uses the
      fastmap, if there is one, to skip over impossible starting points
      fastmap, if there is one, to skip over impossible starting points
      for matches.  */
      for matches.  */
-  char *fastmap;
+  char *__REPB_PREFIX(fastmap);
 
 
   /* Either a translate table to apply to all characters before
   /* Either a translate table to apply to all characters before
      comparing them, or zero for no translation.  The translation is
      comparing them, or zero for no translation.  The translation is
      applied to a pattern when it is compiled and to a string when it
      applied to a pattern when it is compiled and to a string when it
      is matched.  */
      is matched.  */
-  RE_TRANSLATE_TYPE translate;
+  __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
 
 
   /* Number of subexpressions found by the compiler.  */
   /* Number of subexpressions found by the compiler.  */
   size_t re_nsub;
   size_t re_nsub;
@@ -382,34 +384,36 @@ struct re_pattern_buffer
      Well, in truth it's used only in `re_search_2', to see whether or
      Well, in truth it's used only in `re_search_2', to see whether or
      not we should use the fastmap, so we don't set this absolutely
      not we should use the fastmap, so we don't set this absolutely
      perfectly; see `re_compile_fastmap' (the `duplicate' case).  */
      perfectly; see `re_compile_fastmap' (the `duplicate' case).  */
-  unsigned can_be_null : 1;
+  unsigned __REPB_PREFIX(can_be_null) : 1;
 
 
   /* If REGS_UNALLOCATED, allocate space in the `regs' structure
   /* If REGS_UNALLOCATED, allocate space in the `regs' structure
      for `max (RE_NREGS, re_nsub + 1)' groups.
      for `max (RE_NREGS, re_nsub + 1)' groups.
      If REGS_REALLOCATE, reallocate space if necessary.
      If REGS_REALLOCATE, reallocate space if necessary.
      If REGS_FIXED, use what's there.  */
      If REGS_FIXED, use what's there.  */
-#define REGS_UNALLOCATED 0
-#define REGS_REALLOCATE 1
-#define REGS_FIXED 2
-  unsigned regs_allocated : 2;
+#ifdef __USE_GNU
+# define REGS_UNALLOCATED 0
+# define REGS_REALLOCATE 1
+# define REGS_FIXED 2
+#endif
+  unsigned __REPB_PREFIX(regs_allocated) : 2;
 
 
   /* Set to zero when `regex_compile' compiles a pattern; set to one
   /* Set to zero when `regex_compile' compiles a pattern; set to one
      by `re_compile_fastmap' if it updates the fastmap.  */
      by `re_compile_fastmap' if it updates the fastmap.  */
-  unsigned fastmap_accurate : 1;
+  unsigned __REPB_PREFIX(fastmap_accurate) : 1;
 
 
   /* If set, `re_match_2' does not return information about
   /* If set, `re_match_2' does not return information about
      subexpressions.  */
      subexpressions.  */
-  unsigned no_sub : 1;
+  unsigned __REPB_PREFIX(no_sub) : 1;
 
 
   /* If set, a beginning-of-line anchor doesn't match at the beginning
   /* If set, a beginning-of-line anchor doesn't match at the beginning
      of the string.  */
      of the string.  */
-  unsigned not_bol : 1;
+  unsigned __REPB_PREFIX(not_bol) : 1;
 
 
   /* Similarly for an end-of-line anchor.  */
   /* Similarly for an end-of-line anchor.  */
-  unsigned not_eol : 1;
+  unsigned __REPB_PREFIX(not_eol) : 1;
 
 
   /* If true, an anchor at a newline matches.  */
   /* If true, an anchor at a newline matches.  */
-  unsigned newline_anchor : 1;
+  unsigned __REPB_PREFIX(newline_anchor) : 1;
 };
 };
 
 
 typedef struct re_pattern_buffer regex_t;
 typedef struct re_pattern_buffer regex_t;
@@ -418,6 +422,7 @@ typedef struct re_pattern_buffer regex_t;
 typedef int regoff_t;
 typedef int regoff_t;
 
 
 
 
+#ifdef __USE_GNU
 /* This is the structure we store register match data in.  See
 /* This is the structure we store register match data in.  See
    regex.texinfo for a full description of what registers match.  */
    regex.texinfo for a full description of what registers match.  */
 struct re_registers
 struct re_registers
@@ -431,8 +436,9 @@ struct re_registers
 /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
 /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
    `re_match_2' returns information about at least this many registers
    `re_match_2' returns information about at least this many registers
    the first time a `regs' structure is passed.  */
    the first time a `regs' structure is passed.  */
-#ifndef RE_NREGS
-# define RE_NREGS 30
+# ifndef RE_NREGS
+#  define RE_NREGS 30
+# endif
 #endif
 #endif
 
 
 
 
@@ -447,7 +453,7 @@ typedef struct
 
 
 /* Declarations for routines.  */
 /* Declarations for routines.  */
 
 
-
+#ifdef __USE_GNU
 /* Sets the current default syntax to SYNTAX, and return the old syntax.
 /* Sets the current default syntax to SYNTAX, and return the old syntax.
    You can also simply assign to the `re_syntax_options' variable.  */
    You can also simply assign to the `re_syntax_options' variable.  */
 extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
 extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
@@ -515,8 +521,9 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
 			      struct re_registers *__regs,
 			      struct re_registers *__regs,
 			      unsigned int __num_regs,
 			      unsigned int __num_regs,
 			      regoff_t *__starts, regoff_t *__ends);
 			      regoff_t *__starts, regoff_t *__ends);
+#endif /* Use GNU */
 
 
-#if defined _REGEX_RE_COMP || defined _LIBC
+#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
 # ifndef _CRAY
 # ifndef _CRAY
 /* 4.2 bsd compatibility.  */
 /* 4.2 bsd compatibility.  */
 extern char *re_comp (const char *);
 extern char *re_comp (const char *);
@@ -537,7 +544,8 @@ extern int re_exec (const char *);
 #endif
 #endif
 /* gcc 3.1 and up support the [restrict] syntax.  */
 /* gcc 3.1 and up support the [restrict] syntax.  */
 #ifndef __restrict_arr
 #ifndef __restrict_arr
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
+     && !defined __GNUG__
 #  define __restrict_arr __restrict
 #  define __restrict_arr __restrict
 # else
 # else
 #  define __restrict_arr
 #  define __restrict_arr