diff options
author | mdejong <mdejong> | 2004-02-12 23:19:16 (GMT) |
---|---|---|
committer | mdejong <mdejong> | 2004-02-12 23:19:16 (GMT) |
commit | ca6210d8ee161c693666daeaea1177f167b5bd6b (patch) | |
tree | 203658a18c8764b45f51ead82435e051a0b723a8 /win | |
parent | 7908936cc52c32a80423c76fa8d10a1dc9090355 (diff) | |
download | tcl-ca6210d8ee161c693666daeaea1177f167b5bd6b.zip tcl-ca6210d8ee161c693666daeaea1177f167b5bd6b.tar.gz tcl-ca6210d8ee161c693666daeaea1177f167b5bd6b.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')
-rw-r--r-- | win/tclWinInit.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c index ee83490..98a6936 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.44 2004/01/17 07:29:09 davygrvy Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.45 2004/02/12 23:19:17 mdejong Exp $ */ #include "tclWinInt.h" @@ -369,6 +369,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++ @@ -391,10 +410,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 @@ -404,7 +423,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)); |