summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
diff options
context:
space:
mode:
authormdejong <mdejong>2004-02-20 05:27:16 (GMT)
committermdejong <mdejong>2004-02-20 05:27:16 (GMT)
commitb113aaa0fbe796a63f7df34aa5cb900cc3cdfe60 (patch)
treef1ec3e7f2239b72afa6d21108c6625f9b894a37b /win/tclWinInit.c
parent1b45f8297f0b2cab2a3b775fb404ff655774243e (diff)
downloadtcl-b113aaa0fbe796a63f7df34aa5cb900cc3cdfe60.zip
tcl-b113aaa0fbe796a63f7df34aa5cb900cc3cdfe60.tar.gz
tcl-b113aaa0fbe796a63f7df34aa5cb900cc3cdfe60.tar.bz2
* win/tclWinInit.c (AppendEnvironment):
Use the tail component of the passed in lib path instead of just blindly using lib+4. That worked when lib was "lib/..." but fails for other values. Thanks go to Patrick Samson for pointing this out.
Diffstat (limited to 'win/tclWinInit.c')
-rw-r--r--win/tclWinInit.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 2a87937..96d6980 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclWinInit.c,v 1.40.2.2 2003/11/10 20:32:34 dgp Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.40.2.3 2004/02/20 05:27:17 mdejong Exp $
*/
#include "tclWinInt.h"
@@ -362,6 +362,25 @@ AppendEnvironment(
Tcl_Obj *objPtr;
Tcl_DString ds;
CONST char **pathv;
+ char *shortlib;
+
+ /*
+ * The shortlib value needs to be the tail component of the
+ * lib path. For example, "lib/tcl8.4" -> "tcl8.4" while
+ * "usr/share/tcl8.5" -> "tcl8.5".
+ */
+ for (shortlib = (char *) (lib + strlen(lib) - 1); shortlib > lib ; shortlib--) {
+ if (*shortlib == '/') {
+ if (shortlib == (lib + strlen(lib) - 1)) {
+ Tcl_Panic("last character in lib cannot be '/'");
+ }
+ shortlib++;
+ break;
+ }
+ }
+ if (shortlib == lib) {
+ Tcl_Panic("no '/' character found in lib");
+ }
/*
* The "L" preceeding the TCL_LIBRARY string is used to tell VC++
@@ -384,10 +403,10 @@ AppendEnvironment(
/*
* The lstrcmpi() will work even if pathv[pathc - 1] is random
- * UTF-8 chars because I know lib is ascii.
+ * UTF-8 chars because I know shortlib is ascii.
*/
- if ((pathc > 0) && (lstrcmpiA(lib + 4, pathv[pathc - 1]) != 0)) {
+ if ((pathc > 0) && (lstrcmpiA(shortlib, pathv[pathc - 1]) != 0)) {
CONST char *str;
/*
* TCL_LIBRARY is set but refers to a different tcl
@@ -397,7 +416,7 @@ AppendEnvironment(
* version string.
*/
- pathv[pathc - 1] = (lib + 4);
+ pathv[pathc - 1] = shortlib;
Tcl_DStringInit(&ds);
str = Tcl_JoinPath(pathc, pathv, &ds);
objPtr = Tcl_NewStringObj(str, Tcl_DStringLength(&ds));