mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
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:
parent
32d3bddae4
commit
5ec1c2422c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user