On Wed, Apr 13, 2016 at 10:34:31AM +0200, Vincent Lefevre wrote: > On 2016-04-12 12:41:05 -0700, Kevin J. McCarthy wrote: > > I'm attaching a slightly revised part1 patch, and adding another patch > > to the series. The first patch is changed so that the spacing can be > > invoked when pad=0. (There still might be a spacing issue for that case.) > > > > The second patch fixes softpad when the pad character itself is multicolumn. > > In this second patch: > > + pad = ((signed)(destlen - wlen - len)) / pl; > > The cast to "signed" seems useless and confusing: what is its goal?
Hi Vincent, Thanks for taking a look at the patches. That particular line was actually just moved from above the "if (pad >= 0)" to inside it. I think because destlen, wlen, and len are all size_t, if wlen+len were larger then destlen the resulting subtraction could turn into a large value, instead of the desired negative number (e.g., if we ran out of space). COLS is an int, so we don't have the issue for the calculation based on number of columns. I've been a little worried about the same issue for the parameters to mutt_wstr_trunc(), but didn't have a chance yet to look. In my testing, shrinking the window down to one column worked, but I wanted to take a closer look. Just fyi, after I posted the second round of patches I discovered that right justification "%>X" could have a spacing issue if pad==0, so I moved that check from below: - if (pad > 0) + if (pad >= 0) - else if (soft && pad <= 0) + else if (soft && pad < 0) Thank you. -- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA http://www.8t8.us/configs/gpg-key-transition-statement.txt
signature.asc
Description: PGP signature
