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

From: Andrey Chernov <ache_at_freebsd.org>
Date: Wed, 25 Nov 2015 16:34:17 +0300
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/


Received on Wed Nov 25 2015 - 13:05:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:01 UTC