From owner-freebsd-current@freebsd.org Wed Nov 25 13:51: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 43298A367E6 for ; Wed, 25 Nov 2015 13:51:05 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) (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 C77031384; Wed, 25 Nov 2015 13:51:04 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: by wmvv187 with SMTP id v187so258005552wmv.1; Wed, 25 Nov 2015 05:51: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=4J9qY8lVU0E9CcAHZ6xzULABiUp2+HaYDxdgipZ3e78=; b=BCpADGeUiSXCexJYkxwDz1ucistZWWbtzJg0pJ30HacKrWyfqAGr0Le7Vx2LFWP4VU mNrhhwH0zb/4CZ29zsFxxKDhuzmQWQ0FBHw1jtKP14G4VnOU2n2PG3Aj+FkwQbsKbFZD lTRZmP4wmJty6TiRaziwU6TzevpOt624QU05rbDkQ61AKHqVcUsJ+sxqmKBpvEpbVTb+ e6/+wUn9wMnhzQkh5udg+vm7Zor0sbx0/a3s03nP/pq41Fw3x46qcR7dpulbOMp3qa8+ n2TaREPu/6WIvag8TepsRS6soiMpBkBdBSjQj3+e2tZtox9XIgUCnibhnt16U4dI5iMM Sfqw== X-Received: by 10.194.116.133 with SMTP id jw5mr6222834wjb.110.1448459463372; Wed, 25 Nov 2015 05:51:03 -0800 (PST) Received: from ivaldir.etoilebsd.net ([2001:41d0:8:db4c::1]) by smtp.gmail.com with ESMTPSA id h67sm3592570wmf.17.2015.11.25.05.51.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Nov 2015 05:51:02 -0800 (PST) Sender: Baptiste Daroussin Date: Wed, 25 Nov 2015 14:51: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: <20151125135059.GC77370@ivaldir.etoilebsd.net> References: <20151120104253.GA21071@ivaldir.etoilebsd.net> <20151120110212.GB21071@ivaldir.etoilebsd.net> <20151120122352.GA5751@stack.nl> <20151121003541.GF21071@ivaldir.etoilebsd.net> <5650DACA.2090501@freebsd.org> <20151125001513.GC70014@ivaldir.etoilebsd.net> <56550F69.8050609@freebsd.org> <20151125125325.GB77370@ivaldir.etoilebsd.net> <5655B8D9.8060805@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IpbVkmxF4tDyP/Kb" Content-Disposition: inline In-Reply-To: <5655B8D9.8060805@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 13:51:05 -0000 --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--