Check that g_utf8_normalize was non-NULL, fallback otherwise

This commit is contained in:
Christian Dywan 2009-12-27 22:18:02 +01:00
parent 33565cc2f3
commit 8b7fdb7a56

View file

@ -755,21 +755,42 @@ midori_location_entry_completion_match_cb (GtkEntryCompletion* completion,
match = FALSE; match = FALSE;
if (G_LIKELY (uri)) if (G_LIKELY (uri))
{ {
gchar* nkey = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); gchar* nkey;
gchar* nuri = g_utf8_normalize (uri, -1, G_NORMALIZE_ALL); gchar* fkey;
gchar* fkey = g_utf8_casefold (nkey, -1); gchar* nuri;
gchar* furi = g_utf8_casefold (nuri, -1); gchar* furi;
g_free (uri);
if ((nkey = g_utf8_normalize (key, -1, G_NORMALIZE_ALL)))
{
fkey = g_utf8_casefold (nkey, -1);
g_free (nkey); g_free (nkey);
}
else
fkey = g_utf8_casefold (key, -1);
if ((nuri = g_utf8_normalize (uri, -1, G_NORMALIZE_ALL)))
{
furi = g_utf8_casefold (nuri, -1);
g_free (nuri); g_free (nuri);
}
else
furi = g_utf8_casefold (uri, -1);
g_free (uri);
match = strstr (furi, fkey) != NULL; match = strstr (furi, fkey) != NULL;
g_free (furi); g_free (furi);
if (!match && G_LIKELY (title)) if (!match && G_LIKELY (title))
{ {
gchar* ntitle = g_utf8_normalize (title, -1, G_NORMALIZE_ALL); gchar* ntitle;
gchar* ftitle = g_utf8_casefold (ntitle, -1); gchar* ftitle;
if ((ntitle = g_utf8_normalize (title, -1, G_NORMALIZE_ALL)))
{
ftitle = g_utf8_casefold (ntitle, -1);
g_free (ntitle); g_free (ntitle);
}
else
ftitle = g_utf8_casefold (title, -1);
match = strstr (ftitle, fkey) != NULL; match = strstr (ftitle, fkey) != NULL;
g_free (ftitle); g_free (ftitle);
} }