dia-list  

lib/text.c can't handle multibyte string correctly

Kouhei Sutou
Tue, 24 Feb 2004 20:16:14 -0800

Hi,

Now, lib/text.c compares between utf - str (byte length) with
strlen (UTF-8 string's length). Therefore, a multibyte
string is inserted as string that has shorter length than
strlen.

--
kou

Index: lib/text.c
===================================================================
RCS file: /cvs/gnome/dia/lib/text.c,v
retrieving revision 1.51
diff -u -p -r1.51 text.c
--- lib/text.c  30 Nov 2003 13:19:38 -0000      1.51
+++ lib/text.c  25 Feb 2004 04:11:59 -0000
@@ -871,11 +871,12 @@ text_key_event(Focus *focus, guint keyva
         break;
       default:
         if (str || (strlen>0)) {
+          int str_len;
 
           return_val = TRUE;
-          utf = str;
-          for (utf = str ; utf && *utf && (utf-str <= strlen) ; 
-              utf = g_utf8_next_char (utf)) {
+          for (utf = str, str_len = strlen;
+               utf && *utf && str_len > 0;
+               utf = g_utf8_next_char (utf), str_len--) {
             c = g_utf8_get_char (utf);
             
             *change = text_create_change (text, TYPE_INSERT_CHAR, c,

_______________________________________________
Dia-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://www.lysator.liu.se/~alla/dia/faq.html
Main page at http://www.lysator.liu.se/~alla/dia

  • lib/text.c can't handle multibyte string correctly Kouhei Sutou