summaryrefslogtreecommitdiff
path: root/src/Fl_SVG_Image.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-10-21 14:02:55 +0000
committerManolo Gouy <Manolo>2017-10-21 14:02:55 +0000
commit1a153d7899dce54cccf6cc873bec3eb821988a10 (patch)
tree5d4509f65cbd08596720cdc1688458b143201f8b /src/Fl_SVG_Image.cxx
parent071f4912a72a12718a9cd4fb53758feaa375bd51 (diff)
Fl_SVG_Image: remove use of gzdirect() that is absent in some old versions of zlib
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12519 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_SVG_Image.cxx')
-rw-r--r--src/Fl_SVG_Image.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx
index d631e6a76..557388c49 100644
--- a/src/Fl_SVG_Image.cxx
+++ b/src/Fl_SVG_Image.cxx
@@ -79,15 +79,19 @@ float Fl_SVG_Image::svg_scaling_(int W, int H) {
#if defined(HAVE_LIBZ)
static char *svg_inflate(const char *fname) {
- struct stat b;
- fl_stat(fname, &b);
- long size = b.st_size;
+ FILE *in = fl_fopen(fname, "r");
+ if (!in) return NULL;
+ unsigned char header[2];
+ fread(header, 2, 1, in);
+ int direct = (header[0] != 0x1f || header[1] != 0x8b);
+ fseek(in, 0, SEEK_END);
+ long size = ftell(in);
+ fclose(in);
int fd = fl_open_ext(fname, 1, 0);
if (fd < 0) return NULL;
gzFile gzf = gzdopen(fd, "r");
if (!gzf) return NULL;
int l;
- int direct = gzdirect(gzf);
long out_size = direct ? size + 1 : 3*size + 1;
char *out = (char*)malloc(out_size);
char *p = out;