regex.h: use _DEFAULT_SOURCE

This file was imported from glibx and uses __USE_GNU as defined by
glibc(s features.h. Our implementation of features.h is simpler, just
defining _DEFAULT_SOURCE directly and that's what we use in other
headers.

As a result, using GNU extensions to regex.h required defining __USE_GNU
directly in applications (for example in TraX).

Fixes #11818

Change-Id: I11e4cf2e88c330cf58083852c4b33aedb8a3a9ea
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7238
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
PulkoMandy 2023-12-24 14:13:44 +01:00 committed by waddlesplash
parent a787cf81fe
commit dbe86e4638
2 changed files with 9 additions and 18 deletions

View File

@ -92,7 +92,7 @@
#define MQ_OPEN_MAX (0) /* MSG */
#define MQ_PRIO_MAX (0) /* MSG */
#define RE_DUP_MAX (255) /* for conformance, redefined in regex.h */
#define RE_DUP_MAX (0x7fff)
#ifdef _XOPEN_SOURCE
/* The XSI name for PAGESIZE, with extra underscore included. Only define if

View File

@ -22,6 +22,7 @@
#ifndef _REGEX_H
#define _REGEX_H 1
#include <compatibility/bsd/features.h>
#include <sys/types.h>
/* Allow the use in C++ code. */
@ -43,7 +44,7 @@ typedef __haiku_addr_t active_reg_t;
add or remove a bit, only one other definition need change. */
typedef __haiku_uint32 reg_syntax_t;
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
/* If this bit is not set, then \ inside a bracket expression is literal.
If set, then such a \ quotes the following character. */
# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
@ -182,7 +183,7 @@ typedef __haiku_uint32 reg_syntax_t;
already-compiled regexps. */
extern reg_syntax_t re_syntax_options;
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
don't delete them!) */
@ -253,18 +254,8 @@ extern reg_syntax_t re_syntax_options;
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
/* [[[end syntaxes]]] */
/* Maximum number of duplicates an interval can allow. Some systems
(erroneously) define this in other header files, but we want our
value, so remove any previous define. */
# ifdef RE_DUP_MAX
# undef RE_DUP_MAX
# endif
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
# define RE_DUP_MAX (0x7fff)
#endif
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
/* If this bit is set, then use extended regular expression syntax.
@ -342,12 +333,12 @@ typedef enum
#ifndef RE_TRANSLATE_TYPE
# define __RE_TRANSLATE_TYPE unsigned char *
# ifdef __USE_GNU
# ifdef _DEFAULT_SOURCE
# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
# endif
#endif
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
# define __REPB_PREFIX(name) name
#else
# define __REPB_PREFIX(name) __##name
@ -393,7 +384,7 @@ struct re_pattern_buffer
for `max (RE_NREGS, re_nsub + 1)' groups.
If REGS_REALLOCATE, reallocate space if necessary.
If REGS_FIXED, use what's there. */
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
# define REGS_UNALLOCATED 0
# define REGS_REALLOCATE 1
# define REGS_FIXED 2
@ -425,7 +416,7 @@ typedef struct re_pattern_buffer regex_t;
typedef int regoff_t;
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
/* This is the structure we store register match data in. See
regex.texinfo for a full description of what registers match. */
struct re_registers
@ -456,7 +447,7 @@ typedef struct
/* Declarations for routines. */
#ifdef __USE_GNU
#ifdef _DEFAULT_SOURCE
/* 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 (reg_syntax_t __syntax);