[evolution-patches] gtkhtml: upper/lower string crash fix



attached patch fixes lowering/upping strings in editor. it's crashing
for non-ascii utf8 strings right now (Miguel, thanks for bringing that
up)

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1906
diff -u -p -r1.1906 ChangeLog
--- ChangeLog	18 Nov 2003 19:06:53 -0000	1.1906
+++ ChangeLog	20 Nov 2003 21:33:01 -0000
@@ -1,3 +1,8 @@
+2003-11-20  Radek Doulik  <rodo ximian com>
+
+	* htmlengine-edit-text.c (upper_lower): use g_utf8 functions to
+	lower/upper string
+
 2003-11-18  Radek Doulik  <rodo ximian com>
 
 	* Makefile.am: enable deprecated gtk stuff. gtkcombo.h is
Index: htmlengine-edit-text.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-text.c,v
retrieving revision 1.10
diff -u -p -r1.10 htmlengine-edit-text.c
--- htmlengine-edit-text.c	8 Nov 2001 23:13:18 -0000	1.10
+++ htmlengine-edit-text.c	20 Nov 2003 21:33:01 -0000
@@ -49,13 +49,12 @@ upper_lower (HTMLObject *obj, HTMLEngine
 {
 	if (html_object_is_text (obj)) {
 		gboolean up = GPOINTER_TO_INT (data);
-		guchar *text;
+		guchar *old_text;
 
-		text = HTML_TEXT (obj)->text;
-		while (*text) {
-			*text = (up) ? toupper (*text) : tolower (*text);
-			text++;
-		}
+		old_text = HTML_TEXT (obj)->text;
+		HTML_TEXT (obj)->text = up ? g_utf8_strup (old_text, -1) : g_utf8_strdown (old_text, -1);
+		g_free (old_text);
+		HTML_TEXT (obj)->text_bytes = g_utf8_strlen (HTML_TEXT (obj)->text, -1);
 	}
 }
 


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