Subject: Use (preferred) Tcl_ObjSetVar2 in stead of Tcl_SetVar in tclAppInit.c, both UNIX and Win.

From: "jan.nijtmans" <[email-masked]>
Date: Sun, 17 Feb 2013 21:03:56 +0000

---
 generic/tclDecls.h |  3 +++
 unix/tclAppInit.c  |  8 +++++---
 win/tclAppInit.c   | 10 +++++++---
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index fe9ba2b..d931873 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -3783,6 +3783,7 @@ extern const TclStubs *tclStubsPtr;
 #   undef Tcl_Init
 #   undef Tcl_SetPanicProc
 #   undef Tcl_SetVar
+#   undef Tcl_ObjSetVar2
 #   undef Tcl_StaticPackage
 #   undef TclFSGetNativePath
 #   define Tcl_CreateInterp() (tclStubsPtr->tcl_CreateInterp())
@@ -3791,6 +3792,8 @@ extern const TclStubs *tclStubsPtr;
 #   define Tcl_SetPanicProc(proc) (tclStubsPtr->tcl_SetPanicProc(proc))
 #   define Tcl_SetVar(interp, varName, newValue, flags) \
 	    (tclStubsPtr->tcl_SetVar(interp, varName, newValue, flags))
+#   define Tcl_ObjSetVar2(interp, part1, part2, newValue, flags) \
+	    (tclStubsPtr->tcl_ObjSetVar2(interp, part1, part2, newValue, flags))
 #endif
 
 #if defined(_WIN32) && defined(UNICODE)
diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c
index 159bbd8..f3edcff 100644
--- a/unix/tclAppInit.c
+++ b/unix/tclAppInit.c
@@ -48,7 +48,7 @@ MODULE_SCOPE int main(int, char **);
  */
 
 #ifdef TCL_LOCAL_MAIN_HOOK
-extern int TCL_LOCAL_MAIN_HOOK(int *argc, char ***argv);
+MODULE_SCOPE int TCL_LOCAL_MAIN_HOOK(int *argc, char ***argv);
 #endif
 
 /*
@@ -150,9 +150,11 @@ Tcl_AppInit(
      */
 
 #ifdef DJGPP
-    (Tcl_SetVar)(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY);
+    (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
+	    Tcl_NewStringObj("~/tclsh.rc", -1), TCL_GLOBAL_ONLY);
 #else
-    (Tcl_SetVar)(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
+    (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
+	    Tcl_NewStringObj("~/.tclshrc", -1), TCL_GLOBAL_ONLY);
 #endif
 
     return TCL_OK;
diff --git a/win/tclAppInit.c b/win/tclAppInit.c
index 56f45a0..753eaff 100644
--- a/win/tclAppInit.c
+++ b/win/tclAppInit.c
@@ -45,7 +45,10 @@ static void setargv(int *argcPtr, TCHAR ***argvPtr);
 #ifndef TCL_LOCAL_APPINIT
 #define TCL_LOCAL_APPINIT Tcl_AppInit
 #endif
-extern int TCL_LOCAL_APPINIT(Tcl_Interp *interp);
+#ifndef MODULE_SCOPE
+#   define MODULE_SCOPE extern
+#endif
+MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *);
 
 /*
  * The following #if block allows you to change how Tcl finds the startup
@@ -54,7 +57,7 @@ extern int TCL_LOCAL_APPINIT(Tcl_Interp *interp);
  */
 
 #ifdef TCL_LOCAL_MAIN_HOOK
-extern int TCL_LOCAL_MAIN_HOOK(int *argc, TCHAR ***argv);
+MODULE_SCOPE int TCL_LOCAL_MAIN_HOOK(int *argc, TCHAR ***argv);
 #endif
 
 /*
@@ -193,7 +196,8 @@ Tcl_AppInit(
      * specific startup file will be run under any conditions.
      */
 
-    (Tcl_SetVar)(interp, "tcl_rcFileName", "~/tclshrc.tcl", TCL_GLOBAL_ONLY);
+    (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
+	    Tcl_NewStringObj("~/tclshrc.tcl", -1), TCL_GLOBAL_ONLY);
     return TCL_OK;
 }
 
-- 
cgit v0.12