gbranden pushed a commit to branch master
in repository groff.

commit c182f5f5a4da2b4842d1a4e282e47026634ebcfe
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed May 6 08:24:06 2026 -0500

    src/roff/troff/env.cpp: Slightly refactor.
    
    * src/roff/troff/env.cpp (temporary_indent): Rename `temp` local
      variable to `amount` for clarity.  Shift output line breaking logic
      earlier, separating it from argument handling.  Drop redundant
      `skip_line()` call when handling no-argument case.  Move declaration
      of `is_valid` local variable within its narrower applicable brace
      scope.
---
 ChangeLog              |  9 +++++++++
 src/roff/troff/env.cpp | 36 ++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 06f63f95b..526e2c6e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-05-06  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp (temporary_indent): Slightly refactor.
+       Rename `temp` local variable to `amount` for clarity.  Shift
+       output line breaking logic earlier, separating it from
+       argument handling.  Drop redundant `skip_line()` call when
+       handling no-argument case.  Move declaration of `is_valid` local
+       variable within its narrower applicable brace scope.
+
 2026-05-06  G. Branden Robinson <[email protected]>
 
        [troff]: Rename `.zoom` register to `.fzoom`.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index f50298367..9e43344fa 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1679,16 +1679,14 @@ void indent() // .in
 
 void temporary_indent() // .ti
 {
-  bool is_valid = true;
-  hunits temp = H0;
-  if (!has_arg()) {
+  hunits amount = H0;
+  if (was_invoked_with_regular_control_character)
+    curenv->do_break();
+  if (!has_arg())
     warning(WARN_MISSING, "temporary indentation request expects"
            " argument");
-    skip_line();
-    // _Don't_ return early; when invoked with the ordinary control
-    // character this request still breaks the line.
-  }
   else {
+    bool is_valid = true;
     if (curenv->centered_line_count > 0) {
       is_valid = false;
       warning(WARN_STYLE, "ignoring temporary indentation request while"
@@ -1699,20 +1697,18 @@ void temporary_indent() // .ti
       warning(WARN_STYLE, "ignoring temporary indentation request while"
              " right-aligning text");
     }
-    if (!read_hunits(&temp, 'm', curenv->get_indent()))
+    if (!read_hunits(&amount, 'm', curenv->get_indent()))
       is_valid = false;
-  }
-  if (was_invoked_with_regular_control_character)
-    curenv->do_break();
-  if (temp < H0) {
-    warning(WARN_RANGE, "treating total indentation %1u as zero",
-           temp.to_units());
-    temp = H0;
-  }
-  if (is_valid) {
-    curenv->temporary_indent = temp;
-    curenv->have_temporary_indent = true;
-    curdiv->modified_tag.incl(MTSM_TI);
+    if (amount < H0) {
+      warning(WARN_RANGE, "treating total indentation %1u as zero",
+             amount.to_units());
+      amount = H0;
+    }
+    if (is_valid) {
+      curenv->temporary_indent = amount;
+      curenv->have_temporary_indent = true;
+      curdiv->modified_tag.incl(MTSM_TI);
+    }
   }
   skip_line();
 }

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

Reply via email to