public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* tcl8.4.1 - tclWinInit - AppendEnvironment()
@ 2004-01-14  8:43 Patrick Samson
  2004-02-12 23:26 ` Mo DeJong
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Samson @ 2004-01-14  8:43 UTC (permalink / raw)
  To: insight

This function was designed at a time when the
parameter
'lib' was fed with a value such as "lib/tclX.Y",
so there is two times a "lib + 4" pointer to extract
the "tclX.Y" part.

But the value has changed to "share/tclX.Y" in
TclpInitLibraryPath(), and now lib + 4 points to
"/tclX.Y", which is of no use !

The caller and the calling should be accorded.
As "lib + a number" is a poor coding design (this
issue
shows how fragile it is), I suggest to change it
entirely to a more robust one (RedHat/Cygwin people to
inform developers at sourceforge?).


I also have a doubt about this part of code, at the
end:
  } else {
      objPtr = Tcl_NewStringObj(buf, -1);
  }
  Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);

In my understanding, it means that the same object is
appended a second time. Am I wrong?


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tcl8.4.1 - tclWinInit - AppendEnvironment()
  2004-01-14  8:43 tcl8.4.1 - tclWinInit - AppendEnvironment() Patrick Samson
@ 2004-02-12 23:26 ` Mo DeJong
  0 siblings, 0 replies; 2+ messages in thread
From: Mo DeJong @ 2004-02-12 23:26 UTC (permalink / raw)
  To: insight

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));

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-12 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-14  8:43 tcl8.4.1 - tclWinInit - AppendEnvironment() Patrick Samson
2004-02-12 23:26 ` Mo DeJong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).