Ticket #4446 (closed defect: fixed)

Opened 5 weeks ago

Last modified 4 weeks ago

Paragraph formatting allows lines one character longer than the margin

Reported by: proski Owned by: andrew_b
Priority: major Milestone: 4.8.30
Component: mcedit Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master


The default word wrap setting is 72 characters, but Alt-P acts as if the setting is 73 characters.

It turns out there is a bug in line_pixel_length(). When xn (the visual width) exceed l (the target width), b (the byte offset in the string and the returnable value) is still incremented before the for loop ends. That's how for loops work. But we want the byte offset after the last character that would fit, i.e. the non-incremented value.

The attached patch moves the increment of the return value to a separate line. The initial increment is not needed, so char_length starts with 0.

I've tested the patch with different charsets, including wide characters.


0001-Fix-off-by-one-error-in-paragraph-formatting-code.patch (1.4 KB) - added by proski 5 weeks ago.

Change History

Changed 5 weeks ago by proski


comment:1 Changed 5 weeks ago by andrew_b

  • Status changed from new to accepted
  • Owner set to andrew_b
  • Branch state changed from no branch to on review
  • Milestone changed from Future Releases to 4.8.30


Branch: 4446_paragraph_format

comment:2 Changed 4 weeks ago by andrew_b

  • Votes for changeset set to andrew_b
  • Branch state changed from on review to approved

comment:3 Changed 4 weeks ago by andrew_b

  • Status changed from accepted to testing
  • Votes for changeset changed from andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:4 Changed 4 weeks ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.