From 79bb6f0c99ceeeff529f07101edd47747d7b8e45 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 2 Aug 2013 17:01:55 +0200 Subject: hotfix for meh using giflib 5.x Fixes #6 --- src/gif.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gif.c b/src/gif.c index 61b30a9..fe4c090 100644 --- a/src/gif.c +++ b/src/gif.c @@ -32,7 +32,11 @@ static struct image *gif_open(FILE *f){ /* HACK HACK HACK */ rewind(f); lseek(fileno(f), 0L, SEEK_SET); +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 + if(!(gif = DGifOpenFileHandle(fileno(f), NULL))){ +#else if(!(gif = DGifOpenFileHandle(fileno(f)))){ +#endif /* HACK AND HOPE */ rewind(f); lseek(fileno(f), 0L, SEEK_SET); @@ -55,8 +59,9 @@ static int gif_read(struct image *img){ struct gif_t *g = (struct gif_t *)img; GifColorType *colormap; SavedImage *s; + int ret; - if(DGifSlurp(g->gif) == GIF_ERROR) + if((ret = DGifSlurp(g->gif)) != GIF_OK) goto error; s = &g->gif->SavedImages[0]; @@ -79,8 +84,10 @@ static int gif_read(struct image *img){ return 0; error: -#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4) - fprintf(stderr, "%s\n", GifErrorString()); +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 + fprintf(stderr, "GIFLIB: %s\n", GifErrorString(ret)); +#elif defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4) + fprintf(stderr, "GIFLIB: %s\n", GifErrorString()); #else PrintGifError(); #endif -- cgit v1.2.3