Re: Bug#160282: cal: Should use the latter Chinese char for day of the week
ha shao wrote:
> On Sun, Sep 15, 2002 at 10:25:23PM +0800, Rex Tsai wrote:
> The problem has been discussed before in this list. Please search
> cal in the archive.
我看了先前的讨论,大概了解问题在那里。对不起,我先前那封信弄错,朋友今天提醒
我,其实 Gentoo 的 cal 正常,是因为那是 util-linux-2.11u。不是 bsdmainutils。
我也稍微看过了 bsdmainutils-5.20020211,发现里面用了 widechar 相关的函式。似乎
跟原本的 bsdmainutils 差别颇大。我稍微 dirty hack 了一下,下面是我的 patch,如
果星期的字串是 DBCS 的话,就不用强迫砍成两个 Byte。出来的结果会是
九月 2002
周日 周一 周二 周三 周四 周五 周六
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
LC_ALL=C
September 2002
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
- 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 (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 以后是使用这一
套。我希望能将他修正成日子与星期的排列是对齐的,这样会美观许多。
http://www.kernel.org/pub/linux/utils/util-linux/
--
-Rex, geek by nature linux by choice
--
To UNSUBSCRIBE, email to debian-chinese-big5-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
--
| This message was re-posted from debian-chinese-big5@lists.debian.org
| and converted from big5 to gb2312 by an automatic gateway.
Reply to: