X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdgif_lib.c;h=df67571e9baad8efc69bc66ae41d56f031ce4875;hb=f0e0a4c7571df85198f5dab18d97dcb71f2971a5;hp=d56832d0d295d0600809eeeb4e50b65c94b97228;hpb=fb022c5b8ea6aca36b9661a6b2707afdd07e4c05;p=chise%2Fxemacs-chise.git.1 diff --git a/src/dgif_lib.c b/src/dgif_lib.c index d56832d..df67571 100644 --- a/src/dgif_lib.c +++ b/src/dgif_lib.c @@ -11,23 +11,10 @@ * 19 Feb 98 - Version 1.2 by Jareth Hein (Support for user specified I/O) * ******************************************************************************/ -#ifdef __MSDOS__ -#include -#include -#include -#include -#else -#include -#include -#endif /* __MSDOS__ */ - -#include -#include -#include +#include +#include "lisp.h" -#ifdef HAVE_FCNTL_H -#include -#endif +#include "sysfile.h" #include "gifrlib.h" @@ -52,11 +39,11 @@ void DGifOpenFileName(GifFileType *GifFile, const char *FileName) FILE *f; if ((f = fopen(FileName, -#ifdef __MSDOS__ +#ifdef WIN32_NATIVE "rb" #else "r" -#endif /* __MSDOS__ */ +#endif /* WIN32_NATIVE */ )) == NULL) GifInternError(GifFile, D_GIF_ERR_OPEN_FAILED); @@ -73,13 +60,13 @@ void DGifOpenFileHandle(GifFileType *GifFile, int FileHandle) { FILE *f; -#ifdef __MSDOS__ +#ifdef WIN32_NATIVE setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ #else f = fdopen(FileHandle, "r"); /* Make it into a stream: */ -#endif /* __MSDOS__ */ +#endif /* WIN32_NATIVE */ GifStdIOInit(GifFile, f, -1); DGifInitRead(GifFile); @@ -110,9 +97,9 @@ void DGifInitRead(GifFileType *GifFile) /* The GIF Version number is ignored at this time. Maybe we should do */ /* something more useful with it. */ Buf[GIF_STAMP_LEN] = 0; - if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) { + if (strncmp(GIF_STAMP, (const char *) Buf, GIF_VERSION_POS) != 0) { GifInternError(GifFile, D_GIF_ERR_NOT_GIF_FILE); - } + } DGifGetScreenDesc(GifFile); } @@ -249,7 +236,7 @@ void DGifGetImageDesc(GifFileType *GifFile) MakeMapObject (GifFile->Image.ColorMap->ColorCount, GifFile->Image.ColorMap->Colors); } - sp->RasterBits = (GifPixelType *)NULL; + sp->RasterBits = NULL; sp->ExtensionBlockCount = 0; sp->ExtensionBlocks = (ExtensionBlock *)NULL; } @@ -277,11 +264,11 @@ void DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) if (!LineLen) LineLen = GifFile->Image.Width; -#if defined(__MSDOS__) || defined(__GNUC__) +#if defined(WIN32_NATIVE) || defined(__GNUC__) if ((Private->PixelCount -= LineLen) > 0xffff0000UL) #else if ((Private->PixelCount -= LineLen) > 0xffff0000) -#endif /* __MSDOS__ */ +#endif /* WIN32_NATIVE */ { GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); } @@ -310,11 +297,11 @@ void DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) GifInternError(GifFile, D_GIF_ERR_NOT_READABLE); } -#if defined(__MSDOS__) || defined(__GNUC__) +#if defined(WIN32_NATIVE) || defined(__GNUC__) if (--Private->PixelCount > 0xffff0000UL) #else if (--Private->PixelCount > 0xffff0000) -#endif /* __MSDOS__ */ +#endif /* WIN32_NATIVE */ { GifInternError(GifFile, D_GIF_ERR_DATA_TOO_BIG); } @@ -379,10 +366,11 @@ void DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) ******************************************************************************/ int DGifCloseFile(GifFileType *GifFile) { - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; + GifFilePrivateType *Private; if (GifFile == NULL) return -1; + Private = (GifFilePrivateType *)GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ @@ -745,7 +733,7 @@ void DGifSlurp(GifFileType *GifFile) ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height; sp->RasterBits - = (GifPixelType*) malloc(ImageSize * sizeof(GifPixelType)); + = (GifPixelType*) malloc (ImageSize * sizeof(GifPixelType)); DGifGetLine(GifFile, sp->RasterBits, ImageSize); break; @@ -753,11 +741,11 @@ void DGifSlurp(GifFileType *GifFile) case EXTENSION_RECORD_TYPE: DGifGetExtension(GifFile,&sp->Function,&ExtData); - do { + while (ExtData != NULL) { if (AddExtensionBlock(sp, ExtData[0], ExtData+1) == GIF_ERROR) GifInternError(GifFile, D_GIF_ERR_NOT_ENOUGH_MEM); DGifGetExtensionNext(GifFile, &ExtData); - } while (ExtData != NULL); + } break; case TERMINATE_RECORD_TYPE: @@ -856,7 +844,7 @@ SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom) CopyFrom->ImageDesc.ColorMap->Colors); /* next, the raster */ - sp->RasterBits = (char *)malloc(sizeof(GifPixelType) + sp->RasterBits = (GifPixelType *) malloc(sizeof(GifPixelType) * CopyFrom->ImageDesc.Height * CopyFrom->ImageDesc.Width); memcpy(sp->RasterBits, @@ -911,7 +899,7 @@ void FreeSavedImages(GifFileType *GifFile) * Miscellaneous utility functions * ******************************************************************************/ -int BitSize(int n) +static int BitSize(int n) /* return smallest bitfield size n will fit in */ { register int i; @@ -943,7 +931,10 @@ ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap) Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType)); if (Object->Colors == (GifColorType *)NULL) + { + free (Object); return((ColorMapObject *)NULL); + } Object->ColorCount = ColorCount; Object->BitsPerPixel = BitSize(ColorCount);