gbranden pushed a commit to branch master
in repository groff.

commit a2e129c9a7c6ec4fda3b136471ff038ee418faa7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri May 16 07:03:38 2025 -0500

    [troff]: Warn on contradictory `cflags` request.
    
    * src/roff/troff/input.cpp (set_character_flags): Throw warning in
      category "syntax" and ignore request if contradictory flag bits are
      set in the first argument.
    
    * doc/groff.texi.in (Warnings):
    * src/roff/troff/troff.1.man (Warnings): Document it.
---
 ChangeLog                  | 11 +++++++++++
 doc/groff.texi.in          |  2 +-
 src/roff/troff/input.cpp   | 11 +++++++++++
 src/roff/troff/troff.1.man |  2 +-
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 372e24d8d..e1a782d9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-05-16  G. Branden Robinson <[email protected]>
+
+       [troff]: Warn on contradictory `cflags` request argument.
+
+       * src/roff/troff/input.cpp (set_character_flags): Throw warning
+       in category "syntax" and ignore request if contradictory flag
+       bits are set in the first argument.
+
+       * doc/groff.texi.in (Warnings):
+       * src/roff/troff/troff.1.man (Warnings): Document it.
+
 2025-05-16  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/dictionary.cpp (dictionary::lookup):
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index ff448ca6e..216ed23a6 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -18403,7 +18403,7 @@ A numeric expression was out of range for its context.
 
 @item syntax
 @itemx 128
-A self-contradictory hyphenation mode was requested;
+A self-contradictory hyphenation mode or character flags were requested;
 an empty or incomplete numeric expression was encountered;
 an operand to a numeric operator was missing;
 a recognized but inapposite escape sequence
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index e58b7f6c6..8ce5b6937 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8079,6 +8079,17 @@ static void set_character_flags()
       skip_line();
       return;
     }
+    if (((flags & charinfo::ENDS_SENTENCE)
+         && (flags & charinfo::IS_TRANSPARENT_TO_END_OF_SENTENCE))
+       || ((flags & charinfo::ALLOWS_BREAK_BEFORE)
+         && (flags & charinfo::PROHIBITS_BREAK_BEFORE))
+       || ((flags & charinfo::ALLOWS_BREAK_AFTER)
+         && (flags & charinfo::PROHIBITS_BREAK_AFTER))) {
+      warning(WARN_SYNTAX, "contradictory character flags ignored: "
+       "%1", flags);
+      skip_line();
+      return;
+    }
     // TODO: Check for contradictory character flags.
     if (!has_arg()) {
       warning(WARN_MISSING, "character flags configuration request"
diff --git a/src/roff/troff/troff.1.man b/src/roff/troff/troff.1.man
index e8ed36c68..4aafeeab6 100644
--- a/src/roff/troff/troff.1.man
+++ b/src/roff/troff/troff.1.man
@@ -785,7 +785,7 @@ It never occurs in compatibility mode.
 .
 .TP
 .BR syntax "\t128"
-A self-contradictory hyphenation mode was requested;
+A self-contradictory hyphenation mode or character flags were requested;
 an empty or incomplete numeric expression was encountered;
 an operand to a numeric operator was missing;
 a recognized but inapposite escape sequence

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

Reply via email to