gunidecomp: Add some explanatory comments to g_utf8_normalize()

Just to make it a bit easier for people to understand the logic in the
implementation in future, because it took me a while.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-10-21 17:10:01 +01:00
parent 32d3bddae4
commit 5ec1c2422c
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -359,6 +359,8 @@ _g_utf8_normalize_wc (const gchar *str,
gboolean do_compose = (mode == G_NORMALIZE_NFC ||
mode == G_NORMALIZE_NFKC);
/* Do a first pass to work out the length of the normalised string so we can
* allocate a buffer. */
n_wc = 0;
p = str;
while ((max_len < 0 || p < str + max_len) && *p)
@ -409,8 +411,10 @@ _g_utf8_normalize_wc (const gchar *str,
p = next;
}
/* Allocate the buffer for the result. */
wc_buffer = g_new (gunichar, n_wc + 1);
/* Do another pass to fill the buffer with the normalised string. */
last_start = 0;
n_wc = 0;
p = str;