summaryrefslogtreecommitdiff
path: root/gtk/gtktextbtree.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-11-02 05:08:31 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-11-02 05:08:31 +0000
commit6002bc6582859ea2089f81f7bfddb3cb952820c7 (patch)
tree2f4ac5322779d3cf23e07f2eee21a28d44f2014b /gtk/gtktextbtree.c
parent2b8bac8304f0e1815b79f31190f8c570687b63a9 (diff)
downloadgtk+-6002bc6582859ea2089f81f7bfddb3cb952820c7.tar.gz
Replace manual offset calculations by g_utf8_offset_to_pointer().
2005-11-02 Matthias Clasen <mclasen@redhat.com> * gtk/gtktextbtree.c (_gtk_text_line_char_to_byte_offsets): * gtk/gtktextiter.c (gtk_text_iter_backward_chars): Replace manual offset calculations by g_utf8_offset_to_pointer(). (#320360, Paolo Borelli)
Diffstat (limited to 'gtk/gtktextbtree.c')
-rw-r--r--gtk/gtktextbtree.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index f9e1594a1d..c323c713fa 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -4144,16 +4144,11 @@ _gtk_text_line_char_to_byte_offsets (GtkTextLine *line,
if (seg->type == &gtk_text_char_type)
{
- *seg_byte_offset = 0;
- while (offset > 0)
- {
- gint bytes;
- const char * start = seg->body.chars + *seg_byte_offset;
+ const char *p;
- bytes = g_utf8_next_char (start) - start;
- *seg_byte_offset += bytes;
- offset -= 1;
- }
+ p = g_utf8_offset_to_pointer (seg->body.chars, offset);
+
+ *seg_byte_offset = p - seg->body.chars;
g_assert (*seg_byte_offset < seg->byte_count);