1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

core: send all command line parameters not beginning with a dash to all plugins, add info "auto_load_scripts"

This fixes an issue with IRC URL given on command line when it starts with
`ircs://` or `irc6://`: the server is not created at all (only `irc://` works
fine).
This commit is contained in:
Sébastien Helleu
2023-05-30 20:53:42 +02:00
parent eda62e1218
commit 71b85f1238
29 changed files with 208 additions and 52 deletions
+17 -13
View File
@@ -274,20 +274,18 @@ plugin_check_autoload (const char *filename)
*/
void
plugin_get_args (struct t_weechat_plugin *plugin,
int argc, char **argv,
plugin_get_args (int argc, char **argv,
int *plugin_argc, char ***plugin_argv,
int *no_connect)
int *no_connect, int *no_script)
{
int i, temp_argc, length_plugin_name;
int i, temp_argc;
char **temp_argv;
temp_argc = 0;
temp_argv = NULL;
*no_connect = 0;
length_plugin_name = strlen (plugin->name);
*no_script = 0;
if (argc > 0)
{
@@ -302,10 +300,11 @@ plugin_get_args (struct t_weechat_plugin *plugin,
*no_connect = 1;
}
else if ((strcmp (argv[i], "-s") == 0)
|| (strcmp (argv[i], "--no-script") == 0)
|| ((strncmp (argv[i], plugin->name,
length_plugin_name) == 0)
&& (argv[i][length_plugin_name] == ':')))
|| (strcmp (argv[i], "--no-script") == 0))
{
*no_script = 1;
}
else if (argv[i][0] != '-')
{
temp_argv[temp_argc++] = argv[i];
}
@@ -336,7 +335,8 @@ int
plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
{
t_weechat_init_func *init_func;
int plugin_argc, no_connect, rc, old_auto_connect;
int no_connect, rc, old_auto_connect, no_script, old_auto_load_scripts;
int plugin_argc;
char **plugin_argv;
if (plugin->initialized)
@@ -348,12 +348,15 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
return 0;
/* get arguments for the plugin */
plugin_get_args (plugin, argc, argv,
&plugin_argc, &plugin_argv, &no_connect);
plugin_get_args (argc, argv,
&plugin_argc, &plugin_argv, &no_connect, &no_script);
old_auto_connect = weechat_auto_connect;
weechat_auto_connect = (no_connect) ? 0 : 1;
old_auto_load_scripts = weechat_auto_load_scripts;
weechat_auto_load_scripts = (no_script) ? 0 : 1;
/* init plugin */
if (weechat_debug_core >= 1)
{
@@ -377,6 +380,7 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
}
weechat_auto_connect = old_auto_connect;
weechat_auto_load_scripts = old_auto_load_scripts;
if (plugin_argv)
free (plugin_argv);