summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-08-22 23:53:13 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-08-22 23:53:13 +0000
commit9a2e1914e525e56b7fcb25699e19c9667f2c5491 (patch)
tree0f851982f6f9642944181a8317ee5d9a203d8c2d
parent057c4d839c8f979700df14eaa73e1c4d2a55f0d0 (diff)
downloadpango-9a2e1914e525e56b7fcb25699e19c9667f2c5491.tar.gz
Simply use g_utf8_validate() to validate the text, avoiding problem where
Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (pango_layout_set_text): Simply use g_utf8_validate() to validate the text, avoiding problem where layout was left in hosed state for invalid UTF-8, and also a bug with reading one-past length.
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-1-07
-rw-r--r--ChangeLog.pre-1-107
-rw-r--r--ChangeLog.pre-1-27
-rw-r--r--ChangeLog.pre-1-47
-rw-r--r--ChangeLog.pre-1-67
-rw-r--r--ChangeLog.pre-1-87
-rw-r--r--pango/pango-layout.c51
8 files changed, 62 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index bda4851f..6444b3c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index bda4851f..6444b3c9 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,10 @@
+Wed Aug 22 19:52:18 2001 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-layout.c (pango_layout_set_text): Simply
+ use g_utf8_validate() to validate the text, avoiding
+ problem where layout was left in hosed state for invalid
+ UTF-8, and also a bug with reading one-past length.
+
2001-08-16 Alexander Larsson <alexl@redhat.com>
* pango/pangowin32.c:
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 093da577..46436e11 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -720,51 +720,26 @@ pango_layout_set_text (PangoLayout *layout,
const char *text,
int length)
{
+ const gchar *end;
+
g_return_if_fail (layout != NULL);
g_return_if_fail (length == 0 || text != NULL);
+
+ if (!g_utf8_validate (text, length, &end))
+ g_warning ("Invalid UTF8 string passed to pango_layout_set_text()");
+ length = end - text;
+
if (layout->text)
g_free (layout->text);
- if (length == 0)
- {
- layout->text = g_strdup ("");
- layout->n_chars = 0;
- }
- else
- {
- const char *p = text;
- int n_chars = 0;
-
- while (*p && (length < 0 || p < text + length))
- {
- if (g_utf8_get_char (p) == (gunichar)-1)
- {
- g_warning ("Invalid UTF8 string passed to pango_layout_set_text()");
- return;
- }
- p = g_utf8_next_char (p);
- n_chars++;
- }
-
- if (length < 0)
- length = p - text;
-
- if (length >= 0 && p != text + length)
- g_warning ("string passed to pango_layout_set_text() contains embedded NULL");
-
- length = p - text;
-
- /* NULL-terminate the text for convenience.
- */
-
- layout->text = g_malloc (length + 1);
- memcpy (layout->text, text, length);
- layout->text[length] = '\0';
+ /* NULL-terminate the text for convenience.
+ */
+ layout->text = g_malloc (length + 1);
+ memcpy (layout->text, text, length);
+ layout->text[length] = '\0';
- layout->n_chars = n_chars;
- }
-
+ layout->n_chars = g_utf8_strlen (layout->text, -1);
layout->length = length;
pango_layout_clear_lines (layout);