Skip to content

Instantly share code, notes, and snippets.

@scottjg
Last active August 29, 2015 14:14
Show Gist options
  • Save scottjg/19c85ba39817ceaba1c4 to your computer and use it in GitHub Desktop.
Save scottjg/19c85ba39817ceaba1c4 to your computer and use it in GitHub Desktop.
patch for swftools 0.9.2 and giflib5
diff -ru swftools-0.9.2.orig/src/gif2swf.c swftools-0.9.2/src/gif2swf.c
--- swftools-0.9.2.orig/src/gif2swf.c 2011-01-01 19:30:29.000000000 -0800
+++ swftools-0.9.2/src/gif2swf.c 2015-01-30 17:17:10.000000000 -0800
@@ -65,6 +65,17 @@
RESTORE_TO_PREVIOUS
};
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+void
+PrintGifError(int ErrorCode) {
+ const char *Err = GifErrorString(ErrorCode);
+
+ if (Err != NULL)
+ fprintf(stderr, "GIF-LIB error: %s.\n", Err);
+ else
+ fprintf(stderr, "GIF-LIB undefined error %d.\n", ErrorCode);
+}
+#endif
void SetFrameAction(TAG ** t, const char *src, int ver)
{
@@ -230,13 +241,21 @@
}
fclose(fi);
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ if ((gft = DGifOpenFileName(sname, NULL)) == NULL) {
+#else
if ((gft = DGifOpenFileName(sname)) == NULL) {
+#endif
fprintf(stderr, "%s is not a GIF file!\n", sname);
return t;
}
if (DGifSlurp(gft) != GIF_OK) {
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ PrintGifError(gft->Error);
+#else
PrintGifError();
+#endif
return t;
}
@@ -455,7 +474,12 @@
free(pal);
free(imagedata);
+
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gft, NULL);
+#else
DGifCloseFile(gft);
+#endif
return t;
}
@@ -488,7 +512,11 @@
}
fclose(fi);
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ if ((gft = DGifOpenFileName(s, NULL)) == NULL) {
+#else
if ((gft = DGifOpenFileName(s)) == NULL) {
+#endif
fprintf(stderr, "%s is not a GIF file!\n", fname);
return -1;
}
@@ -499,7 +527,11 @@
global.max_image_height = gft->SHeight;
if (DGifSlurp(gft) != GIF_OK) {
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ PrintGifError(gft->Error);
+#else
PrintGifError();
+#endif
return -1;
}
// After DGifSlurp() call, gft->ImageCount become available
@@ -518,7 +550,11 @@
fprintf(stderr, "frame: %u, delay: %.3f sec\n", i + 1, getGifDelayTime(gft, i) / 100.0);
}
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gft, NULL);
+#else
DGifCloseFile(gft);
+#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment