summaryrefslogtreecommitdiffstats
path: root/generic/tkImgGIF.c
diff options
context:
space:
mode:
authorstanton <stanton>1999-04-16 01:51:06 (GMT)
committerstanton <stanton>1999-04-16 01:51:06 (GMT)
commit03656f44f81469f459031fa3a4a7b09c8bc77712 (patch)
tree31378e81bd58f8c726fc552d6b30cbf3ca07497b /generic/tkImgGIF.c
parent404fc236f34304df53b7e44bc7971d786b87d453 (diff)
downloadtk-03656f44f81469f459031fa3a4a7b09c8bc77712.zip
tk-03656f44f81469f459031fa3a4a7b09c8bc77712.tar.gz
tk-03656f44f81469f459031fa3a4a7b09c8bc77712.tar.bz2
* Merged 8.1 branch into the main trunk
Diffstat (limited to 'generic/tkImgGIF.c')
-rw-r--r--generic/tkImgGIF.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index d9dd900..88edfa8 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -27,7 +27,7 @@
* | provided "as is" without express or implied warranty. |
* +-------------------------------------------------------------------+
*
- * RCS: @(#) $Id: tkImgGIF.c,v 1.2 1998/09/14 18:23:12 stanton Exp $
+ * RCS: @(#) $Id: tkImgGIF.c,v 1.3 1999/04/16 01:51:15 stanton Exp $
*/
/*
@@ -61,6 +61,17 @@ typedef struct mFile {
#include "tkPort.h"
/*
+ * HACK ALERT!! HACK ALERT!! HACK ALERT!!
+ * This code is hard-wired for reading from files. In order to read
+ * from a data stream, we'll trick fread so we can reuse the same code
+ */
+
+typedef struct ThreadSpecificData {
+ int fromData;
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
+
+/*
* The format record for the GIF file format:
*/
@@ -100,14 +111,6 @@ Tk_PhotoImageFormat tkImgFmtGIF = {
#define ReadOK(file,buffer,len) (Fread(buffer, len, 1, file) != 0)
/*
- * HACK ALERT!! HACK ALERT!! HACK ALERT!!
- * This code is hard-wired for reading from files. In order to read
- * from a data stream, we'll trick fread so we can reuse the same code
- */
-
-static int fromData=0;
-
-/*
* Prototypes for local procedures defined in this file:
*/
@@ -184,7 +187,7 @@ FileMatchGIF(chan, fileName, formatString, widthPtr, heightPtr)
*
* Results:
* A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
+ * then an error message is left in the interp's result.
*
* Side effects:
* The access position in file f is changed, and new data is
@@ -287,12 +290,14 @@ FileReadGIF(interp, chan, fileName, formatString, imageHandle, destX, destY,
*/
if (Fread(buf, 1, 1, chan) != 1) {
- interp->result =
- "error reading extension function code in GIF image";
+ Tcl_SetResult(interp,
+ "error reading extension function code in GIF image",
+ TCL_STATIC);
goto error;
}
if (DoExtension(chan, buf[0], &transparent) < 0) {
- interp->result = "error reading extension in GIF image";
+ Tcl_SetResult(interp, "error reading extension in GIF image",
+ TCL_STATIC);
goto error;
}
continue;
@@ -306,7 +311,9 @@ FileReadGIF(interp, chan, fileName, formatString, imageHandle, destX, destY,
}
if (Fread(buf, 1, 9, chan) != 9) {
- interp->result = "couldn't read left/top/width/height in GIF image";
+ Tcl_SetResult(interp,
+ "couldn't read left/top/width/height in GIF image",
+ TCL_STATIC);
goto error;
}
@@ -418,7 +425,7 @@ StringMatchGIF(string, formatString, widthPtr, heightPtr)
*
* Results:
* A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
+ * then an error message is left in the interp's result.
*
* Side effects:
* new data is added to the image given by imageHandle. This
@@ -439,15 +446,18 @@ StringReadGIF(interp,string,formatString,imageHandle,
int width, height; /* image to copy */
int srcX, srcY;
{
- int result;
- MFile handle;
- mInit((unsigned char *)string,&handle);
- fromData = 1;
- result = FileReadGIF(interp, (Tcl_Channel) &handle, "inline data",
- formatString, imageHandle, destX, destY, width, height,
- srcX, srcY);
- fromData = 0;
- return(result);
+ int result;
+ MFile handle;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ mInit((unsigned char *)string,&handle);
+ tsdPtr->fromData = 1;
+ result = FileReadGIF(interp, (Tcl_Channel) &handle, "inline data",
+ formatString, imageHandle, destX, destY, width, height,
+ srcX, srcY);
+ tsdPtr->fromData = 0;
+ return(result);
}
/*
@@ -619,7 +629,7 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap,
}
if (LWZReadByte(chan, 1, c) < 0) {
- interp->result = "format error in GIF image";
+ Tcl_SetResult(interp, "format error in GIF image", TCL_STATIC);
return TCL_ERROR;
}
@@ -1051,7 +1061,10 @@ Fread(dst, hunk, count, chan)
size_t hunk,count; /* how many */
Tcl_Channel chan;
{
- if (fromData) {
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ if (tsdPtr->fromData) {
return(Mread(dst, hunk, count, (MFile *) chan));
} else {
return Tcl_Read(chan, (char *) dst, (int) (hunk * count));