comparison 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
comparison
equal deleted inserted replaced
7260:49839c4cbb1c 7261:1930e3d00ecd
1248 1248
1249 /************************************************************************** 1249 /**************************************************************************
1250 * String Functions 1250 * String Functions
1251 **************************************************************************/ 1251 **************************************************************************/
1252 const char * 1252 const char *
1253 gaim_normalize(const char *s) 1253 gaim_normalize(const GaimAccount *account, const char *s)
1254 { 1254 {
1255 static char buf[BUF_LEN]; 1255 GaimPlugin *prpl = NULL;
1256 char *tmp; 1256 GaimPluginProtocolInfo *prpl_info = NULL;
1257 int i, j; 1257
1258 1258 if(account)
1259 g_return_val_if_fail(s != NULL, NULL); 1259 prpl = gaim_find_prpl(gaim_account_get_protocol(account));
1260 1260
1261 strncpy(buf, s, BUF_LEN); 1261 if(prpl)
1262 for (i=0, j=0; buf[j]; i++, j++) { 1262 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
1263 while (buf[j] == ' ') 1263
1264 j++; 1264 if(prpl_info && prpl_info->normalize) {
1265 buf[i] = buf[j]; 1265 return prpl_info->normalize(account, s);
1266 } 1266 } else {
1267 buf[i] = '\0'; 1267 static char buf[BUF_LEN];
1268 1268 char *tmp;
1269 tmp = g_utf8_strdown(buf, -1); 1269 int i, j;
1270 g_snprintf(buf, sizeof(buf), "%s", tmp); 1270
1271 g_free(tmp); 1271 g_return_val_if_fail(s != NULL, NULL);
1272 tmp = g_utf8_normalize(buf, -1, G_NORMALIZE_DEFAULT); 1272
1273 g_snprintf(buf, sizeof(buf), "%s", tmp); 1273 strncpy(buf, s, BUF_LEN);
1274 g_free(tmp); 1274 for (i=0, j=0; buf[j]; i++, j++) {
1275 1275 while (buf[j] == ' ')
1276 return buf; 1276 j++;
1277 buf[i] = buf[j];
1278 }
1279 buf[i] = '\0';
1280
1281 tmp = g_utf8_strdown(buf, -1);
1282 g_snprintf(buf, sizeof(buf), "%s", tmp);
1283 g_free(tmp);
1284 tmp = g_utf8_normalize(buf, -1, G_NORMALIZE_DEFAULT);
1285 g_snprintf(buf, sizeof(buf), "%s", tmp);
1286 g_free(tmp);
1287
1288 return buf;
1289 }
1277 } 1290 }
1278 1291
1279 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date, 1292 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date,
1280 or time */ 1293 or time */
1281 const char * 1294 const char *