From owner-freebsd-current@freebsd.org Fri Nov 20 12:23:56 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 02394A3269F for ; Fri, 20 Nov 2015 12:23:56 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 95D591EE7; Fri, 20 Nov 2015 12:23:55 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 790843592E1; Fri, 20 Nov 2015 13:23:52 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 661A328494; Fri, 20 Nov 2015 13:23:52 +0100 (CET) Date: Fri, 20 Nov 2015 13:23:52 +0100 From: Jilles Tjoelker To: Baptiste Daroussin Cc: "Sergey V. Dyatko" , freebsd-current@freebsd.org Subject: Re: /bin/ls formatting broken for non-C(?) locales Message-ID: <20151120122352.GA5751@stack.nl> References: <20151120110556.6e20a71f@laptop.minsk.domain> <20151120104253.GA21071@ivaldir.etoilebsd.net> <20151120110212.GB21071@ivaldir.etoilebsd.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151120110212.GB21071@ivaldir.etoilebsd.net> User-Agent: Mutt/1.5.21 (2010-09-15) 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: Fri, 20 Nov 2015 12:23:56 -0000 On Fri, Nov 20, 2015 at 12:02:13PM +0100, Baptiste Daroussin wrote: > On Fri, Nov 20, 2015 at 11:42:53AM +0100, Baptiste Daroussin wrote: > > On Fri, Nov 20, 2015 at 11:05:56AM +0300, Sergey V. Dyatko wrote: > > > subj. http://i.imgur.com/F9QO29l.png > > > it is on head@r290573: > > > WTR: > > > env LC_ALL=uk_UA.UTF-8 ls -la /usr/ports/databases/ or env LC_ALL=ru_RU.UTF-8 > > > ls -la /usr/ports/databases/ > > > env LC_ALL=C ls -la /usr/ports/databases/ works fine > > > also on old stable/10 (r286868) as I can see 'month' field length 3 symbols > > Thanks for reporting, I can reproduce the issue with some other > > locales. The thing is there seems to be no standard for abbreviated > > length. Formerly we had a 3 character lenght for abbreviated month. > > We now use CLDR which seems to follow the abbreviated rules from IBM: > > "Each string must be of equal length and contain 5 characters or less" > > There are 2 possible fixes: either always pad those in the locale > > definition which seems wrong or modify ls so that it by itself pads > > properly. > > Neither posix nor ISO-14652 defines the length of the abbreviated form > > padding in the locales themself would be wrong so I do propose to > > pad in the ls command. And padding with 5 characters. > For the record glibc/linux had the same problem: > https://sourceware.org/bugzilla/show_bug.cgi?id=9859 > "fixed" in coreutils (gnu ls) the way I propose to do for us > http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=612b647dd16d5abc03b295abe42d8b4a0fe660f7 Coreutils fixed it slightly better: it calculates the maximum width of the abbreviated month names and pads to that (with a maximum of 5). In particular, this ensures that the output does not change for locales that have 3-character abbreviations, such as the POSIX locale. I think this is valuable. They also keep the list of month names from this calculation and they say this speeds up ls noticeably compared to having strftime() expand %b for every file. -- Jilles Tjoelker