fixed nickname formatting bug.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 26 Mar 2002 22:03:18 +0000 (22:03 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 26 Mar 2002 22:03:18 +0000 (22:03 +0000)
CHANGES
TODO
apps/silcer/intl/dcigettext.c
apps/silcer/intl/gettext.h
apps/silcer/intl/gettextP.h
apps/silcer/intl/loadmsgcat.c
lib/silcclient/idlist.c

diff --git a/CHANGES b/CHANGES
index be5c28e67c74a62b7e136f74b7021d384dc5a6e6..ee399f1ca5c2dd00670f30e62ec78097fdb526cb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Wed Mar 27 00:07:11 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Don't change the topic if olod topic is same as new one.
diff --git a/TODO b/TODO
index bde8ca0bc2bf7fd3a79dd2a8b3289a9d55a9dfd1..8c389dbc5d9f0704bbdf8a5635dffc312a7bcab1 100644 (file)
--- 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
index 3c4593007480fb49669d2fc144fb6d43be8d5e85..b7627bf611cd01abe9da98f7a5d8aed68599690f 100644 (file)
@@ -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.  */
index 0c9a102e9db31577026dcb01ef0f85b6edbabe66..eb5889074a460c9a6b7724136b9e7d6208830729 100644 (file)
 #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 @@ */
index bd54d7cb3713f824cf76b39c1ffecd0efb97f799..ee8ca48e95a2a61956a34c87cdb0913ab434af10 100644 (file)
@@ -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 <byteswap.h>
 # 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;
index 61321d5fabdadd29d3e8d01e215da68ff4df761c..d589243b20ecd34da8fab8edbb5c4504ab65b1ae 100644 (file)
@@ -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:
index 1bd0230943fa9ea17cb3ecd7583437ff71e34170..15455b69d509f46cdb74b353692475eab9429d0b 100644 (file)
@@ -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;