From 3f067f206552aa9fa9f30df6e6432cc0fa92766d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 27 Oct 2018 08:52:20 +0200 Subject: buflist: fix warning displayed when script buffers.pl is loaded (closes #1274) --- src/plugins/buflist/buflist.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index bdc8aea76..79459c6d6 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "../weechat-plugin.h" #include "buflist.h" @@ -363,7 +364,7 @@ int buflist_script_loaded_cb (const void *pointer, void *data, const char *signal, const char *type_data, void *signal_data) { - int length; + char *base_name, *base_name2; /* make C compiler happy */ (void) pointer; @@ -378,9 +379,14 @@ buflist_script_loaded_cb (const void *pointer, void *data, const char *signal, if (!signal_data) return WEECHAT_RC_OK; - length = strlen (signal_data); - if ((length >= 10) - && (strncmp (signal_data + length - 10, "buffers.pl", 10) == 0)) + base_name = basename (signal_data); + if (!base_name) + return WEECHAT_RC_OK; + base_name2 = strdup (base_name); + if (!base_name2) + return WEECHAT_RC_OK; + + if (strcmp (base_name2, "buffers.pl") == 0) { weechat_printf (NULL, _("%sbuflist: warning: the script buffers.pl is " @@ -393,6 +399,8 @@ buflist_script_loaded_cb (const void *pointer, void *data, const char *signal, weechat_prefix ("error")); } + free (base_name2); + return WEECHAT_RC_OK; } -- cgit v1.2.3