gbranden pushed a commit to branch master
in repository groff.
commit 3212249502f393939e9531cbfe7842ca94992847
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Dec 13 15:56:20 2025 -0600
[troff]: Fix code style nits.
* src/roff/troff/env.cpp (environment::possibly_break_line):
Parenthesize formally complex expressions. Arrange equality
comparisons to avoid inadvertent lvalue assignment.
---
ChangeLog | 7 +++++++
src/roff/troff/env.cpp | 10 +++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7ac71a6e1..b050d498f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,13 @@
Arrange equality comparisons to avoid inadvertent lvalue
assignment. Parenthesize formally complex expressions.
+2025-12-13 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/env.cpp (environment::possibly_break_line): Fix
+ code style nits. Parenthesize formally complex expressions.
+ Arrange equality comparisons to avoid inadvertent lvalue
+ assignment.
+
2025-12-13 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 386b12f48..17128fd4d 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2277,18 +2277,18 @@ extern char warn_scaling_unit;
void environment::possibly_break_line(bool must_break_here,
bool must_adjust)
{
- bool was_centered = centered_line_count > 0;
+ bool was_centered = (centered_line_count > 0);
if (!is_filling || (current_tab != TAB_NONE) || has_current_field
|| is_dummy_env)
return;
- while (line != 0 /* nullptr */
+ while ((line != 0 /* nullptr */)
&& (must_adjust
// When a macro follows a paragraph in fill mode, the
// current line should not be empty.
- || (width_total - line->width()) > target_text_length)) {
+ || ((width_total - line->width()) > target_text_length))) {
possibly_hyphenate_line(must_break_here);
breakpoint *bp = choose_breakpoint();
- if (bp == 0 /* nullptr */)
+ if (0 /* nullptr */ == bp)
// we'll find one eventually
return;
node *pre, *post;
@@ -2300,7 +2300,7 @@ void environment::possibly_break_line(bool
must_break_here,
// The space deficit tells us how much the line is overset if
// negative, or underset if positive, relative to the configured
// line length.
- hunits space_deficit = target_text_length - bp->width;
+ hunits space_deficit = (target_text_length - bp->width);
// An overset line always gets a warning.
if (space_deficit < H0) {
double dsd = static_cast<double>(space_deficit.to_units());
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit