Mercurial > pidgin
comparison libgaim/plugins/log_reader.c @ 15009:c6fd017c4121
[gaim-migrate @ 17790]
Part of SF Patch #1599432 from Leonardo Fernandes
"This patch ... solves a check for NULL that produced an error in the
debug console."
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Mon, 20 Nov 2006 05:33:32 +0000 |
| parents | 82d1a2fc6d25 |
| children | d24de6319f87 |
comparison
equal
deleted
inserted
replaced
| 15008:7589733ba1aa | 15009:c6fd017c4121 |
|---|---|
| 971 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { | 971 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { |
| 972 const char *friendly_name = gaim_connection_get_display_name(log->account->gc); | 972 const char *friendly_name = gaim_connection_get_display_name(log->account->gc); |
| 973 | 973 |
| 974 if (friendly_name != NULL) { | 974 if (friendly_name != NULL) { |
| 975 int friendly_name_length = strlen(friendly_name); | 975 int friendly_name_length = strlen(friendly_name); |
| 976 int alias_length = log->account->alias ? strlen(log->account->alias) : 0; | 976 const char *alias; |
| 977 int alias_length; | |
| 977 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); | 978 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); |
| 978 gboolean from_name_matches; | 979 gboolean from_name_matches; |
| 979 gboolean to_name_matches; | 980 gboolean to_name_matches; |
| 980 | 981 |
| 981 if (buddy && buddy->alias) | 982 if (buddy && buddy->alias) |
| 982 their_name = buddy->alias; | 983 their_name = buddy->alias; |
| 984 | |
| 985 if (log->account->alias) | |
| 986 { | |
| 987 alias = log->account->alias; | |
| 988 alias_length = strlen(alias); | |
| 989 } | |
| 990 else | |
| 991 { | |
| 992 alias = ""; | |
| 993 alias_length = 0; | |
| 994 } | |
| 983 | 995 |
| 984 /* Try to guess which user is me. | 996 /* Try to guess which user is me. |
| 985 * The first step is to determine if either of the names matches either my | 997 * The first step is to determine if either of the names matches either my |
| 986 * friendly name or alias. For this test, "match" is defined as: | 998 * friendly name or alias. For this test, "match" is defined as: |
| 987 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ | 999 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ |
| 988 */ | 1000 */ |
| 989 from_name_matches = (gaim_str_has_prefix(from_name, friendly_name) && | 1001 from_name_matches = (gaim_str_has_prefix(from_name, friendly_name) && |
| 990 !isalnum(*(from_name + friendly_name_length))) || | 1002 !isalnum(*(from_name + friendly_name_length))) || |
| 991 (gaim_str_has_prefix(from_name, log->account->alias) && | 1003 (gaim_str_has_prefix(from_name, alias) && |
| 992 !isalnum(*(from_name + alias_length))); | 1004 !isalnum(*(from_name + alias_length))); |
| 993 | 1005 |
| 994 to_name_matches = to_name != NULL && ( | 1006 to_name_matches = to_name != NULL && ( |
| 995 (gaim_str_has_prefix(to_name, friendly_name) && | 1007 (gaim_str_has_prefix(to_name, friendly_name) && |
| 996 !isalnum(*(to_name + friendly_name_length))) || | 1008 !isalnum(*(to_name + friendly_name_length))) || |
| 997 (gaim_str_has_prefix(to_name, log->account->alias) && | 1009 (gaim_str_has_prefix(to_name, alias) && |
| 998 !isalnum(*(to_name + alias_length)))); | 1010 !isalnum(*(to_name + alias_length)))); |
| 999 | 1011 |
| 1000 if (from_name_matches) { | 1012 if (from_name_matches) { |
| 1001 if (!to_name_matches) { | 1013 if (!to_name_matches) { |
| 1002 name_guessed = NAME_GUESS_ME; | 1014 name_guessed = NAME_GUESS_ME; |
