core: add values djb2_32 and sum_32 for option weechat.look.nick_color_hash (issue #1394)

v2.8-utf8proc
Sébastien Helleu 2019-08-20 21:20:33 +02:00
parent 21dca71ee0
commit 608ec9f483
25 changed files with 167 additions and 57 deletions

View File

@ -31,7 +31,7 @@ New features::
Bug fixes::
* core: use fixed-width integer for computing nick and hashtable DJB2 key hashes (issue #1394)
* core: use fixed-width integer for computing nick and hashtable DJB2 key hashes, add values "djb2_32" and "sum_32" for option weechat.look.nick_color_hash (issue #1394)
* core: create or update option weechat.notify.xxx when function buffer_set is called with "notify" property (issue #1390)
* core: fix memory leak in case of error when building content of bar item for display (issue #1384)
* core: send command line parameter to plugins only if the name starts with the plugin name followed by a colon

View File

@ -20,6 +20,28 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog]
[[v2.6]]
== Version 2.6 (under dev)
[[v2.6_nick_colors]]
=== Nick colors
The function to compute the colors based on the nick letters has been fixed
(now the function uses only a 64-bit integer even if the underlying architecture
is 32-bit).
If you're running WeeChat on a 32-bit architecture and want to keep same colors
as the previous releases, you can use one of the two new hash values.
If you were using "djb2", you can switch to "djb2_32":
----
/set weechat.look.nick_color_hash djb2_32
----
If you were using "sum", you can switch to "sum_32":
----
/set weechat.look.nick_color_hash sum_32
----
[[v2.6_python3_default]]
=== Python 3 by default

View File

@ -921,9 +921,9 @@
** Standardwert: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** Beschreibung: pass:none[Gibt an welcher Hash-Algorithmus zur Farbauswahl für Nicks genutzt werden soll: djb2 = Variante des djb2 (Position der Buchstaben innerhalb des Nicks werden berücksichtigt: Anagramme eines Nick erhalten eine andere Farbe), sum = hier ist nur die Anzahl der Buchstaben maßgeblich]
** Beschreibung: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer]
** Typ: integer
** Werte: djb2, sum
** Werte: djb2, sum, djb2_32, sum_32
** Standardwert: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -921,9 +921,9 @@
** default value: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** description: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), sum = sum of letters]
** description: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer]
** type: integer
** values: djb2, sum
** values: djb2, sum, djb2_32, sum_32
** default value: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -921,9 +921,9 @@
** valeur par défaut: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** description: pass:none[algorithme de hash utilisé pour trouver la couleur du pseudo : djb2 = variante de djb2 (la position des lettres compte : les anagrammes d'un pseudo ont une couleur différente), sum = somme des lettres]
** description: pass:none[algorithme de hash utilisé pour trouver la couleur du pseudo : djb2 = variante de djb2 (la position des lettres compte : les anagrammes d'un pseudo ont une couleur différente), sum = somme des lettres, djb2_32 = variante de djb2 en utilisant un entier sur 32 bits au lieu de 64 bits, sum_32 = somme des lettres en utilisant un entier sur 32 bits au lieu de 64 bits]
** type: entier
** valeurs: djb2, sum
** valeurs: djb2, sum, djb2_32, sum_32
** valeur par défaut: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -921,9 +921,9 @@
** valore predefinito: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** descrizione: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), sum = sum of letters]
** descrizione: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer]
** tipo: intero
** valori: djb2, sum
** valori: djb2, sum, djb2_32, sum_32
** valore predefinito: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -921,9 +921,9 @@
** デフォルト値: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** 説明: pass:none[ニックネームに対する色を見つけるハッシュアルゴリズム: djb2 = djb2 (文字の位置が重要: ニックネームに同じ色が使われにくくなる) の亜種、sum = 文字の総和]
** 説明: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer]
** タイプ: 整数
** 値: djb2, sum
** 値: djb2, sum, djb2_32, sum_32
** デフォルト値: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -921,9 +921,9 @@
** domyślna wartość: `+""+`
* [[option_weechat.look.nick_color_hash]] *weechat.look.nick_color_hash*
** opis: pass:none[algorytm haszujący używany do znalezienia koloru dla nicka: djb2 = odmiana djb2 (pozycja liter ma znaczenie: anagramy nicka mają różne kolory), sum = suma liter]
** opis: pass:none[hash algorithm used to find the color for a nick: djb2 = variant of djb2 (position of letters matters: anagrams of a nick have different color), djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer]
** typ: liczba
** wartości: djb2, sum
** wartości: djb2, sum, djb2_32, sum_32
** domyślna wartość: `+djb2+`
* [[option_weechat.look.nick_color_stop_chars]] *weechat.look.nick_color_stop_chars*

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3431,8 +3431,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
#, fuzzy

View File

@ -24,7 +24,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-08-10 16:57+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@ -4148,10 +4148,12 @@ msgstr ""
"möglich die Nicks, für diese Einstellung, ausschließlich in Kleinschrift "
"aufzuführen"
#, fuzzy
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
"Gibt an welcher Hash-Algorithmus zur Farbauswahl für Nicks genutzt werden "
"soll: djb2 = Variante des djb2 (Position der Buchstaben innerhalb des Nicks "

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3585,8 +3585,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
#, fuzzy

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"PO-Revision-Date: 2019-07-29 22:48+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-08-20 20:17+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -4033,12 +4033,16 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
"algorithme de hash utilisé pour trouver la couleur du pseudo : djb2 = "
"variante de djb2 (la position des lettres compte : les anagrammes d'un "
"pseudo ont une couleur différente), sum = somme des lettres"
"pseudo ont une couleur différente), sum = somme des lettres, djb2_32 = "
"variante de djb2 en utilisant un entier sur 32 bits au lieu de 64 bits, "
"sum_32 = somme des lettres en utilisant un entier sur 32 bits au lieu de 64 "
"bits"
msgid ""
"chars used to stop in nick when computing color with letters of nick (at "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2999,8 +2999,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
msgid ""

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3677,8 +3677,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
#, fuzzy

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-06-22 08:40+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@ -3889,10 +3889,12 @@ msgstr ""
"われます。このため、このオプションのニックネーム部分を小文字だけで書く事もで"
"きます"
#, fuzzy
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
"ニックネームに対する色を見つけるハッシュアルゴリズム: djb2 = djb2 (文字の位置"
"が重要: ニックネームに同じ色が使われにくくなる) の亜種、sum = 文字の総和"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-06-22 08:40+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <kde-i18n-doc@kde.org>\n"
@ -3966,10 +3966,12 @@ msgstr ""
"dopasowania porównania dokładnego, następnie z małych liter, jest więc "
"możliwe używanie tylko małych liter w tej opcji"
#, fuzzy
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
"algorytm haszujący używany do znalezienia koloru dla nicka: djb2 = odmiana "
"djb2 (pozycja liter ma znaczenie: anagramy nicka mają różne kolory), sum = "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@ -3906,10 +3906,12 @@ msgstr ""
"cor2\"); procura-se pelo nick exato e pelo nick em minúsculas, por isso pode "
"indicá-los só em minúsculas nesta opção"
#, fuzzy
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
"algoritmo de hash usado para encontra a cor para um nick: djb2 = variante de "
"djb2 (a posição das letras importa: anagramas de um nick tem cores "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3600,8 +3600,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
#, fuzzy

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3031,8 +3031,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
msgid ""

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2736,8 +2736,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
msgid ""

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-07-29 09:38+0200\n"
"POT-Creation-Date: 2019-08-20 16:13+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2731,8 +2731,9 @@ msgstr ""
msgid ""
"hash algorithm used to find the color for a nick: djb2 = variant of djb2 "
"(position of letters matters: anagrams of a nick have different color), sum "
"= sum of letters"
"(position of letters matters: anagrams of a nick have different color), "
"djb2_32 = variant of djb2 using 32-bit instead of 64-bit integer, sum = sum "
"of letters, sum_32 = sum of letters using 32-bit instead of 64-bit integer"
msgstr ""
msgid ""

View File

@ -3240,8 +3240,10 @@ config_weechat_init_options ()
"nick_color_hash", "integer",
N_("hash algorithm used to find the color for a nick: djb2 = variant "
"of djb2 (position of letters matters: anagrams of a nick have "
"different color), sum = sum of letters"),
"djb2|sum", 0, 0, "djb2", NULL, 0,
"different color), djb2_32 = variant of djb2 using 32-bit instead "
"of 64-bit integer, sum = sum of letters, sum_32 = sum of letters "
"using 32-bit instead of 64-bit integer"),
"djb2|sum|djb2_32|sum_32", 0, 0, "djb2", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_nick_color_stop_chars = config_file_new_option (
weechat_config_file, ptr_section,

View File

@ -58,6 +58,8 @@ enum t_config_look_nick_color_hash
{
CONFIG_LOOK_NICK_COLOR_HASH_DJB2 = 0,
CONFIG_LOOK_NICK_COLOR_HASH_SUM,
CONFIG_LOOK_NICK_COLOR_HASH_DJB2_32,
CONFIG_LOOK_NICK_COLOR_HASH_SUM_32,
};
enum t_config_look_prefix_align

View File

@ -47,6 +47,7 @@ int
gui_nick_hash_color (const char *nickname)
{
uint64_t color;
uint32_t color_32;
const char *ptr_nick;
if (!nickname || !nickname[0])
@ -81,6 +82,27 @@ gui_nick_hash_color (const char *nickname)
ptr_nick = utf8_next_char (ptr_nick);
}
break;
case CONFIG_LOOK_NICK_COLOR_HASH_DJB2_32:
/* variant of djb2 hash (using 32-bit integer) */
color_32 = 5381;
while (ptr_nick && ptr_nick[0])
{
color_32 ^= (color_32 << 5) + (color_32 >> 2)
+ utf8_char_int (ptr_nick);
ptr_nick = utf8_next_char (ptr_nick);
}
color = color_32;
break;
case CONFIG_LOOK_NICK_COLOR_HASH_SUM_32:
/* sum of letters (using 32-bit integer) */
color_32 = 0;
while (ptr_nick && ptr_nick[0])
{
color_32 += utf8_char_int (ptr_nick);
ptr_nick = utf8_next_char (ptr_nick);
}
color = color_32;
break;
}
return (color % config_num_nick_colors);

View File

@ -58,22 +58,64 @@ TEST(GuiNick, NickHashColor)
{
config_file_option_set (config_color_chat_nick_colors, NICK_COLORS, 0);
config_file_option_set (config_look_nick_color_hash, "dbj2", 0);
/* test hash: djb2 */
config_file_option_set (config_look_nick_color_hash, "djb2", 0);
LONGS_EQUAL(0, gui_nick_hash_color (NULL));
LONGS_EQUAL(0, gui_nick_hash_color (""));
LONGS_EQUAL(71, gui_nick_hash_color ("a"));
LONGS_EQUAL(108, gui_nick_hash_color ("abc"));
LONGS_EQUAL(146, gui_nick_hash_color ("abcdef"));
LONGS_EQUAL(73, gui_nick_hash_color ("abcdefghi"));
LONGS_EQUAL(170, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(124, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(94, gui_nick_hash_color ("zzzzzz"));
/* test hash: sum */
config_file_option_set (config_look_nick_color_hash, "sum", 0);
LONGS_EQUAL(0, gui_nick_hash_color (NULL));
LONGS_EQUAL(0, gui_nick_hash_color (""));
LONGS_EQUAL(97, gui_nick_hash_color ("a"));
LONGS_EQUAL(38, gui_nick_hash_color ("abc"));
LONGS_EQUAL(85, gui_nick_hash_color ("abcdef"));
LONGS_EQUAL(141, gui_nick_hash_color ("abcdefghi"));
LONGS_EQUAL(31, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(62, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(220, gui_nick_hash_color ("zzzzzz"));
/* test hash: djb2_32 */
config_file_option_set (config_look_nick_color_hash, "djb2_32", 0);
LONGS_EQUAL(0, gui_nick_hash_color (NULL));
LONGS_EQUAL(0, gui_nick_hash_color (""));
LONGS_EQUAL(71, gui_nick_hash_color ("a"));
LONGS_EQUAL(108, gui_nick_hash_color ("abc"));
LONGS_EQUAL(146, gui_nick_hash_color ("abcdef"));
LONGS_EQUAL(73, gui_nick_hash_color ("abcdefghi"));
LONGS_EQUAL(209, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(116, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(94, gui_nick_hash_color ("zzzzzz"));
/* test hash: sum_32 */
config_file_option_set (config_look_nick_color_hash, "sum_32", 0);
LONGS_EQUAL(0, gui_nick_hash_color (NULL));
LONGS_EQUAL(0, gui_nick_hash_color (""));
LONGS_EQUAL(97, gui_nick_hash_color ("a"));
LONGS_EQUAL(38, gui_nick_hash_color ("abc"));
LONGS_EQUAL(85, gui_nick_hash_color ("abcdef"));
LONGS_EQUAL(141, gui_nick_hash_color ("abcdefghi"));
LONGS_EQUAL(31, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(62, gui_nick_hash_color ("abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(220, gui_nick_hash_color ("zzzzzz"));
config_file_option_reset (config_color_chat_nick_colors, 0);