*** doc/SetResult.3.orig	Wed Nov 19 22:36:12 2008
--- doc/SetResult.3	Thu Nov 27 23:21:18 2008
***************
*** 11,17 ****
  .TH Tcl_SetResult 3 8.0 Tcl "Tcl Library Procedures"
  .BS
  .SH NAME
! Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendResultVA, Tcl_AppendElement, Tcl_ResetResult, Tcl_FreeResult \- manipulate Tcl result
  .SH SYNOPSIS
  .nf
  \fB#include <tcl.h>\fR
--- 11,17 ----
  .TH Tcl_SetResult 3 8.0 Tcl "Tcl Library Procedures"
  .BS
  .SH NAME
! Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_SetStringResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendResultVA, Tcl_AppendElement, Tcl_ResetResult, Tcl_FreeResult \- manipulate Tcl result
  .SH SYNOPSIS
  .nf
  \fB#include <tcl.h>\fR
***************
*** 23,28 ****
--- 23,30 ----
  .sp
  \fBTcl_SetResult\fR(\fIinterp, result, freeProc\fR)
  .sp
+ \fBTcl_SetStringResult\fR(\fIinterp, result\fR)
+ .sp
  const char *
  \fBTcl_GetStringResult\fR(\fIinterp\fR)
  .sp
***************
*** 41,50 ****
  Interpreter whose result is to be modified or read.
  .AP Tcl_Obj *objPtr in
  Object value to become result for \fIinterp\fR.
! .AP char *result in
  String value to become result for \fIinterp\fR or to be
  appended to the existing result.
! .AP char *element in
  String value to append as a list element
  to the existing result of \fIinterp\fR.
  .AP Tcl_FreeProc *freeProc in
--- 43,52 ----
  Interpreter whose result is to be modified or read.
  .AP Tcl_Obj *objPtr in
  Object value to become result for \fIinterp\fR.
! .AP "const char" *result in
  String value to become result for \fIinterp\fR or to be
  appended to the existing result.
! .AP "const char" *element in
  String value to append as a list element
  to the existing result of \fIinterp\fR.
  .AP Tcl_FreeProc *freeProc in
***************
*** 60,66 ****
  The procedures described here are utilities for manipulating the
  result value in a Tcl interpreter.
  The interpreter result may be either a Tcl object or a string.
! For example, \fBTcl_SetObjResult\fR and \fBTcl_SetResult\fR
  set the interpreter result to, respectively, an object and a string.
  Similarly, \fBTcl_GetObjResult\fR and \fBTcl_GetStringResult\fR
  return the interpreter result as an object and as a string.
--- 62,68 ----
  The procedures described here are utilities for manipulating the
  result value in a Tcl interpreter.
  The interpreter result may be either a Tcl object or a string.
! For example, \fBTcl_SetObjResult\fR and \fBTcl_SetStringResult\fR
  set the interpreter result to, respectively, an object and a string.
  Similarly, \fBTcl_GetObjResult\fR and \fBTcl_GetStringResult\fR
  return the interpreter result as an object and as a string.
***************
*** 88,96 ****
  they should use \fBTcl_IncrRefCount\fR to increment its reference count
  in order to keep it from being freed too early or accidentally changed.
  .PP
! \fBTcl_SetResult\fR
  arranges for \fIresult\fR to be the result for the current Tcl
  command in \fIinterp\fR, replacing any existing result.
  The \fIfreeProc\fR argument specifies how to manage the storage
  for the \fIresult\fR argument;
  it is discussed in the section
--- 90,106 ----
  they should use \fBTcl_IncrRefCount\fR to increment its reference count
  in order to keep it from being freed too early or accidentally changed.
  .PP
! \fBTcl_SetStringResult\fR
  arranges for \fIresult\fR to be the result for the current Tcl
  command in \fIinterp\fR, replacing any existing result.
+ .PP
+ \fBTcl_SetResult\fR
+ arranges for \fIresult\fR to be the result for the current Tcl
+ command in \fIinterp\fR, replacing any existing result. This
+ function is deprecated in favor of Tcl_SetStringResult. If you
+ want to be sure that Tcl_SetResult functions as before despite
+ of the compatibility macro, compile your extension with
+ -DTCL_NO_DEPRECATED. But using Tcl_SetStringResult is prefered.
  The \fIfreeProc\fR argument specifies how to manage the storage
  for the \fIresult\fR argument;
  it is discussed in the section
***************
*** 98,103 ****
--- 108,116 ----
  If \fIresult\fR is \fBNULL\fR, then \fIfreeProc\fR is ignored
  and \fBTcl_SetResult\fR
  re-initializes \fIinterp\fR's result to point to an empty string.
+ In that case, Tcl_ResetResult is a better choice.
+ If \fIresult\fR is \fBTCL_STATIC\fR or \fBTCL_VOLATILE\fR,
+ then you can simply replace the call with \fBTcl_SetStringResult\fR.
  .PP
  \fBTcl_GetStringResult\fR returns the result for \fIinterp\fR as a string.
  If the result was set to an object by a \fBTcl_SetObjResult\fR call,
***************
*** 183,189 ****
  because it can make the result's string and object forms inconsistent.
  Programs should always read the result
  using the procedures \fBTcl_GetObjResult\fR or \fBTcl_GetStringResult\fR,
! and write the result using \fBTcl_SetObjResult\fR or \fBTcl_SetResult\fR.
  .SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT"
  .PP
  \fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how 
--- 196,202 ----
  because it can make the result's string and object forms inconsistent.
  Programs should always read the result
  using the procedures \fBTcl_GetObjResult\fR or \fBTcl_GetStringResult\fR,
! and write the result using \fBTcl_SetObjResult\fR or \fBTcl_SetStringResult\fR.
  .SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT"
  .PP
  \fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how 
***************
*** 196,206 ****
  If \fIfreeProc\fR is \fBTCL_STATIC\fR it means that \fIresult\fR
  refers to an area of static storage that is guaranteed not to be
  modified until at least the next call to \fBTcl_Eval\fR.
- If \fIfreeProc\fR
- is \fBTCL_DYNAMIC\fR it means that \fIresult\fR was allocated with a call
- to \fBTcl_Alloc\fR and is now the property of the Tcl system.
- \fBTcl_SetResult\fR will arrange for the string's storage to be
- released by calling \fBTcl_Free\fR when it is no longer needed.
  If \fIfreeProc\fR is \fBTCL_VOLATILE\fR it means that \fIresult\fR
  points to an area of memory that is likely to be overwritten when
  \fBTcl_SetResult\fR returns (e.g. it points to something in a stack frame).
--- 209,214 ----
***************
*** 208,213 ****
--- 216,246 ----
  dynamically allocated storage and arrange for the copy to be the
  result for the current Tcl command.
  .PP
+ Starting with Tcl 8.6, other values than \fBTCL_STATIC\f and
+ \fBTCL_VOLATILE\fR are problematic. Because of the compatibility
+ macro, it will lead to a memory leak: the freeProc will never
+ be executed. If you want to prevent that, compile your extension
+ with -DTCL_NO_DEPRECATED, then everything will function as
+ before. For details about that, see TIP #340.
+ .PP
+ If \fIfreeProc\fR
+ is \fBTCL_DYNAMIC\fR it means that \fIresult\fR was allocated with a call
+ to \fBTcl_Alloc\fR and is now the property of the Tcl system.
+ \fBTcl_SetResult\fR will arrange for the string's storage to be
+ released by calling \fBTcl_Free\fR when it is no longer needed. You
+ should replace 
+ .PP
+ .CS
+ Tcl_SetResult(interp, string, TCL_DYNAMIC);
+ .CE
+ .PP
+ with
+ .PP
+ .CS
+ Tcl_SetStringResult(interp, string);
+ ckfree(string);
+ .CE
+ .PP
  If \fIfreeProc\fR is not one of the values \fBTCL_STATIC\fR,
  \fBTCL_DYNAMIC\fR, and \fBTCL_VOLATILE\fR, then it is the address
  of a procedure that Tcl should call to free the string.
***************
*** 222,228 ****
  .CE
  .PP
  When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to
! the value of \fIresult\fR passed to \fBTcl_SetResult\fR.
  .SH "SEE ALSO"
  Tcl_AddErrorInfo, Tcl_CreateObjCommand, Tcl_SetErrorCode, Tcl_Interp
  .SH KEYWORDS
--- 255,274 ----
  .CE
  .PP
  When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to
! the value of \fIresult\fR passed to \fBTcl_SetResult\fR. You
! should replace 
! .PP
! .CS
! Tcl_SetResult(interp, string, freeProc);
! .CE
! .PP
! with
! .PP
! .CS
! Tcl_SetStringResult(interp, string);
! freeProc(string);
! .CE
! .PP
  .SH "SEE ALSO"
  Tcl_AddErrorInfo, Tcl_CreateObjCommand, Tcl_SetErrorCode, Tcl_Interp
  .SH KEYWORDS
*** win/tcl.m4.orig	Sat Nov 15 00:52:01 2008
--- win/tcl.m4	Sat Nov 15 00:52:24 2008
***************
*** 529,535 ****
  
  	CFLAGS_DEBUG=-g
  	CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
! 	CFLAGS_WARNING="-Wall"
  	LDFLAGS_DEBUG=
  	LDFLAGS_OPTIMIZE=
  
--- 529,535 ----
  
  	CFLAGS_DEBUG=-g
  	CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
! 	CFLAGS_WARNING="-Wall -Wwrite-strings"
  	LDFLAGS_DEBUG=
  	LDFLAGS_OPTIMIZE=
  
*** unix/tcl.m4.orig	Sat Nov 15 00:52:08 2008
--- unix/tcl.m4	Sat Nov 15 00:52:31 2008
***************
*** 1103,1109 ****
      CFLAGS_DEBUG=-g
      AS_IF([test "$GCC" = yes], [
  	CFLAGS_OPTIMIZE="-O2"
! 	CFLAGS_WARNING="-Wall"
      ], [
  	CFLAGS_OPTIMIZE=-O
  	CFLAGS_WARNING=""
--- 1103,1109 ----
      CFLAGS_DEBUG=-g
      AS_IF([test "$GCC" = yes], [
  	CFLAGS_OPTIMIZE="-O2"
! 	CFLAGS_WARNING="-Wall -Wwrite-strings"
      ], [
  	CFLAGS_OPTIMIZE=-O
  	CFLAGS_WARNING=""
*** generic/tclTest.c.orig	Thu Nov 27 23:23:29 2008
--- generic/tclTest.c	Thu Nov 27 23:22:59 2008
***************
*** 18,23 ****
--- 18,24 ----
   */
  
  #define TCL_TEST
+ #define TCL_NO_DEPRECATED
  #include "tclInt.h"
  
  /*
***************
*** 746,752 ****
  
      if (argc < 2) {
  	wrongNumArgs:
! 	Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
  	return TCL_ERROR;
      }
      if (strcmp(argv[1], "create") == 0) {
--- 747,753 ----
  
      if (argc < 2) {
  	wrongNumArgs:
! 	Tcl_SetStringResult(interp, "wrong # args");
  	return TCL_ERROR;
      }
      if (strcmp(argv[1], "create") == 0) {
***************
*** 827,833 ****
  		if (Tcl_CreateThread(&threadID, AsyncThreadProc,
  			(ClientData) asyncPtr, TCL_THREAD_STACK_DEFAULT,
  			TCL_THREAD_NOFLAGS) != TCL_OK) {
! 		    Tcl_SetResult(interp, "can't create thread", TCL_STATIC);
  		    return TCL_ERROR;
  		}
  		break;
--- 828,834 ----
  		if (Tcl_CreateThread(&threadID, AsyncThreadProc,
  			(ClientData) asyncPtr, TCL_THREAD_STACK_DEFAULT,
  			TCL_THREAD_NOFLAGS) != TCL_OK) {
! 		    Tcl_SetStringResult(interp, "can't create thread");
  		    return TCL_ERROR;
  		}
  		break;
***************
*** 948,954 ****
  	Tcl_DStringResult(interp, &delString);
      } else if (strcmp(argv[1], "get") == 0) {
  	if (Tcl_GetCommandInfo(interp, argv[2], &info) ==0) {
! 	    Tcl_SetResult(interp, "??", TCL_STATIC);
  	    return TCL_OK;
  	}
  	if (info.proc == CmdProc1) {
--- 949,955 ----
  	Tcl_DStringResult(interp, &delString);
      } else if (strcmp(argv[1], "get") == 0) {
  	if (Tcl_GetCommandInfo(interp, argv[2], &info) ==0) {
! 	    Tcl_SetStringResult(interp, "??");
  	    return TCL_OK;
  	}
  	if (info.proc == CmdProc1) {
***************
*** 1075,1081 ****
  	token = Tcl_CreateCommand(interp, argv[2], CmdProc1,
  		(ClientData) "original", NULL);
  	sprintf(buf, "%p", (void *)token);
! 	Tcl_SetResult(interp, buf, TCL_VOLATILE);
      } else if (strcmp(argv[1], "name") == 0) {
  	Tcl_Obj *objPtr;
  
--- 1076,1082 ----
  	token = Tcl_CreateCommand(interp, argv[2], CmdProc1,
  		(ClientData) "original", NULL);
  	sprintf(buf, "%p", (void *)token);
! 	Tcl_SetStringResult(interp, buf);
      } else if (strcmp(argv[1], "name") == 0) {
  	Tcl_Obj *objPtr;
  
***************
*** 1183,1189 ****
  	result = Tcl_Eval(interp, argv[2]);
  	Tcl_DeleteTrace(interp, cmdTrace);
  	if (!deleteCalled) {
! 	    Tcl_SetResult(interp, "Delete wasn't called", TCL_STATIC);
  	    return TCL_ERROR;
  	} else {
  	    return result;
--- 1184,1190 ----
  	result = Tcl_Eval(interp, argv[2]);
  	Tcl_DeleteTrace(interp, cmdTrace);
  	if (!deleteCalled) {
! 	    Tcl_SetStringResult(interp, "Delete wasn't called");
  	    return TCL_ERROR;
  	} else {
  	    return result;
***************
*** 1485,1491 ****
      Tcl_Interp *slave;
  
      if (argc != 4) {
! 	Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
  	return TCL_ERROR;
      }
  
--- 1486,1492 ----
      Tcl_Interp *slave;
  
      if (argc != 4) {
! 	Tcl_SetStringResult(interp, "wrong # args");
  	return TCL_ERROR;
      }
  
***************
*** 1594,1600 ****
  
      if (argc < 2) {
  	wrongNumArgs:
! 	Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
  	return TCL_ERROR;
      }
      if (strcmp(argv[1], "append") == 0) {
--- 1595,1601 ----
  
      if (argc < 2) {
  	wrongNumArgs:
! 	Tcl_SetStringResult(interp, "wrong # args");
  	return TCL_ERROR;
      }
      if (strcmp(argv[1], "append") == 0) {
***************
*** 1624,1638 ****
  	if (argc != 2) {
  	    goto wrongNumArgs;
  	}
! 	Tcl_SetResult(interp, Tcl_DStringValue(&dstring), TCL_VOLATILE);
      } else if (strcmp(argv[1], "gresult") == 0) {
  	if (argc != 3) {
  	    goto wrongNumArgs;
  	}
  	if (strcmp(argv[2], "staticsmall") == 0) {
! 	    Tcl_SetResult(interp, "short", TCL_STATIC);
  	} else if (strcmp(argv[2], "staticlarge") == 0) {
! 	    Tcl_SetResult(interp, "first0 first1 first2 first3 first4 first5 first6 first7 first8 first9\nsecond0 second1 second2 second3 second4 second5 second6 second7 second8 second9\nthird0 third1 third2 third3 third4 third5 third6 third7 third8 third9\nfourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9\nfifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9\nsixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9\nseventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9\n", TCL_STATIC);
  	} else if (strcmp(argv[2], "free") == 0) {
  	    char *s = (char *) ckalloc(100);
  	    strcpy(s, "This is a malloc-ed string");
--- 1625,1639 ----
  	if (argc != 2) {
  	    goto wrongNumArgs;
  	}
! 	Tcl_SetStringResult(interp, Tcl_DStringValue(&dstring));
      } else if (strcmp(argv[1], "gresult") == 0) {
  	if (argc != 3) {
  	    goto wrongNumArgs;
  	}
  	if (strcmp(argv[2], "staticsmall") == 0) {
! 	    Tcl_SetStringResult(interp, "short");
  	} else if (strcmp(argv[2], "staticlarge") == 0) {
! 	    Tcl_SetStringResult(interp, "first0 first1 first2 first3 first4 first5 first6 first7 first8 first9\nsecond0 second1 second2 second3 second4 second5 second6 second7 second8 second9\nthird0 third1 third2 third3 third4 third5 third6 third7 third8 third9\nfourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9\nfifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9\nsixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9\nseventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9\n");
  	} else if (strcmp(argv[2], "free") == 0) {
  	    char *s = (char *) ckalloc(100);
  	    strcpy(s, "This is a malloc-ed string");
***************
*** 2225,2231 ****
  		" expression\"", NULL);
  	return TCL_ERROR;
      }
!     Tcl_SetResult(interp, "This is a result", TCL_STATIC);
      result = Tcl_ExprLong(interp, argv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
--- 2226,2232 ----
  		" expression\"", NULL);
  	return TCL_ERROR;
      }
!     Tcl_SetStringResult(interp, "This is a result");
      result = Tcl_ExprLong(interp, argv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
***************
*** 2267,2273 ****
  	Tcl_WrongNumArgs(interp, 1, objv, "expression");
  	return TCL_ERROR;
      }
!     Tcl_SetResult(interp, "This is a result", TCL_STATIC);
      result = Tcl_ExprLongObj(interp, objv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
--- 2268,2274 ----
  	Tcl_WrongNumArgs(interp, 1, objv, "expression");
  	return TCL_ERROR;
      }
!     Tcl_SetStringResult(interp, "This is a result");
      result = Tcl_ExprLongObj(interp, objv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
***************
*** 2310,2316 ****
  		" expression\"", NULL);
  	return TCL_ERROR;
      }
!     Tcl_SetResult(interp, "This is a result", TCL_STATIC);
      result = Tcl_ExprDouble(interp, argv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
--- 2311,2317 ----
  		" expression\"", NULL);
  	return TCL_ERROR;
      }
!     Tcl_SetStringResult(interp, "This is a result");
      result = Tcl_ExprDouble(interp, argv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
***************
*** 2353,2359 ****
  	Tcl_WrongNumArgs(interp, 1, objv, "expression");
  	return TCL_ERROR;
      }
!     Tcl_SetResult(interp, "This is a result", TCL_STATIC);
      result = Tcl_ExprDoubleObj(interp, objv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
--- 2354,2360 ----
  	Tcl_WrongNumArgs(interp, 1, objv, "expression");
  	return TCL_ERROR;
      }
!     Tcl_SetStringResult(interp, "This is a result");
      result = Tcl_ExprDoubleObj(interp, objv[1], &exprResult);
      if (result != TCL_OK) {
  	return result;
***************
*** 3195,3201 ****
  	    resultPtr->type = TCL_WIDE_INT;
  	    resultPtr->wideValue = ((w0 > w1)? w0 : w1);
  	} else {
! 	    Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
  	    result = TCL_ERROR;
  	}
      } else if (args[0].type == TCL_DOUBLE) {
--- 3196,3202 ----
  	    resultPtr->type = TCL_WIDE_INT;
  	    resultPtr->wideValue = ((w0 > w1)? w0 : w1);
  	} else {
! 	    Tcl_SetStringResult(interp, "T3: wrong type for arg 2");
  	    result = TCL_ERROR;
  	}
      } else if (args[0].type == TCL_DOUBLE) {
***************
*** 3217,3223 ****
  	    resultPtr->type = TCL_DOUBLE;
  	    resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
  	} else {
! 	    Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
  	    result = TCL_ERROR;
  	}
      } else if (args[0].type == TCL_WIDE_INT) {
--- 3218,3224 ----
  	    resultPtr->type = TCL_DOUBLE;
  	    resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
  	} else {
! 	    Tcl_SetStringResult(interp, "T3: wrong type for arg 2");
  	    result = TCL_ERROR;
  	}
      } else if (args[0].type == TCL_WIDE_INT) {
***************
*** 3240,3250 ****
  	    resultPtr->type = TCL_WIDE_INT;
  	    resultPtr->wideValue = ((w0 > w1)? w0 : w1);
  	} else {
! 	    Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
  	    result = TCL_ERROR;
  	}
      } else {
! 	Tcl_SetResult(interp, "T3: wrong type for arg 1", TCL_STATIC);
  	result = TCL_ERROR;
      }
      return result;
--- 3241,3251 ----
  	    resultPtr->type = TCL_WIDE_INT;
  	    resultPtr->wideValue = ((w0 > w1)? w0 : w1);
  	} else {
! 	    Tcl_SetStringResult(interp, "T3: wrong type for arg 2");
  	    result = TCL_ERROR;
  	}
      } else {
! 	Tcl_SetStringResult(interp, "T3: wrong type for arg 1");
  	result = TCL_ERROR;
      }
      return result;
***************
*** 4213,4219 ****
      const char **argv)		/* Argument strings. */
  {
      if (argc > 6) {
! 	Tcl_SetResult(interp, "too many args", TCL_STATIC);
  	return TCL_ERROR;
      }
      Tcl_SetErrorCode(interp, argv[1], argv[2], argv[3], argv[4],
--- 4214,4220 ----
      const char **argv)		/* Argument strings. */
  {
      if (argc > 6) {
! 	Tcl_SetStringResult(interp, "too many args");
  	return TCL_ERROR;
      }
      Tcl_SetErrorCode(interp, argv[1], argv[2], argv[3], argv[4],
***************
*** 4767,4773 ****
      const char *value;
  
      if (argc == 2) {
! 	Tcl_SetResult(interp, "before get", TCL_STATIC);
  	value = Tcl_GetVar2(interp, argv[1], NULL, flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
--- 4768,4774 ----
      const char *value;
  
      if (argc == 2) {
! 	Tcl_SetStringResult(interp, "before get");
  	value = Tcl_GetVar2(interp, argv[1], NULL, flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
***************
*** 4775,4781 ****
  	Tcl_AppendElement(interp, value);
  	return TCL_OK;
      } else if (argc == 3) {
! 	Tcl_SetResult(interp, "before set", TCL_STATIC);
  	value = Tcl_SetVar2(interp, argv[1], NULL, argv[2], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
--- 4776,4782 ----
  	Tcl_AppendElement(interp, value);
  	return TCL_OK;
      } else if (argc == 3) {
! 	Tcl_SetStringResult(interp, "before set");
  	value = Tcl_SetVar2(interp, argv[1], NULL, argv[2], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
***************
*** 4799,4805 ****
      const char *value;
  
      if (argc == 3) {
! 	Tcl_SetResult(interp, "before get", TCL_STATIC);
  	value = Tcl_GetVar2(interp, argv[1], argv[2], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
--- 4800,4806 ----
      const char *value;
  
      if (argc == 3) {
! 	Tcl_SetStringResult(interp, "before get");
  	value = Tcl_GetVar2(interp, argv[1], argv[2], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
***************
*** 4807,4813 ****
  	Tcl_AppendElement(interp, value);
  	return TCL_OK;
      } else if (argc == 4) {
! 	Tcl_SetResult(interp, "before set", TCL_STATIC);
  	value = Tcl_SetVar2(interp, argv[1], argv[2], argv[3], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
--- 4808,4814 ----
  	Tcl_AppendElement(interp, value);
  	return TCL_OK;
      } else if (argc == 4) {
! 	Tcl_SetStringResult(interp, "before set");
  	value = Tcl_SetVar2(interp, argv[1], argv[2], argv[3], flags);
  	if (value == NULL) {
  	    return TCL_ERROR;
***************
*** 4876,4882 ****
      objPtr = NULL;		/* Lint. */
      switch ((enum options) index) {
      case RESULT_SMALL:
! 	Tcl_SetResult(interp, "small result", TCL_VOLATILE);
  	break;
      case RESULT_APPEND:
  	Tcl_AppendResult(interp, "append result", NULL);
--- 4877,4883 ----
      objPtr = NULL;		/* Lint. */
      switch ((enum options) index) {
      case RESULT_SMALL:
! 	Tcl_SetResult(interp, (char *)"small result", TCL_VOLATILE);
  	break;
      case RESULT_APPEND:
  	Tcl_AppendResult(interp, "append result", NULL);
***************
*** 4984,4990 ****
        Tcl_SetObjResult(interp, idObj);
        return TCL_OK;
    } else {
!       Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
        return TCL_ERROR;
    }
  }
--- 4985,4991 ----
        Tcl_SetObjResult(interp, idObj);
        return TCL_OK;
    } else {
!       Tcl_SetStringResult(interp, "wrong # args");
        return TCL_ERROR;
    }
  }
***************
*** 5786,5792 ****
  	 * Don't use Tcl_WrongNumArgs here, as that is the function
  	 * we want to test!
  	 */
! 	Tcl_SetResult(interp, "insufficient arguments", TCL_STATIC);
  	return TCL_ERROR;
      }
  
--- 5787,5793 ----
  	 * Don't use Tcl_WrongNumArgs here, as that is the function
  	 * we want to test!
  	 */
! 	Tcl_SetStringResult(interp, "insufficient arguments");
  	return TCL_ERROR;
      }
  
***************
*** 5803,5809 ****
  	/*
  	 * Asked for more arguments than were given.
  	 */
! 	Tcl_SetResult(interp, "insufficient arguments", TCL_STATIC);
  	return TCL_ERROR;
      }
  
--- 5804,5810 ----
  	/*
  	 * Asked for more arguments than were given.
  	 */
! 	Tcl_SetStringResult(interp, "insufficient arguments");
  	return TCL_ERROR;
      }
  
***************
*** 6520,6526 ****
      const char **argv)
  {
      if (argc < 2) {
! 	Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
  	return TCL_ERROR;
      } else {
  	int val, i, total=0;
--- 6521,6527 ----
      const char **argv)
  {
      if (argc < 2) {
! 	Tcl_SetStringResult(interp, "wrong # args");
  	return TCL_ERROR;
      } else {
  	int val, i, total=0;
*** generic/tcl.h.orig	Thu Nov 27 23:29:59 2008
--- generic/tcl.h	Thu Nov 27 23:31:30 2008
***************
*** 2440,2445 ****
--- 2440,2452 ----
  	(*((tablePtr)->createProc))(tablePtr, key, newPtr)
  
  /*
+  * TIP #340
+  */
+ 
+ #define Tcl_SetStringResult(interp, s) \
+ 	Tcl_SetObjResult((interp), Tcl_NewStringObj((s), -1))
+ 
+ /*
   * Macros that eliminate the overhead of the thread synchronization functions
   * when compiling without thread support.
   */
***************
*** 2470,2475 ****
--- 2477,2485 ----
  #   undef  Tcl_GlobalEvalObj
  #   define Tcl_GlobalEvalObj(interp,objPtr) \
  	Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
+ #   undef  Tcl_SetResult
+ #   define Tcl_SetResult(interp, s, freeProc) \
+ 	Tcl_SetObjResult((interp), Tcl_NewStringObj((s), -1))
  
      /*
       * These function have been renamed. The old names are deprecated, but we
*** generic/tclResult.c.orig	Thu Nov 27 00:04:36 2008
--- generic/tclResult.c	Thu Nov 27 23:36:37 2008
***************
*** 12,17 ****
--- 12,18 ----
   */
  
  #include "tclInt.h"
+ #undef  Tcl_SetResult
  
  /*
   * Indices of the standard return options dictionary keys.
