[gdk-pixbuf/wip/otte/tga] tests: Implement format_supported() differently
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/wip/otte/tga] tests: Implement format_supported() differently
- Date: Mon, 12 Oct 2015 15:17:28 +0000 (UTC)
commit ac18382871eb1f16065ecdb7eb84ae88025e8bde
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 6 04:17:03 2015 +0200
tests: Implement format_supported() differently
Instead of using
strstr (filename, modulename);
use
has_suffix (filenname, extension_supported_by_module);
That way, files can be named .jpg and .jpeg without things going wrong.
tests/test-common.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/tests/test-common.c b/tests/test-common.c
index fef9d94..0f4e4c0 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -29,35 +29,29 @@
gboolean
format_supported (const gchar *filename)
{
- const gchar *name = NULL;
GSList *formats, *l;
gboolean retval;
- const gchar *names[] = { "png", "jpeg", "bmp", "gif", "ras",
- "tga", "xpm", "xbm", "ico", "tiff" };
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (names); i++)
- {
- if (strstr (filename, names[i]))
- {
- name = names[i];
- break;
- }
- }
- if (name == NULL)
- return FALSE;
retval = FALSE;
formats = gdk_pixbuf_get_formats ();
for (l = formats; l; l = l->next)
{
GdkPixbufFormat *format = l->data;
+ char **extensions = gdk_pixbuf_format_get_extensions (format);
+ gint i;
- if (g_str_equal (gdk_pixbuf_format_get_name (format), name))
+ for (i = 0; extensions[i]; i++)
{
- retval = TRUE;
- break;
+ if (g_str_has_suffix (filename, extensions[i]))
+ {
+ retval = TRUE;
+ break;
+ }
}
+
+ g_free (extensions);
+ if (retval)
+ break;
}
g_slist_free (formats);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]