Date: Wed, 25 Nov 2015 14:51:00 +0100 From: Baptiste Daroussin <bapt@freebsd.org> To: Andrey Chernov <ache@freebsd.org> Cc: Ed Schouten <ed@nuxi.nl>, Jilles Tjoelker <jilles@stack.nl>, "Sergey V. Dyatko" <sergey.dyatko@gmail.com>, FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: /bin/ls formatting broken for non-C(?) locales Message-ID: <20151125135059.GC77370@ivaldir.etoilebsd.net> In-Reply-To: <5655B8D9.8060805@freebsd.org> References: <20151120104253.GA21071@ivaldir.etoilebsd.net> <20151120110212.GB21071@ivaldir.etoilebsd.net> <20151120122352.GA5751@stack.nl> <20151121003541.GF21071@ivaldir.etoilebsd.net> <CABh_MK=cz-zB7krcnKjhqfW9VnwjSmuaZ9%2BAETQiLy3AsHq_vw@mail.gmail.com> <5650DACA.2090501@freebsd.org> <20151125001513.GC70014@ivaldir.etoilebsd.net> <56550F69.8050609@freebsd.org> <20151125125325.GB77370@ivaldir.etoilebsd.net> <5655B8D9.8060805@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--IpbVkmxF4tDyP/Kb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 25, 2015 at 04:34:17PM +0300, Andrey Chernov wrote: > 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 fa= llback on > > the plain strftime meaning you keep localized information but the align= ement is > > broken as of now. >=20 > It will be enough. >=20 > >> 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 >=20 > 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. >=20 > > Review updated (if you prefer a diff by mail just tell me, given you do= not have > > a phabricator account.) >=20 > I don't have phabricator. >=20 > This one > if ((n =3D max_month_width - wab_months_width[i]) > 0) { > wcslcat(wab_months[i], L" "/* MAX_ABMON_WIDTH */, > max_month_width + 1); > } > should be > if ((n =3D max_month_width - wab_months_width[i]) > 0) > wcslcat(wab_months[i], L" "/* MAX_ABMON_WIDTH */, n); >=20 > I.e. you append n spaces and n is the difference between max and current. With wcsncat I would agree, but not with wcslcat. wcslcat works like strlcat: to quote the manpage: "It will append at most dstsize - strlen(dst) - 1 characters." So here with your version it will be n - wcslen(wab_months[i]) -1 which won't fit what we want to do. btw that makes me figure out that what I want is wcsncat because we do care= to make sure we have appended the right number of spaces at the end of the abbreviated month based on character width, not the on the len of the wide string so I changed it if ((n =3D max_month_width - wab_months_width[i]) > 0) wcsncat(wab_months[i], L" "/* MAX_ABMON_WIDTH */, n); If you do not have further comments, I will commit that later today. Then I will work on libarchive and pax (would you like to review the patche= s for those?) Best regards, Bapt --IpbVkmxF4tDyP/Kb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlZVvMMACgkQ8kTtMUmk6ExGzQCfcrizYfapj37PoE8IHX1kWhlQ 0F4AoLC31+gVBQzM5F48o8BoAC/1vymH =S5B+ -----END PGP SIGNATURE----- --IpbVkmxF4tDyP/Kb--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151125135059.GC77370>