Mercurial > pidgin
diff src/util.c @ 11153:8e600ee6ec61
[gaim-migrate @ 13235]
sf patch #1243998, from Evan Schoenberg, also some changes by me
Basically novell needed a prpl->normalize function that
didn't remove spaces. But I didn't like having the default
normalize code make the string lowercase and remove spaces,
so I changed the default to basically do nothing.
Anyhoo, if you think of yourself as the primary contact for
one of the PRPLs, you may want to make sure your PRPL has a
normalize function, if it needs one.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 24 Jul 2005 19:36:22 +0000 |
parents | ee059fe9b362 |
children | 6932df31225f |
line wrap: on
line diff
--- a/src/util.c Sun Jul 24 18:20:04 2005 +0000 +++ b/src/util.c Sun Jul 24 19:36:22 2005 +0000 @@ -2243,7 +2243,7 @@ * String Functions **************************************************************************/ const char * -gaim_normalize(const GaimAccount *account, const char *s) +gaim_normalize(const GaimAccount *account, const char *str) { GaimPlugin *prpl = NULL; GaimPluginProtocolInfo *prpl_info = NULL; @@ -2256,35 +2256,45 @@ prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); if(prpl_info && prpl_info->normalize) - ret = prpl_info->normalize(account, s); - - if(!ret) { + ret = prpl_info->normalize(account, str); + + if(!ret) + { static char buf[BUF_LEN]; char *tmp; - int i, j; - - 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); + + tmp = g_utf8_normalize(str, -1, G_NORMALIZE_DEFAULT); g_snprintf(buf, sizeof(buf), "%s", tmp); g_free(tmp); ret = buf; } + return ret; } +/* + * You probably don't want to call this directly, it is + * mainly for use as a PRPL callback function. See the + * comments in util.h. + */ +const char * +gaim_normalize_nocase(const GaimAccount *account, const char *str) +{ + static char buf[BUF_LEN]; + char *tmp1, *tmp2; + + g_return_val_if_fail(str != NULL, NULL); + + tmp1 = g_utf8_strdown(str, -1); + tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); + g_snprintf(buf, sizeof(buf), "%s", tmp2); + g_free(tmp2); + g_free(tmp1); + + return buf; +} + gchar * gaim_str_sub_away_formatters(const char *str, const char *name) {