Imported Upstream version 5.1.9 into tizen
[platform/upstream/giflib.git] / giftext.c
similarity index 97%
rename from util/giftext.c
rename to giftext.c
index 864f2d5..523ada9 100644 (file)
+++ b/giftext.c
@@ -315,11 +315,11 @@ static void PrintCodeBlock(GifFileType *GifFile, GifByteType *CodeBlock, bool Re
 {
     static int CrntPlace = 0; 
     static long CodeCount = 0;
-    int i, Percent, Len;
-    long NumBytes;
+    int i, Len;
 
     if (Reset || CodeBlock == NULL) {
        if (CodeBlock == NULL) {
+           long NumBytes = 0;
            if (CrntPlace > 0) {
                printf("\n");
                CodeCount += CrntPlace - 16;
@@ -327,12 +327,15 @@ static void PrintCodeBlock(GifFileType *GifFile, GifByteType *CodeBlock, bool Re
            if (GifFile->Image.ColorMap)
                NumBytes = ((((long) GifFile->Image.Width) * GifFile->Image.Height)
                                * GifFile->Image.ColorMap->BitsPerPixel) / 8;
-           else
+           else if (GifFile->SColorMap != NULL)
                NumBytes = ((((long) GifFile->Image.Width) * GifFile->Image.Height)
                                * GifFile->SColorMap->BitsPerPixel) / 8;
-           Percent = 100 * CodeCount / NumBytes;
-           printf("\nCompression ratio: %ld/%ld (%d%%).\n",
+           /* FIXME: What should the compression ratio be if no color table? */
+           if (NumBytes > 0) {
+               int Percent = 100 * CodeCount / NumBytes;
+               printf("\nCompression ratio: %ld/%ld (%d%%).\n",
                        CodeCount, NumBytes, Percent);
+           }
            return;
        }
        CrntPlace = 0;