diff -Naur ImageMagick-6.8.9-8-orig/config/ImageMagick.rc ImageMagick-6.8.9-8/config/ImageMagick.rc --- ImageMagick-6.8.9-8-orig/config/ImageMagick.rc 2012-12-03 03:17:52.000000000 +0400 +++ ImageMagick-6.8.9-8/config/ImageMagick.rc 2014-10-03 20:08:29.155600000 +0400 @@ -49,17 +49,17 @@ // ///////////////////////////////////////////////////////////////////////////// -CODER.XML IMAGEMAGICK DISCARDABLE "..\\bin\\coder.xml" -COLORS.XML IMAGEMAGICK DISCARDABLE "..\\bin\\colors.xml" -CONFIGURE.XML IMAGEMAGICK DISCARDABLE "..\\bin\\configure.xml" -DELEGATES.XML IMAGEMAGICK DISCARDABLE "..\\bin\\delegates.xml" -ENGLISH.XML IMAGEMAGICK DISCARDABLE "..\\bin\\english.xml" -LOCALE.XML IMAGEMAGICK DISCARDABLE "..\\bin\\locale.xml" -LOG.XML IMAGEMAGICK DISCARDABLE "..\\bin\\log.xml" -MAGIC.XML IMAGEMAGICK DISCARDABLE "..\\bin\\magic.xml" -THRESHOLDS.XML IMAGEMAGICK DISCARDABLE "..\\bin\\thresholds.xml" -TYPE.XML IMAGEMAGICK DISCARDABLE "..\\bin\\type.xml" -TYPE-GHOSTSCRIPT.XML IMAGEMAGICK DISCARDABLE "..\\bin\\type-ghostscript.xml" +CODER.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\coder.xml" +COLORS.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\colors.xml" +CONFIGURE.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\configure.xml" +DELEGATES.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\delegates.xml" +ENGLISH.XML IMAGEMAGICK DISCARDABLE "..\\share\\ImageMagick-6\\english.xml" +LOCALE.XML IMAGEMAGICK DISCARDABLE "..\\share\\ImageMagick-6\\locale.xml" +LOG.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\log.xml" +MAGIC.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\magic.xml" +THRESHOLDS.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\thresholds.xml" +TYPE.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\type.xml" +TYPE-GHOSTSCRIPT.XML IMAGEMAGICK DISCARDABLE "..\\etc\\ImageMagick-6\\type-ghostscript.xml" ///////////////////////////////////////////////////////////////////////////// @@ -68,4 +68,4 @@ // ///////////////////////////////////////////////////////////////////////////// -IDR_MAGICKICON ICON DISCARDABLE "..\\..\\images\\ImageMagick.ico" +IDR_MAGICKICON ICON DISCARDABLE "..\\share\\doc\\ImageMagick-6\\images\\ImageMagick.ico" diff -Naur ImageMagick-6.8.9-8-orig/magick/configure.c ImageMagick-6.8.9-8/magick/configure.c --- ImageMagick-6.8.9-8-orig/magick/configure.c 2014-06-26 15:49:06.000000000 +0400 +++ ImageMagick-6.8.9-8/magick/configure.c 2014-10-04 16:35:07.658600000 +0400 @@ -55,6 +55,7 @@ #include "magick/utility.h" #include "magick/xml-tree.h" #include "magick/xml-tree-private.h" +#include "magick/pathtools.h" /* Define declarations. @@ -786,21 +787,22 @@ } #if defined(MAGICKCORE_INSTALLED_SUPPORT) #if defined(MAGICKCORE_SHARE_PATH) - (void) AppendValueToLinkedList(paths,ConstantString(MAGICKCORE_SHARE_PATH)); + char *sharedir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_SHARE_PATH); + (void) AppendValueToLinkedList(paths,ConstantString(sharedir)); #endif #if defined(MAGICKCORE_SHAREARCH_PATH) - (void) AppendValueToLinkedList(paths,ConstantString( - MAGICKCORE_SHAREARCH_PATH)); + char *sharearchdir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_SHAREARCH_PATH); + (void) AppendValueToLinkedList(paths,ConstantString(sharearchdir)); #endif #if defined(MAGICKCORE_CONFIGURE_PATH) - (void) AppendValueToLinkedList(paths,ConstantString( - MAGICKCORE_CONFIGURE_PATH)); + char *configdir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_CONFIGURE_PATH); + (void) AppendValueToLinkedList(paths,ConstantString(configdir)); #endif #if defined(MAGICKCORE_DOCUMENTATION_PATH) - (void) AppendValueToLinkedList(paths,ConstantString( - MAGICKCORE_DOCUMENTATION_PATH)); + char *docdir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_DOCUMENTATION_PATH); + (void) AppendValueToLinkedList(paths,ConstantString(docdir)); #endif -#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_PATH)) +#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_PATH)) { unsigned char *key_value; diff -Naur ImageMagick-6.8.9-8-orig/magick/magick-config.h ImageMagick-6.8.9-8/magick/magick-config.h --- ImageMagick-6.8.9-8-orig/magick/magick-config.h 2013-11-27 23:02:59.000000000 +0400 +++ ImageMagick-6.8.9-8/magick/magick-config.h 2014-10-04 17:14:06.158800000 +0400 @@ -86,8 +86,13 @@ # if defined (_WIN32) || defined (_WIN64) || defined (__MSDOS__) || defined (__DJGPP__) || defined (__OS2__) /* Use Windows separators on all _WIN32 defining environments, except Cygwin. */ -# define MAGICKCORE_DIR_SEPARATOR_CHAR '\\' -# define MAGICKCORE_DIR_SEPARATOR "\\" +# if defined (__MINGW32__) +# define MAGICKCORE_DIR_SEPARATOR_CHAR '/' +# define MAGICKCORE_DIR_SEPARATOR "/" +# else +# define MAGICKCORE_DIR_SEPARATOR_CHAR '\\' +# define MAGICKCORE_DIR_SEPARATOR "\\" +# endif # define MAGICKCORE_PATH_SEPARATOR_CHAR ';' # define MAGICKCORE_PATH_SEPARATOR ";" # endif diff -Naur ImageMagick-6.8.9-8-orig/magick/Makefile.am ImageMagick-6.8.9-8/magick/Makefile.am --- ImageMagick-6.8.9-8-orig/magick/Makefile.am 2014-06-25 16:49:46.000000000 +0400 +++ ImageMagick-6.8.9-8/magick/Makefile.am 2014-10-03 21:57:53.918800000 +0400 @@ -211,6 +211,8 @@ magick/option-private.h \ magick/paint.c \ magick/paint.h \ + magick/pathtools.c \ + magick/pathtools.h \ magick/pixel.c \ magick/pixel.h \ magick/pixel-accessor.h \ diff -Naur ImageMagick-6.8.9-8-orig/magick/module.c ImageMagick-6.8.9-8/magick/module.c --- ImageMagick-6.8.9-8-orig/magick/module.c 2014-04-04 17:59:23.000000000 +0400 +++ ImageMagick-6.8.9-8/magick/module.c 2014-10-04 16:21:25.820000000 +0400 @@ -62,6 +62,7 @@ #include "magick/string_.h" #include "magick/token.h" #include "magick/utility.h" +#include "magick/pathtools.h" #if defined(MAGICKCORE_MODULES_SUPPORT) #if defined(MAGICKCORE_LTDL_DELEGATE) #include "ltdl.h" @@ -555,8 +556,10 @@ "Searching for coder module file \"%s\" ...",filename); module_path=GetEnvironmentValue("MAGICK_CODER_MODULE_PATH"); #if defined(MAGICKCORE_CODER_PATH) - if (module_path == (char *) NULL) - module_path=AcquireString(MAGICKCORE_CODER_PATH); + if (module_path == (char *) NULL) { + char * coderdir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_CODER_PATH); + module_path=AcquireString(coderdir); + } #endif break; } @@ -566,8 +569,10 @@ "Searching for filter module file \"%s\" ...",filename); module_path=GetEnvironmentValue("MAGICK_CODER_FILTER_PATH"); #if defined(MAGICKCORE_FILTER_PATH) - if (module_path == (char *) NULL) - module_path=AcquireString(MAGICKCORE_FILTER_PATH); + if (module_path == (char *) NULL) { + char * filterdir = single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_FILTER_PATH); + module_path=AcquireString(filterdir); + } #endif break; } @@ -612,12 +617,12 @@ case MagickImageCoderModule: default: { - directory=MAGICKCORE_CODER_PATH; + directory=single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_CODER_PATH); break; } case MagickImageFilterModule: { - directory=MAGICKCORE_FILTER_PATH; + directory=single_path_relocation(MAGICKCORE_EXECUTABLE_PATH, MAGICKCORE_FILTER_PATH); break; } } @@ -631,7 +636,7 @@ return(MagickTrue); } #else -#if defined(MAGICKCORE_WINDOWS_SUPPORT) +#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__) { const char *registery_key; diff -Naur ImageMagick-6.8.9-8-orig/magick/pathtools.c ImageMagick-6.8.9-8/magick/pathtools.c --- ImageMagick-6.8.9-8-orig/magick/pathtools.c 1970-01-01 03:00:00.000000000 +0300 +++ ImageMagick-6.8.9-8/magick/pathtools.c 1970-01-01 03:00:00.000000000 +0300 @@ -0,0 +1,538 @@ +/* + .Some useful path tools. + .ASCII only for now. + .Written by Ray Donnelly in 2014. + .Licensed under CC0 (and anything. + .else you need to license it under). + .No warranties whatsoever. + .email: . + */ + +#if defined(__APPLE__) +#include +#else +#include +#endif +#include +#include +#include +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) +#include +#endif +#include + +/* If you don't define this, then get_executable_path() + can only use argv[0] which will often not work well */ +#define IMPLEMENT_SYS_GET_EXECUTABLE_PATH + +#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) +/* Nothing needed, unistd.h is enough. */ +#elif defined(__APPLE__) +#include +#elif defined(_WIN32) +#define WIN32_MEAN_AND_LEAN +#include +#include +#endif +#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */ + +#include "pathtools.h" + +char * +malloc_copy_string(char const * original) +{ + char * result = (char *) malloc (sizeof (char*) * strlen (original)+1); + if (result != NULL) + { + strcpy (result, original); + } + return result; +} + +void +sanitise_path(char * path) +{ + size_t path_size = strlen (path); + + /* Replace any '\' with '/' */ + char * path_p = path; + while ((path_p = strchr (path_p, '\\')) != NULL) + { + *path_p = '/'; + } + /* Replace any '//' with '/' */ + path_p = path; + while ((path_p = strstr (path_p, "//")) != NULL) + { + memmove (path_p, path_p + 1, path_size--); + } + return; +} + +char * +get_relative_path(char const * from_in, char const * to_in) +{ + size_t from_size = (from_in == NULL) ? 0 : strlen (from_in); + size_t to_size = (to_in == NULL) ? 0 : strlen (to_in); + size_t max_size = (from_size + to_size) * 2 + 4; + char * scratch_space = (char *) alloca (from_size + 1 + to_size + 1 + max_size + max_size); + char * from; + char * to; + char * common_part; + char * result; + size_t count; + + /* No to, return "./" */ + if (to_in == NULL) + { + return malloc_copy_string ("./"); + } + + /* If alloca failed or no from was given return a copy of to */ + if ( from_in == NULL + || scratch_space == NULL ) + { + return malloc_copy_string (to_in); + } + + from = scratch_space; + strcpy (from, from_in); + to = from + from_size + 1; + strcpy (to, to_in); + common_part = to + to_size + 1; + result = common_part + max_size; + simplify_path (from); + simplify_path (to); + + result[0] = '\0'; + + size_t match_size_dirsep = 0; /* The match size up to the last /. Always wind back to this - 1 */ + size_t match_size = 0; /* The running (and final) match size. */ + size_t largest_size = (from_size > to_size) ? from_size : to_size; + int to_final_is_slash = (to[to_size-1] == '/') ? 1 : 0; + char from_c; + char to_c; + for (match_size = 0; match_size < largest_size; ++match_size) + { + /* To simplify the logic, always pretend the strings end with '/' */ + from_c = (match_size < from_size) ? from[match_size] : '/'; + to_c = (match_size < to_size) ? to[match_size] : '/'; + + if (from_c != to_c) + { + if (from_c != '\0' || to_c != '\0') + { + match_size = match_size_dirsep; + } + break; + } + else if (from_c == '/') + { + match_size_dirsep = match_size; + } + } + strncpy (common_part, from, match_size); + common_part[match_size] = '\0'; + from += match_size; + to += match_size; + size_t ndotdots = 0; + char const* from_last = from + strlen(from) - 1; + while ((from = strchr (from, '/')) && from != from_last) + { + ++ndotdots; + ++from; + } + for (count = 0; count < ndotdots; ++count) + { + strcat(result, "../"); + } + if (strlen(to) > 0) + { + strcat(result, to+1); + } + /* Make sure that if to ends with '/' result does the same, and + vice-versa. */ + size_t size_result = strlen(result); + if ((to_final_is_slash == 1) + && (!size_result || result[size_result-1] != '/')) + { + strcat (result, "/"); + } + else if (!to_final_is_slash + && size_result && result[size_result-1] == '/') + { + result[size_result-1] = '\0'; + } + + return malloc_copy_string (result); +} + +void +simplify_path(char * path) +{ + ssize_t n_toks = 1; /* in-case we need an empty initial token. */ + ssize_t i, j; + size_t tok_size; + size_t in_size = strlen (path); + int it_ended_with_a_slash = (path[in_size - 1] == '/') ? 1 : 0; + char * result = path; + sanitise_path(result); + char * result_p = result; + + do + { + ++n_toks; + ++result_p; + } while ((result_p = strchr (result_p, '/')) != NULL); + + result_p = result; + char const ** toks = (char const **) alloca (sizeof (char const*) * n_toks); + n_toks = 0; + do + { + if (result_p > result) + { + *result_p++ = '\0'; + } + else if (*result_p == '/') + { + /* A leading / creates an empty initial token. */ + toks[n_toks++] = result_p; + *result_p++ = '\0'; + } + toks[n_toks++] = result_p; + } while ((result_p = strchr (result_p, '/')) != NULL); + + /* Remove all non-leading '.' and any '..' we can match + with an earlier forward path (i.e. neither '.' nor '..') */ + for (i = 1; i < n_toks; ++i) + { + int removals[2] = { -1, -1 }; + if ( strcmp (toks[i], "." ) == 0) + { + removals[0] = i; + } + else if ( strcmp (toks[i], ".." ) == 0) + { + /* Search backwards for a forward path to collapse. + If none are found then the .. also stays. */ + for (j = i - 1; j > -1; --j) + { + if ( strcmp (toks[j], "." ) + && strcmp (toks[j], ".." ) ) + { + removals[0] = j; + removals[1] = i; + break; + } + } + } + for (j = 0; j < 2; ++j) + { + if (removals[j] >= 0) /* Can become -2 */ + { + --n_toks; + memmove (&toks[removals[j]], &toks[removals[j]+1], (n_toks - removals[j])*sizeof (char*)); + --i; + if (!j) + { + --removals[1]; + } + } + } + } + result_p = result; + for (i = 0; i < n_toks; ++i) + { + tok_size = strlen(toks[i]); + memcpy (result_p, toks[i], tok_size); + result_p += tok_size; + if ((!i || tok_size) && ((i < n_toks - 1) || it_ended_with_a_slash == 1)) + { + *result_p = '/'; + ++result_p; + } + } + *result_p = '\0'; +} + +/* Returns actual_to by calculating the relative path from -> to and + applying that to actual_from. An assumption that actual_from is a + dir is made, and it may or may not end with a '/' */ +char const * +get_relocated_path (char const * from, char const * to, char const * actual_from) +{ + char const * relative_from_to = get_relative_path (from, to); + char * actual_to = (char *) malloc (strlen(actual_from) + 2 + strlen(relative_from_to)); + return actual_to; +} + +int +get_executable_path(char const * argv0, char * result, ssize_t max_size) +{ + char * system_result = (char *) alloca (max_size); + ssize_t system_result_size = -1; + ssize_t result_size = -1; + + if (system_result != NULL) + { +#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) + system_result_size = readlink("/proc/self/exe", system_result, max_size); +#elif defined(__APPLE__) + uint32_t bufsize = (uint32_t)max_size; + if (_NSGetExecutablePath(system_result, &bufsize) == 0) + { + system_result_size = (ssize_t)bufsize; + } +#elif defined(_WIN32) + unsigned long bufsize = (unsigned long)max_size; + system_result_size = GetModuleFileNameA(NULL, system_result, bufsize); + if (system_result_size == 0 || system_result_size == (ssize_t)bufsize) + { + /* Error, possibly not enough space. */ + system_result_size = -1; + } + else + { + /* Early conversion to unix slashes instead of more changes + everywhere else .. */ + char * winslash; + system_result[system_result_size] = '\0'; + while ((winslash = strchr (system_result, '\\')) != NULL) + { + *winslash = '/'; + } + } +#else +#warning "Don't know how to get executable path on this system" +#endif +#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */ + } + /* Use argv0 as a default in-case of failure */ + if (system_result_size != -1) + { + strncpy (result, system_result, system_result_size); + result[system_result_size] = '\0'; + } + else + { + if (argv0 != NULL) + { + strncpy (result, argv0, max_size); + result[max_size-1] = '\0'; + } + else + { + result[0] = '\0'; + } + } + result_size = strlen (result); + return result_size; +} + +char const * +strip_n_prefix_folders(char const * path, size_t n) +{ + if (path == NULL) + { + return NULL; + } + + if (path[0] != '/') + { + return path; + } + + char const * last = path; + while (n-- && path != NULL) + { + last = path; + path = strchr (path + 1, '/'); + } + return (path == NULL) ? last : path; +} + +void +strip_n_suffix_folders(char * path, size_t n) +{ + if (path == NULL) + { + return; + } + while (n--) + { + if (strrchr (path + 1, '/')) + { + *strrchr (path + 1, '/') = '\0'; + } + else + { + return; + } + } + return; +} + +size_t +split_path_list(char const * path_list, char split_char, char *** arr) +{ + size_t path_count; + size_t path_list_size; + char const * path_list_p; + + path_list_p = path_list; + if (path_list == NULL || path_list[0] == '\0') + { + return 0; + } + path_list_size = strlen (path_list); + + path_count = 0; + do + { + ++path_count; + ++path_list_p; + } + while ((path_list_p = strchr (path_list_p, split_char)) != NULL); + + /* allocate everything in one go. */ + char * all_memory = (char *) malloc (sizeof (char *) * path_count + strlen(path_list) + 1); + if (all_memory == NULL) + return 0; + *arr = (char **)all_memory; + all_memory += sizeof (char *) * path_count; + + path_count = 0; + path_list_p = path_list; + char const * next_path_list_p = 0; + do + { + next_path_list_p = strchr (path_list_p, split_char); + if (next_path_list_p != NULL) + { + ++next_path_list_p; + } + size_t this_size = (next_path_list_p != NULL) + ? next_path_list_p - path_list_p - 1 + : &path_list[path_list_size] - path_list_p; + memcpy (all_memory, path_list_p, this_size); + all_memory[this_size] = '\0'; + (*arr)[path_count++] = all_memory; + all_memory += this_size + 1; + } while ((path_list_p = next_path_list_p) != NULL); + + return path_count; +} + +char * +get_relocated_path_list(char const * from, char const * to_path_list) +{ + char exe_path[MAX_PATH]; + char * temp; + get_executable_path (NULL, &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0])); + if ((temp = strrchr (exe_path, '/')) != NULL) + { + temp[1] = '\0'; + } + + char **arr = NULL; + /* Ask Alexey why he added this. Are we not 100% sure + that we're dealing with unix paths here? */ + char split_char = ':'; + if (strchr (to_path_list, ';')) + { + split_char = ';'; + } + size_t count = split_path_list (to_path_list, split_char, &arr); + int result_size = 1 + (count - 1); /* count - 1 is for ; delim. */ + size_t exe_path_size = strlen (exe_path); + size_t i; + /* Space required is: + count * (exe_path_size + strlen (rel_to_datadir)) + rel_to_datadir upper bound is: + (count * strlen (from)) + (3 * num_slashes (from)) + + strlen(arr[i]) + 1. + .. pathalogically num_slashes (from) is strlen (from) + (from = ////////) */ + size_t space_required = (count * (exe_path_size + 4 * strlen (from))) + count - 1; + for (i = 0; i < count; ++i) + { + space_required += strlen (arr[i]); + } + char * scratch = (char *) alloca (space_required); + if (scratch == NULL) + return NULL; + for (i = 0; i < count; ++i) + { + char * rel_to_datadir = get_relative_path (from, arr[i]); + scratch[0] = '\0'; + arr[i] = scratch; + strcat (scratch, exe_path); + strcat (scratch, rel_to_datadir); + simplify_path (arr[i]); + size_t arr_i_size = strlen (arr[i]); + result_size += arr_i_size; + scratch = arr[i] + arr_i_size + 1; + } + char * result = (char *) malloc (result_size); + if (result == NULL) + { + return NULL; + } + result[0] = '\0'; + for (i = 0; i < count; ++i) + { + strcat (result, arr[i]); + if (i != count-1) + { +#if defined(_WIN32) + strcat (result, ";"); +#else + strcat (result, ":"); +#endif + } + } + free ((void*)arr); + return result; +} + +char * +single_path_relocation(const char *from, const char *to) +{ +#if defined(__MINGW32__) + char exe_path[PATH_MAX]; + get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0])); + if (strrchr (exe_path, '/') != NULL) + { + strrchr (exe_path, '/')[1] = '\0'; + } + char * rel_to_datadir = get_relative_path (from, to); + strcat (exe_path, rel_to_datadir); + simplify_path (&exe_path[0]); + return malloc_copy_string(exe_path); +#else + return malloc_copy_string(to); +#endif +} + +char * +pathlist_relocation(const char *from_path, const char *to_path_list) +{ +#if defined(__MINGW32__) + static char stored_path[PATH_MAX]; + static int stored = 0; + if (stored == 0) + { + char const * relocated = get_relocated_path_list(from_path, to_path_list); + strncpy (stored_path, relocated, PATH_MAX); + stored_path[PATH_MAX-1] = '\0'; + free ((void *)relocated); + stored = 1; + } + return stored_path; +#else + return (to_path_list); +#endif +} diff -Naur ImageMagick-6.8.9-8-orig/magick/pathtools.h ImageMagick-6.8.9-8/magick/pathtools.h --- ImageMagick-6.8.9-8-orig/magick/pathtools.h 1970-01-01 03:00:00.000000000 +0300 +++ ImageMagick-6.8.9-8/magick/pathtools.h 1970-01-01 03:00:00.000000000 +0300 @@ -0,0 +1,52 @@ +/* + .Some useful path tools. + .ASCII only for now. + .Written by Ray Donnelly in 2014. + .Licensed under CC0 (and anything. + .else you need to license it under). + .No warranties whatsoever. + .email: . + */ + +#ifndef PATHTOOLS_H +#define PATHTOOLS_H + +#include +#if defined(__APPLE__) +#include +#else +#include +#endif +#include + +char * malloc_copy_string(char const * original); + +/* In-place replaces any '\' with '/' and any '//' with '/' */ +void sanitise_path(char * path); + +/* Uses a host OS specific function to determine the path of the executable, + if IMPLEMENT_SYS_GET_EXECUTABLE_PATH is defined, otherwise uses argv0. */ +int get_executable_path(char const * argv0, char * result, ssize_t max_size); + +/* Where possible, in-place removes occourances of '.' and 'path/..' */ +void simplify_path(char * path); + +/* Allocates (via malloc) and returns the path to get from from to to. */ +char * get_relative_path(char const * from, char const * to); + +size_t split_path_list(char const * path_list, char split_char, char *** arr); + +/* Advances path along by the amount that removes n prefix folders. */ +char const * +strip_n_prefix_folders(char const * path, size_t n); + +/* NULL terminates path to remove n suffix folders. */ +void +strip_n_suffix_folders(char * path, size_t n); + +char * get_relocated_path_list(char const * from, char const * to_path_list); + +char * single_path_relocation(const char *from, const char *to); +char * pathlist_relocation(const char *from_path, const char *to_path_list); + +#endif /* PATHTOOLS_H */ diff -Naur ImageMagick-6.8.9-8-orig/winpath.sh ImageMagick-6.8.9-8/winpath.sh --- ImageMagick-6.8.9-8-orig/winpath.sh 2013-11-18 17:03:16.000000000 +0400 +++ ImageMagick-6.8.9-8/winpath.sh 2014-10-03 15:10:50.573200000 +0400 @@ -16,56 +16,4 @@ # # Written by Bob Friesenhahn, June 2002 # -arg="$1" -escapes=0 -if test -n "$2" -then - escapes="$2" -fi -if test $escapes -gt 3 -then - echo "$0: escape level must in range 0 - 3" - exit 1 -fi -result='' -length=0 -max_length=0 -mount | sed -e 's:\\:/:g' | ( - IFS="\n" - while read mount_entry - do - win_mount_path=`echo "$mount_entry" | sed -e 's: .*::g'` - unix_mount_path=`echo "$mount_entry" | sed -e 's:.* on ::;s: type .*::'` - temp=`echo "$arg" | sed -e "s!^$unix_mount_path!$win_mount_path/!"` - if test "$temp" != "$arg" - then - candidate="$temp" - length=${#unix_mount_path} - if test $length -gt $max_length - then - result=$candidate - max_length=$length - fi - fi - done - if test -z "$result" - then - echo "$0: path \"$arg\" is not mounted" - exit 1 - fi - case $escapes in - 0) - echo "$result" | sed -e 's:/:\\:g' - ;; - 1) - echo "$result" | sed -e 's:/:\\\\:g' - ;; - 2) - echo "$result" | sed -e 's:/:\\\\\\\\:g' - ;; - 3) - echo "$result" | sed -e 's:/:\\\\\\\\\\\\\\\\:g' - ;; - esac - exit 0; - ) +echo "$1"