Date: Wed, 25 Nov 2015 16:52: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: <20151125155200.GE77370@ivaldir.etoilebsd.net> In-Reply-To: <5655D444.1050901@freebsd.org> References: <5650DACA.2090501@freebsd.org> <20151125001513.GC70014@ivaldir.etoilebsd.net> <56550F69.8050609@freebsd.org> <20151125125325.GB77370@ivaldir.etoilebsd.net> <5655B8D9.8060805@freebsd.org> <20151125135059.GC77370@ivaldir.etoilebsd.net> <5655C059.8010701@freebsd.org> <20151125143501.GD77370@ivaldir.etoilebsd.net> <5655CFC6.7010805@freebsd.org> <5655D444.1050901@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--X3gaHHMYHkYqP6yf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 25, 2015 at 06:31:16PM +0300, Andrey Chernov wrote: > On 25.11.2015 18:12, Andrey Chernov wrote: > > On 25.11.2015 17:35, Baptiste Daroussin wrote: > >>> BTW, array size looks suspicious: > >>> static wchar_t wab_months[12][MAX_ABMON_WIDTH * 2 * MB_LEN_MAX]; > >>> what MB_LEN_MAX doing here? This constant is for multiple-bytes encod= ed, > >>> not for wide chars. > >> Bad copy/paste sorry it should be "MAX_ABMON_WIDTH * 2" > >=20 > > I don't check deep enough, it seems first array > > MAX_ABMON_WIDTH * MB_LEN_MAX + 1 > > and second one > > MAX_ABMON_WIDTH * 2 + 1 > >=20 >=20 > No. We can't assume anything here and should integrate limits from the > locale for months fields instead. F.e. in abstract general case in wide > array can be 100 zero-width characters + 5 of normal characters, so > width-oriented sizes not prevents overflowing. >=20 > First array size should be from locale internals, There is no max size for an abbreviated month in the locale internals So maybe the best here is to consider your first proposal: MAX_ABMON_WIDTH * MB_LEN_MAX + 1 and MAX_ABMON_WIDTH * 2 + 1 Check that it does not overflow and fallack if it overflows. Having 100 zero-width characters in a locale have very little probability to happen and if it does one day, it problably means something went wrong in t= he code generation Bapt --X3gaHHMYHkYqP6yf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlZV2SAACgkQ8kTtMUmk6Ey6mwCgrK3BAa3w/GJGS2Hq2Dh9yzfV 2IAAnjJgP8CKz3d2pPTB2vZMW0k6IZY+ =VtHh -----END PGP SIGNATURE----- --X3gaHHMYHkYqP6yf--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151125155200.GE77370>