[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



Hi, all

In zh_TW locale of glibc, the "abday" fields contain 2 Chinese words (4 bytes
long), but the cal(aka ncal) cut the day of the week as 2 bytes long. The
output of cal is very "strange". For example: it looks like

'Sunday' -> 'day'
'Monday' -> 'day'
 ...

here is the patch to fixed, this code disable cal to cut "DBCS" words, please
apply it.

- 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 -
-- 
-Rex, geek by nature linux by choice




Reply to: