gbranden pushed a commit to branch master
in repository groff.
commit 40a04dfeeaca561aaa9e46b3597f769de1986979
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Dec 3 08:24:12 2025 -0600
[troff]: Refactor.
Bust character flag dumping (a report to the standard error stream) into
its own member function of the `charinfo` class because (A) it's about
50 lines of code and (B) we're about to need another call site, and
there's no way repeating 50 lines of code is a good idea.
* src/roff/troff/charinfo.h (class charinfo): Declare new `dump_flags()`
member function returning `void`.
* src/roff/troff/input.cpp (charinfo::dump_flags): Implement it, moving
code to here...
(charinfo::dump): ...from here, instead calling the new function.
---
ChangeLog | 15 +++++++
src/roff/troff/charinfo.h | 1 +
src/roff/troff/input.cpp | 103 ++++++++++++++++++++++++----------------------
3 files changed, 70 insertions(+), 49 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ef5b06939..c486bbdd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-12-03 G. Branden Robinson <[email protected]>
+
+ [troff]: Refactor. Bust character flag dumping (a report to the
+ standard error stream) into its own member function of the
+ `charinfo` class because (A) it's about 50 lines of code and (B)
+ we're about to need another call site, and there's no way
+ repeating 50 lines of code is a good idea.
+
+ * src/roff/troff/charinfo.h (class charinfo): Declare new
+ `dump_flags()` member function returning `void`.
+ * src/roff/troff/input.cpp (charinfo::dump_flags): Implement it,
+ moving code to here...
+ (charinfo::dump): ...from here, instead calling the new
+ function.
+
2025-12-03 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (token::description): Describe a
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 72da4cd40..b58480032 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -119,6 +119,7 @@ public:
bool contains(int, bool = false);
bool contains(symbol, bool = false);
bool contains(charinfo *, bool = false);
+ void dump_flags();
void dump();
};
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a32b651ef..f972a97b9 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -10850,6 +10850,59 @@ bool charinfo::contains(charinfo *, bool)
return false;
}
+void charinfo::dump_flags()
+{
+ errprint(" flags: %1 (", flags);
+ if (0U == flags)
+ errprint("none)\n");
+ else {
+ char none[] = { '\0' };
+ char comma[] = { ',', ' ', '\0' };
+ 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");
+ }
+}
+
void charinfo::dump()
{
if (is_class()) {
@@ -10913,55 +10966,7 @@ void charinfo::dump()
static_cast<int>(special_translation));
errprint(" hyphenation code: %1\n",
static_cast<int>(hyphenation_code));
- errprint(" flags: %1 (", flags);
- if (0U == flags)
- errprint("none)\n");
- else {
- char none[] = { '\0' };
- char comma[] = { ',', ' ', '\0' };
- 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");
- }
+ dump_flags();
errprint(" asciify code: %1\n", static_cast<int>(asciify_code));
errprint(" ASCII code: %1\n", static_cast<int>(ascii_code));
// Also see node.cpp::glyph_node::asciify().
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit