Update of bug #68972 (group groff):

                  Status:               Confirmed => In Progress
                 Summary: [troff] input `.hw -` causes assertion failure since
groff 1.25.0 => [PATCH] [troff] input `.hw -` causes assertion failure since
groff 1.25.0

    _______________________________________________________

Follow-up Comment #1:


diff --git a/ChangeLog b/ChangeLog
index 97588ffee..ff51e15a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2026-11-27  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp (read_hyphenation_exception_word): Fix
+       assertion failure on input like `.hw -`.  Replace assert(3) call
+       with warning in category "char" and return `false`.
+
+       Fixes <https://savannah.gnu.org/bugs/?68972>.  Problem
+       introduced by me in commit 9f82762791, 10 April.  I said then:
+       "Replace a test of the index into the hyphenation exception word
+       being greater than zero with an assert(3)ion of the same inside
+       the branch, as it's now an invariant that a valid hyphenation
+       exception word contains a nonzero count of characters bearing
+       hyphenation codes."  That invariant still holds, but I didn't
+       think of the case where some wit would supply a hyphenation
+       exception word consisting _only_ of hyphens, which don't have a
+       hyphenation code but which we must accept in the input for this
+       function to do its job.
+
 2026-11-27  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/env.cpp (read_hyphenation_exception_word):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 49dfa1647..53f13be1e 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -4082,8 +4082,11 @@ static bool read_hyphenation_exception_word(unsigned
char *word,
   }
   // A valid hyphenation exception word contains a nonzero count of
   // characters bearing hyphenation codes.
-  if (is_word_valid)
-    assert(i > 0);
+  if (is_word_valid && (0 == i)) {
+    warning(WARN_CHAR, "skipping hyphenation exception word"
+           " containing only hyphens");
+    return false;
+  }
   word[i] = '\0';
   // Clark uses `unsigned char` here for a small nonnegative quantity
   // indicating the positions of hyphenation break points within a word




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68972>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to