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

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



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,




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK