From: Pekka Riikonen Date: Tue, 26 Mar 2002 22:03:18 +0000 (+0000) Subject: fixed nickname formatting bug. X-Git-Tag: silc.client.0.8.4~2 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=4bf2e4e8aca7496bc79ff421075d6c13933d5816 fixed nickname formatting bug. --- diff --git a/CHANGES b/CHANGES index be5c28e6..ee399f1c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,11 @@ +Wed Mar 27 00:07:11 EET 2002 Pekka Riikonen + + * Fixed a bug in the silc_client_nickname_format function that + handles the multiple same nickname formatting. Two clients + with same nickname caused problems after the first one left + and rejoined. It didn't format the nickname correctly. + Affected file is lib/silcclient/idlist.c. + Tue Mar 26 19:33:03 CET 2002 Pekka Riikonen * Don't change the topic if olod topic is same as new one. diff --git a/TODO b/TODO index bde8ca0b..8c389dbc 100644 --- a/TODO +++ b/TODO @@ -8,10 +8,6 @@ TODO/bugs in Irssi SILC client TODO/bugs In SILC Client Library ================================ - o Three clients, two with same nickname, one nick, other nick@host, - the nick quits and rejoins channel it becomes nick@host for the third - client. Both shows nick@host in the third client. This is a bug. - o The PRIVATE_MESSAGE_KEY packet is not handled (it is implemented though). This should be added and perhaps new client operation should be added to notify application that it was received and diff --git a/apps/silcer/intl/dcigettext.c b/apps/silcer/intl/dcigettext.c index 3c459300..b7627bf6 100644 --- a/apps/silcer/intl/dcigettext.c +++ b/apps/silcer/intl/dcigettext.c @@ -698,14 +698,14 @@ _nl_find_msg (domain_file, domainbinding, msgid, lengthp) if (domain->hash_size > 2 && domain->hash_tab != NULL) { /* Use the hashing table. */ - nls_SilcUInt32 len = strlen (msgid); - nls_SilcUInt32 hash_val = hash_string (msgid); - nls_SilcUInt32 idx = hash_val % domain->hash_size; - nls_SilcUInt32 incr = 1 + (hash_val % (domain->hash_size - 2)); + nls_uint32 len = strlen (msgid); + nls_uint32 hash_val = hash_string (msgid); + nls_uint32 idx = hash_val % domain->hash_size; + nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); while (1) { - nls_SilcUInt32 nstr = W (domain->must_swap, domain->hash_tab[idx]); + nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]); if (nstr == 0) /* Hash table entry is empty. */ diff --git a/apps/silcer/intl/gettext.h b/apps/silcer/intl/gettext.h index 0c9a102e..eb588907 100644 --- a/apps/silcer/intl/gettext.h +++ b/apps/silcer/intl/gettext.h @@ -53,13 +53,13 @@ #endif #if UINT_MAX == UINT_MAX_32_BITS -typedef unsigned nls_SilcUInt32; +typedef unsigned nls_uint32; #else # if USHRT_MAX == UINT_MAX_32_BITS -typedef unsigned short nls_SilcUInt32; +typedef unsigned short nls_uint32; # else # if ULONG_MAX == UINT_MAX_32_BITS -typedef unsigned long nls_SilcUInt32; +typedef unsigned long nls_uint32; # else /* The following line is intended to throw an error. Using #error is not portable enough. */ @@ -73,27 +73,27 @@ typedef unsigned long nls_SilcUInt32; struct mo_file_header { /* The magic number. */ - nls_SilcUInt32 magic; + nls_uint32 magic; /* The revision number of the file format. */ - nls_SilcUInt32 revision; + nls_uint32 revision; /* The number of strings pairs. */ - nls_SilcUInt32 nstrings; + nls_uint32 nstrings; /* Offset of table with start offsets of original strings. */ - nls_SilcUInt32 orig_tab_offset; + nls_uint32 orig_tab_offset; /* Offset of table with start offsets of translation strings. */ - nls_SilcUInt32 trans_tab_offset; + nls_uint32 trans_tab_offset; /* Size of hashing table. */ - nls_SilcUInt32 hash_tab_size; + nls_uint32 hash_tab_size; /* Offset of first hashing entry. */ - nls_SilcUInt32 hash_tab_offset; + nls_uint32 hash_tab_offset; }; struct string_desc { /* Length of addressed string. */ - nls_SilcUInt32 length; + nls_uint32 length; /* Offset of string in file. */ - nls_SilcUInt32 offset; + nls_uint32 offset; }; /* @@ begin of epilog @@ */ diff --git a/apps/silcer/intl/gettextP.h b/apps/silcer/intl/gettextP.h index bd54d7cb..ee8ca48e 100644 --- a/apps/silcer/intl/gettextP.h +++ b/apps/silcer/intl/gettextP.h @@ -31,7 +31,7 @@ #include "loadinfo.h" -#include "gettext.h" /* Get nls_SilcUInt32. */ +#include "gettext.h" /* Get nls_uint32. */ /* @@ end of prolog @@ */ @@ -62,9 +62,9 @@ # include # define SWAP(i) bswap_32 (i) #else -static inline nls_SilcUInt32 +static inline nls_uint32 SWAP (i) - nls_SilcUInt32 i; + nls_uint32 i; { return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); } @@ -123,11 +123,11 @@ struct loaded_domain int use_mmap; size_t mmap_size; int must_swap; - nls_SilcUInt32 nstrings; + nls_uint32 nstrings; struct string_desc *orig_tab; struct string_desc *trans_tab; - nls_SilcUInt32 hash_size; - nls_SilcUInt32 *hash_tab; + nls_uint32 hash_size; + nls_uint32 *hash_tab; int codeset_cntr; #ifdef _LIBC __gconv_t conv; diff --git a/apps/silcer/intl/loadmsgcat.c b/apps/silcer/intl/loadmsgcat.c index 61321d5f..d589243b 100644 --- a/apps/silcer/intl/loadmsgcat.c +++ b/apps/silcer/intl/loadmsgcat.c @@ -468,7 +468,7 @@ _nl_load_domain (domain_file, domainbinding) domain->trans_tab = (struct string_desc *) ((char *) data + W (domain->must_swap, data->trans_tab_offset)); domain->hash_size = W (domain->must_swap, data->hash_tab_size); - domain->hash_tab = (nls_SilcUInt32 *) + domain->hash_tab = (nls_uint32 *) ((char *) data + W (domain->must_swap, data->hash_tab_offset)); break; default: diff --git a/lib/silcclient/idlist.c b/lib/silcclient/idlist.c index 1bd02309..15455b69 100644 --- a/lib/silcclient/idlist.c +++ b/lib/silcclient/idlist.c @@ -999,6 +999,7 @@ void silc_client_nickname_format(SilcClient client, char *cp; char *newnick = NULL; int i, off = 0, len; + bool freebase; SilcClientEntry *clients; SilcUInt32 clients_count = 0; SilcClientEntry unformatted = NULL; @@ -1021,10 +1022,15 @@ void silc_client_nickname_format(SilcClient client, return; len = 0; - for (i = 0; i < clients_count; i++) + freebase = TRUE; + for (i = 0; i < clients_count; i++) { if (clients[i]->valid && clients[i] != client_entry) len++; - if (!len) + if (clients[i]->valid && clients[i] != client_entry && + !strcmp(clients[i]->nickname, client_entry->nickname)) + freebase = FALSE; + } + if (!len || freebase) return; cp = client->internal->params->nickname_format;