diff options
Diffstat (limited to 'irc/weechat/files/patch-src-plugins-scripts-script_c')
-rw-r--r-- | irc/weechat/files/patch-src-plugins-scripts-script_c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/irc/weechat/files/patch-src-plugins-scripts-script_c b/irc/weechat/files/patch-src-plugins-scripts-script_c new file mode 100644 index 000000000000..1c935827582e --- /dev/null +++ b/irc/weechat/files/patch-src-plugins-scripts-script_c @@ -0,0 +1,168 @@ +--- src/plugins/scripts/script.c.orig 2009-09-04 08:25:47.000000000 +0000 ++++ src/plugins/scripts/script.c 2009-11-16 12:08:54.000000000 +0000 +@@ -439,24 +439,15 @@ + script_search_by_full_name (struct t_plugin_script *scripts, + const char *full_name) + { +- char *full_name_copy, *base_name; ++ char *base_name; + struct t_plugin_script *ptr_script; + +- full_name_copy = strdup (full_name); +- +- if (full_name_copy) ++ for (ptr_script = scripts; ptr_script; ++ ptr_script = ptr_script->next_script) + { +- for (ptr_script = scripts; ptr_script; +- ptr_script = ptr_script->next_script) +- { +- base_name = basename (ptr_script->filename); +- if (strcmp (base_name, full_name) == 0) +- { +- free (full_name_copy); +- return ptr_script; +- } +- } +- free (full_name_copy); ++ base_name = basename (ptr_script->filename); ++ if (strcmp (base_name, full_name) == 0) ++ return ptr_script; + } + + /* script not found */ +@@ -915,7 +906,8 @@ + int (*script_load)(const char *filename), + char **list) + { +- char **argv, *name, *base_name, *new_path, *autoload_path, *symlink_path; ++ char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path; ++ char *symlink_path; + const char *dir_home, *dir_separator; + int argc, i, length; + struct t_plugin_script *ptr_script; +@@ -930,67 +922,71 @@ + name = strdup (argv[i]); + if (name) + { +- base_name = basename (name); +- +- /* unload script, if script is loaded */ +- ptr_script = script_search_by_full_name (scripts, base_name); +- if (ptr_script) +- (*script_unload) (ptr_script); ++ ptr_base_name = basename (name); ++ base_name = strdup (ptr_base_name); ++ if (base_name) ++ { ++ /* unload script, if script is loaded */ ++ ptr_script = script_search_by_full_name (scripts, base_name); ++ if (ptr_script) ++ (*script_unload) (ptr_script); + +- /* remove script file(s) */ +- script_remove_file (weechat_plugin, base_name, 0); ++ /* remove script file(s) */ ++ script_remove_file (weechat_plugin, base_name, 0); + +- /* move file from install dir to language dir */ +- dir_home = weechat_info_get ("weechat_dir", ""); +- length = strlen (dir_home) + strlen (weechat_plugin->name) + +- strlen (base_name) + 16; +- new_path = malloc (length); +- if (new_path) +- { +- snprintf (new_path, length, "%s/%s/%s", +- dir_home, weechat_plugin->name, base_name); +- if (rename (name, new_path) == 0) ++ /* move file from install dir to language dir */ ++ dir_home = weechat_info_get ("weechat_dir", ""); ++ length = strlen (dir_home) + strlen (weechat_plugin->name) + ++ strlen (base_name) + 16; ++ new_path = malloc (length); ++ if (new_path) + { +- /* make link in autoload dir */ +- length = strlen (dir_home) + +- strlen (weechat_plugin->name) + 8 + +- strlen (base_name) + 16; +- autoload_path = malloc (length); +- if (autoload_path) ++ snprintf (new_path, length, "%s/%s/%s", ++ dir_home, weechat_plugin->name, base_name); ++ if (rename (name, new_path) == 0) + { +- snprintf (autoload_path, length, +- "%s/%s/autoload/%s", +- dir_home, weechat_plugin->name, +- base_name); +- dir_separator = weechat_info_get ("dir_separator", ""); +- length = 2 + strlen (dir_separator) + +- strlen (base_name) + 1; +- symlink_path = malloc (length); +- if (symlink_path) ++ /* make link in autoload dir */ ++ length = strlen (dir_home) + ++ strlen (weechat_plugin->name) + 8 + ++ strlen (base_name) + 16; ++ autoload_path = malloc (length); ++ if (autoload_path) + { +- snprintf (symlink_path, length, "..%s%s", +- dir_separator, base_name); +- symlink (symlink_path, autoload_path); +- free (symlink_path); +- } ++ snprintf (autoload_path, length, ++ "%s/%s/autoload/%s", ++ dir_home, weechat_plugin->name, ++ base_name); ++ dir_separator = weechat_info_get ("dir_separator", ""); ++ length = 2 + strlen (dir_separator) + ++ strlen (base_name) + 1; ++ symlink_path = malloc (length); ++ if (symlink_path) ++ { ++ snprintf (symlink_path, length, "..%s%s", ++ dir_separator, base_name); ++ symlink (symlink_path, autoload_path); ++ free (symlink_path); ++ } + free (autoload_path); +- } ++ } + +- /* load script */ +- (*script_load) (new_path); +- } +- else +- { +- weechat_printf (NULL, +- _("%s%s: failed to move script %s " +- "to %s (%s)"), +- weechat_prefix ("error"), +- weechat_plugin->name, +- name, +- new_path, +- strerror (errno)); ++ /* load script */ ++ (*script_load) (new_path); ++ } ++ else ++ { ++ weechat_printf (NULL, ++ _("%s%s: failed to move script %s " ++ "to %s (%s)"), ++ weechat_prefix ("error"), ++ weechat_plugin->name, ++ name, ++ new_path, ++ strerror (errno)); ++ } ++ free (new_path); + } +- free (new_path); ++ free (base_name); + } + free (name); + } |