bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #60673] adjustment algorithm should disregard nonadjusted lines in


From: Dave
Subject: [bug #60673] adjustment algorithm should disregard nonadjusted lines in its alternation pattern
Date: Wed, 26 May 2021 02:34:50 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0

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

[Prev in Thread] Current Thread [Next in Thread]