diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-08-20 21:20:33 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-08-20 21:20:33 +0200 |
commit | 608ec9f4834630a2a73a8d0292883cf6dd837622 (patch) | |
tree | 039291c39886fdc81fb8aa0c7c97ff03c66fda95 | |
parent | 21dca71ee06d8fe4897f1348ce10ac483d8bcc5c (diff) | |
download | weechat-608ec9f4834630a2a73a8d0292883cf6dd837622.zip |
core: add values djb2_32 and sum_32 for option weechat.look.nick_color_hash (issue #1394)
-rw-r--r-- | ChangeLog.adoc | 2 | ||||
-rw-r--r-- | ReleaseNotes.adoc | 22 | ||||
-rw-r--r-- | doc/de/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | doc/en/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | doc/fr/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | doc/it/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | doc/ja/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | doc/pl/autogen/user/weechat_options.adoc | 4 | ||||
-rw-r--r-- | po/cs.po | 7 | ||||
-rw-r--r-- | po/de.po | 8 | ||||
-rw-r--r-- | po/es.po | 7 | ||||
-rw-r--r-- | po/fr.po | 14 | ||||
-rw-r--r-- | po/hu.po | 7 | ||||
-rw-r--r-- | po/it.po | 7 | ||||
-rw-r--r-- | po/ja.po | 8 | ||||
-rw-r--r-- | po/pl.po | 8 | ||||
-rw-r--r-- | po/pt.po | 8 | ||||
-rw-r--r-- | po/pt_BR.po | 7 | ||||
-rw-r--r-- | po/ru.po | 7 | ||||
-rw-r--r-- | po/tr.po | 7 | ||||
-rw-r--r-- | po/weechat.pot | 7 | ||||
-rw-r--r-- | src/core/wee-config.c | 6 | ||||
-rw-r--r-- | src/core/wee-config.h | 2 | ||||
-rw-r--r-- | src/gui/gui-nick.c | 22 | ||||
-rw-r--r-- | tests/unit/gui/test-gui-nick.cpp | 44 |
25 files changed, 167 insertions, 57 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 4c759d615..44d4e34ce 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -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 diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index afc42f534..d0be05646 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -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 diff --git a/doc/de/autogen/user/weechat_options.adoc b/doc/de/autogen/user/weechat_options.adoc index 372ec4a62..84bfca609 100644 --- a/doc/de/autogen/user/weechat_options.adoc +++ b/doc/de/autogen/user/weechat_options.adoc @@ -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* diff --git a/doc/en/autogen/user/weechat_options.adoc b/doc/en/autogen/user/weechat_options.adoc index 644ac5d54..499418035 100644 --- a/doc/en/autogen/user/weechat_options.adoc +++ b/doc/en/autogen/user/weechat_options.adoc @@ -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* diff --git a/doc/fr/autogen/user/weechat_options.adoc b/doc/fr/autogen/user/weechat_options.adoc index 85e20e83b..6de8c1b33 100644 --- a/doc/fr/autogen/user/weechat_options.adoc +++ b/doc/fr/autogen/user/weechat_options.adoc @@ -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* diff --git a/doc/it/autogen/user/weechat_options.adoc b/doc/it/autogen/user/weechat_options.adoc index 386e486ca..a1878b9b2 100644 --- a/doc/it/autogen/user/weechat_options.adoc +++ b/doc/it/autogen/user/weechat_options.adoc @@ -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* diff --git a/doc/ja/autogen/user/weechat_options.adoc b/doc/ja/autogen/user/weechat_options.adoc index 62f519dee..5075e4d35 100644 --- a/doc/ja/autogen/user/weechat_options.adoc +++ b/doc/ja/autogen/user/weechat_options.adoc @@ -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* diff --git a/doc/pl/autogen/user/weechat_options.adoc b/doc/pl/autogen/user/weechat_options.adoc index 38ff119f2..4e7373e70 100644 --- a/doc/pl/autogen/user/weechat_options.adoc +++ b/doc/pl/autogen/user/weechat_options.adoc @@ -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* @@ -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 @@ -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 " @@ -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 @@ -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 " @@ -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 "" @@ -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 @@ -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 = 文字の総和" @@ -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 = " @@ -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 " diff --git a/po/pt_BR.po b/po/pt_BR.po index 0471fde26..0b28f0efd 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -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 @@ -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 "" @@ -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 "" diff --git a/po/weechat.pot b/po/weechat.pot index 03038c16e..adb832659 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -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 "" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index d09ed7773..cfde1bdb3 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -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, diff --git a/src/core/wee-config.h b/src/core/wee-config.h index d3fc51694..8cf1a61bf 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -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 diff --git a/src/gui/gui-nick.c b/src/gui/gui-nick.c index e2685dc5e..9a575cb2a 100644 --- a/src/gui/gui-nick.c +++ b/src/gui/gui-nick.c @@ -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); diff --git a/tests/unit/gui/test-gui-nick.cpp b/tests/unit/gui/test-gui-nick.cpp index 198fecd61..fbf8cf425 100644 --- a/tests/unit/gui/test-gui-nick.cpp +++ b/tests/unit/gui/test-gui-nick.cpp @@ -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); |