[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] [troff]: Make unbreakable spaces have a minimum length.
From: |
Alejandro Colomar |
Subject: |
[PATCH] [troff]: Make unbreakable spaces have a minimum length. |
Date: |
Tue, 7 Mar 2023 13:55:56 +0100 |
Previously, there was a bug by which a very long unbreakable element was
right after an unbreakable adjustable space, the space would be adjusted
to a negative value, so that the line is not broken and it would "seem
right" to troff(1). Of course, a negative space would have the unwanted
effect of hiding previous text, which wouldn't seem so right to a
reader.
Now, we don't adjust space negatively, so \~ has now a minimum length of
a single space.
Closes: <https://savannah.gnu.org/bugs/?52517>
Closes: <https://savannah.gnu.org/bugs/?63873>
Reported-by: Bjarni Ingi Gislason <bjarniig@vortex.is>
Reported-by: Alejandro Colomar <alx@kernel.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
Hi Branden,
I tested my reproducer and Bjarni's (2017) reproducer before and after
this patch, and both are fixed by this patch. Existing tests are not
affected (I can't reproduce the failure I had yesterday, which was about
fonts, IIRC).
I would add a regression test, but don't really know how to do it, so
I'll let you (or Bjarni) do it.
Cheers,
Alex
src/roff/troff/env.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 9f00284c6..f15225af7 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2081,11 +2081,8 @@ 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)
+ if (desired_space.to_units() <= 0 || 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.
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 +2095,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());
--
2.39.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] [troff]: Make unbreakable spaces have a minimum length.,
Alejandro Colomar <=