From 85f8c7f8adce6d88440beee8743265e94b305ae1 Mon Sep 17 00:00:00 2001 From: mdejong Date: Thu, 12 Feb 2004 23:19:16 +0000 Subject: * 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. FossilOrigin-Name: dab9952df9336c69f025c5a4cedb54890bb710c6 --- ChangeLog | 9 +++++++++ win/tclWinInit.c | 27 +++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfe117d..b6d7396 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-02-12 Mo DeJong + + * 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. + 2004-02-10 David Gravereaux * win/nmakehlp.c: better macro grepping logic. 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)); -- cgit v0.12