bug-groff
[Top][All Lists]
Advanced

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

[bug #63873] \~ can overwrite previous text.


From: Alejandro Colomar
Subject: [bug #63873] \~ can overwrite previous text.
Date: Tue, 7 Mar 2023 07:09:42 -0500 (EST)

Follow-up Comment #3, bug #63873 (project groff):


[comment #2 comment #2:]
>   See bug #52517 (26th November 2017).

Thanks!  Seems a duplicate.  I have a couple of patches that would fix the bug
(I think the first one is better, but I'll propose both, since I may miss some
groff obscure stuff):

```diff
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 9f00284c6..0ec4e40e3 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2081,11 +2081,12 @@ static node *node_list_reverse(node *n)
 static void distribute_space(node *n, int nspaces, hunits desired_space,
                             bool force_reverse_node_list = false)
 {
-  if (desired_space.is_zero() || nspaces == 0)
-    return;
   // Positive desired space is the typical case.  Negative desired space
-  // is possible if we have overrun an unbreakable line.  But we should
-  // not get here if there are no adjustable space nodes to adjust.
+  // is possible if we have overrun an unbreakable line.
+  if (desired_space.to_units() <= 0 || nspaces == 0)
+    return;
+  // But we should not get here if there are no adjustable space nodes
+  // to adjust.
   assert(nspaces > 0);
   // Space cannot always be distributed evenly among all of the space
   // nodes in the node list: there are limits to device resolution.  We
@@ -2098,8 +2099,7 @@ static void distribute_space(node *n, int nspaces,
hunits desired_space,
   static bool do_reverse_node_list = false;
   if (force_reverse_node_list || do_reverse_node_list)
     n = node_list_reverse(n);
-  if (!force_reverse_node_list && spread_limit >= 0
-      && desired_space.to_units() > 0) {
+  if (!force_reverse_node_list && spread_limit >= 0) {
     hunits em = curenv->get_size();
     double Ems = (double)desired_space.to_units() / nspaces
                 / (em.is_zero() ? hresolution : em.to_units());
```


Alternative:

```diff
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 9f00284c6..e7724fe30 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2106,8 +2106,10 @@ static void distribute_space(node *n, int nspaces,
hunits desired_space,
     if (Ems > spread_limit)
       output_warning(WARN_BREAK, "spreading %1m per space", Ems);
   }
-  for (node *tem = n; tem; tem = tem->next)
-    tem->spread_space(&nspaces, &desired_space);
+  if (desired_space.to_units() > 0) {
+    for (node *tem = n; tem; tem = tem->next)
+      tem->spread_space(&nspaces, &desired_space);
+  }
   if (force_reverse_node_list || do_reverse_node_list)
     (void)node_list_reverse(n);
   if (!force_reverse_node_list)
```


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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