meh-giflib.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. diff -u -r meh-0.3/src/gif.c meh-0.3-git/src/gif.c
  2. --- meh-0.3/src/gif.c 2010-01-04 17:45:01.000000000 +0000
  3. +++ meh-0.3-git/src/gif.c 2015-08-27 16:11:39.082286073 +0100
  4. @@ -32,7 +32,11 @@
  5. /* HACK HACK HACK */
  6. rewind(f);
  7. lseek(fileno(f), 0L, SEEK_SET);
  8. +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
  9. + if(!(gif = DGifOpenFileHandle(fileno(f), NULL))){
  10. +#else
  11. if(!(gif = DGifOpenFileHandle(fileno(f)))){
  12. +#endif
  13. /* HACK AND HOPE */
  14. rewind(f);
  15. lseek(fileno(f), 0L, SEEK_SET);
  16. @@ -55,11 +59,10 @@
  17. struct gif_t *g = (struct gif_t *)img;
  18. GifColorType *colormap;
  19. SavedImage *s;
  20. + int ret;
  21. - if(DGifSlurp(g->gif) == GIF_ERROR){
  22. - PrintGifError();
  23. - return 1;
  24. - }
  25. + if((ret = DGifSlurp(g->gif)) != GIF_OK)
  26. + goto error;
  27. s = &g->gif->SavedImages[0];
  28. @@ -67,10 +70,8 @@
  29. colormap = s->ImageDesc.ColorMap->Colors;
  30. else if(g->gif->SColorMap)
  31. colormap = g->gif->SColorMap->Colors;
  32. - else{
  33. - PrintGifError();
  34. - return 1;
  35. - }
  36. + else
  37. + goto error;
  38. for(i = 0; i < img->bufwidth * img->bufheight; i++){
  39. unsigned char idx = s->RasterBits[i];
  40. @@ -82,11 +83,37 @@
  41. img->state |= LOADED | SLOWLOADED;
  42. return 0;
  43. +error:
  44. +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
  45. + fprintf(stderr, "GIFLIB: %s\n", GifErrorString(ret));
  46. +#elif defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
  47. + fprintf(stderr, "GIFLIB: %s\n", GifErrorString());
  48. +#else
  49. + PrintGifError();
  50. +#endif
  51. + return 1;
  52. }
  53. void gif_close(struct image *img){
  54. struct gif_t *g = (struct gif_t *)img;
  55. +#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1)
  56. + int ret;
  57. +#endif
  58. +
  59. +#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1)
  60. + DGifCloseFile(g->gif,&ret);
  61. + if(ret != GIF_OK) {
  62. +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
  63. + fprintf(stderr, "GIFLIB: %s\n", GifErrorString(ret));
  64. +#elif defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
  65. + fprintf(stderr, "GIFLIB: %s\n", GifErrorString());
  66. +#else
  67. + PrintGifError();
  68. +#endif
  69. + }
  70. +#else
  71. DGifCloseFile(g->gif);
  72. +#endif
  73. fclose(g->f);
  74. }