Follow-up Comment #1, bug #60673 (project groff):

Based on aforementioned code snippet in bug #60665, it looks like fixing this
may be as simple as three lines of code:


diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 1be86470..312c0f7d 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2087,6 +2087,7 @@ static void distribute_space(node *n, int nspaces,
hunits desired_space,
                             int force_reverse = 0)
 {
   static int reverse = 0;
+  int inhibit_reverse;
   if (force_reverse || reverse)
     n = node_list_reverse(n);
   if (!force_reverse && nspaces > 0 && spread_limit >= 0
@@ -2097,11 +2098,12 @@ static void distribute_space(node *n, int nspaces,
hunits desired_space,
     if (Ems > spread_limit)
       output_warning(WARN_BREAK, "spreading %1m per space", Ems);
   }
+  inhibit_reverse = desired_space.is_zero();
   for (node *tem = n; tem; tem = tem->next)
     tem->spread_space(&nspaces, &desired_space);
   if (force_reverse || reverse)
     (void)node_list_reverse(n);
-  if (!force_reverse)
+  if (!force_reverse && !inhibit_reverse)
     reverse = !reverse;
   assert(desired_space.is_zero() && nspaces == 0);
 }


Caveats:

* This is completely untested beyond confirming that it creates the "desired"
output handcrafted in comment #0.  Someday I'll have to get around to learning
how to use the test suite we have now.
* My C is rusty and my C++ skills nonexistent, so this may not be the most
idiomatic way to do this.
* As #60665 observes, the alternating behavior is already a change from AT&T
troff necessitating a note in the documentation; this would be a further
change that should also be documented.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60673>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply via email to