Attachment "globaleval.patch" to
ticket [2790615f]
added by
ferrieux
2009-05-13 22:59:39.
Index: generic/tkCanvas.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkCanvas.c,v
retrieving revision 1.59
diff -u -r1.59 tkCanvas.c
--- generic/tkCanvas.c 6 Jan 2009 21:58:15 -0000 1.59
+++ generic/tkCanvas.c 13 May 2009 15:49:01 -0000
@@ -5470,7 +5470,7 @@
/*
* Save all the relevant values from the canvasPtr, because it might be
- * deleted as part of either of the two calls to Tcl_VarEval below.
+ * deleted as part of either of the two calls to TkVarGlobalEval below.
*/
interp = canvasPtr->interp;
@@ -5497,7 +5497,7 @@
Tcl_Obj *fractions = ScrollFractions(xOrigin + inset,
xOrigin + width - inset, scrollX1, scrollX2);
- result = Tcl_VarEval(interp, xScrollCmd," ",Tcl_GetString(fractions),
+ result = TkVarGlobalEval(interp, xScrollCmd," ",Tcl_GetString(fractions),
NULL);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
@@ -5511,7 +5511,7 @@
Tcl_Obj *fractions = ScrollFractions(yOrigin + inset,
yOrigin + height - inset, scrollY1, scrollY2);
- result = Tcl_VarEval(interp, yScrollCmd," ",Tcl_GetString(fractions),
+ result = TkVarGlobalEval(interp, yScrollCmd," ",Tcl_GetString(fractions),
NULL);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
Index: generic/tkEntry.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkEntry.c,v
retrieving revision 1.58
diff -u -r1.58 tkEntry.c
--- generic/tkEntry.c 3 Feb 2009 23:55:47 -0000 1.58
+++ generic/tkEntry.c 13 May 2009 15:49:01 -0000
@@ -2933,7 +2933,7 @@
EntryVisibleRange(entryPtr, &first, &last);
Tcl_PrintDouble(NULL, first, firstStr);
Tcl_PrintDouble(NULL, last, lastStr);
- code = Tcl_VarEval(interp, entryPtr->scrollCmd, " ", firstStr, " ",
+ code = TkVarGlobalEval(interp, entryPtr->scrollCmd, " ", firstStr, " ",
lastStr, NULL);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
Index: generic/tkInt.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkInt.h,v
retrieving revision 1.101
diff -u -r1.101 tkInt.h
--- generic/tkInt.h 27 Apr 2009 10:31:35 -0000 1.101
+++ generic/tkInt.h 13 May 2009 15:49:02 -0000
@@ -1246,6 +1246,12 @@
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
+
+/* Interim utility (before inclusion into the Tcl stub table) */
+
+MODULE_SCOPE int TkVarGlobalEval(Tcl_Interp *interp, ...);
+
+
/*
* Unsupported commands.
*/
Index: generic/tkListbox.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkListbox.c,v
retrieving revision 1.55
diff -u -r1.55 tkListbox.c
--- generic/tkListbox.c 3 Feb 2009 23:55:47 -0000 1.55
+++ generic/tkListbox.c 13 May 2009 15:49:02 -0000
@@ -3267,12 +3267,12 @@
/*
* We must hold onto the interpreter from the listPtr because the data at
- * listPtr might be freed as a result of the Tcl_VarEval.
+ * listPtr might be freed as a result of the TkVarGlobalEval.
*/
interp = listPtr->interp;
Tcl_Preserve(interp);
- result = Tcl_VarEval(interp, listPtr->yScrollCmd, " ", firstStr, " ",
+ result = TkVarGlobalEval(interp, listPtr->yScrollCmd, " ", firstStr, " ",
lastStr, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -3332,12 +3332,12 @@
/*
* We must hold onto the interpreter because the data referred to at
- * listPtr might be freed as a result of the call to Tcl_VarEval.
+ * listPtr might be freed as a result of the call to TkVarGlobalEval.
*/
interp = listPtr->interp;
Tcl_Preserve(interp);
- result = Tcl_VarEval(interp, listPtr->xScrollCmd, " ", firstStr, " ",
+ result = TkVarGlobalEval(interp, listPtr->xScrollCmd, " ", firstStr, " ",
lastStr, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
Index: generic/tkMenu.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkMenu.c,v
retrieving revision 1.51
diff -u -r1.51 tkMenu.c
--- generic/tkMenu.c 10 Apr 2009 16:16:02 -0000 1.51
+++ generic/tkMenu.c 13 May 2009 15:49:03 -0000
@@ -1047,7 +1047,7 @@
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1);
Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1);
- result = Tcl_Eval(interp, Tcl_DStringValue(&ds));
+ result = Tcl_GlobalEval(interp, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
} else if ((mePtr->type == CHECK_BUTTON_ENTRY)
&& (mePtr->namePtr != NULL)) {
Index: generic/tkText.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkText.c,v
retrieving revision 1.89
diff -u -r1.89 tkText.c
--- generic/tkText.c 6 Feb 2009 08:12:07 -0000 1.89
+++ generic/tkText.c 13 May 2009 15:49:04 -0000
@@ -4860,7 +4860,7 @@
argv[2] = buffer;
argv[3] = NULL;
list = Tcl_Merge(3, argv);
- Tcl_VarEval(interp, Tcl_GetString(command), " ", list, NULL);
+ TkVarGlobalEval(interp, Tcl_GetString(command), " ", list, NULL);
ckfree(list);
if ((textPtr->flags & DESTROYED) ||
TkBTreeEpoch(textPtr->sharedTextPtr->tree) != oldStateEpoch) {
Index: generic/tkTextDisp.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextDisp.c,v
retrieving revision 1.72
diff -u -r1.72 tkTextDisp.c
--- generic/tkTextDisp.c 9 Dec 2008 21:22:56 -0000 1.72
+++ generic/tkTextDisp.c 13 May 2009 15:49:06 -0000
@@ -6059,7 +6059,7 @@
buf2[0] = ' ';
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
- code = Tcl_VarEval(interp, textPtr->xScrollCmd, buf1, buf2, NULL);
+ code = TkVarGlobalEval(interp, textPtr->xScrollCmd, buf1, buf2, NULL);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (horizontal scrolling command executed by text)");
@@ -6341,7 +6341,7 @@
buf2[0] = ' ';
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
- code = Tcl_VarEval(interp, textPtr->yScrollCmd, buf1, buf2, NULL);
+ code = TkVarGlobalEval(interp, textPtr->yScrollCmd, buf1, buf2, NULL);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (vertical scrolling command executed by text)");
Index: generic/tkUtil.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkUtil.c,v
retrieving revision 1.29
diff -u -r1.29 tkUtil.c
--- generic/tkUtil.c 10 Apr 2009 16:00:12 -0000 1.29
+++ generic/tkUtil.c 13 May 2009 15:49:06 -0000
@@ -1175,6 +1175,61 @@
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkVarGlobalEval --
+ *
+ * Like Tcl_VarEval but in global scope.
+ *
+ * This routine should find its home in Tcl and be used by Tk through the Tcl
+ * stub table, but is made available locally to ease modular testing between
+ * sync'ed releases of Tcl and Tk. so this routine does not reenter the
+ * interpreter.
+ *
+ *----------------------------------------------------------------------
+ */
+static int TkVarGlobalEvalVA(
+ Tcl_Interp *interp, /* Interpreter in which to evaluate command */
+ va_list argList) /* Variable argument list. */
+{
+ Tcl_DString buf;
+ char *string;
+ int result;
+
+ /*
+ * Copy the strings one after the other into a single larger string. Use
+ * stack-allocated space for small commands, but if the command gets too
+ * large than call ckalloc to create the space.
+ */
+
+ Tcl_DStringInit(&buf);
+ while (1) {
+ string = va_arg(argList, char *);
+ if (string == NULL) {
+ break;
+ }
+ Tcl_DStringAppend(&buf, string, -1);
+ }
+
+ result = Tcl_GlobalEval(interp, Tcl_DStringValue(&buf));
+ Tcl_DStringFree(&buf);
+ return result;
+}
+int TkVarGlobalEval(Tcl_Interp *interp, ...)
+{
+ va_list argList;
+ int result;
+
+ va_start(argList, interp);
+ result = TkVarGlobalEvalVA(interp, argList);
+ va_end(argList);
+
+ return result;
+}
+
+
/*
* Local Variables:
* mode: c
Index: generic/tkWindow.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkWindow.c,v
retrieving revision 1.103
diff -u -r1.103 tkWindow.c
--- generic/tkWindow.c 27 Feb 2009 23:04:39 -0000 1.103
+++ generic/tkWindow.c 13 May 2009 15:49:07 -0000
@@ -3181,7 +3181,7 @@
if (geometry != NULL) {
Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
- code = Tcl_VarEval(interp, "wm geometry . ", geometry, NULL);
+ code = TkVarGlobalEval(interp, "wm geometry . ", geometry, NULL);
if (code != TCL_OK) {
goto done;
}
Index: generic/ttk/ttkScroll.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/ttk/ttkScroll.c,v
retrieving revision 1.6
diff -u -r1.6 ttkScroll.c
--- generic/ttk/ttkScroll.c 19 Aug 2008 14:47:55 -0000 1.6
+++ generic/ttk/ttkScroll.c 13 May 2009 15:49:07 -0000
@@ -91,7 +91,7 @@
Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1);
Tcl_Preserve(corePtr);
- code = Tcl_VarEval(interp, s->scrollCmd, arg1, arg2, NULL);
+ code = TkVarGlobalEval(interp, s->scrollCmd, arg1, arg2, NULL);
if (WidgetDestroyed(corePtr)) {
Tcl_Release(corePtr);
return TCL_ERROR;
Index: macosx/tkMacOSXScale.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXScale.c,v
retrieving revision 1.16
diff -u -r1.16 tkMacOSXScale.c
--- macosx/tkMacOSXScale.c 9 Dec 2008 21:22:56 -0000 1.16
+++ macosx/tkMacOSXScale.c 13 May 2009 15:49:07 -0000
@@ -171,7 +171,7 @@
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
Tcl_Preserve((ClientData) interp);
sprintf(string, scalePtr->format, scalePtr->value);
- result = Tcl_VarEval(interp, scalePtr->command, " ", string, NULL);
+ result = TkVarGlobalEval(interp, scalePtr->command, " ", string, NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
Tcl_BackgroundException(interp, result);
Index: unix/tkUnixScale.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixScale.c,v
retrieving revision 1.14
diff -u -r1.14 tkUnixScale.c
--- unix/tkUnixScale.c 9 Dec 2008 21:22:56 -0000 1.14
+++ unix/tkUnixScale.c 13 May 2009 15:49:07 -0000
@@ -553,7 +553,7 @@
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
Tcl_Preserve((ClientData) interp);
sprintf(string, scalePtr->format, scalePtr->value);
- result = Tcl_VarEval(interp, scalePtr->command, " ", string,
+ result = TkVarGlobalEval(interp, scalePtr->command, " ", string,
(char *) NULL);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (command executed by scale)");