gbranden pushed a commit to branch master
in repository groff.

commit 0652060f9c7d119257b370fa25759ff07205049c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri May 16 07:21:42 2025 -0500

    [troff]: Make reported character flags scrutable.
    
    * src/roff/troff/input.cpp (charinfo::dump): When dumping character
      information with the `pchar` request, convert character flags bit mask
      to comprehensible human language.
---
 ChangeLog                |  8 ++++++++
 src/roff/troff/input.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e1a782d9c..5b9c3d88a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-05-16  G. Branden Robinson <[email protected]>
+
+       [troff]: Make reported character flags scrutable.
+
+       * src/roff/troff/input.cpp (charinfo::dump): When dumping
+       character information with the `pchar` request, convert
+       character flags bit mask to comprehensible human language.
+
 2025-05-16  G. Branden Robinson <[email protected]>
 
        [troff]: Warn on contradictory `cflags` request argument.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8ce5b6937..f1d026cf1 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -10378,7 +10378,55 @@ void charinfo::dump()
           static_cast<int>(special_translation));
   errprint("  hyphenation code: %1\n",
           static_cast<int>(hyphenation_code));
-  errprint("  flags: %1\n", flags);
+  errprint("  flags: %1 (", flags);
+  if (0U == flags)
+    errprint("none)\n");
+  else {
+    char none[] = { '\0', '\0' };
+    char comma[] = { ',', ' ' };
+    char *separator = none;
+    if (flags & ENDS_SENTENCE) {
+      errprint("%1ends sentence", separator);
+      separator = comma;
+    }
+    if (flags & ALLOWS_BREAK_BEFORE) {
+      errprint("%1allows break before", separator);
+      separator = comma;
+    }
+    if (flags & ALLOWS_BREAK_AFTER) {
+      errprint("%1allows break after", separator);
+      separator = comma;
+    }
+    if (flags & OVERLAPS_HORIZONTALLY) {
+      errprint("%1overlaps horizontally", separator);
+      separator = comma;
+    }
+    if (flags & OVERLAPS_VERTICALLY) {
+      errprint("%1overlaps vertically", separator);
+      separator = comma;
+    }
+    if (flags & IS_TRANSPARENT_TO_END_OF_SENTENCE) {
+      errprint("%1is transparent to end of sentence", separator);
+      separator = comma;
+    }
+    if (flags & IGNORES_SURROUNDING_HYPHENATION_CODES) {
+      errprint("%1ignores surrounding hyphenation codes", separator);
+      separator = comma;
+    }
+    if (flags & PROHIBITS_BREAK_BEFORE) {
+      errprint("%1prohibits break before", separator);
+      separator = comma;
+    }
+    if (flags & PROHIBITS_BREAK_AFTER) {
+      errprint("%1prohibits break after", separator);
+      separator = comma;
+    }
+    if (flags & IS_INTERWORD_SPACE) {
+      errprint("%1is interword space", separator);
+      separator = comma;
+    }
+    errprint(")\n");
+  }
   errprint("  ASCII code: %1\n", static_cast<int>(ascii_code));
   errprint("  asciify code: %1\n", static_cast<int>(asciify_code));
   errprint("  is%1 found\n", is_not_found ? " not" : "");

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

Reply via email to