From owner-freebsd-current@freebsd.org Wed Nov 25 15:52:05 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF97AA374FB for ; Wed, 25 Nov 2015 15:52:05 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 26486155B; Wed, 25 Nov 2015 15:52:05 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: by wmec201 with SMTP id c201so75826129wme.1; Wed, 25 Nov 2015 07:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=9qpwFKPEveruYAqWNHeU0UK0IEvE/q4mxKlelpG411o=; b=QPtLyl+37P1GkLauKq51It5mNHgr4ikTQMhM/U8xEOQ3FxQ/9+M//alfJezsi2WYrB YN31W9rzR9XHuV1lm2Qpk6ZaMCRMvlg6ThelrBDRj2O0OFhcuS760DdNsZoj8HcSgKZq IBYcO1fs2TUv3HzOxzGgUG08gWEnKiNBllDJm9KjMBJO5a24WAnd9Yz/J8wRQxHunr1h KL6HUgWn/7QgUEvisnqVwOPfCuhf1hCYGAxBzNTtLooGP4MxuBN6QlmjJwfzki0hpvT1 wbWlRHFd/iLQCbB07Bkt2ywlRlbU8Wqg95A06P0mfLb+Zd2jvOFGfI2zgdzOokk4HHnP DIcA== X-Received: by 10.28.215.209 with SMTP id o200mr5056706wmg.31.1448466723430; Wed, 25 Nov 2015 07:52:03 -0800 (PST) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by smtp.gmail.com with ESMTPSA id 143sm4110739wmv.18.2015.11.25.07.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Nov 2015 07:52:02 -0800 (PST) Sender: Baptiste Daroussin Date: Wed, 25 Nov 2015 16:52:00 +0100 From: Baptiste Daroussin To: Andrey Chernov Cc: Ed Schouten , Jilles Tjoelker , "Sergey V. Dyatko" , FreeBSD Current Subject: Re: /bin/ls formatting broken for non-C(?) locales Message-ID: <20151125155200.GE77370@ivaldir.etoilebsd.net> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="X3gaHHMYHkYqP6yf" Content-Disposition: inline In-Reply-To: <5655D444.1050901@freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2015 15:52:06 -0000 --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--