[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#160282: cal: Should use the latter Chinese char for day of the week



On Tue, Sep 17, 2002 at 12:16:27AM +0800, Rex Tsai wrote:
> 
> - patch -
> diff -u usr.bin/ncal/ncal.c.orig usr.bin/ncal/ncal.c|more
> --- usr.bin/ncal/ncal.c.orig    Mon Sep 16 22:21:05 2002
> +++ usr.bin/ncal/ncal.c Mon Sep 16 23:47:01 2002
> @@ -783,10 +783,13 @@
>                 len = mbstowcs(NULL, buf, 0);
>                 wcs = calloc(len + 1, sizeof(wchar_t));
>                 mbstowcs(wcs, buf, len);
> -               for (j = 0; j < len; j++)
> +               if(len == wcswidth(wcs, (size_t)10)) {
for (size_t)10, if you can replace it with 'len', it's better
not to use some magic number. :)

Maybe you can supply your patch to the bug reported by Danny.
As a temperal solution since someone suggested to change the
abday inside the libc in the future.

Maybe not temperal since other locales might has the similar
problem. 

> +                   for (j = 0; j < len; j++)
>                         if (wcswidth(wcs, j + 1) >= 2)
> -                               break;
> -               wcs[j + 1] = L'\0';
> +                           break;
> +                   wcs[j+1] = L'\0';
> +               }
> +
>                 col = wcswidth(wcs, j + 1);
>                 len = wcstombs(NULL, wcs, 0);
>                 wds->names[i] = calloc(len + 2 - col + 1, sizeof(char));
> - patch -
> 
>   看起來 util-linux 中的 cal 比較適合 Linux 使用,希望 Debian 以後是使用這一
> 套。我希望能將他修正成日子與星期的排列是對齊的,這樣會美觀許多。
> 



-- 
Best regard
hashao



Reply to: