summaryrefslogtreecommitdiff
path: root/lib/regex.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-06-28 12:23:31 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-06-28 12:24:21 -0700
commitf59be4169e656da3be4510ebe68db83d8200074c (patch)
tree9e9ed5e3e09ed06b2d4e2d26d79375097fafff8b /lib/regex.h
parent16aa5a2efe82e01a147b4022258fa9a272f67625 (diff)
downloadgnulib-f59be4169e656da3be4510ebe68db83d8200074c.tar.gz
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.
Diffstat (limited to 'lib/regex.h')
-rw-r--r--lib/regex.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/regex.h b/lib/regex.h
index 9ed74c3dfd..32933bc6d5 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 _Restrict_arr_ __restrict_arr
+# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \
+ && !defined __GNUG__)
# define _Restrict_arr_ _Restrict_
# else
# define _Restrict_arr_