bugGNU roff - Bugs: bug #52517, [troff] adjustment can cause...

 
 

bug #52517: [troff] adjustment can cause overwritten text on lines using \~

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Sun 26 Nov 2017 06:24:27 PM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  None
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 14 Apr 2023 08:08:03 PM UTC, comment #3: 

I'm not actively working on this; it seems to be entangled with enough other stuff that I don't feel I can give it proper attention until after the 1.23.0 release settles out.

But people are welcome to apply the patch in comment #1 and report their experiences with it!

G. Branden Robinson <gbranden>
Group administrator
Thu 30 Mar 2023 06:54:36 PM UTC, comment #2: 

Bug #63873 was marked as a duplicate of this bug.

Dave <barx>
Group Member
Thu 30 Mar 2023 12:13:47 PM UTC, 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.

G. Branden Robinson <gbranden>
Group administrator
Sun 26 Nov 2017 06:24:27 PM UTC, original submission:  

  I discovered this bug while replacing ".nh/.hy" pairs with "\%" in the
"contrib/groffer/groffer.1.man" file.

  Backspaces can been seen in the output if it is piped though "od -tcx1".

  Test file (hyphen.gro):

.pl 10
.\"ll 1n
.tm hyphenation at start is \n[.hy]
.hy 12
.tm Extent of hyphenation is (.hy) is \n[.hy]
.nr LL 10
.ll \n[LL]
.\".na
.while \n[LL]>0 \{\
.tm Line length is \n[LL]
www\~mode
.nr LL \n[LL]-1
.ll \n[LL]
.\}

  Output is also in the attachment.

command line: test-groff hyphen.gro

Output (without backspaces):


hyphenation at start is 14
Extent of hyphenation is (.hy) is 12
Line length is 10
Line length is 9
Line length is 8
Line length is 7
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 0.5i]: can't break line
Line length is 6
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 0.7i]: can't break line
Line length is 5
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 0.8i]: can't break line
Line length is 4
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 1.0i]: can't break line
Line length is 3
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 1.2i]: can't break line
Line length is 2
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 1.3i]: can't break line
Line length is 1
../testen/hyphen.gro:11: backtrace: while loop
../testen/hyphen.gro:14: warning [p 1, 1.5i]: can't break line
www   mode
www  mode
www mode
wwwmode
wwmode
wmode
mode
mode
modew
modeww


Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #42491:  attachment added by bjarniig (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by barx (Posted a comment)
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by gbranden (original reporter of #63873)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-08-10 gbranden StatusPostponed None
        Summaryadjustment can cause overwritten text on lines using \~ [troff] adjustment can cause overwritten text on lines using \~
    2023-04-14 gbranden StatusIn Progress Postponed
    2023-03-30 gbranden StatusNone In Progress
        Assigned toNone gbranden
        Summarysrc: adjustments of a line can break down if it contains &quot;\~&quot; adjustment can cause overwritten text on lines using \~
        Carbon-Copy- Added -email is unavailable-
    2017-11-26 bjarniig Attached File- Added attachment, #42491

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code