Hi,
I wrote a small patch to fix this behaviour. I am sure this patch could
be optimized, because I am not really into c-coding.
The patch applies clean to remind-03.01.01 and with offset to
remind-03.00.24.
Regards,
Wolfgang
-- 
Wolfgang Kroener              ooo       /|    |\
                         )-='=iii===`==( |    |
http://www.azog.de         ((.ICI_. ))  \|   ()
GnuPG: B3F4532E             `-UUU:=-'
--- remind-03.01.01.orig/src/calendar.c	2007-08-12 04:03:13.000000000 +0200
+++ remind-03.01.01/src/calendar.c	2007-08-23 10:44:21.000000000 +0200
@@ -14,6 +14,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <wchar.h>
 #include <ctype.h>
 
 #include <stdlib.h>
@@ -371,6 +372,9 @@
     char *s;
     char *space;
     int numwritten = 0;
+    int tmplen;
+    mbstate_t ps = {0};
+    int twobytestart = 1;
 
 /* Print as many characters as possible within the column */
     space = NULL;
@@ -398,7 +402,20 @@
     if (!space) {
 	for (s = e->pos; s - e->pos < ColSpaces; s++) {
 	    if (!*s) break;
-	    numwritten++;
+            tmplen = mbrlen(s, 2, &ps);
+            if ((size_t)tmplen != (size_t)-1 && (size_t)tmplen != (size_t)-2) {
+              /* non-twobyte character found */
+              numwritten++;
+            } else {
+              /* twobyte character */
+              if (twobytestart == 1) {
+                numwritten++;
+                twobytestart = 0;
+              } else {
+                e->pos++;
+                twobytestart = 1;
+              }
+            }
 	    PutChar(*s);
 	}
 	e->pos = s;
@@ -407,7 +424,19 @@
 /* We found a space - print everything before it. */
 	for (s = e->pos; s<space; s++) {
 	    if (!*s) break;
-	    numwritten++;
+            tmplen = mbrlen(s, 2, &ps);
+            if ((size_t)tmplen != (size_t)-1 && (size_t)tmplen != (size_t)-2) {
+              /* non-twobyte character found */
+              numwritten++;
+            } else {
+              /* twobyte character */
+              if (twobytestart == 1) {
+                numwritten++;
+                twobytestart = 0;
+              } else {
+                twobytestart = 1;
+              }
+            }
 	    PutChar(*s);
 	}
     }

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Remind-fans mailing list
Remind-fans@lists.whatexit.org
http://lists.whatexit.org/mailman/listinfo/remind-fans

Reply via email to