summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-07-22 04:37:27 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-07-22 04:37:27 +0000
commit804083681e077becd98adb3d86f58c68025e3074 (patch)
treec2cce929e2c45ca1552b9f5b914d61c24c2f1708 /gdk-pixbuf
parent9c002e4abc1942610dc98b827f05e46bf6948634 (diff)
downloadgdk-pixbuf-804083681e077becd98adb3d86f58c68025e3074.tar.gz
Interpret patterns where the first byte of the mask is '*' as unanchored.
2005-07-22 Matthias Clasen <mclasen@redhat.com> * gdk-pixbuf-io.c (format_check): Interpret patterns where the first byte of the mask is '*' as unanchored. (#311011) (gdk_pixbuf_new_from_file): Use the first 256 bytes for sniffing the file format.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog7
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c60
2 files changed, 44 insertions, 23 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index a58d80bf9..c79228407 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,10 @@
+2005-07-22 Matthias Clasen <mclasen@redhat.com>
+
+ * gdk-pixbuf-io.c (format_check): Interpret patterns where
+ the first byte of the mask is '*' as unanchored. (#311011)
+ (gdk_pixbuf_new_from_file): Use the first 256 bytes for
+ sniffing the file format.
+
2005-07-15 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.3 ===
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index dc0408d2f..a8faa782f 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -48,32 +48,46 @@
static gint
format_check (GdkPixbufModule *module, guchar *buffer, int size)
{
- int j;
+ int i, j;
gchar m;
GdkPixbufModulePattern *pattern;
+ gboolean unanchored;
+ guchar *prefix, *mask;
for (pattern = module->info->signature; pattern->prefix; pattern++) {
- for (j = 0; j < size && pattern->prefix[j] != 0; j++) {
- m = pattern->mask ? pattern->mask[j] : ' ';
- if (m == ' ') {
- if (buffer[j] != pattern->prefix[j])
- break;
- }
- else if (m == '!') {
- if (buffer[j] == pattern->prefix[j])
- break;
- }
- else if (m == 'z') {
- if (buffer[j] != 0)
- break;
- }
- else if (m == 'n') {
- if (buffer[j] == 0)
- break;
- }
- }
- if (pattern->prefix[j] == 0)
- return pattern->relevance;
+ if (pattern->mask && pattern->mask[0] == '*') {
+ prefix = pattern->prefix + 1;
+ mask = pattern->mask + 1;
+ unanchored = TRUE;
+ }
+ else {
+ prefix = pattern->prefix;
+ mask = pattern->mask;
+ unanchored = FALSE;
+ }
+ for (i = 0; unanchored && i < size; i++) {
+ for (j = 0; i + j < size && prefix[j] != 0; j++) {
+ m = mask ? mask[j] : ' ';
+ if (m == ' ') {
+ if (buffer[i + j] != prefix[j])
+ break;
+ }
+ else if (m == '!') {
+ if (buffer[i + j] == prefix[j])
+ break;
+ }
+ else if (m == 'z') {
+ if (buffer[i + j] != 0)
+ break;
+ }
+ else if (m == 'n') {
+ if (buffer[i + j] == 0)
+ break;
+ }
+ }
+ if (prefix[j] == 0)
+ return pattern->relevance;
+ }
}
return 0;
}
@@ -821,7 +835,7 @@ gdk_pixbuf_new_from_file (const char *filename,
GdkPixbuf *pixbuf;
int size;
FILE *f;
- guchar buffer [128];
+ guchar buffer[256];
GdkPixbufModule *image_module;
gchar *display_name;