]> Savannah Git Hosting - gnulib.git/commitdiff
regex: match current Emacs behavior
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Apr 2025 01:01:08 +0000 (18:01 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Apr 2025 01:03:02 +0000 (18:03 -0700)
* config/srclist.txt: Comment out regex.h, since we now
disagree with glibc.
* lib/regex.h (RE_SYNTAX_EMACS):
Match Emacs 21+ behavior, not Emacs 20-.
* m4/regex.m4 (gl_REGEX): Check for this Emacs fix.

ChangeLog
config/srclist.txt
doc/regex.texi
lib/regex.h
m4/regex.m4

index 2ea548d13f696de37c282d5947fb6eb5a062733c..c20c1517577a9d28850d1f2cc3e313d025ead200 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-04-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       regex: match current Emacs behavior
+       * config/srclist.txt: Comment out regex.h, since we now
+       disagree with glibc.
+       * lib/regex.h (RE_SYNTAX_EMACS):
+       Match Emacs 21+ behavior, not Emacs 20-.
+       * m4/regex.m4 (gl_REGEX): Check for this Emacs fix.
+
 2025-04-13  Bruno Haible  <bruno@clisp.org>
 
        getlogin_r tests: Avoid writing to a literal string.
index 173f23edaf57a28ad97028818fa845cfef8ed7ac..62816dcf4a6becdec25b7b09abd4765d5b78cd9c 100644 (file)
@@ -68,7 +68,7 @@ $LIBCSRC malloc/scratch_buffer_set_array_size.c       lib/malloc
 #$LIBCSRC misc/sys/cdefs.h             lib
 #$LIBCSRC posix/regcomp.c              lib
 $LIBCSRC posix/regex.c                 lib
-$LIBCSRC posix/regex.h                 lib
+#$LIBCSRC posix/regex.h                        lib
 #$LIBCSRC posix/regex_internal.c       lib
 #$LIBCSRC posix/regex_internal.h       lib
 #$LIBCSRC posix/regexec.c              lib
index cba1e13520b3221d9f323b3159be41c4279ccd01..925b0db639568517dbd48e4fc3ec91e03520336b 100644 (file)
@@ -316,7 +316,8 @@ regular expressions.
 The predefined syntaxes---taken directly from @file{regex.h}---are:
 
 @smallexample
-#define RE_SYNTAX_EMACS 0
+# define RE_SYNTAX_EMACS                                                \
+  (RE_CHAR_CLASSES | RE_INTERVALS)
 
 #define RE_SYNTAX_AWK                                                   \
   (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL                       \
index 67a3aa70a518605ede0f4a3b91df73574466040c..c4c6089a8c8a50e441496881c8506a87b0fb8c56 100644 (file)
@@ -66,9 +66,8 @@ typedef unsigned long int active_reg_t;
 
 /* The following bits are used to determine the regexp syntax we
    recognize.  The set/not-set meanings are chosen so that Emacs syntax
-   remains the value 0.  The bits are given in alphabetical order, and
-   the definitions shifted by one from the previous bit; thus, when we
-   add or remove a bit, only one other definition need change.  */
+   is the value 0 for Emacs 20 (2000) and earlier, and the value
+   RE_SYNTAX_EMACS for Emacs 21 (2001) and later.  */
 typedef unsigned long int reg_syntax_t;
 
 #ifdef __USE_GNU
@@ -215,7 +214,8 @@ extern reg_syntax_t re_syntax_options;
    (The [[[ comments delimit what gets put into the Texinfo file, so
    don't delete them!)  */
 /* [[[begin syntaxes]]] */
-# define RE_SYNTAX_EMACS 0
+# define RE_SYNTAX_EMACS                                               \
+  (RE_CHAR_CLASSES | RE_INTERVALS)
 
 # define RE_SYNTAX_AWK                                                 \
   (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL                    \
index 80dfb8e1e5f926b73d582fbd011ab709f9e5b12d..1b2012fe004d411cc208ae95d81e45ead59b82f3 100644 (file)
@@ -1,5 +1,5 @@
 # regex.m4
-# serial 78
+# serial 79
 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,
@@ -53,6 +53,10 @@ AC_DEFUN([gl_REGEX],
             /* Exit with distinguishable exit code.  */
             static void sigabrt_no_core (int sig) { raise (SIGTERM); }
             #endif
+
+            #if RE_SYNTAX_EMACS != (RE_CHAR_CLASSES | RE_INTERVALS)
+            # error "RE_SYNTAX_EMACS does not match Emacs behavior"
+            #endif
           ]],
           [[int result = 0;
             static struct re_pattern_buffer regex;