From e174f461c67cf4814b9aa9bcfc256e99fab15ee4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Jan 2007 04:43:23 +0000 Subject: [PATCH] Clarify the behaviour is max_len is zero. (#400044, Benjamin Dauvergne) 2007-01-23 Matthias Clasen * glib/gutf8.c (g_utf8_get_char_validated): Clarify the behaviour is max_len is zero. (#400044, Benjamin Dauvergne) svn path=/branches/glib-2-12/; revision=5312 --- ChangeLog | 6 ++++++ glib/gutf8.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f2e5b20b..a576fcba1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-01-23 Matthias Clasen + + * glib/gutf8.c (g_utf8_get_char_validated): Clarify + the behaviour is max_len is zero. (#400044, + Benjamin Dauvergne) + 2007-01-23 Matthias Clasen Merge from trunk: diff --git a/glib/gutf8.c b/glib/gutf8.c index 6c2136a9f..ad9a267b9 100644 --- a/glib/gutf8.c +++ b/glib/gutf8.c @@ -764,14 +764,20 @@ g_utf8_get_char_extended (const gchar *p, * * Return value: the resulting character. If @p points to a partial * sequence at the end of a string that could begin a valid - * character, returns (gunichar)-2; otherwise, if @p does not point - * to a valid UTF-8 encoded Unicode character, returns (gunichar)-1. + * character (or if @max_len is zero), returns (gunichar)-2; + * otherwise, if @p does not point to a valid UTF-8 encoded + * Unicode character, returns (gunichar)-1. **/ gunichar g_utf8_get_char_validated (const gchar *p, gssize max_len) { - gunichar result = g_utf8_get_char_extended (p, max_len); + gunichar result; + + if (max_len == 0) + return (gunichar)-2; + + result = g_utf8_get_char_extended (p, max_len); if (result & 0x80000000) return result;