summaryrefslogtreecommitdiff
path: root/src/regex.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-07-12 18:44:13 -0600
committerTom Tromey <tromey@redhat.com>2013-07-12 18:44:13 -0600
commitb34a529f177a6ea32da5cb1254f91bf9d71838db (patch)
tree477131abc15d3107b30b635223d87a22550b480b /src/regex.h
parente6f63071a3f7721f55220514b6d9a8ee8c1232d8 (diff)
parent5e301d7651c0691bb2bc7f3fbe711fdbe26ac471 (diff)
downloademacs-b34a529f177a6ea32da5cb1254f91bf9d71838db.tar.gz
Merge from trunk
Diffstat (limited to 'src/regex.h')
-rw-r--r--src/regex.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/regex.h b/src/regex.h
index 175eed10177..31be0504c9e 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -528,31 +528,41 @@ extern int re_exec (const char *);
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
- "restrict", and "configure" may have defined "restrict". */
-#ifndef __restrict
-# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
-# if defined restrict || 199901L <= __STDC_VERSION__
-# define __restrict restrict
-# else
-# define __restrict
-# endif
+ "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__)
+# define _Restrict_ __restrict
+# else
+# define _Restrict_
# endif
#endif
-/* For now conditionally define __restrict_arr to expand to nothing.
- Ideally we would have a test for the compiler which allows defining
- it to restrict. */
-#ifndef __restrict_arr
-# define __restrict_arr
+/* 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. */
+#ifndef _Restrict_arr_
+# if ((199901L <= __STDC_VERSION__ \
+ || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
+ && !defined __STRICT_ANSI__)) \
+ && !defined __GNUG__)
+# define _Restrict_arr_ _Restrict_
+# else
+# define _Restrict_arr_
+# endif
#endif
/* POSIX compatibility. */
-extern reg_errcode_t regcomp (regex_t *__restrict __preg,
- const char *__restrict __pattern,
+extern reg_errcode_t regcomp (regex_t *_Restrict_ __preg,
+ const char *_Restrict_ __pattern,
int __cflags);
-extern reg_errcode_t regexec (const regex_t *__restrict __preg,
- const char *__restrict __string, size_t __nmatch,
- regmatch_t __pmatch[__restrict_arr],
+extern reg_errcode_t regexec (const regex_t *_Restrict_ __preg,
+ const char *_Restrict_ __string, size_t __nmatch,
+ regmatch_t __pmatch[_Restrict_arr_],
int __eflags);
extern size_t regerror (int __errcode, const regex_t * __preg,