This patch is inspired by Adhemerval Zanella's recent proposal
https://www.sourceware.org/ml/libc-alpha/2018-06/msg00905.html
to merge glibc and Gnulib regex. It aims to simplify the merge on
the glibc side, without keeping Gnulib portable.
* lib/regex.h: Fix a problem with glibc installed-header checking,
as follows:
(_Restrict_): Prefer __restrict if defined or if GCC 2.95 or later.
(_Restrict_arr_): Prefer __restrict_arr if defined,
otherwise prefer _Restrict_ if C99 or GCC 3.1 or later (but not C++).
* lib/regex_internal.c (re_string_realloc_buffers, build_wcs_buffer)
(build_wcs_upper_buffer, build_upper_buffer)
(re_string_translate_buffer, re_string_context_at):
Move decls here from lib/regex_internal.h, for glibc internal tests.
(build_wcs_upper_buffer): Use __wcrtomb, not wcrtomb, fixing
glibc BZ #18496.
* lib/regex_internal.h (lock_fini) [_LIBC]: Cast to 0 to pacify
-Wunused-value.
(bitset_set, bitset_clear, bitset_contain, bitset_empty)
(bitset_set_all, bitset_copy, bitset_not, bitset_merge)
(bitset_mask): Now static inline, and without any __attribute__
((unused)) decoration, for glibc internal tests.
---
ChangeLog| 25 +
lib/regex.h | 25 -
lib/regex_internal.c | 12 +++-
lib/regex_internal.h | 31 ++-
4 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a356a4086..1b2505a1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2018-06-28 Paul Eggert
+
+ regex: port to recently proposed glibc regex merge
+ This patch is inspired by Adhemerval Zanella's recent proposal
+ https://www.sourceware.org/ml/libc-alpha/2018-06/msg00905.html
+ to merge glibc and Gnulib regex. It aims to simplify the merge on
+ the glibc side, without keeping Gnulib portable.
+ * lib/regex.h: Fix a problem with glibc installed-header checking,
+ as follows:
+ (_Restrict_): Prefer __restrict if defined or if GCC 2.95 or later.
+ (_Restrict_arr_): Prefer __restrict_arr if defined,
+ otherwise prefer _Restrict_ if C99 or GCC 3.1 or later (but not C++).
+ * lib/regex_internal.c (re_string_realloc_buffers, build_wcs_buffer)
+ (build_wcs_upper_buffer, build_upper_buffer)
+ (re_string_translate_buffer, re_string_context_at):
+ Move decls here from lib/regex_internal.h, for glibc internal tests.
+ (build_wcs_upper_buffer): Use __wcrtomb, not wcrtomb, fixing
+ glibc BZ #18496.
+ * lib/regex_internal.h (lock_fini) [_LIBC]: Cast to 0 to pacify
+ -Wunused-value.
+ (bitset_set, bitset_clear, bitset_contain, bitset_empty)
+ (bitset_set_all, bitset_copy, bitset_not, bitset_merge)
+ (bitset_mask): Now static inline, and without any __attribute__
+ ((unused)) decoration, for glibc internal tests.
+
2018-06-25 Bruno Haible
threadlib: Fix LIBMULTITHREAD on platforms where --as-needed is enabled.
diff --git a/lib/regex.h b/lib/regex.h
index 9ed74c3df..32933bc6d 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,7 +1,6 @@
/* Definitions for data structures and routines for the regular
expression library.
- Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2018 Free Software
- Foundation, Inc.
+ Copyright (C) 1985, 1989-2018 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
@@ -608,28 +607,28 @@ extern int re_exec (const char *);
# endif
#endif
-/* GCC 2.95 and later have "__restrict"; C99 compilers have
+/* For plain 'restrict', use glibc's __restrict if defined.
+ Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict".
Other compilers use __restrict, __restrict__, and _Restrict, and
'configure' might #define 'restrict' to those words, so pick a
different name. */
#ifndef _Restrict_
-# if 199901L <= __STDC_VERSION__
-# define _Restrict_ restrict
-# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__)
# define _Restrict_ __restrict
+# elif 199901L <= __STDC_VERSION__ || defined restrict
+# define _Restrict_ restrict
# else
# define _Restrict_
# endif
#endif
-/* gcc 3.1 and up support the [restrict] syntax. Don't trust
- sys/cdefs.h's definition of __restrict_arr, though, as it
- mishandles gcc -ansi -pedantic. */
+/* For [restrict], use glibc's __restrict_arr if available.
+ Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */
#ifndef _Restrict_arr_
-# if ((199901L <= __STDC_VERSION__ \
- || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))\
- && !defined __STRICT_ANSI__))
\
- && !defined __GNUG__)
+# ifdef __restrict_arr
+# define