summaryrefslogtreecommitdiffstats
path: root/generic/tkSelect.c
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1998-09-29 00:25:04 (GMT)
committerstanton <stanton@noemail.net>1998-09-29 00:25:04 (GMT)
commitf110d4e2a4b45b23f037e22b18041093a18a028f (patch)
tree99c199f65b7d32755dc8f0ee5cc773bd922a74a6 /generic/tkSelect.c
parent44fe62a9cda522475be53f14654970aaa3d4a648 (diff)
downloadtk-f110d4e2a4b45b23f037e22b18041093a18a028f.zip
tk-f110d4e2a4b45b23f037e22b18041093a18a028f.tar.gz
tk-f110d4e2a4b45b23f037e22b18041093a18a028f.tar.bz2
initial tk8.1a2 version
FossilOrigin-Name: 644396f2dabc649ad5784768cfe962017d991df1
Diffstat (limited to 'generic/tkSelect.c')
-rw-r--r--generic/tkSelect.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 7263e30..d43c121 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -6,12 +6,12 @@
* and Tcl commands.
*
* Copyright (c) 1990-1993 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright (c) 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.
*
- * SCCS: @(#) tkSelect.c 1.57 96/05/03 10:52:40
+ * SCCS: @(#) tkSelect.c 1.58 97/11/07 21:17:56
*/
#include "tkInt.h"
@@ -431,7 +431,7 @@ Tk_ClearSelection(tkwin, selection)
* Results:
* The return value is a standard Tcl return value.
* If an error occurs (such as no selection exists)
- * then an error message is left in interp->result.
+ * then an error message is left in the interp's result.
*
* Side effects:
* The standard X11 protocols are used to retrieve the
@@ -457,7 +457,7 @@ Tk_ClearSelection(tkwin, selection)
* the "portion" arguments in separate calls will contain
* successive parts of the selection. Proc should normally
* return TCL_OK. If it detects an error then it should return
- * TCL_ERROR and leave an error message in interp->result; the
+ * TCL_ERROR and leave an error message in the interp's result; the
* remainder of the selection retrieval will be aborted.
*
*--------------------------------------------------------------
@@ -602,9 +602,8 @@ Tk_SelectionCmd(clientData, interp, argc, argv)
char **args;
if (argc < 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s option ?arg arg ...?\"",
- argv[0]);
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " option ?arg arg ...?\"", (char *) NULL);
return TCL_ERROR;
}
c = argv[1][0];
@@ -854,7 +853,7 @@ Tk_SelectionCmd(clientData, interp, argc, argv)
if ((infoPtr != NULL)
&& (infoPtr->owner != winPtr->dispPtr->clipWindow)) {
- interp->result = Tk_PathName(infoPtr->owner);
+ Tcl_SetResult(interp, Tk_PathName(infoPtr->owner), TCL_STATIC);
}
return TCL_OK;
}
@@ -878,9 +877,8 @@ Tk_SelectionCmd(clientData, interp, argc, argv)
Tk_OwnSelection(tkwin, selection, LostSelection, (ClientData) lostPtr);
return TCL_OK;
} else {
- sprintf(interp->result,
- "bad option \"%.50s\": must be clear, get, handle, or own",
- argv[1]);
+ Tcl_AppendResult(interp, "bad option \"", argv[1],
+ "\": must be clear, get, handle, or own", (char *) NULL);
return TCL_ERROR;
}
}
@@ -1155,11 +1153,12 @@ HandleTclCommand(clientData, offset, buffer, maxBytes)
Tcl_DStringInit(&oldResult);
Tcl_DStringGetResult(interp, &oldResult);
if (TkCopyAndGlobalEval(interp, command) == TCL_OK) {
- length = strlen(interp->result);
+ length = strlen(Tcl_GetStringResult(interp));
if (length > maxBytes) {
length = maxBytes;
}
- memcpy((VOID *) buffer, (VOID *) interp->result, (size_t) length);
+ memcpy((VOID *) buffer, (VOID *) Tcl_GetStringResult(interp),
+ (size_t) length);
buffer[length] = '\0';
} else {
length = -1;
@@ -1302,8 +1301,7 @@ LostSelection(clientData)
ClientData clientData; /* Pointer to CommandInfo structure. */
{
LostCommand *lostPtr = (LostCommand *) clientData;
- char *oldResultString;
- Tcl_FreeProc *oldFreeProc;
+ Tcl_Obj *objPtr;
Tcl_Interp *interp;
interp = lostPtr->interp;
@@ -1314,22 +1312,16 @@ LostSelection(clientData)
* restore it after executing the command.
*/
- oldFreeProc = interp->freeProc;
- if (oldFreeProc != TCL_STATIC) {
- oldResultString = interp->result;
- } else {
- oldResultString = (char *) ckalloc((unsigned)
- (strlen(interp->result) + 1));
- strcpy(oldResultString, interp->result);
- oldFreeProc = TCL_DYNAMIC;
- }
- interp->freeProc = TCL_STATIC;
+ objPtr = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(objPtr);
+ Tcl_ResetResult(interp);
+
if (TkCopyAndGlobalEval(interp, lostPtr->command) != TCL_OK) {
Tcl_BackgroundError(interp);
}
- Tcl_FreeResult(interp);
- interp->result = oldResultString;
- interp->freeProc = oldFreeProc;
+
+ Tcl_SetObjResult(interp, objPtr);
+ Tcl_DecrRefCount(objPtr);
Tcl_Release((ClientData) interp);