summaryrefslogtreecommitdiff
path: root/test/XpmWrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/XpmWrite.c')
-rw-r--r--test/XpmWrite.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/XpmWrite.c b/test/XpmWrite.c
index 53e010e..10b6207 100644
--- a/test/XpmWrite.c
+++ b/test/XpmWrite.c
@@ -60,6 +60,22 @@ is_compressed(const char *filepath)
}
/*
+ * If a filename ends in ".Z" or ".gz", remove that extension to avoid
+ * confusing libXpm into applying compression when not desired.
+ */
+static inline void
+strip_compress_ext(char *filepath)
+{
+ char *ext = strrchr(filepath, '.');
+
+ if ((ext != NULL) &&
+ (((ext[1] == 'Z') && (ext[2] == 0)) ||
+ ((ext[1] == 'g') && (ext[2] == 'z') && (ext[3] == 0)))) {
+ *ext = '\0';
+ }
+}
+
+/*
* XpmWriteFileFromXpmImage - Write XPM files without requiring an X Display
*/
static void
@@ -114,6 +130,7 @@ TestWriteFileFromXpmImage(const gchar *filepath)
g_assert_no_error(err);
filename = g_path_get_basename(filepath);
+ strip_compress_ext(filename);
newfilepath = g_build_filename(testdir, filename, NULL);
test_WFFXI_helper(newfilepath, &imageA, &infoA);
@@ -123,10 +140,12 @@ TestWriteFileFromXpmImage(const gchar *filepath)
test_WFFXI_helper(cmpfilepath, &imageA, &infoA);
g_free(cmpfilepath);
+#ifdef XPM_PATH_COMPRESS
cmpfilepath = g_strdup_printf("%s.Z", newfilepath);
test_WFFXI_helper(cmpfilepath, &imageA, &infoA);
g_free(cmpfilepath);
#endif
+#endif
XpmFreeXpmImage(&imageA);
XpmFreeXpmInfo(&infoA);
@@ -203,6 +222,7 @@ TestWriteFileFromData(const gchar *filepath)
g_assert_no_error(err);
filename = g_path_get_basename(filepath);
+ strip_compress_ext(filename);
newfilepath = g_build_filename(testdir, filename, NULL);
test_WFFXD_helper(newfilepath, data);
@@ -212,10 +232,12 @@ TestWriteFileFromData(const gchar *filepath)
test_WFFXD_helper(cmpfilepath, data);
g_free(cmpfilepath);
+#ifdef XPM_PATH_COMPRESS
cmpfilepath = g_strdup_printf("%s.Z", newfilepath);
test_WFFXD_helper(cmpfilepath, data);
g_free(cmpfilepath);
#endif
+#endif
XpmFree(data);
@@ -259,6 +281,7 @@ TestWriteFileFromBuffer(const gchar *filepath)
g_assert_no_error(err);
filename = g_path_get_basename(filepath);
+ strip_compress_ext(filename);
newfilepath = g_build_filename(testdir, filename, NULL);
g_test_message("...writing %s", newfilepath);