gbranden pushed a commit to branch master
in repository groff.

commit e0398ddda2fd8a1aea17470e122c7016e32c01d0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 22 10:30:22 2026 -0500

    [troff]: Drop nested character class code.
    
    It's dead or unreachable.
    
    * src/roff/troff/charinfo.h (class charinfo): Drop `nested_classes`
      member variable.  Drop declaration of overloaded `add_to_class()`
      member function taking a pointer to a `charinfo` as argument.
    
      (charinfo::add_to_class): Drop definition per above.
    
      (charinfo::is_class): Simplify test to eliminate dereference of now-
      vanished `nested_classes` member variable.
    
    * src/roff/troff/input.cpp (define_class_request): Generalize condition
      under which warning diagnostics about inability to nest character
      classes are thrown.  Drop branches unreached in a "make check" build
      that required the aforementioned member function signature.
    
      (charinfo::contains, charinfo::dump): Drop iterators of nested classes
      `#if 0`-ed out in groff 1.24.0 release.
---
 ChangeLog                 | 19 +++++++++++++++++++
 src/roff/troff/charinfo.h | 10 +---------
 src/roff/troff/input.cpp  | 45 ++++++---------------------------------------
 3 files changed, 26 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index abaa0b6b2..cb9988264 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2026-04-22  G. Branden Robinson <[email protected]>
+
+       [troff]: Drop dead/unreachable nested character class code.
+
+       * src/roff/troff/charinfo.h (class charinfo): Drop
+       `nested_classes` member variable.  Drop declaration of
+       overloaded `add_to_class()` member function taking a pointer to
+       a `charinfo` as argument.
+       (charinfo::add_to_class): Drop definition per above.
+       (charinfo::is_class): Simplify test to eliminate dereference of
+       now-vanished `nested_classes` member variable.
+       * src/roff/troff/input.cpp (define_class_request): Generalize
+       condition under which warning diagnostics about inability to
+       nest character classes are thrown.  Drop branches unreached in a
+       "make check" build that required the aforementioned member
+       function signature.
+       (charinfo::contains, charinfo::dump): Drop iterators of nested
+       classes `#if 0`-ed out in groff 1.24.0 release.
+
 2022-04-17  Dave Kemper <[email protected]>
 
        * tmac/pspic.tmac: Allow `PSPIC` macro to place image at bottom
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 593826487..90f3840c9 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -42,7 +42,6 @@ class charinfo : glyph {
   char_mode mode;
   // Unicode character classes
   std::vector<std::pair<int, int> > ranges;
-  std::vector<charinfo *> nested_classes; // XXX: see Savannah #67770
 public:
   // Values for the flags bitmask.  See groff manual, description of the
   // '.cflags' request.
@@ -115,7 +114,6 @@ public:
   symbol *get_symbol();
   void add_to_class(int);
   void add_to_class(int, int);
-  void add_to_class(charinfo *);
   bool is_class();
   bool contains(int, bool = false);
   bool contains(symbol, bool = false);
@@ -302,15 +300,9 @@ inline void charinfo::add_to_class(int lo,
   ranges.push_back(std::pair<int, int>(lo, hi));
 }
 
-inline void charinfo::add_to_class(charinfo *ci)
-{
-  using_character_classes = true;
-  nested_classes.push_back(ci);
-}
-
 inline bool charinfo::is_class()
 {
-  return (!ranges.empty() || !nested_classes.empty());
+  return !ranges.empty();
 }
 
 // Local Variables:
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 445be9d88..f4e68c6ca 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -9018,12 +9018,9 @@ static void define_class_request() // .class
     }
     else if (child1 != 0 /* nullptr */) {
       if (child1->is_class()) {
-       if (ci == child1) {
-         warning(WARN_SYNTAX, "cannot nest character classes");
-         skip_line();
-         return;
-       }
-       ci->add_to_class(child1);
+       warning(WARN_SYNTAX, "cannot nest character classes");
+       skip_line();
+       return;
       }
       else {
        int u1 = child1->get_unicode_mapping();
@@ -9059,12 +9056,9 @@ static void define_class_request() // .class
   }
   if (child1 != 0 /* nullptr */) {
     if (child1->is_class()) {
-      if (ci == child1) {
-       warning(WARN_SYNTAX, "cannot nest character classes");
-       skip_line();
-       return;
-      }
-      ci->add_to_class(child1);
+      warning(WARN_SYNTAX, "cannot nest character classes");
+      skip_line();
+      return;
     }
     else {
       int u1 = child1->get_unicode_mapping();
@@ -11156,18 +11150,6 @@ bool charinfo::contains(int c, bool already_called)
     }
     ++ranges_iter;
   }
-
-  // Nested classes don't work.  See Savannah #67770.
-#if 0
-  std::vector<charinfo *>::const_iterator nested_iter;
-  nested_iter = nested_classes.begin();
-  while (nested_iter != nested_classes.end()) {
-    if ((*nested_iter)->contains(c, true))
-      return true;
-    ++nested_iter;
-  }
-#endif
-
   return false;
 }
 
@@ -11298,21 +11280,6 @@ void charinfo::dump()
     if (!has_ranges)
       errprint("(none)");
     errprint("\n");
-#if 0
-    // Nested classes don't work.  See Savannah #67770.
-    errprint("  contains nested classes: ");
-    std::vector<charinfo *>::const_iterator nested_iter;
-    nested_iter = nested_classes.begin();
-    bool has_nested_classes = false;
-    while (nested_iter != nested_classes.end()) {
-      has_nested_classes = true;
-      // TODO: Here's where JSON would really pay off.
-      (*nested_iter)->dump();
-    }
-    if (!has_nested_classes)
-      errprint("(none)");
-    errprint("\n");
-#endif
     dump_flags();
   }
   else {

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to