This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: tcl8.4.1 - tclWinInit - AppendEnvironment()
On Wed, 14 Jan 2004 00:43:57 -0800 (PST)
Patrick Samson <p_samson@yahoo.com> wrote:
> This function was designed at a time when the
> parameter 'lib' was fed with a value such as "lib/tclX.Y",
> ...
> I suggest to change it
> entirely to a more robust one (RedHat/Cygwin people to
> inform developers at sourceforge?).
Patrick, thanks for pointing out this problem. I created a little
patch to fix this and checked in into the CVS for the Tcl project
on Source Forge. Feel free to use it with Insight.
2004-02-12 Mo DeJong <mdejong@users.sourceforge.net>
* 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.
Index: win/tclWinInit.c
===================================================================
RCS file: /cvsroot/sourcenav/src/tcl/win/tclWinInit.c,v
retrieving revision 1.1
diff -u -r1.1 tclWinInit.c
--- win/tclWinInit.c 5 Feb 2003 10:55:19 -0000 1.1
+++ win/tclWinInit.c 12 Feb 2004 23:12:29 -0000
@@ -336,6 +336,25 @@
char *str;
Tcl_DString ds;
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++
@@ -361,7 +380,7 @@
* UTF-8 chars because I know lib is ascii.
*/
- if ((pathc > 0) && (lstrcmpiA(lib + 4, pathv[pathc - 1]) != 0)) {
+ if ((pathc > 0) && (lstrcmpiA(shortlib, pathv[pathc - 1]) != 0)) {
/*
* TCL_LIBRARY is set but refers to a different tcl
* installation than the current version. Try fiddling with the
@@ -370,7 +389,7 @@
* version string.
*/
- pathv[pathc - 1] = (char *) (lib + 4);
+ pathv[pathc - 1] = shortlib;
Tcl_DStringInit(&ds);
str = Tcl_JoinPath(pathc, pathv, &ds);
objPtr = Tcl_NewStringObj(str, Tcl_DStringLength(&ds));