Mercurial > pidgin
diff src/util.c @ 7261:1930e3d00ecd
[gaim-migrate @ 7838]
prpl-specific normalize is back, after my crusade to kill it.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 14 Oct 2003 05:07:39 +0000 |
parents | d14e026611c0 |
children | 85fcaff1505d |
line wrap: on
line diff
--- a/src/util.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/util.c Tue Oct 14 05:07:39 2003 +0000 @@ -1250,30 +1250,43 @@ * String Functions **************************************************************************/ const char * -gaim_normalize(const char *s) +gaim_normalize(const GaimAccount *account, const char *s) { - static char buf[BUF_LEN]; - char *tmp; - int i, j; + GaimPlugin *prpl = NULL; + GaimPluginProtocolInfo *prpl_info = NULL; + + if(account) + prpl = gaim_find_prpl(gaim_account_get_protocol(account)); - g_return_val_if_fail(s != NULL, NULL); + if(prpl) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if(prpl_info && prpl_info->normalize) { + return prpl_info->normalize(account, s); + } else { + static char buf[BUF_LEN]; + char *tmp; + int i, j; - strncpy(buf, s, BUF_LEN); - for (i=0, j=0; buf[j]; i++, j++) { - while (buf[j] == ' ') - j++; - buf[i] = buf[j]; - } - buf[i] = '\0'; + g_return_val_if_fail(s != NULL, NULL); + + strncpy(buf, s, BUF_LEN); + for (i=0, j=0; buf[j]; i++, j++) { + while (buf[j] == ' ') + j++; + buf[i] = buf[j]; + } + buf[i] = '\0'; - tmp = g_utf8_strdown(buf, -1); - g_snprintf(buf, sizeof(buf), "%s", tmp); - g_free(tmp); - tmp = g_utf8_normalize(buf, -1, G_NORMALIZE_DEFAULT); - g_snprintf(buf, sizeof(buf), "%s", tmp); - g_free(tmp); + tmp = g_utf8_strdown(buf, -1); + g_snprintf(buf, sizeof(buf), "%s", tmp); + g_free(tmp); + tmp = g_utf8_normalize(buf, -1, G_NORMALIZE_DEFAULT); + g_snprintf(buf, sizeof(buf), "%s", tmp); + g_free(tmp); - return buf; + return buf; + } } /* Look for %n, %d, or %t in msg, and replace with the sender's name, date,