[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #52517] adjustment can cause overwritten text on lines using \~
From: |
G. Branden Robinson |
Subject: |
[bug #52517] adjustment can cause overwritten text on lines using \~ |
Date: |
Thu, 30 Mar 2023 08:13:48 -0400 (EDT) |
Update of bug #52517 (project groff):
Status: None => In Progress
Assigned to: None => gbranden
Summary: src: adjustments of a line can break down if it
contains "\~" => adjustment can cause overwritten text on lines using \~
_______________________________________________________
Follow-up Comment #1:
Affects groff 1.22.4.
Here's a nonce patch. What I really want to do is examine each caller of
`distribute_space()` and see if we're checking our invariants properly in
those places.
For clarity of the change proper, this patch doesn't alter indentation.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 9f00284c6..be07a740c 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2081,6 +2081,7 @@ static node *node_list_reverse(node *n)
static void distribute_space(node *n, int nspaces, hunits desired_space,
bool force_reverse_node_list = false)
{
+ assert(desired_space >= H0);
if (desired_space.is_zero() || nspaces == 0)
return;
// Positive desired space is the typical case. Negative desired space
@@ -2136,6 +2137,11 @@ void environment::possibly_break_line(int start_here,
int forced)
bp->nd->split(bp->index, &pre, &post);
*ndp = post;
hunits extra_space_width = H0;
+ if (target_text_length - bp->width < 0)
+ output_warning(WARN_BREAK, "cannot break before exceeding line"
+ " length");
+ else {
+ extra_space_width = target_text_length - bp->width;
switch(adjust_mode) {
case ADJUST_BOTH:
if (bp->nspaces != 0)
@@ -2153,6 +2159,7 @@ void environment::possibly_break_line(int start_here,
int forced)
break;
}
distribute_space(pre, bp->nspaces, extra_space_width);
+ }
hunits output_width = bp->width + extra_space_width;
// This should become an assert() when we can get reliable width
// data from CJK glyphs. See Savannah #44018.
While we're tackling this one, it might be an opportunity to implement
squeezable inter-word space. See bug #40963.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?52517>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #52517] adjustment can cause overwritten text on lines using \~,
G. Branden Robinson <=