gbranden pushed a commit to branch master
in repository groff.

commit 20feac542d6686159121f08778f7c01ca8f19e86
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 23 16:07:21 2025 -0600

    [troff]: Fix blunders in `assert()` usage.
    
    * src/roff/troff/input.cpp (assign_control_character)
      (assign_no_break_control_character): Do it.  I'm trying to make groff
      safe for builds using `NDEBUG`.  That can't be achieved if we wrap
      substantive function calls (or expressions with side effects) with
      `assert()`.
    
    Continues commit e09bc6c083, 7 May 2023 (but not merged onto the master
    branch until after the groff 1.23.0 release).
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/input.cpp | 12 ++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 309bc9602..0f7a090e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-11-23  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (assign_control_character)
+       (assign_no_break_control_character): Fix blunders in `assert()`
+       usage.  I'm trying to make groff safe for builds using `NDEBUG`.
+       That can't be achieved if we wrap substantive function calls (or
+       expressions with side effects) with `assert()`.
+
+       Continues commit e09bc6c083, 7 May 2023 (but not merged onto the
+       master branch until after the groff 1.23.0 release).
+
 2025-11-23  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (assign_control_character)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 223f7db55..dfe60b3cd 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -273,6 +273,7 @@ void assign_control_character()
       already_message = already_nbcc;
       do_nothing = true;
   }
+  bool assignment_worked = false;
   if (do_nothing)
     error("ignoring control character change request; %1%2 %3",
          is_invalid ? "cannot select invalid control character, and"
@@ -280,10 +281,11 @@ void assign_control_character()
   else if (is_invalid) {
     error("cannot select %1 as control character; using '.'",
          tok.description());
-    assert(curenv->set_control_character('.'));
+    assignment_worked = curenv->set_control_character('.');
   }
   else
-    assert(curenv->set_control_character(cc));
+    assignment_worked = curenv->set_control_character(cc);
+  assert(assignment_worked);
   skip_line();
 }
 
@@ -311,6 +313,7 @@ void assign_no_break_control_character()
       already_message = already_cc;
       do_nothing = true;
   }
+  bool assignment_worked = false;
   if (do_nothing)
     error("ignoring no-break control character change request; %1%2 %3",
          is_invalid ? "cannot select invalid no-break control"
@@ -319,10 +322,11 @@ void assign_no_break_control_character()
   else if (is_invalid) {
     error("cannot select %1 as no-break control character;"
          " using \"\'\"", tok.description());
-    assert(curenv->set_no_break_control_character('\''));
+    assignment_worked = curenv->set_no_break_control_character('\'');
   }
   else
-    assert(curenv->set_no_break_control_character(nbcc));
+    assignment_worked = curenv->set_no_break_control_character(nbcc);
+  assert(assignment_worked);
   skip_line();
 }
 

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

Reply via email to