summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-12-15 00:52:00 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-12-15 00:52:00 +0000
commit2142a98c9e8826323941ec3da2c75325ca00eb52 (patch)
tree3c9509561e876b43e094f3cbb9383ef87cf209bf /tests
parent94ec8cff934d0d5559d6474131b3682e943bbc8e (diff)
downloadgdk-pixbuf-2142a98c9e8826323941ec3da2c75325ca00eb52.tar.gz
fix unicode validation when reading a file
2000-12-14 Havoc Pennington <hp@redhat.com> * gtk/testtext.c (fill_file_buffer): fix unicode validation when reading a file
Diffstat (limited to 'tests')
-rw-r--r--tests/testtext.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/tests/testtext.c b/tests/testtext.c
index 4eaf62b75..50da85b6d 100644
--- a/tests/testtext.c
+++ b/tests/testtext.c
@@ -638,22 +638,14 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename)
while (!feof (f))
{
gint count;
- char *leftover, *next;
+ const char *leftover;
int to_read = 2047 - remaining;
count = fread (buf + remaining, 1, to_read, f);
buf[count + remaining] = '\0';
- leftover = next = buf;
- while (next)
- {
- leftover = next;
- if (!*leftover)
- break;
-
- next = g_utf8_find_next_char (next, buf + count + remaining);
- }
-
+ g_utf8_validate (buf, -1, &leftover);
+
g_assert (g_utf8_validate (buf, leftover - buf, NULL));
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);