summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPPM.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkImgPPM.c')
-rw-r--r--generic/tkImgPPM.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index 9d62a66..a9d0391 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -3,8 +3,8 @@
*
* A photo image file handler for PPM (Portable PixMap) files.
*
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -146,7 +146,7 @@ FileReadPPM(
{
int fileWidth, fileHeight, maxIntensity;
int nLines, h, type, bytesPerChannel = 1;
- int nBytes, count;
+ size_t nBytes, count;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
@@ -205,7 +205,7 @@ FileReadPPM(
}
if (srcY > 0) {
- Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR);
+ Tcl_Seek(chan, (long long)srcY * block.pitch, SEEK_CUR);
}
nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
@@ -290,7 +290,8 @@ FileWritePPM(
Tk_PhotoImageBlock *blockPtr)
{
Tcl_Channel chan;
- int w, h, greenOffset, blueOffset, nBytes;
+ int w, h, greenOffset, blueOffset;
+ size_t nBytes;
unsigned char *pixelPtr, *pixLinePtr;
char header[16 + TCL_INTEGER_SPACE * 2];
@@ -306,7 +307,7 @@ FileWritePPM(
}
snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
- Tcl_Write(chan, header, -1);
+ Tcl_Write(chan, header, TCL_INDEX_NONE);
pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
@@ -315,16 +316,16 @@ FileWritePPM(
if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
&& (blockPtr->pitch == (blockPtr->width * 3))) {
nBytes = blockPtr->height * blockPtr->pitch;
- if (Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
+ if ((size_t)Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
goto writeerror;
}
} else {
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 ||
- Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == -1 ||
- Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == -1) {
+ if (Tcl_Write(chan,(char *)&pixelPtr[0], 1) == TCL_IO_FAILURE ||
+ Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == TCL_IO_FAILURE ||
+ Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == TCL_IO_FAILURE) {
goto writeerror;
}
pixelPtr += blockPtr->pixelSize;
@@ -497,13 +498,13 @@ StringReadPPM(
&maxIntensity, &dataBuffer, &dataSize);
if (type == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't read raw PPM header from string", -1));
+ "couldn't read raw PPM header from string", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "NO_HEADER", NULL);
return TCL_ERROR;
}
if ((fileWidth <= 0) || (fileHeight <= 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "PPM image data has dimension(s) <= 0", -1));
+ "PPM image data has dimension(s) <= 0", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "DIMENSIONS", NULL);
return TCL_ERROR;
}
@@ -555,7 +556,7 @@ StringReadPPM(
if (block.pitch*height > dataSize) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "truncated PPM data", -1));
+ "truncated PPM data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL);
return TCL_ERROR;
}
@@ -591,7 +592,7 @@ StringReadPPM(
if (dataSize < nBytes) {
ckfree(pixelPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "truncated PPM data", -1));
+ "truncated PPM data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL);
return TCL_ERROR;
}
@@ -762,7 +763,7 @@ ReadPPMStringHeader(
#define BUFFER_SIZE 1000
char buffer[BUFFER_SIZE], c;
int i, numFields, type = 0;
- int dataSize;
+ Tcl_Size dataSize;
unsigned char *dataBuffer;
dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);