gutenprint/gutenprint-postscriptdriver.patch

100 lines
3.3 KiB
Diff

diff -up gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver gutenprint-5.2.6/src/main/gutenprint-internal.h
--- gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver 2010-08-04 02:33:56.000000000 +0200
+++ gutenprint-5.2.6/src/main/gutenprint-internal.h 2010-08-11 16:11:19.000000000 +0200
@@ -56,6 +56,8 @@ extern void stpi_init_printer(void);
#define BUFFER_FLAG_FLIP_X 0x1
#define BUFFER_FLAG_FLIP_Y 0x2
extern stp_image_t* stpi_buffer_image(stp_image_t* image, unsigned int flags);
+extern stp_list_t *stp_paths_copy_with_prefix(stp_list_t* list,
+ const char *prefix);
#define STPI_ASSERT(x,v) \
do \
diff -up gutenprint-5.2.6/src/main/module.c.postscriptdriver gutenprint-5.2.6/src/main/module.c
--- gutenprint-5.2.6/src/main/module.c.postscriptdriver 2006-09-30 17:02:59.000000000 +0200
+++ gutenprint-5.2.6/src/main/module.c 2010-08-11 16:13:43.000000000 +0200
@@ -151,12 +151,20 @@ int stp_module_load(void)
}
else
{
+ const char *prefix = getenv("DESTDIR");
#ifdef USE_LTDL
stp_path_split(dir_list, getenv("LTDL_LIBRARY_PATH"));
stp_path_split(dir_list, lt_dlgetsearchpath());
#else
stp_path_split(dir_list, PKGMODULEDIR);
#endif
+ if (prefix)
+ {
+ stp_list_t *prefix_list;
+ prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
+ stp_list_destroy(dir_list);
+ dir_list = prefix_list;
+ }
}
#ifdef USE_LTDL
file_list = stp_path_search(dir_list, ".la");
diff -up gutenprint-5.2.6/src/main/path.c.postscriptdriver gutenprint-5.2.6/src/main/path.c
--- gutenprint-5.2.6/src/main/path.c.postscriptdriver 2008-06-01 16:41:18.000000000 +0200
+++ gutenprint-5.2.6/src/main/path.c 2010-08-11 16:13:43.000000000 +0200
@@ -158,7 +158,17 @@ stpi_data_path(void)
if (getenv("STP_DATA_PATH"))
stp_path_split(dir_list, getenv("STP_DATA_PATH"));
else
- stp_path_split(dir_list, PKGXMLDATADIR);
+ {
+ const char *prefix = getenv("DESTDIR");
+ stp_path_split(dir_list, PKGXMLDATADIR);
+ if (prefix)
+ {
+ stp_list_t *prefix_list;
+ prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
+ stp_list_destroy(dir_list);
+ dir_list = prefix_list;
+ }
+ }
return dir_list;
}
@@ -226,6 +236,40 @@ stp_path_split(stp_list_t *list, /* List
}
}
+/*
+ * Split a PATH-type string (colon-delimited) into separate
+ * directories.
+ */
+stp_list_t *
+stp_paths_copy_with_prefix(stp_list_t *list, /* List to add prefix to */
+ const char *prefix) /* Prefix to add */
+{
+ stp_list_t *new_list;
+ stp_list_item_t *item;
+ int prefixlen = strlen (prefix);
+ if (!(new_list = stp_list_create()))
+ return;
+
+ item = stp_list_get_start (list);
+ while (item)
+ {
+ const char *data;
+ char *new_data;
+ int len;
+ data = stp_list_item_get_data (item);
+ len = strlen (data);
+ new_data = (char *) stp_malloc(prefixlen + 1 + len + 1);
+ strncpy(new_data, prefix, prefixlen);
+ new_data[prefixlen] = '/';
+ strcpy(new_data + prefixlen + 1, data);
+ stp_list_item_create(new_list, NULL, new_data);
+
+ item = stp_list_item_next (item);
+ }
+
+ return new_list;
+}
+
/* Adapted from GNU libc <dirent.h>
These macros extract size information from a `struct dirent *'.
They may evaluate their argument multiple times, so it must not