diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-25 17:17:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-25 17:17:36 (GMT) |
commit | 2de66fa92b783d8956a5df8852deba5fc3af6aa3 (patch) | |
tree | 695b0deaad3dc9c50923e0e580c08bfc73b021ea /generic | |
parent | 1c3ec3130a20b461eed9361fad3c67a8240e14d4 (diff) | |
download | tk-2de66fa92b783d8956a5df8852deba5fc3af6aa3.zip tk-2de66fa92b783d8956a5df8852deba5fc3af6aa3.tar.gz tk-2de66fa92b783d8956a5df8852deba5fc3af6aa3.tar.bz2 |
Don't use -encoding "binary" any more in Tk. Backport some more formatting changes
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkImgBmap.c | 46 | ||||
-rw-r--r-- | generic/tkImgGIF.c | 45 | ||||
-rw-r--r-- | generic/tkImgPNG.c | 21 | ||||
-rw-r--r-- | generic/tkImgPPM.c | 13 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 155 |
5 files changed, 131 insertions, 149 deletions
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index a7fd14e..f02b560 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -77,15 +77,15 @@ static int GetByte(Tcl_Channel chan); static int ImgBmapCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); -static ClientData ImgBmapGet(Tk_Window tkwin, ClientData clientData); -static void ImgBmapDisplay(ClientData clientData, + void **clientDataPtr); +static void *ImgBmapGet(Tk_Window tkwin, void *clientData); +static void ImgBmapDisplay(void *clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, int height, int drawableX, int drawableY); -static void ImgBmapFree(ClientData clientData, Display *display); -static void ImgBmapDelete(ClientData clientData); -static int ImgBmapPostscript(ClientData clientData, +static void ImgBmapFree(void *clientData, Display *display); +static void ImgBmapDelete(void *clientData); +static int ImgBmapPostscript(void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass); @@ -145,9 +145,9 @@ typedef struct ParseInfo { * Prototypes for procedures used only locally in this file: */ -static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, +static int ImgBmapCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static void ImgBmapCmdDeletedProc(ClientData clientData); +static void ImgBmapCmdDeletedProc(void *clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); static int ImgBmapConfigureModel(BitmapModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); @@ -180,7 +180,7 @@ ImgBmapCreate( TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */ Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ - ClientData *clientDataPtr) /* Store manager's token for image here; it + void **clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { BitmapModel *modelPtr = (BitmapModel *)ckalloc(sizeof(BitmapModel)); @@ -513,10 +513,6 @@ TkGetBitmapData( != TCL_OK) { return NULL; } - if (Tcl_SetChannelOption(interp, pi.chan, "-encoding", "binary") - != TCL_OK) { - return NULL; - } } else { pi.chan = NULL; } @@ -744,7 +740,7 @@ NextBitmapWord( static int ImgBmapCmd( - ClientData clientData, /* Information about the image model. */ + void *clientData, /* Information about the image model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -768,14 +764,14 @@ ImgBmapCmd( return TCL_ERROR; } return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) modelPtr, Tcl_GetString(objv[2]), 0); + (char *)modelPtr, Tcl_GetString(objv[2]), 0); case 1: /* configure */ if (objc == 2) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, NULL, 0); + configSpecs, (char *)modelPtr, NULL, 0); } else if (objc == 3) { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, + configSpecs, (char *)modelPtr, Tcl_GetString(objv[2]), 0); } else { return ImgBmapConfigureModel(modelPtr, objc-2, objv+2, @@ -805,11 +801,11 @@ ImgBmapCmd( *---------------------------------------------------------------------- */ -static ClientData +static void * ImgBmapGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ - ClientData modelData) /* Pointer to our model structure for the + void *modelData) /* Pointer to our model structure for the * image. */ { BitmapModel *modelPtr = (BitmapModel *)modelData; @@ -876,7 +872,7 @@ ImgBmapGet( static void ImgBmapDisplay( - ClientData clientData, /* Pointer to BitmapInstance structure for + void *clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display, /* Display on which to draw image. */ Drawable drawable, /* Pixmap or window in which to draw image. */ @@ -937,7 +933,7 @@ ImgBmapDisplay( static void ImgBmapFree( - ClientData clientData, /* Pointer to BitmapInstance structure for + void *clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display) /* Display containing window that used image. */ { @@ -999,7 +995,7 @@ ImgBmapFree( static void ImgBmapDelete( - ClientData modelData) /* Pointer to BitmapModel structure for + void *modelData) /* Pointer to BitmapModel structure for * image. Must not have any more instances. */ { BitmapModel *modelPtr = (BitmapModel *)modelData; @@ -1017,7 +1013,7 @@ ImgBmapDelete( if (modelPtr->maskData != NULL) { ckfree(modelPtr->maskData); } - Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0); + Tk_FreeOptions(configSpecs, (char *)modelPtr, NULL, 0); ckfree(modelPtr); } @@ -1040,7 +1036,7 @@ ImgBmapDelete( static void ImgBmapCmdDeletedProc( - ClientData clientData) /* Pointer to BitmapModel structure for + void *clientData) /* Pointer to BitmapModel structure for * image. */ { BitmapModel *modelPtr = (BitmapModel *)clientData; @@ -1181,7 +1177,7 @@ ImgBmapPsImagemask( static int ImgBmapPostscript( - ClientData clientData, + void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 549a997..5cb43bb 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -111,7 +111,7 @@ typedef struct { * serializing in the GIF format. */ -typedef int (WriteBytesFunc) (ClientData clientData, const char *bytes, +typedef int (WriteBytesFunc) (void *clientData, const char *bytes, int byteCount); /* @@ -135,7 +135,7 @@ static int FileWriteGIF(Tcl_Interp *interp, const char *filename, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); static int StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); -static int CommonWriteGIF(Tcl_Interp *interp, ClientData clientData, +static int CommonWriteGIF(Tcl_Interp *interp, void *clientData, WriteBytesFunc *writeProc, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); @@ -280,7 +280,7 @@ typedef struct { */ int initialBits; - ClientData destination; + void *destination; WriteBytesFunc *writeProc; int clearCode; @@ -308,7 +308,7 @@ typedef struct { static int ColorNumber(GifWriterState *statePtr, int red, int green, int blue); -static void Compress(int initBits, ClientData handle, +static void Compress(int initBits, void *handle, WriteBytesFunc *writeProc, ifunptr readValue, GifWriterState *statePtr); static int IsNewColor(GifWriterState *statePtr, @@ -351,7 +351,7 @@ FileMatchGIF( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here if the file is a valid raw GIF file. */ - Tcl_Interp *interp) /* not used */ + TCL_UNUSED(Tcl_Interp *), /* not used */ { GIFImageConfig gifConf; @@ -603,7 +603,7 @@ FileReadGIF( goto error; } nBytes = fileWidth * fileHeight * 3; - trashBuffer = ckalloc(nBytes); + trashBuffer = (unsigned char *)ckalloc(nBytes); if (trashBuffer) { memset(trashBuffer, 0, nBytes); } @@ -706,7 +706,7 @@ FileReadGIF( goto error; } nBytes = block.pitch * imageHeight; - pixelPtr = ckalloc(nBytes); + pixelPtr = (unsigned char*)ckalloc(nBytes); if (pixelPtr) { memset(pixelPtr, 0, nBytes); } @@ -1050,7 +1050,8 @@ ReadImage( Tcl_Channel chan, int len, int rows, unsigned char cmap[MAXCOLORMAPSIZE][4], - int srcX, int srcY, + TCL_UNUSED(int), + TCL_UNUSED(int), int interlace, int transparent) { @@ -1446,8 +1447,8 @@ Mread( size_t numChunks, /* number of chunks */ MFile *handle) /* mmdecode "file" handle */ { - int i, c; - int count = chunkSize * numChunks; + int c; + int i, count = chunkSize * numChunks; for (i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) { *dst++ = c; @@ -1602,20 +1603,20 @@ Fread( if (gifConfPtr->fromData == INLINE_DATA_BINARY) { MFile *handle = (MFile *) chan; - if (handle->length <= 0 || (size_t) handle->length < hunk*count) { + if ((handle->length <= 0) || ((size_t)handle->length < hunk*count)) { return -1; } - memcpy(dst, handle->data, (size_t) (hunk * count)); + memcpy(dst, handle->data, hunk * count); handle->data += hunk * count; handle->length -= hunk * count; - return (int)(hunk * count); + return hunk * count; } /* * Otherwise we've got a real file to read. */ - return Tcl_Read(chan, (char *) dst, (int) (hunk * count)); + return Tcl_Read(chan, (char *) dst, hunk * count); } /* @@ -1660,8 +1661,8 @@ FileWriteGIF( if (!chan) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1696,22 +1697,22 @@ StringWriteGIF( static int WriteToChannel( - ClientData clientData, + void *clientData, const char *bytes, int byteCount) { - Tcl_Channel handle = clientData; + Tcl_Channel handle = (Tcl_Channel)clientData; return Tcl_Write(handle, bytes, byteCount); } static int WriteToByteArray( - ClientData clientData, + void *clientData, const char *bytes, int byteCount) { - Tcl_Obj *objPtr = clientData; + Tcl_Obj *objPtr = (Tcl_Obj *)clientData; Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount); Tcl_IncrRefCount(tmpObj); @@ -1723,7 +1724,7 @@ WriteToByteArray( static int CommonWriteGIF( Tcl_Interp *interp, - ClientData handle, + void *handle, WriteBytesFunc *writeProc, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr) @@ -1979,7 +1980,7 @@ ReadValue( static void Compress( int initialBits, - ClientData handle, + void *handle, WriteBytesFunc *writeProc, ifunptr readValue, GifWriterState *statePtr) diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index fccb465..99ba37a 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -2387,7 +2387,8 @@ DecodePNG( * image being read. */ { unsigned long chunkType; - int result, chunkSz; + int result; + int chunkSz; unsigned long crc; /* @@ -2525,11 +2526,11 @@ DecodePNG( pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); - pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen); + pngPtr->block.pixelPtr = (unsigned char *)attemptckalloc(pngPtr->blockLen); if (!pngPtr->block.pixelPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "memory allocation failed", -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); return TCL_ERROR; } @@ -2852,7 +2853,7 @@ WriteData( int srcSz, unsigned long *crcPtr) { - if (!srcPtr || !srcSz) { + if (!srcPtr || srcSz <= 0) { return TCL_OK; } @@ -3135,9 +3136,10 @@ WriteIDAT( PNGImage *pngPtr, Tk_PhotoImageBlock *blockPtr) { - int rowNum, flush = TCL_ZLIB_NO_FLUSH, outputSize, result; + int rowNum, flush = TCL_ZLIB_NO_FLUSH, result; Tcl_Obj *outputObj; unsigned char *outputBytes; + int outputSize; /* * Filter and compress each row one at a time. @@ -3483,13 +3485,8 @@ FileWritePNG( goto cleanup; } - /* - * Set the translation mode to binary so that CR and LF are not to the - * platform's EOL sequence. - */ - - if (Tcl_SetChannelOption(interp, chan, "-translation", - "binary") != TCL_OK) { + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) { goto cleanup; } diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index fe76e36..9d62a66 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -145,7 +145,8 @@ FileReadPPM( * image being read. */ { int fileWidth, fileHeight, maxIntensity; - int nLines, nBytes, h, type, count, bytesPerChannel = 1; + int nLines, h, type, bytesPerChannel = 1; + int nBytes, count; unsigned char *pixelPtr; Tk_PhotoImageBlock block; @@ -303,11 +304,6 @@ FileWritePPM( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); Tcl_Write(chan, header, -1); @@ -326,7 +322,7 @@ FileWritePPM( for (h = blockPtr->height; h > 0; h--) { pixelPtr = pixLinePtr; for (w = blockPtr->width; w > 0; w--) { - if ( Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 || + if (Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 || Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == -1 || Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == -1) { goto writeerror; @@ -765,7 +761,8 @@ ReadPPMStringHeader( { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE], c; - int i, numFields, dataSize, type = 0; + int i, numFields, type = 0; + int dataSize; unsigned char *dataBuffer; dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index e619910..5d5921b 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -102,9 +102,9 @@ static const char *const optionNames[] = { static int ImgPhotoCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); -static void ImgPhotoDelete(ClientData clientData); -static int ImgPhotoPostscript(ClientData clientData, + void **clientDataPtr); +static void ImgPhotoDelete(void *clientData); +static int ImgPhotoPostscript(void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, int x, int y, int width, int height, int prepass); @@ -172,14 +172,14 @@ static const Tk_ConfigSpec configSpecs[] = { * Forward declarations */ -static void PhotoFormatThreadExitProc(ClientData clientData); -static int ImgPhotoCmd(ClientData clientData, Tcl_Interp *interp, +static void PhotoFormatThreadExitProc(void *clientData); +static int ImgPhotoCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int ParseSubcommandOptions( struct SubcommandOptions *optPtr, Tcl_Interp *interp, int allowedOptions, int *indexPtr, int objc, Tcl_Obj *const objv[]); -static void ImgPhotoCmdDeletedProc(ClientData clientData); +static void ImgPhotoCmdDeletedProc(void *clientData); static int ImgPhotoConfigureModel(Tcl_Interp *interp, PhotoModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); @@ -335,9 +335,9 @@ ImgPhotoCreate( Tcl_Obj *const objv[], /* Argument objects for options (doesn't * include image name or type). */ TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */ - Tk_ImageModel model, /* Token for image, to be used by us in later + Tk_ImageModel model, /* Token for image, to be used by us in later * callbacks. */ - ClientData *clientDataPtr) /* Store manager's token for image here; it + void **clientDataPtr) /* Store manager's token for image here; it * will be returned in later callbacks. */ { PhotoModel *modelPtr; @@ -390,7 +390,7 @@ ImgPhotoCreate( static int ImgPhotoCmd( - ClientData clientData, /* Information about photo model. */ + void *clientData, /* Information about photo model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -405,15 +405,16 @@ ImgPhotoCmd( PHOTO_WRITE }; - PhotoModel *modelPtr = clientData; - int result, index, x, y, width, height, dataWidth, dataHeight, listObjc; + PhotoModel *modelPtr = (PhotoModel *)clientData; + int result, x, y, width, height, dataWidth, dataHeight, listObjc; + int index; struct SubcommandOptions options; Tcl_Obj **listObjv, **srcObjv; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - size_t length; + int length; int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; @@ -463,7 +464,7 @@ ImgPhotoCmd( } } else { Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, - (char *) modelPtr, Tcl_GetString(objv[2]), 0); + (char *)modelPtr, Tcl_GetString(objv[2]), 0); } return TCL_OK; } @@ -477,7 +478,7 @@ ImgPhotoCmd( Tcl_Obj *obj, *subobj; result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) modelPtr, NULL, 0); + configSpecs, (char *)modelPtr, NULL, 0); if (result != TCL_OK) { return result; } @@ -486,14 +487,14 @@ ImgPhotoCmd( if (modelPtr->dataString) { Tcl_ListObjAppendElement(NULL, subobj, modelPtr->dataString); } else { - Tcl_AppendStringsToObj(subobj, " {}", NULL); + Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); if (modelPtr->format) { Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format); } else { - Tcl_AppendStringsToObj(subobj, " {}", NULL); + Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL); } Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp)); @@ -505,7 +506,7 @@ ImgPhotoCmd( length = objv[2]->length; if (length > 1 && !strncmp(arg, "-data", length)) { - Tcl_AppendResult(interp, "-data {} {} {}", NULL); + Tcl_AppendResult(interp, "-data {} {} {}", (char *)NULL); if (modelPtr->dataString) { /* * TODO: Modifying result is bad! @@ -514,12 +515,12 @@ ImgPhotoCmd( Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->dataString); } else { - Tcl_AppendResult(interp, " {}", NULL); + Tcl_AppendResult(interp, " {}", (char *)NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-format", length)) { - Tcl_AppendResult(interp, "-format {} {} {}", NULL); + Tcl_AppendResult(interp, "-format {} {} {}", (char *)NULL); if (modelPtr->format) { /* * TODO: Modifying result is bad! @@ -528,7 +529,7 @@ ImgPhotoCmd( Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->format); } else { - Tcl_AppendResult(interp, " {}", NULL); + Tcl_AppendResult(interp, " {}", (char *)NULL); } return TCL_OK; } else { @@ -573,7 +574,7 @@ ImgPhotoCmd( "image \"%s\" doesn't exist or is not a photo image", Tcl_GetString(options.name))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO", - Tcl_GetString(options.name), NULL); + Tcl_GetString(options.name), (char *)NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); @@ -583,7 +584,7 @@ ImgPhotoCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); return TCL_ERROR; } @@ -658,7 +659,7 @@ ImgPhotoCmd( options.toY2) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); return TCL_ERROR; } } @@ -701,7 +702,7 @@ ImgPhotoCmd( || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -822,7 +823,7 @@ ImgPhotoCmd( "%s get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1051,7 +1052,7 @@ ImgPhotoCmd( if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); return TCL_ERROR; } @@ -1069,11 +1070,6 @@ ImgPhotoCmd( Tcl_Close(NULL, chan); return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - Tcl_Close(NULL, chan); - return TCL_ERROR; - } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, &imageFormat, @@ -1092,7 +1088,7 @@ ImgPhotoCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1114,7 +1110,7 @@ ImgPhotoCmd( Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1207,7 +1203,7 @@ ImgPhotoCmd( "%s transparency get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1237,7 +1233,7 @@ ImgPhotoCmd( "%s transparency set: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", - NULL); + (char *)NULL); return TCL_ERROR; } @@ -1302,7 +1298,7 @@ ImgPhotoCmd( if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't write image to a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); return TCL_ERROR; } @@ -1332,7 +1328,7 @@ ImgPhotoCmd( || (options.fromY2 > modelPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -1414,7 +1410,7 @@ ImgPhotoCmd( fmtString)); } Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - fmtString, NULL); + fmtString, (char *)NULL); if (options.background) { Tk_FreeColor(options.background); } @@ -1513,9 +1509,9 @@ ParseSubcommandOptions( * TK_PHOTO_COMPOSITE_* constants. */ NULL }; - size_t length; - int index, c, bit, currentBit; - int values[4], numValues, maxValues, argIndex; + int index, length, argIndex; + int c, bit, currentBit; + int values[4], numValues, maxValues; const char *option, *expandedOption, *needed; const char *const *listPtr; Tcl_Obj *msgObj; @@ -1526,8 +1522,7 @@ ParseSubcommandOptions( * optPtr->name. */ - expandedOption = option = Tcl_GetString(objv[index]); - length = objv[index]->length; + expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; @@ -1724,20 +1719,20 @@ ParseSubcommandOptions( oneValueRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires a value", expandedOption)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", (char *)NULL); return TCL_ERROR; manyValuesRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires one %s integer values", expandedOption, (maxValues == 2) ? "or two": "to four")); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", (char *)NULL); return TCL_ERROR; numberOutOfRange: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value(s) for the %s option must be %s", expandedOption, needed)); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", (char *)NULL); return TCL_ERROR; unknownOrAmbiguousOption: @@ -1757,7 +1752,7 @@ ParseSubcommandOptions( bit <<= 1; } Tcl_SetObjResult(interp, msgObj); - Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", (char *)NULL); return TCL_ERROR; } @@ -1795,15 +1790,14 @@ ImgPhotoConfigureModel( const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; Tcl_Obj *tempdata, *tempformat; - size_t length; - int i, result, imageWidth, imageHeight, oldformat; + int i, length; + int result, imageWidth, imageHeight, oldformat; double oldGamma; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; for (i = 0; i < objc; i++) { - const char *arg = Tcl_GetString(objv[i]); - length = objv[i]->length; + const char *arg = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (arg[0] == '-')) { if ((arg[1] == 'd') && !strncmp(arg, "-data", length)) { @@ -1813,7 +1807,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-data\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "MISSING_VALUE", NULL); + "MISSING_VALUE", (char *)NULL); return TCL_ERROR; } } else if ((arg[1] == 'f') && @@ -1824,7 +1818,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-format\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "MISSING_VALUE", NULL); + "MISSING_VALUE", (char *)NULL); return TCL_ERROR; } } @@ -1915,7 +1909,7 @@ ImgPhotoConfigureModel( modelPtr->height) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } @@ -1936,7 +1930,7 @@ ImgPhotoConfigureModel( Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); - Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); + Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL); goto errorExit; } @@ -1945,12 +1939,8 @@ ImgPhotoConfigureModel( goto errorExit; } - /* - * -translation binary also sets -encoding binary - */ - - if ((Tcl_SetChannelOption(interp, chan, - "-translation", "binary") != TCL_OK) || + if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") + != TCL_OK) || (MatchFileFormat(interp, chan, modelPtr->fileString, modelPtr->format, &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK)) { @@ -1962,7 +1952,7 @@ ImgPhotoConfigureModel( Tcl_Close(NULL, chan); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } tempformat = modelPtr->format; @@ -1993,7 +1983,7 @@ ImgPhotoConfigureModel( if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); goto errorExit; } tempformat = modelPtr->format; @@ -2133,7 +2123,7 @@ ToggleComplexAlphaIfNeeded( static void ImgPhotoDelete( - ClientData modelData) /* Pointer to PhotoModel structure for image. + void *modelData) /* Pointer to PhotoModel structure for image. * Must not have any more instances. */ { PhotoModel *modelPtr = (PhotoModel *)modelData; @@ -2185,7 +2175,7 @@ ImgPhotoDelete( static void ImgPhotoCmdDeletedProc( - ClientData clientData) /* Pointer to PhotoModel structure for + void *clientData) /* Pointer to PhotoModel structure for * image. */ { PhotoModel *modelPtr = (PhotoModel *)clientData; @@ -2422,7 +2412,8 @@ MatchFileFormat( * here. */ int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched = 0, useoldformat = 0; + int matched = 0; + int useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -2450,7 +2441,7 @@ MatchFileFormat( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_FILE_FORMAT", NULL); + "NOT_FILE_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2484,7 +2475,7 @@ MatchFileFormat( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_FILE_FORMAT", NULL); + "NOT_FILE_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2510,13 +2501,13 @@ MatchFileFormat( "image file format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - formatString, NULL); + formatString, (char *)NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't recognize data in image file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE", - "UNRECOGNIZED_DATA", NULL); + "UNRECOGNIZED_DATA", (char *)NULL); } return TCL_ERROR; } @@ -2590,7 +2581,7 @@ MatchStringFormat( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_DATA_FORMAT", NULL); + "NOT_DATA_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2617,7 +2608,7 @@ MatchStringFormat( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "NOT_DATA_FORMAT", NULL); + "NOT_DATA_FORMAT", (char *)NULL); return TCL_ERROR; } } @@ -2636,12 +2627,12 @@ MatchStringFormat( Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", - formatString, NULL); + formatString, (char *)NULL); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't recognize image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", - "UNRECOGNIZED_DATA", NULL); + "UNRECOGNIZED_DATA", (char *)NULL); } return TCL_ERROR; } @@ -2678,7 +2669,7 @@ Tk_FindPhoto( const char *imageName) /* Name of the desired photo image. */ { const Tk_ImageType *typePtr; - ClientData clientData = + void *clientData = Tk_GetImageMasterData(interp, imageName, &typePtr); if ((typePtr == NULL) || (typePtr->name != tkPhotoImageType.name)) { @@ -2789,7 +2780,7 @@ Tk_PhotoPutBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -2806,7 +2797,7 @@ Tk_PhotoPutBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } goto errorExit; } @@ -3235,7 +3226,7 @@ Tk_PhotoPutZoomedBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -3251,7 +3242,7 @@ Tk_PhotoPutZoomedBlock( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } goto errorExit; } @@ -3656,7 +3647,7 @@ Tk_PhotoExpand( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -3731,7 +3722,7 @@ Tk_PhotoSetSize( if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); - Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); + Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL); } return TCL_ERROR; } @@ -4074,7 +4065,7 @@ Tk_PhotoGetImage( static int ImgPhotoPostscript( - ClientData clientData, /* Handle for the photo image. */ + void *clientData, /* Handle for the photo image. */ Tcl_Interp *interp, /* Interpreter. */ TCL_UNUSED(Tk_Window), /* (unused) */ Tk_PostscriptInfo psInfo, /* Postscript info. */ |