comparison src/conversation.c @ 4793:677d3cb193a1

[gaim-migrate @ 5113] this removes all the remaining deprecated glib, gdk, gdk-pixbuf, and gtk function calls. Hopefully I didn't break anything. Most of this is due to the deprecation of g_strcasecmp and g_strncasecmp. Two functions I never thought would be deprecated, but apparently they're no good at comparing utf8 text. g_ascii_str{,n}casecmp is OK when you're sure that it's ASCII. Otherwise, we're supposed to use g_utf8_collate(), except that it is case sensitive. Since glib doesn't currently have a case-insensitive one, I wrote one. If you need to compare utf8 text, you can use gaim_utf8_strcasecmp(). I have to go do dishes now. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 16 Mar 2003 00:01:49 +0000
parents 283fb289c510
children 1c371e4244d6
comparison
equal deleted inserted replaced
4792:9212d1c5b7dc 4793:677d3cb193a1
86 find_nick(struct gaim_connection *gc, const char *message) 86 find_nick(struct gaim_connection *gc, const char *message)
87 { 87 {
88 char *msg, *who, *p; 88 char *msg, *who, *p;
89 int n; 89 int n;
90 90
91 msg = g_strdup(message); 91 msg = g_utf8_strdown(message, -1);
92 g_strdown(msg); 92
93 93 who = g_utf8_strdown(gc->username, -1);
94 who = g_strdup(gc->username);
95 g_strdown(who);
96 n = strlen(who); 94 n = strlen(who);
97 95
98 if ((p = strstr(msg, who)) != NULL) { 96 if ((p = strstr(msg, who)) != NULL) {
99 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) { 97 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) {
100 g_free(who); 98 g_free(who);
104 } 102 }
105 } 103 }
106 104
107 g_free(who); 105 g_free(who);
108 106
109 if (!g_strcasecmp(gc->username, gc->displayname)) { 107 if (!gaim_utf8_strcasecmp(gc->username, gc->displayname)) {
110 g_free(msg); 108 g_free(msg);
111 109
112 return FALSE; 110 return FALSE;
113 } 111 }
114 112
115 who = g_strdup(gc->displayname); 113 who = g_utf8_strdown(gc->displayname, -1);
116 g_strdown(who);
117 n = strlen(who); 114 n = strlen(who);
118 115
119 if (n > 0 && (p = strstr(msg, who)) != NULL) { 116 if (n > 0 && (p = strstr(msg, who)) != NULL) {
120 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) { 117 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) {
121 g_free(who); 118 g_free(who);
1340 cuser = g_strdup(normalize(name)); 1337 cuser = g_strdup(normalize(name));
1341 1338
1342 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { 1339 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
1343 c = (struct gaim_conversation *)cnv->data; 1340 c = (struct gaim_conversation *)cnv->data;
1344 1341
1345 if (!g_strcasecmp(cuser, normalize(gaim_conversation_get_name(c)))) 1342 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))))
1346 break; 1343 break;
1347 1344
1348 c = NULL; 1345 c = NULL;
1349 } 1346 }
1350 1347
1366 cuser = g_strdup(normalize(name)); 1363 cuser = g_strdup(normalize(name));
1367 1364
1368 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { 1365 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
1369 c = (struct gaim_conversation *)cnv->data; 1366 c = (struct gaim_conversation *)cnv->data;
1370 1367
1371 if (!g_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) && 1368 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) &&
1372 account == gaim_conversation_get_account(c)) { 1369 account == gaim_conversation_get_account(c)) {
1373 1370
1374 break; 1371 break;
1375 } 1372 }
1376 1373
1778 ignored != NULL; 1775 ignored != NULL;
1779 ignored = ignored->next) { 1776 ignored = ignored->next) {
1780 1777
1781 const char *ign = (const char *)ignored->data; 1778 const char *ign = (const char *)ignored->data;
1782 1779
1783 if (!g_strcasecmp(user, ign) || 1780 if (!gaim_utf8_strcasecmp(user, ign) ||
1784 ((*ign == '+' || *ign == '%') && !g_strcasecmp(user, ign + 1))) 1781 ((*ign == '+' || *ign == '%') && !gaim_utf8_strcasecmp(user, ign + 1)))
1785 return ign; 1782 return ign;
1786 1783
1787 if (*ign == '@') { 1784 if (*ign == '@') {
1788 ign++; 1785 ign++;
1789 1786
1790 if ((*ign == '+' && !g_strcasecmp(user, ign + 1)) || 1787 if ((*ign == '+' && !gaim_utf8_strcasecmp(user, ign + 1)) ||
1791 (*ign != '+' && !g_strcasecmp(user, ign))) 1788 (*ign != '+' && !gaim_utf8_strcasecmp(user, ign)))
1792 return ign; 1789 return ign;
1793 } 1790 }
1794 } 1791 }
1795 1792
1796 return NULL; 1793 return NULL;
1872 if (!(flags & WFLAG_WHISPER)) { 1869 if (!(flags & WFLAG_WHISPER)) {
1873 char *str; 1870 char *str;
1874 1871
1875 str = g_strdup(normalize(who)); 1872 str = g_strdup(normalize(who));
1876 1873
1877 if (!g_strcasecmp(str, normalize(gc->username)) || 1874 if (!gaim_utf8_strcasecmp(str, normalize(gc->username)) ||
1878 !g_strcasecmp(str, normalize(gc->displayname))) { 1875 !gaim_utf8_strcasecmp(str, normalize(gc->displayname))) {
1879 1876
1880 flags |= WFLAG_SEND; 1877 flags |= WFLAG_SEND;
1881 } 1878 }
1882 else { 1879 else {
1883 flags |= WFLAG_RECV; 1880 flags |= WFLAG_RECV;
1966 1963
1967 for (names = gaim_chat_get_users(chat); 1964 for (names = gaim_chat_get_users(chat);
1968 names != NULL; 1965 names != NULL;
1969 names = names->next) { 1966 names = names->next) {
1970 1967
1971 if (!g_strcasecmp((char *)names->data, old_user)) { 1968 if (!gaim_utf8_strcasecmp((char *)names->data, old_user)) {
1972 gaim_chat_set_users(chat, 1969 gaim_chat_set_users(chat,
1973 g_list_remove(gaim_chat_get_users(chat), names->data)); 1970 g_list_remove(gaim_chat_get_users(chat), names->data));
1974 break; 1971 break;
1975 } 1972 }
1976 } 1973 }
2013 2010
2014 for (names = gaim_chat_get_users(chat); 2011 for (names = gaim_chat_get_users(chat);
2015 names != NULL; 2012 names != NULL;
2016 names = names->next) { 2013 names = names->next) {
2017 2014
2018 if (!g_strcasecmp((char *)names->data, user)) { 2015 if (!gaim_utf8_strcasecmp((char *)names->data, user)) {
2019 gaim_chat_set_users(chat, 2016 gaim_chat_set_users(chat,
2020 g_list_remove(gaim_chat_get_users(chat), names->data)); 2017 g_list_remove(gaim_chat_get_users(chat), names->data));
2021 break; 2018 break;
2022 } 2019 }
2023 } 2020 }