diff options
-rw-r--r-- | src/core/wee-command.c | 5 | ||||
-rw-r--r-- | src/core/wee-secure-buffer.c | 2 | ||||
-rw-r--r-- | src/core/wee-upgrade.c | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 3 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 8 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 3 | ||||
-rw-r--r-- | src/plugins/plugin.c | 2 | ||||
-rw-r--r-- | tests/unit/gui/test-gui-buffer.cpp | 46 |
8 files changed, 35 insertions, 37 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 3f4f631f2..cc96fd9b5 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -706,7 +706,7 @@ COMMAND_CALLBACK(buffer) argv[arg_name]); return WEECHAT_RC_OK; } - ptr_buffer = gui_buffer_search_by_name (PLUGIN_CORE, argv[arg_name]); + ptr_buffer = gui_buffer_search (PLUGIN_CORE, argv[arg_name]); if (!ptr_buffer) { ptr_buffer = gui_buffer_new_user ( @@ -5351,8 +5351,7 @@ COMMAND_CALLBACK(print) argv[arg_new_buffer_name]); return WEECHAT_RC_OK; } - ptr_buffer = gui_buffer_search_by_name (PLUGIN_CORE, - argv[arg_new_buffer_name]); + ptr_buffer = gui_buffer_search (PLUGIN_CORE, argv[arg_new_buffer_name]); if (!ptr_buffer) { ptr_buffer = gui_buffer_new_user ( diff --git a/src/core/wee-secure-buffer.c b/src/core/wee-secure-buffer.c index a9ee39586..ac3cedb13 100644 --- a/src/core/wee-secure-buffer.c +++ b/src/core/wee-secure-buffer.c @@ -201,7 +201,7 @@ secure_buffer_assign () { if (!secure_buffer) { - secure_buffer = gui_buffer_search_by_name (NULL, SECURE_BUFFER_NAME); + secure_buffer = gui_buffer_search (NULL, SECURE_BUFFER_NAME); if (secure_buffer) { secure_buffer->input_callback = &secure_buffer_input_cb; diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c index 05c1b9a50..497065e2f 100644 --- a/src/core/wee-upgrade.c +++ b/src/core/wee-upgrade.c @@ -779,8 +779,7 @@ upgrade_weechat_read_hotlist (struct t_infolist *infolist) buffer_name = infolist_string (infolist, "buffer_name"); if (plugin_name && buffer_name) { - ptr_buffer = gui_buffer_search_by_name (plugin_name, - buffer_name); + ptr_buffer = gui_buffer_search (plugin_name, buffer_name); if (ptr_buffer) { buf = infolist_buffer (infolist, "creation_time", &size); diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 8bbcfe048..ee455ad9b 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -1297,8 +1297,7 @@ gui_color_buffer_assign () { if (!gui_color_buffer) { - gui_color_buffer = gui_buffer_search_by_name (NULL, - GUI_COLOR_BUFFER_NAME); + gui_color_buffer = gui_buffer_search (NULL, GUI_COLOR_BUFFER_NAME); if (gui_color_buffer) { gui_color_buffer->input_callback = &gui_color_buffer_input_cb; diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 8ad9949a0..bfade9dc9 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -806,7 +806,7 @@ gui_buffer_new_props_with_id (long long id, if (!name || !name[0]) return NULL; - if (gui_buffer_search_by_name (plugin_get_name (plugin), name)) + if (gui_buffer_search (plugin_get_name (plugin), name)) { gui_chat_printf (NULL, _("%sA buffer with same name (%s) already exists"), @@ -2901,11 +2901,13 @@ gui_buffer_search_by_full_name (const char *full_name) } /* - * Searches for a buffer by plugin and name. + * Searches for a buffer by plugin and name, full name or id. + * + * If plugin is "==", the name is used to search by full name. */ struct t_gui_buffer * -gui_buffer_search_by_name (const char *plugin, const char *name) +gui_buffer_search (const char *plugin, const char *name) { struct t_gui_buffer *ptr_buffer; int plugin_match, plugin_case_sensitive, name_case_sensitive; diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index b8a20e301..3f540d442 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -392,8 +392,7 @@ extern void gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer, extern int gui_buffer_is_main (const char *plugin_name, const char *name); extern struct t_gui_buffer *gui_buffer_search_main (); extern struct t_gui_buffer *gui_buffer_search_by_full_name (const char *full_name); -extern struct t_gui_buffer *gui_buffer_search_by_name (const char *plugin, - const char *name); +extern struct t_gui_buffer *gui_buffer_search (const char *plugin, const char *name); extern struct t_gui_buffer *gui_buffer_search_by_partial_name (const char *plugin, const char *name); extern struct t_gui_buffer *gui_buffer_search_by_number (int number); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index aa0792d8e..314264c94 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -831,7 +831,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->buffer_new = &gui_buffer_new; new_plugin->buffer_new_props = &gui_buffer_new_props; - new_plugin->buffer_search = &gui_buffer_search_by_name; + new_plugin->buffer_search = &gui_buffer_search; new_plugin->buffer_search_main = &gui_buffer_search_main; new_plugin->buffer_clear = &gui_buffer_clear; new_plugin->buffer_close = &gui_buffer_close; diff --git a/tests/unit/gui/test-gui-buffer.cpp b/tests/unit/gui/test-gui-buffer.cpp index b61dc1352..5093a14b3 100644 --- a/tests/unit/gui/test-gui-buffer.cpp +++ b/tests/unit/gui/test-gui-buffer.cpp @@ -1346,10 +1346,10 @@ TEST(GuiBuffer, SearchByFullName) /* * Tests functions: - * gui_buffer_search_by_name + * gui_buffer_search */ -TEST(GuiBuffer, SearchByName) +TEST(GuiBuffer, Search) { struct t_gui_buffer *buffer; @@ -1358,32 +1358,32 @@ TEST(GuiBuffer, SearchByName) NULL, NULL, NULL); CHECK(buffer); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name (NULL, NULL)); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name (NULL, "")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("", NULL)); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("", "")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("==", NULL)); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("==", "")); - POINTERS_EQUAL(NULL, gui_buffer_search_by_name ("==", "(?i)")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search (NULL, NULL)); + POINTERS_EQUAL(gui_buffers, gui_buffer_search (NULL, "")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("", NULL)); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("", "")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("==", NULL)); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("==", "")); + POINTERS_EQUAL(NULL, gui_buffer_search ("==", "(?i)")); - POINTERS_EQUAL(NULL, gui_buffer_search_by_name ("==", "xxx")); - POINTERS_EQUAL(NULL, gui_buffer_search_by_name ("==", "weechat")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("==", "core.weechat")); - POINTERS_EQUAL(buffer, gui_buffer_search_by_name ("==", "core." TEST_BUFFER_NAME)); + POINTERS_EQUAL(NULL, gui_buffer_search ("==", "xxx")); + POINTERS_EQUAL(NULL, gui_buffer_search ("==", "weechat")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("==", "core.weechat")); + POINTERS_EQUAL(buffer, gui_buffer_search ("==", "core." TEST_BUFFER_NAME)); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("", "")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("", "(?i)")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("", "")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("", "(?i)")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("core", "weechat")); - POINTERS_EQUAL(buffer, gui_buffer_search_by_name ("core", TEST_BUFFER_NAME)); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("core", "weechat")); + POINTERS_EQUAL(buffer, gui_buffer_search ("core", TEST_BUFFER_NAME)); - POINTERS_EQUAL(NULL, gui_buffer_search_by_name ("CORE", "WEECHAT")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("(?i)CORE", "weechat")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("core", "(?i)WEECHAT")); - POINTERS_EQUAL(gui_buffers, gui_buffer_search_by_name ("(?i)CORE", "(?i)WEECHAT")); + POINTERS_EQUAL(NULL, gui_buffer_search ("CORE", "WEECHAT")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("(?i)CORE", "weechat")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("core", "(?i)WEECHAT")); + POINTERS_EQUAL(gui_buffers, gui_buffer_search ("(?i)CORE", "(?i)WEECHAT")); - POINTERS_EQUAL(NULL, gui_buffer_search_by_name ("CORE", TEST_BUFFER_NAME)); - POINTERS_EQUAL(buffer, gui_buffer_search_by_name ("(?i)CORE", TEST_BUFFER_NAME)); + POINTERS_EQUAL(NULL, gui_buffer_search ("CORE", TEST_BUFFER_NAME)); + POINTERS_EQUAL(buffer, gui_buffer_search ("(?i)CORE", TEST_BUFFER_NAME)); gui_buffer_close (buffer); } |