On 4/14/25 07:30, Bruno Haible wrote:
- Application code sees the gnulib regex.h (due to -I options).
Things would be different if the 'regex' module would be using a
regex.in.h from which a regex.h is conditionally generated. But
the way things are, gnulib regex.h is used unconditionally.
- Nothing in the reg*.c files uses RE_SYNTAX_EMACS.
Thanks, good catch. I installed into Gnulib the attached patch, which
implements your suggestion and also adds some documentation about this
issue.From 6ff0345dd56403f8a7953602b10c914f81f80d20 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Mon, 14 Apr 2025 14:43:02 -0700
Subject: [PATCH] =?UTF-8?q?regex:=20don=E2=80=99t=20check=20RE=5FSYNTAX=5F?=
=?UTF-8?q?EMACS?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* m4/regex.m4 (gl_REGEX): Do not check RE_SYNTAX_EMACS’s value.
Suggested by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2025-04/msg00098.html
---
ChangeLog | 7 +++++++
doc/posix-headers/regex.texi | 13 +++++++++++++
m4/regex.m4 | 9 +++++----
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 634f5b089e..1d4a399379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-04-14 Paul Eggert <[email protected]>
+
+ regex: don’t check RE_SYNTAX_EMACS
+ * m4/regex.m4 (gl_REGEX): Do not check RE_SYNTAX_EMACS’s value.
+ Suggested by Bruno Haible in:
+ https://lists.gnu.org/r/bug-gnulib/2025-04/msg00098.html
+
2025-04-14 Bruno Haible <[email protected]>
c32is*, c32to* tests: Avoid test failures on macOS 15.4.
diff --git a/doc/posix-headers/regex.texi b/doc/posix-headers/regex.texi
index b54c243060..403088c6fc 100644
--- a/doc/posix-headers/regex.texi
+++ b/doc/posix-headers/regex.texi
@@ -11,6 +11,19 @@ regex.h
@item
This header file is missing on some platforms:
mingw, MSVC 14.
+
+@item
+On some systems that have this header file,
+GNU extensions like @code{re_set_syntax} and @code{RE_SYNTAX_EMACS}
+are not declared or supported:
+FreeBSD 14.2, OpenBSD 7.6, NetBSD 10.1, macOS 15,
+Minix 3.3.0, AIX 7.3, HP-UX 11, Solaris 11.4.
+
+@item
+On some systems that support GNU extensions, @code{RE_SYNTAX_EMACS} is 0
+even though it should be @code{(RE_CHAR_CLASSES | RE_INTERVALS)}
+to be compatible with Emacs 21 (2001) and later:
+glibc 2.41, Cygwin 2.6.x.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/m4/regex.m4 b/m4/regex.m4
index 52ce5c3b37..49a8059f61 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,5 +1,5 @@
# regex.m4
-# serial 80
+# serial 81
dnl Copyright (C) 1996-2001, 2003-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -54,9 +54,10 @@ AC_DEFUN([gl_REGEX]
static void sigabrt_no_core (int sig) { raise (SIGTERM); }
#endif
- #if !RE_SYNTAX_EMACS
- # error "RE_SYNTAX_EMACS does not match Emacs behavior"
- #endif
+ /* There is no need to check whether RE_SYNTAX_EMACS is
+ (RE_CHAR_CLASSES | RE_INTERVALS), corresponding to
+ Emacs 21 (2001) and later, because Gnulib's lib/regex.h
+ is always used and has this value. */
]],
[[int result = 0;
static struct re_pattern_buffer regex;
--
2.49.0