From dcd872bc45be6a8352bfd461f35099eaf21be75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 28 Apr 2024 13:07:08 +0200 Subject: [PATCH] core: fix recursive search of group in nicklist --- ChangeLog.adoc | 1 + src/gui/gui-nicklist.c | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 6cb202576..5a75a593c 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -49,6 +49,7 @@ New features:: Bug fixes:: + * core: fix recursive search of group in nicklist * core: use nick offline highlight color for prefix of action message when the nick is offline with a highlight * core: add missing hdata name "buffer" in hdata "hotlist" * core: fix reset to initial scroll position after search of text in buffer (issue #2093) diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index e696eb8f5..b1e1abe2d 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -193,7 +193,7 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer, const char *name, int skip_digits) { - struct t_gui_nick_group *ptr_group; + struct t_gui_nick_group *ptr_group, *ptr_group_found; const char *ptr_name; if (!buffer || !name) @@ -205,24 +205,24 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer, if (!from_group) return NULL; + ptr_name = (skip_digits) ? + gui_nicklist_get_group_start (from_group->name) : from_group->name; + if (strcmp (ptr_name, name) == 0) + return from_group; + if (from_group->children) { - ptr_group = gui_nicklist_search_group_internal (buffer, - from_group->children, - name, - skip_digits); - if (ptr_group) - return ptr_group; - } - - ptr_group = from_group; - while (ptr_group) - { - ptr_name = (skip_digits) ? - gui_nicklist_get_group_start (ptr_group->name) : ptr_group->name; - if (strcmp (ptr_name, name) == 0) - return ptr_group; - ptr_group = ptr_group->next_group; + for (ptr_group = from_group->children; ptr_group; + ptr_group = ptr_group->next_group) + { + ptr_group_found = gui_nicklist_search_group_internal ( + buffer, + ptr_group, + name, + skip_digits); + if (ptr_group_found) + return ptr_group_found; + } } /* group not found */