summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-02-28 21:11:34 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-02-28 21:11:34 +0000
commite4cc18210575125c7aea1ce62496772f73768158 (patch)
treee9f1d1bbdd1b94a020151d8aa8f8b3a84e8e32e0
parent8c662f69f97d1adfd83c8fd7b6427bdfa386ca98 (diff)
downloadweechat-e4cc18210575125c7aea1ce62496772f73768158.zip
Script plugins now load scripts in WeeChat system share directory
-rw-r--r--ChangeLog1
-rw-r--r--po/cs.po4
-rw-r--r--po/es.po4
-rw-r--r--po/fr.po4
-rw-r--r--po/hu.po4
-rw-r--r--po/weechat.pot4
-rw-r--r--src/plugins/scripts/lua/weechat-lua.c24
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c24
-rw-r--r--src/plugins/scripts/python/weechat-python.c24
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.c24
-rw-r--r--src/plugins/scripts/weechat-script.c56
-rw-r--r--src/plugins/scripts/weechat-script.h2
-rw-r--r--weechat/ChangeLog1
-rw-r--r--weechat/po/cs.po4
-rw-r--r--weechat/po/es.po4
-rw-r--r--weechat/po/fr.po4
-rw-r--r--weechat/po/hu.po4
-rw-r--r--weechat/po/weechat.pot4
-rw-r--r--weechat/src/plugins/scripts/lua/weechat-lua.c24
-rw-r--r--weechat/src/plugins/scripts/perl/weechat-perl.c24
-rw-r--r--weechat/src/plugins/scripts/python/weechat-python.c24
-rw-r--r--weechat/src/plugins/scripts/ruby/weechat-ruby.c24
-rw-r--r--weechat/src/plugins/scripts/weechat-script.c56
-rw-r--r--weechat/src/plugins/scripts/weechat-script.h2
24 files changed, 162 insertions, 188 deletions
diff --git a/ChangeLog b/ChangeLog
index c6bcf0940..e4f621eae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ ChangeLog - 2006-02-28
Version 0.1.8 (under dev!):
+ * script plugins now load scripts in WeeChat system share directory
* /msg command does not open any buffer any more
* fixed crash when using global history (when older entry is removed)
* added IRC raw data buffer (new key: alt-J + alt-R)
diff --git a/po/cs.po b/po/cs.po
index b50441e05..ed42c1dd1 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:26+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1438,7 +1438,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s přezdívka \"%s\" nebyla nalezena pro příkaz \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s nemohu vytvořít nové soukromý buffer\"%s\"\n"
diff --git a/po/es.po b/po/es.po
index 06d0a784c..a121132fb 100644
--- a/po/es.po
+++ b/po/es.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:25+0100\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1450,7 +1450,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s usuario \"%s\" no encontrado para el comando \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s no es posible crear una nueva ventana privada \"%s\"\n"
diff --git a/po/fr.po b/po/fr.po
index 08b0ec9b2..468b0e76d 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:32+0100\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1447,7 +1447,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s pseudo \"%s\" non trouvé pour la commande \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s impossible de créer le tampon privé \"%s\"\n"
diff --git a/po/hu.po b/po/hu.po
index 606758da4..2743386b6 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:26+0100\n"
"Last-Translator: voroskoi <voroskoi@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1449,7 +1449,7 @@ msgstr "%s \"%s\" parancs csak a szobaablakban futtatható\n"
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s név \"%s\" nem található a \"%s\" parancshoz\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s nem sikerült új privát ablakot nyitni \"%s\"\n"
diff --git a/po/weechat.pot b/po/weechat.pot
index 61a8eceea..e34d31182 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1331,7 +1331,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr ""
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr ""
diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c
index 798433c12..e2efb8d6b 100644
--- a/src/plugins/scripts/lua/weechat-lua.c
+++ b/src/plugins/scripts/lua/weechat-lua.c
@@ -1593,8 +1593,8 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1705,25 +1705,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Lua script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/lua/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "lua", argv[1]);
weechat_lua_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index f8c581480..c1605e22a 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -1401,8 +1401,8 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1513,25 +1513,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Perl script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/perl/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "perl", argv[1]);
weechat_perl_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index b7afb327a..cca2db855 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -1365,8 +1365,8 @@ weechat_python_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1477,25 +1477,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Python script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/python/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "python", argv[1]);
weechat_python_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c
index 13e4d1d3b..13f1e927f 100644
--- a/src/plugins/scripts/ruby/weechat-ruby.c
+++ b/src/plugins/scripts/ruby/weechat-ruby.c
@@ -1544,8 +1544,8 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1656,25 +1656,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Ruby script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/ruby/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "ruby", argv[1]);
weechat_ruby_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/src/plugins/scripts/weechat-script.c b/src/plugins/scripts/weechat-script.c
index 636d121e3..c5ee3cca3 100644
--- a/src/plugins/scripts/weechat-script.c
+++ b/src/plugins/scripts/weechat-script.c
@@ -85,6 +85,62 @@ weechat_script_search (t_weechat_plugin *plugin,
}
/*
+ * weechat_script_search_full_name: search the full path name of a script
+ */
+
+char *
+weechat_script_search_full_name (t_weechat_plugin *plugin,
+ char *language, char *filename)
+{
+ char *final_name, *dir_home, *dir_system;
+ int length;
+ struct stat st;
+
+ if ((strstr(filename, "/")) || (strstr(filename, "\\")))
+ return strdup(filename);
+
+ /* try WeeChat user's dir */
+ dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
+ if (dir_home)
+ {
+ length = strlen (dir_home) + strlen (language) + strlen (filename) + 16;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name, length, "%s/%s/%s", dir_home, language, filename);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (dir_home);
+ return final_name;
+ }
+ free (final_name);
+ }
+ free (dir_home);
+ }
+
+ /* try WeeChat system dir */
+ dir_system = plugin->get_info (plugin, "weechat_sharedir", NULL);
+ if (dir_system)
+ {
+ length = strlen (dir_system) + strlen (dir_system) + strlen (filename) + 16;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name,length, "%s/%s/%s", dir_system, language, filename);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (dir_system);
+ return final_name;
+ }
+ free (final_name);
+ }
+ free (dir_system);
+ }
+
+ return NULL;
+}
+
+/*
* weechat_script_add: add a script to list of scripts
*/
diff --git a/src/plugins/scripts/weechat-script.h b/src/plugins/scripts/weechat-script.h
index d60c03c97..007bc8713 100644
--- a/src/plugins/scripts/weechat-script.h
+++ b/src/plugins/scripts/weechat-script.h
@@ -43,6 +43,8 @@ extern void weechat_script_auto_load (t_weechat_plugin *, char *,
int (*)(t_weechat_plugin *, char *));
extern t_plugin_script *weechat_script_search (t_weechat_plugin *,
t_plugin_script **, char *);
+extern char *weechat_script_search_full_name (t_weechat_plugin *,
+ char *, char *);
extern t_plugin_script *weechat_script_add (t_weechat_plugin *,
t_plugin_script **, char *, char *,
char *, char *, char *);
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index c6bcf0940..e4f621eae 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -5,6 +5,7 @@ ChangeLog - 2006-02-28
Version 0.1.8 (under dev!):
+ * script plugins now load scripts in WeeChat system share directory
* /msg command does not open any buffer any more
* fixed crash when using global history (when older entry is removed)
* added IRC raw data buffer (new key: alt-J + alt-R)
diff --git a/weechat/po/cs.po b/weechat/po/cs.po
index b50441e05..ed42c1dd1 100644
--- a/weechat/po/cs.po
+++ b/weechat/po/cs.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:26+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1438,7 +1438,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s přezdívka \"%s\" nebyla nalezena pro příkaz \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s nemohu vytvořít nové soukromý buffer\"%s\"\n"
diff --git a/weechat/po/es.po b/weechat/po/es.po
index 06d0a784c..a121132fb 100644
--- a/weechat/po/es.po
+++ b/weechat/po/es.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:25+0100\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1450,7 +1450,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s usuario \"%s\" no encontrado para el comando \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s no es posible crear una nueva ventana privada \"%s\"\n"
diff --git a/weechat/po/fr.po b/weechat/po/fr.po
index 08b0ec9b2..468b0e76d 100644
--- a/weechat/po/fr.po
+++ b/weechat/po/fr.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:32+0100\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1447,7 +1447,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s pseudo \"%s\" non trouvé pour la commande \"%s\"\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s impossible de créer le tampon privé \"%s\"\n"
diff --git a/weechat/po/hu.po b/weechat/po/hu.po
index 606758da4..2743386b6 100644
--- a/weechat/po/hu.po
+++ b/weechat/po/hu.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.1.8-cvs\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: 2006-02-22 10:26+0100\n"
"Last-Translator: voroskoi <voroskoi@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1449,7 +1449,7 @@ msgstr "%s \"%s\" parancs csak a szobaablakban futtatható\n"
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr "%s név \"%s\" nem található a \"%s\" parancshoz\n"
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr "%s nem sikerült új privát ablakot nyitni \"%s\"\n"
diff --git a/weechat/po/weechat.pot b/weechat/po/weechat.pot
index 61a8eceea..e34d31182 100644
--- a/weechat/po/weechat.pot
+++ b/weechat/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2006-02-22 10:32+0100\n"
+"POT-Creation-Date: 2006-02-28 16:59+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1331,7 +1331,7 @@ msgstr ""
msgid "%s nick \"%s\" not found for \"%s\" command\n"
msgstr ""
-#: src/irc/irc-send.c:1231 src/irc/irc-send.c:1603
+#: src/irc/irc-send.c:1603
#, c-format
msgid "%s cannot create new private buffer \"%s\"\n"
msgstr ""
diff --git a/weechat/src/plugins/scripts/lua/weechat-lua.c b/weechat/src/plugins/scripts/lua/weechat-lua.c
index 798433c12..e2efb8d6b 100644
--- a/weechat/src/plugins/scripts/lua/weechat-lua.c
+++ b/weechat/src/plugins/scripts/lua/weechat-lua.c
@@ -1593,8 +1593,8 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1705,25 +1705,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Lua script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/lua/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "lua", argv[1]);
weechat_lua_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/weechat/src/plugins/scripts/perl/weechat-perl.c b/weechat/src/plugins/scripts/perl/weechat-perl.c
index f8c581480..c1605e22a 100644
--- a/weechat/src/plugins/scripts/perl/weechat-perl.c
+++ b/weechat/src/plugins/scripts/perl/weechat-perl.c
@@ -1401,8 +1401,8 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1513,25 +1513,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Perl script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/perl/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "perl", argv[1]);
weechat_perl_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c
index b7afb327a..cca2db855 100644
--- a/weechat/src/plugins/scripts/python/weechat-python.c
+++ b/weechat/src/plugins/scripts/python/weechat-python.c
@@ -1365,8 +1365,8 @@ weechat_python_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1477,25 +1477,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Python script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/python/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "python", argv[1]);
weechat_python_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/weechat/src/plugins/scripts/ruby/weechat-ruby.c b/weechat/src/plugins/scripts/ruby/weechat-ruby.c
index 13e4d1d3b..13f1e927f 100644
--- a/weechat/src/plugins/scripts/ruby/weechat-ruby.c
+++ b/weechat/src/plugins/scripts/ruby/weechat-ruby.c
@@ -1544,8 +1544,8 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
char *server, char *command, char *arguments,
char *handler_args, void *handler_pointer)
{
- int argc, path_length, handler_found;
- char **argv, *path_script, *dir_home;
+ int argc, handler_found;
+ char **argv, *path_script;
t_plugin_script *ptr_script;
t_plugin_handler *ptr_handler;
@@ -1656,25 +1656,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
if (plugin->ascii_strcasecmp (plugin, argv[0], "load") == 0)
{
/* load Ruby script */
- if ((strstr (argv[1], "/")) || (strstr (argv[1], "\\")))
- path_script = NULL;
- else
- {
- dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
- if (dir_home)
- {
- path_length = strlen (dir_home) + strlen (argv[1]) + 16;
- path_script = (char *) malloc (path_length * sizeof (char));
- if (path_script)
- snprintf (path_script, path_length, "%s/ruby/%s",
- dir_home, argv[1]);
- else
- path_script = NULL;
- free (dir_home);
- }
- else
- path_script = NULL;
- }
+ path_script = weechat_script_search_full_name (plugin, "ruby", argv[1]);
weechat_ruby_load (plugin, (path_script) ? path_script : argv[1]);
if (path_script)
free (path_script);
diff --git a/weechat/src/plugins/scripts/weechat-script.c b/weechat/src/plugins/scripts/weechat-script.c
index 636d121e3..c5ee3cca3 100644
--- a/weechat/src/plugins/scripts/weechat-script.c
+++ b/weechat/src/plugins/scripts/weechat-script.c
@@ -85,6 +85,62 @@ weechat_script_search (t_weechat_plugin *plugin,
}
/*
+ * weechat_script_search_full_name: search the full path name of a script
+ */
+
+char *
+weechat_script_search_full_name (t_weechat_plugin *plugin,
+ char *language, char *filename)
+{
+ char *final_name, *dir_home, *dir_system;
+ int length;
+ struct stat st;
+
+ if ((strstr(filename, "/")) || (strstr(filename, "\\")))
+ return strdup(filename);
+
+ /* try WeeChat user's dir */
+ dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
+ if (dir_home)
+ {
+ length = strlen (dir_home) + strlen (language) + strlen (filename) + 16;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name, length, "%s/%s/%s", dir_home, language, filename);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (dir_home);
+ return final_name;
+ }
+ free (final_name);
+ }
+ free (dir_home);
+ }
+
+ /* try WeeChat system dir */
+ dir_system = plugin->get_info (plugin, "weechat_sharedir", NULL);
+ if (dir_system)
+ {
+ length = strlen (dir_system) + strlen (dir_system) + strlen (filename) + 16;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name,length, "%s/%s/%s", dir_system, language, filename);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (dir_system);
+ return final_name;
+ }
+ free (final_name);
+ }
+ free (dir_system);
+ }
+
+ return NULL;
+}
+
+/*
* weechat_script_add: add a script to list of scripts
*/
diff --git a/weechat/src/plugins/scripts/weechat-script.h b/weechat/src/plugins/scripts/weechat-script.h
index d60c03c97..007bc8713 100644
--- a/weechat/src/plugins/scripts/weechat-script.h
+++ b/weechat/src/plugins/scripts/weechat-script.h
@@ -43,6 +43,8 @@ extern void weechat_script_auto_load (t_weechat_plugin *, char *,
int (*)(t_weechat_plugin *, char *));
extern t_plugin_script *weechat_script_search (t_weechat_plugin *,
t_plugin_script **, char *);
+extern char *weechat_script_search_full_name (t_weechat_plugin *,
+ char *, char *);
extern t_plugin_script *weechat_script_add (t_weechat_plugin *,
t_plugin_script **, char *, char *,
char *, char *, char *);