summaryrefslogtreecommitdiff
path: root/src/plugins/script/script-repo.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-08-30 08:50:22 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-08-30 08:50:22 +0200
commit80e740b72ffda6e404b3e03bab8ea5b60c0e283c (patch)
tree813a170e9452e9c6eb0371dabcf791d58b88f3c0 /src/plugins/script/script-repo.c
parent186053f90c07cfabfaa8b3823a6dc5196b3e1e7e (diff)
downloadweechat-80e740b72ffda6e404b3e03bab8ea5b60c0e283c.zip
script: add diff between current script and version in repository
New options: - script.look.diff_command - script.look.diff_color Key alt-d has been changed to alt-v on script buffer (view script). Key alt-d is now used on detail of script to jump to diff (if diff is displayed).
Diffstat (limited to 'src/plugins/script/script-repo.c')
-rw-r--r--src/plugins/script/script-repo.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 4d5be3fe5..5b140eb63 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -23,6 +23,7 @@
#define _XOPEN_SOURCE 700
+#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
@@ -147,6 +148,61 @@ script_repo_search_by_name_ext (const char *name_with_extension)
}
/*
+ * script_repo_get_filename_loaded: get filename of a loaded script
+ * (it returns name of file and not the link,
+ * if there is a symbolic to file)
+ * Note: result has to be free() after use
+ */
+
+char *
+script_repo_get_filename_loaded (struct t_repo_script *script)
+{
+ const char *weechat_home;
+ char *filename, resolved_path[PATH_MAX];
+ int length;
+ struct stat st;
+
+ weechat_home = weechat_info_get ("weechat_dir", NULL);
+ length = strlen (weechat_home) + strlen (script->name_with_extension) + 64;
+ filename = malloc (length);
+ if (filename)
+ {
+ snprintf (filename, length, "%s/%s/autoload/%s",
+ weechat_home,
+ script_language[script->language],
+ script->name_with_extension);
+ if (stat (filename, &st) != 0)
+ {
+ snprintf (filename, length, "%s/%s/%s",
+ weechat_home,
+ script_language[script->language],
+ script->name_with_extension);
+ if (stat (filename, &st) != 0)
+ {
+ filename[0] = '\0';
+ }
+ }
+ }
+
+ if (!filename[0])
+ {
+ free (filename);
+ return NULL;
+ }
+
+ if (realpath (filename, resolved_path))
+ {
+ if (strcmp (filename, resolved_path) != 0)
+ {
+ free (filename);
+ return strdup (resolved_path);
+ }
+ }
+
+ return filename;
+}
+
+/*
* script_repo_get_status_for_display: get status for display
* list is the codes of status to display
* (exemple: "*iaHrN" for all status)