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.
This commit is contained in:
parent
9c002e4abc
commit
804083681e
@ -1,3 +1,8 @@
|
|||||||
|
2005-07-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk-pixbuf/tmpl/module_interface.sgml: Document unanchored
|
||||||
|
patterns.
|
||||||
|
|
||||||
2005-07-21 Federico Mena Quintero <federico@ximian.com>
|
2005-07-21 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
* gtk/tmpl/gtkfilechooserdialog.sgml (dialog): Expand the Save
|
* gtk/tmpl/gtkfilechooserdialog.sgml (dialog): Expand the Save
|
||||||
|
@ -204,14 +204,19 @@ operations.
|
|||||||
<!-- ##### STRUCT GdkPixbufModulePattern ##### -->
|
<!-- ##### STRUCT GdkPixbufModulePattern ##### -->
|
||||||
<para>
|
<para>
|
||||||
The signature of a module is a set of prefixes. Prefixes are encoded as
|
The signature of a module is a set of prefixes. Prefixes are encoded as
|
||||||
pairs of ordinary strings, where the second string, if not %NULL, must be
|
pairs of ordinary strings, where the second string, called the mask, if
|
||||||
of the same length as the first one and may contain ' ', '!', 'x', 'z',
|
not %NULL, must be of the same length as the first one and may contain
|
||||||
and 'n' to indicate bytes that must be matched, not matched,
|
' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
|
||||||
"don't-care"-bytes, zeros and non-zeros.
|
not matched, "don't-care"-bytes, zeros and non-zeros.
|
||||||
Each prefix has an associated integer that describes the relevance of
|
Each prefix has an associated integer that describes the relevance of
|
||||||
the prefix, with 0 meaning a mismatch and 100 a "perfect match".
|
the prefix, with 0 meaning a mismatch and 100 a "perfect match".
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
|
||||||
|
indicating an unanchored pattern that matches not only at the beginning,
|
||||||
|
but also in the middle. Versions prior to 2.8 will interpret the '*'
|
||||||
|
like an 'x'.
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The signature of a module is stored as an array of
|
The signature of a module is stored as an array of
|
||||||
#GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
|
#GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
|
||||||
|
@ -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>
|
2005-07-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* === Released 2.7.3 ===
|
* === Released 2.7.3 ===
|
||||||
|
@ -48,33 +48,47 @@
|
|||||||
static gint
|
static gint
|
||||||
format_check (GdkPixbufModule *module, guchar *buffer, int size)
|
format_check (GdkPixbufModule *module, guchar *buffer, int size)
|
||||||
{
|
{
|
||||||
int j;
|
int i, j;
|
||||||
gchar m;
|
gchar m;
|
||||||
GdkPixbufModulePattern *pattern;
|
GdkPixbufModulePattern *pattern;
|
||||||
|
gboolean unanchored;
|
||||||
|
guchar *prefix, *mask;
|
||||||
|
|
||||||
for (pattern = module->info->signature; pattern->prefix; pattern++) {
|
for (pattern = module->info->signature; pattern->prefix; pattern++) {
|
||||||
for (j = 0; j < size && pattern->prefix[j] != 0; j++) {
|
if (pattern->mask && pattern->mask[0] == '*') {
|
||||||
m = pattern->mask ? pattern->mask[j] : ' ';
|
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 (m == ' ') {
|
||||||
if (buffer[j] != pattern->prefix[j])
|
if (buffer[i + j] != prefix[j])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (m == '!') {
|
else if (m == '!') {
|
||||||
if (buffer[j] == pattern->prefix[j])
|
if (buffer[i + j] == prefix[j])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (m == 'z') {
|
else if (m == 'z') {
|
||||||
if (buffer[j] != 0)
|
if (buffer[i + j] != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (m == 'n') {
|
else if (m == 'n') {
|
||||||
if (buffer[j] == 0)
|
if (buffer[i + j] == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pattern->prefix[j] == 0)
|
if (prefix[j] == 0)
|
||||||
return pattern->relevance;
|
return pattern->relevance;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +835,7 @@ gdk_pixbuf_new_from_file (const char *filename,
|
|||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
int size;
|
int size;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
guchar buffer [128];
|
guchar buffer[256];
|
||||||
GdkPixbufModule *image_module;
|
GdkPixbufModule *image_module;
|
||||||
gchar *display_name;
|
gchar *display_name;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user