summaryrefslogtreecommitdiffstats
path: root/generic/tkImgGIF.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkImgGIF.c')
-rw-r--r--generic/tkImgGIF.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 62d364f..fed4da4 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -430,10 +430,10 @@ FileReadGIF(
return TCL_ERROR;
}
if (i == (argc-1)) {
- Tcl_AppendResult(interp, "no value given for \"",
- Tcl_GetString(objv[i]), "\" option", NULL);
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "OPT_VALUE",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "no value given for \"%s\" option",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "OPT_VALUE", NULL);
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[++i], &index) != TCL_OK) {
@@ -446,14 +446,14 @@ FileReadGIF(
*/
if (!ReadGIFHeader(gifConfPtr, chan, &fileWidth, &fileHeight)) {
- Tcl_AppendResult(interp, "couldn't read GIF header from file \"",
- fileName, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't read GIF header from file \"%s\"", fileName));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "HEADER", NULL);
return TCL_ERROR;
}
if ((fileWidth <= 0) || (fileHeight <= 0)) {
- Tcl_AppendResult(interp, "GIF image file \"", fileName,
- "\" has dimension(s) <= 0", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "GIF image file \"%s\" has dimension(s) <= 0", fileName));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BOGUS_SIZE", NULL);
return TCL_ERROR;
}
@@ -469,9 +469,9 @@ FileReadGIF(
if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
- Tcl_AppendResult(interp, "error reading color map", NULL);
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error reading color map", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL);
return TCL_ERROR;
}
}
@@ -507,8 +507,8 @@ FileReadGIF(
* Premature end of image.
*/
- Tcl_AppendResult(interp,
- "premature end of image data for this index", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "premature end of image data for this index", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END",
NULL);
goto error;
@@ -516,7 +516,8 @@ FileReadGIF(
switch (buf[0]) {
case GIF_TERMINATOR:
- Tcl_AppendResult(interp, "no image data for this index", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "no image data for this index", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", NULL);
goto error;
@@ -526,17 +527,17 @@ FileReadGIF(
*/
if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"error reading extension function code in GIF image",
- TCL_STATIC);
+ -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
NULL);
goto error;
}
if (DoExtension(gifConfPtr, chan, buf[0],
gifConfPtr->workingBuffer, &transparent) < 0) {
- Tcl_SetResult(interp, "error reading extension in GIF image",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error reading extension in GIF image", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
NULL);
goto error;
@@ -544,9 +545,9 @@ FileReadGIF(
continue;
case GIF_START:
if (Fread(gifConfPtr, buf, 1, 9, chan) != 9) {
- Tcl_SetResult(interp,
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
"couldn't read left/top/width/height in GIF image",
- TCL_STATIC);
+ -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "DIMENSIONS",
NULL);
goto error;
@@ -576,7 +577,8 @@ FileReadGIF(
if (BitSet(buf[8], LOCALCOLORMAP)) {
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
- Tcl_AppendResult(interp, "error reading color map", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error reading color map", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF",
"COLOR_MAP", NULL);
goto error;
@@ -625,7 +627,8 @@ FileReadGIF(
if (BitSet(buf[8], LOCALCOLORMAP)) {
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
- Tcl_AppendResult(interp, "error reading color map", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error reading color map", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL);
goto error;
}
@@ -677,7 +680,7 @@ FileReadGIF(
block.pixelPtr = ckalloc(nBytes);
if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth,
- imageHeight, colorMap, srcX, srcY, BitSet(buf[8],INTERLACE),
+ imageHeight, colorMap, srcX, srcY, BitSet(buf[8], INTERLACE),
transparent) != TCL_OK) {
ckfree(block.pixelPtr);
goto error;
@@ -695,7 +698,7 @@ FileReadGIF(
* which suits as well). We're done.
*/
- Tcl_AppendResult(interp, tkImgFmtGIF.name, NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1));
result = TCL_OK;
error:
@@ -921,19 +924,19 @@ DoExtension(
int count;
switch (label) {
- case 0x01: /* Plain Text Extension */
+ case 0x01: /* Plain Text Extension */
break;
- case 0xff: /* Application Extension */
+ case 0xff: /* Application Extension */
break;
- case 0xfe: /* Comment Extension */
+ case 0xfe: /* Comment Extension */
do {
count = GetDataBlock(gifConfPtr, chan, buf);
} while (count > 0);
return count;
- case 0xf9: /* Graphic Control Extension */
+ case 0xf9: /* Graphic Control Extension */
count = GetDataBlock(gifConfPtr, chan, buf);
if (count < 0) {
return 1;
@@ -1029,13 +1032,13 @@ ReadImage(
*/
if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) {
- Tcl_AppendResult(interp, "error reading GIF image: ",
- Tcl_PosixError(interp), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading GIF image: %s", Tcl_PosixError(interp)));
return TCL_ERROR;
}
if (initialCodeSize > MAX_LWZ_BITS) {
- Tcl_SetResult(interp, "malformed image", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "MALFORMED", NULL);
return TCL_ERROR;
}
@@ -1435,7 +1438,7 @@ Mgetc(
handle->data++;
} while (c == GIF_SPACE);
- if (c>GIF_SPECIAL) {
+ if (c > GIF_SPECIAL) {
handle->state = GIF_DONE;
return handle->c;
}
@@ -1708,7 +1711,7 @@ CommonWriteGIF(
state.pixelPitch = blockPtr->pitch;
SaveMap(&state, blockPtr);
if (state.num >= MAXCOLORMAPSIZE) {
- Tcl_AppendResult(interp, "too many colors", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("too many colors", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLORFUL", NULL);
return TCL_ERROR;
}