gbranden pushed a commit to branch master
in repository groff.
commit 569757393f3676ab6882a9dd0daa8115d57ee13d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 4 01:53:50 2025 -0500
[troff]: Trivially refactor.
The `environment` class's member function `hyphenate_line` doesn't
necessarily hyphenate the line; it can break the line without
hyphenation.
* src/roff/troff/env.cpp (environment::hyphenate_line): Rename this...
(environment::possibly_hyphenate_line): ...to this. Also parenthesize
formally complex expression.
(environment::possibly_break_line): Update call site.
* src/roff/troff/env.h: Rename in declaration.
Also relocate comment for clarity.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/env.cpp | 8 ++++----
src/roff/troff/env.h | 2 +-
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e09770b72..61116e808 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-10-04 G. Branden Robinson <[email protected]>
+
+ [troff]: Trivially refactor.
+
+ The `environment` class's member function `hyphenate_line`
+ doesn't necessarily hyphenate the line; it can break the line
+ without hyphenation.
+
+ * src/roff/troff/env.cpp (environment::hyphenate_line): Rename
+ this...
+ (environment::possibly_hyphenate_line): ...to this. Also
+ parenthesize formally complex expression.
+ (environment::possibly_break_line): Update call site.
+ * src/roff/troff/env.h: Rename in declaration.
+
2025-10-04 G. Branden Robinson <[email protected]>
[troff]: Slightly refactor.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 2f6f779ac..109e22253 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2140,7 +2140,7 @@ breakpoint *environment::choose_breakpoint()
return 0 /* nullptr */;
}
-void environment::hyphenate_line(bool must_break_here)
+void environment::possibly_hyphenate_line(bool must_break_here)
{
assert(line != 0 /* nullptr */);
hyphenation_type prev_type = line->get_hyphenation_type();
@@ -2163,6 +2163,7 @@ void environment::hyphenate_line(bool must_break_here)
tem = tem->next;
} while (tem != 0 /* nullptr */
&& tem->get_hyphenation_type() == HYPHEN_MIDDLE);
+ // This is for characters like hyphen and em dash.
bool inhibit = (tem != 0 /* nullptr */
&& tem->get_hyphenation_type() == HYPHEN_INHIBIT);
node *end = tem;
@@ -2178,7 +2179,6 @@ void environment::hyphenate_line(bool must_break_here)
forward = tem1;
}
if (!inhibit) {
- // this is for characters like hyphen and emdash
unsigned char prev_code = 0U;
for (hyphen_list *h = sl; h; h = h->next) {
h->is_breakable = (prev_code != 0U
@@ -2187,7 +2187,7 @@ void environment::hyphenate_line(bool must_break_here)
prev_code = h->hyphenation_code;
}
}
- if (hyphenation_mode != 0
+ if ((hyphenation_mode != 0)
&& !inhibit
// this may not be right if we have extra space on this line
&& !((hyphenation_mode & HYPHEN_NOT_LAST_LINE)
@@ -2273,7 +2273,7 @@ void environment::possibly_break_line(bool
must_break_here,
// When a macro follows a paragraph in fill mode, the
// current line should not be empty.
|| (width_total - line->width()) > target_text_length)) {
- hyphenate_line(must_break_here);
+ possibly_hyphenate_line(must_break_here);
breakpoint *bp = choose_breakpoint();
if (bp == 0 /* nullptr */)
// we'll find one eventually
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index d683a0a1a..a70e42224 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -243,7 +243,7 @@ class environment {
void mark_last_line();
#endif /* WIDOW_CONTROL */
breakpoint *choose_breakpoint();
- void hyphenate_line(bool /* must_break_here */ = false);
+ void possibly_hyphenate_line(bool /* must_break_here */ = false);
void start_field();
void wrap_up_field();
void add_padding();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit