Subject: bug#76945: [PATCH] etags: character classes and intervals not working in --regex

From: Vladimir Gorsunov <[email-masked]>
Date: Tue, 11 Mar 2025 14:28:45 +0200

Before commit d904cc83 regex syntax flags used in etags were

   RE_CHAR_CLASSES | RE_INTERVALS | RE_SHY_GROUPS | RE_FRUGAL

   that got changed to 0. Including a patch that restores
   RE_CHAR_CLASSES and RE_INTERVALS and adds check for these features
   to the test. As far I can understand from the bug 74861, the
   absence of shy groups and non-greedy matching won't be fixed
   until Gnulib supports them

From 4b52446ab9e0f09db30afb211468b77740bed617 Mon Sep 17 00:00:00 2001
From: vg <[email-masked]>
Date: Tue, 11 Mar 2025 03:45:37 +0200
Subject: [PATCH] etags: restore some regex features that used to work before

Before switching to Gnulib for regex functions, etags supported
intervals and character classes in the --regex parameter. Bringing
the support back

* lib-src/etags.c: changed re_set_syntax parameter
* test/manual/etags/Makefile: added check for the features
---
 lib-src/etags.c            | 6 ++----
 test/manual/etags/Makefile | 3 ++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index b59b70c9ec7..b476c552d1f 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -7256,10 +7256,8 @@ add_regex (char *regexp_pattern, language *lang)
   else
     pat = regexp_pattern;
 
-  if (single_line)
-    re_set_syntax (RE_SYNTAX_EMACS | RE_DOT_NEWLINE);
-  else
-    re_set_syntax (RE_SYNTAX_EMACS);
+  re_set_syntax (RE_CHAR_CLASSES | RE_INTERVALS |
+		 (single_line ? RE_DOT_NEWLINE : 0));
 
   err = re_compile_pattern (pat, strlen (pat), patbuf);
   if (multi_line)
diff --git a/test/manual/etags/Makefile b/test/manual/etags/Makefile
index 7480356d2d3..9985918474a 100644
--- a/test/manual/etags/Makefile
+++ b/test/manual/etags/Makefile
@@ -39,7 +39,8 @@ NONSRCS=
 ETAGS_PROG=../../../lib-src/etags
 CTAGS_PROG=../../../lib-src/ctags
 
-REGEX=/[ \t]*DEFVAR_[A-Z_ \t\n(]+"\([^"]+\)"/
+# Check conditional RE features: character classes and intervals
+REGEX=/[[:space:]]*DEFVAR_[A-Z_ \t\n(]\{1,80\}"\([^"]+\)"/
 xx="this line is here because of a fontlock bug
 
 RUN=
-- 
2.31.1