summaryrefslogtreecommitdiffstats
path: root/win/tclWinDde.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-10-06 16:37:17 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-10-06 16:37:17 (GMT)
commit757296c3e92ae4145012c8081d89063fd84fac6d (patch)
tree9f4375cdd57e3a0d6be40c390fc31ca0d3834d4b /win/tclWinDde.c
parentc9460f40ff148c46d7f52e7b5d7d7d16f32d64e1 (diff)
downloadtcl-757296c3e92ae4145012c8081d89063fd84fac6d.zip
tcl-757296c3e92ae4145012c8081d89063fd84fac6d.tar.gz
tcl-757296c3e92ae4145012c8081d89063fd84fac6d.tar.bz2
* generic/tclBasic.c:
* generic/tclBinary.c: * generic/tclCmdAH.c: * generic/tclCmdIL.c: * generic/tclCmdMZ.c: * generic/tclCompExpr.c: * generic/tclDictObj.c: * generic/tclEncoding.c: * generic/tclExecute.c: * generic/tclFCmd.c: * generic/tclHistory.c: * generic/tclIndexObj.c: * generic/tclInterp.c: * generic/tclIO.c: * generic/tclIOCmd.c: * generic/tclNamesp.c: * generic/tclObj.c: * generic/tclPkg.c: * generic/tclResult.c: * generic/tclScan.c: * generic/tclTimer.c: * generic/tclTrace.c: * generic/tclUtil.c: * generic/tclVar.c: * unix/tclUnixFCmd.c: * unix/tclUnixPipe.c: * win/tclWinDde.c: * win/tclWinFCmd.c: * win/tclWinPipe.c: It is a poor practice to directly set or append to the value of the objResult of an interp, because that value might be shared, and in that circumstance a Tcl_Panic() will be the result. Searched for example of this practice and replaced with safer alternatives, often using the Tcl_AppendResult() routine that dkf just rehabilitated. * library/dde/pkgIndex.tcl: Bump to dde 1.3.1
Diffstat (limited to 'win/tclWinDde.c')
-rw-r--r--win/tclWinDde.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/win/tclWinDde.c b/win/tclWinDde.c
index 16e32ff..b1599f7 100644
--- a/win/tclWinDde.c
+++ b/win/tclWinDde.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinDde.c,v 1.22 2004/10/06 14:10:27 dkf Exp $
+ * RCS: @(#) $Id: tclWinDde.c,v 1.23 2004/10/06 16:37:18 dgp Exp $
*/
#include "tclInt.h"
@@ -71,7 +71,7 @@ static DWORD ddeInstance; /* The application instance handle given
* to us by DdeInitialize. */
static int ddeIsServer = 0;
-#define TCL_DDE_VERSION "1.3"
+#define TCL_DDE_VERSION "1.3.1"
#define TCL_DDE_PACKAGE_NAME "dde"
#define TCL_DDE_SERVICE_NAME "TclEval"
@@ -1007,23 +1007,29 @@ DdeServicesOnAck(HWND hwnd, WPARAM wParam, LPARAM lParam)
if ((es->service == (ATOM)NULL || es->service == service)
&& (es->topic == (ATOM)NULL || es->topic == topic)) {
Tcl_Obj *matchPtr = Tcl_NewListObj(0, NULL);
+ Tcl_Obj *resultPtr = Tcl_GetObjResult(es->interp);
GlobalGetAtomName((ATOM)service, sz, 255);
- Tcl_ListObjAppendElement(es->interp, matchPtr,
+ Tcl_ListObjAppendElement(NULL, matchPtr,
Tcl_NewStringObj(sz, -1));
GlobalGetAtomName(topic, sz, 255);
- Tcl_ListObjAppendElement(es->interp, matchPtr,
+ Tcl_ListObjAppendElement(NULL, matchPtr,
Tcl_NewStringObj(sz, -1));
/* Adding the hwnd as a third list element provides a unique
* identifier in the case of multiple servers with the name
* application and topic names.
*/
/* Needs a TIP though
- * Tcl_ListObjAppendElement(es->interp, matchPtr,
+ * Tcl_ListObjAppendElement(NULL, matchPtr,
* Tcl_NewLongObj((long)hwndRemote));
*/
- Tcl_ListObjAppendElement(es->interp,
- Tcl_GetObjResult(es->interp), matchPtr);
+ if (Tcl_IsShared(resultPtr)) {
+ resultPtr = Tcl_DuplicateObj(resultPtr);
+ }
+ if (Tcl_ListObjAppendElement(es->interp, resultPtr, matchPtr)
+ == TCL_OK) {
+ Tcl_SetObjResult(es->interp, resultPtr);
+ }
}
/* tell the server we are no longer interested */
@@ -1093,29 +1099,27 @@ static void
SetDdeError(
Tcl_Interp *interp) /* The interp to put the message in.*/
{
- Tcl_Obj *resultPtr = Tcl_GetObjResult(interp);
- int err;
-
- err = DdeGetLastError(ddeInstance);
- switch (err) {
+ switch (DdeGetLastError(ddeInstance)) {
case DMLERR_DATAACKTIMEOUT:
case DMLERR_EXECACKTIMEOUT:
case DMLERR_POKEACKTIMEOUT:
- Tcl_SetStringObj(resultPtr,
- "remote interpreter did not respond", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "remote interpreter did not respond", -1));
break;
case DMLERR_BUSY:
- Tcl_SetStringObj(resultPtr, "remote server is busy", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "remote server is busy", -1));
break;
case DMLERR_NOTPROCESSED:
- Tcl_SetStringObj(resultPtr,
- "remote server cannot handle this command", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "remote server cannot handle this command", -1));
break;
default:
- Tcl_SetStringObj(resultPtr, "dde command failed", -1);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("dde command failed", -1));
}
}
@@ -1223,10 +1227,9 @@ Tcl_DdeObjCmd(
break;
} else {
Tcl_ResetResult(interp);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "bad option \"", Tcl_GetString(objv[i]),
- "\": must be -force, -handler or --",
- (char*)NULL);
+ Tcl_AppendResult(interp, "bad option \"",
+ Tcl_GetString(objv[i]),
+ "\": must be -force, -handler or --", (char*)NULL);
return TCL_ERROR;
}
}
@@ -1364,8 +1367,7 @@ Tcl_DdeObjCmd(
serviceName = DdeSetServerName(interp, serviceName,
exact, handlerPtr);
if (serviceName != NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- serviceName, -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(serviceName, -1));
} else {
Tcl_ResetResult(interp);
}
@@ -1374,8 +1376,8 @@ Tcl_DdeObjCmd(
case DDE_EXECUTE: {
dataString = Tcl_GetStringFromObj(objv[firstArg + 2], &dataLength);
if (dataLength == 0) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "cannot execute null data", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "cannot execute null data", -1));
result = TCL_ERROR;
break;
}
@@ -1415,8 +1417,8 @@ Tcl_DdeObjCmd(
case DDE_REQUEST: {
itemString = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
if (length == 0) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "cannot request value of null data", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "cannot request value of null data", -1));
goto errorNoResult;
}
hConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL);
@@ -1461,8 +1463,8 @@ Tcl_DdeObjCmd(
case DDE_POKE: {
itemString = Tcl_GetStringFromObj(objv[firstArg + 2], &length);
if (length == 0) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "cannot have a null item", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "cannot have a null item", -1));
goto errorNoResult;
}
dataString = Tcl_GetStringFromObj(objv[firstArg + 3], &length);
@@ -1498,8 +1500,8 @@ Tcl_DdeObjCmd(
}
case DDE_EVAL: {
if (serviceName == NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "invalid service name \"\"", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "invalid service name \"\"", -1));
goto errorNoResult;
}
@@ -1706,8 +1708,8 @@ Tcl_DdeObjCmd(
return result;
error:
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "invalid data returned from server", -1);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "invalid data returned from server", -1));
errorNoResult:
if (ddeCookie != NULL) {