Index: glib/gutf8.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gutf8.c,v
retrieving revision 1.45
diff -u -p -r1.45 gutf8.c
--- glib/gutf8.c	30 Oct 2005 03:05:21 -0000	1.45
+++ glib/gutf8.c	8 Nov 2005 20:32:08 -0000
@@ -291,9 +291,28 @@ g_utf8_offset_to_pointer  (const gchar *
 			   glong        offset)    
 {
   const gchar *s = str;
-  while (offset--)
-    s = g_utf8_next_char (s);
-  
+  if (offset > 0) 
+    while (offset--)
+      s = g_utf8_next_char (s);
+  else
+#if SANE
+    while (offset) 
+      {
+        s--;
+        if ((*s & 0xc0) != 0x80))
+          offset++;
+      }  
+#else
+    while (offset)
+      {
+	s += offset;
+	while ((*s & 0xc0) == 0x80)
+          s--;
+
+	offset += g_utf8_pointer_to_offset (e, str);
+      }
+#endif
+
   return (gchar *)s;
 }
 
