forked from old/legacy-imlib2
gz, bz2 loaders: Fix recent breakage when file name has more than two dots
This commit is contained in:
parent
1a0c29c873
commit
8bd07dbcea
|
@ -51,14 +51,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
ImlibLoader *loader;
|
ImlibLoader *loader;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int dest, res;
|
int dest, res;
|
||||||
char *file, *p, *q, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
|
const char *s, *p, *q;
|
||||||
char *real_ext;
|
char tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
|
||||||
|
char *file, *real_ext;
|
||||||
|
|
||||||
/* make sure this file ends in ".bz2" and that there's another ext
|
/* make sure this file ends in ".bz2" and that there's another ext
|
||||||
* (e.g. "foo.png.bz2") */
|
* (e.g. "foo.png.bz2") */
|
||||||
p = strrchr(im->real_file, '.');
|
for (s = im->real_file, p = q = NULL; *s; s++)
|
||||||
q = strchr(im->real_file, '.');
|
{
|
||||||
if (!p || p == im->real_file || strcasecmp(p + 1, "bz2") || p == q)
|
if (*s != '.')
|
||||||
|
continue;
|
||||||
|
q = p;
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
if (!q || q == im->real_file || strcasecmp(p + 1, "bz2"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
||||||
|
|
|
@ -44,14 +44,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
ImlibLoader *loader;
|
ImlibLoader *loader;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int dest, res;
|
int dest, res;
|
||||||
char *file, *p, *q, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
const char *s, *p, *q;
|
||||||
char *real_ext;
|
char tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
||||||
|
char *file, *real_ext;
|
||||||
|
|
||||||
/* make sure this file ends in ".gz" and that there's another ext
|
/* make sure this file ends in ".gz" and that there's another ext
|
||||||
* (e.g. "foo.png.gz") */
|
* (e.g. "foo.png.gz") */
|
||||||
p = strrchr(im->real_file, '.');
|
for (s = im->real_file, p = q = NULL; *s; s++)
|
||||||
q = strchr(im->real_file, '.');
|
{
|
||||||
if (!p || p == im->real_file || strcasecmp(p + 1, "gz") || p == q)
|
if (*s != '.')
|
||||||
|
continue;
|
||||||
|
q = p;
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
if (!q || q == im->real_file || strcasecmp(p + 1, "gz"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
if (!(real_ext = strndup(q + 1, p - q - 1)))
|
||||||
|
|
Loading…
Reference in New Issue