/bin/ls formatting broken for non-C(?) locales

Andrey Chernov ache at freebsd.org
Wed Nov 25 14:05:20 UTC 2015


On 25.11.2015 15:53, Baptiste Daroussin wrote:
> What I did for now is set max_month_width to -1 and in ls_strftime I fallback on
> the plain strftime meaning you keep localized information but the alignement is
> broken as of now.

It will be enough.

>> 3) wcwidth/wcswidth may return -1 too, it needs to be checked too.
> done and truncate the name of the month to the latest valid character

I think there is no point for sofisticated truncating, if locale is not
valid. F.e. you may truncate to just 1 char. The thing above will be
enough for all such cases.

> Review updated (if you prefer a diff by mail just tell me, given you do not have
> a phabricator account.)

I don't have phabricator.

This one
if ((n = max_month_width - wab_months_width[i]) > 0) {
    wcslcat(wab_months[i], L"     "/* MAX_ABMON_WIDTH */,
        max_month_width + 1);
}
should be
if ((n = max_month_width - wab_months_width[i]) > 0)
    wcslcat(wab_months[i], L"     "/* MAX_ABMON_WIDTH */, n);

I.e. you append n spaces and n is the difference between max and current.

-- 
http://ache.vniz.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20151125/c9da8b47/attachment.bin>


More information about the freebsd-current mailing list