Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Baptiste Daroussin
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

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Andrey Chernov
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 encoded, >>> not for wide chars.

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Andrey Chernov
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 encoded, >> not for wide chars. > Bad copy/paste sorry it should be "MAX_ABMON_W

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Baptiste Daroussin
On Wed, Nov 25, 2015 at 05:06:17PM +0300, Andrey Chernov wrote: > On 25.11.2015 16:51, Baptiste Daroussin wrote: > > 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_month

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Andrey Chernov
On 25.11.2015 16:51, Baptiste Daroussin wrote: > 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 figu

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Andrey Chernov
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 fallback > on > the plain strftime meaning you keep localized information but the alignement > is > broken as of now. It will be enough. >> 3) wcwidth/wcswidth may return -1 too

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Baptiste Daroussin
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 > > fallback on > > the plain strftime meaning you keep localized information but the > > alignement is > > bro

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-25 Thread Baptiste Daroussin
On Wed, Nov 25, 2015 at 04:31:21AM +0300, Andrey Chernov wrote: > On 25.11.2015 3:15, Baptiste Daroussin wrote: > > On Sat, Nov 21, 2015 at 11:57:46PM +0300, Andrey Chernov wrote: > >> On 21.11.2015 15:18, Ed Schouten wrote: > >>> Hi Baptiste, > >>> > >>> I suppose you should use the wcswidth() fun

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-24 Thread Andrey Chernov
On 25.11.2015 4:31, Andrey Chernov wrote: > 4) The whole processing looks overcomplicated and not effective. What > about this instead? > for (i = 0; i < 12; i++) { > count wcswidth() of each month and store it in wab_months_width[]. > count max_width_month. > } > for (i = 0; i < 12; i++) {

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-24 Thread Andrey Chernov
On 25.11.2015 3:15, Baptiste Daroussin wrote: > On Sat, Nov 21, 2015 at 11:57:46PM +0300, Andrey Chernov wrote: >> On 21.11.2015 15:18, Ed Schouten wrote: >>> Hi Baptiste, >>> >>> I suppose you should use the wcswidth() function somewhere to compute >>> the visible width of the month name. Some cha

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-24 Thread Baptiste Daroussin
On Wed, Nov 25, 2015 at 01:15:13AM +0100, Baptiste Daroussin wrote: > On Sat, Nov 21, 2015 at 11:57:46PM +0300, Andrey Chernov wrote: > > On 21.11.2015 15:18, Ed Schouten wrote: > > > Hi Baptiste, > > > > > > I suppose you should use the wcswidth() function somewhere to compute > > > the visible w

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-24 Thread Baptiste Daroussin
On Sat, Nov 21, 2015 at 11:57:46PM +0300, Andrey Chernov wrote: > On 21.11.2015 15:18, Ed Schouten wrote: > > Hi Baptiste, > > > > I suppose you should use the wcswidth() function somewhere to compute > > the visible width of the month name. Some characters may be > > double-width, others may have

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-21 Thread Andrey Chernov
On 21.11.2015 15:18, Ed Schouten wrote: > Hi Baptiste, > > I suppose you should use the wcswidth() function somewhere to compute > the visible width of the month name. Some characters may be > double-width, others may have no effective width at all. > I agree. Checking error return of wide chars

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-21 Thread Ed Schouten
Hi Baptiste, I suppose you should use the wcswidth() function somewhere to compute the visible width of the month name. Some characters may be double-width, others may have no effective width at all. -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 __

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Baptiste Daroussin
On Sat, Nov 21, 2015 at 03:45:29AM +0300, Andrey Chernov wrote: > On 21.11.2015 3:35, Baptiste Daroussin wrote: > > > Here is what I do propose (sorry for the ugly pad_to_col name, if one has > > better > > please share :D > > > > https://reviews.freebsd.org/D4239 > > The whole function is ugly

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Andrey Chernov
On 21.11.2015 3:35, Baptiste Daroussin wrote: > Here is what I do propose (sorry for the ugly pad_to_col name, if one has > better > please share :D > > https://reviews.freebsd.org/D4239 The whole function is ugly, not only its name. Please no hardcoded constants assuming some internal encoding

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Baptiste Daroussin
On Fri, Nov 20, 2015 at 01:23:52PM +0100, Jilles Tjoelker wrote: > 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:/

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Jilles Tjoelker
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: > > > en

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Baptiste Daroussin
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: > > Hi, > > > > 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_AL

Re: /bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Baptiste Daroussin
On Fri, Nov 20, 2015 at 11:05:56AM +0300, Sergey V. Dyatko wrote: > Hi, > > 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/databa

/bin/ls formatting broken for non-C(?) locales

2015-11-20 Thread Sergey V. Dyatko
Hi, 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