diff options
author | dgp <dgp@users.sourceforge.net> | 2003-11-10 20:34:11 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2003-11-10 20:34:11 (GMT) |
commit | f38d3f45e484452ba99ef07b5348e2c479650d4a (patch) | |
tree | cd0670715ebd514c77d2894bd372f15b2a7f3bac | |
parent | 3b1188db0613694c7f2529386464c9ef96e8bca3 (diff) | |
download | tcl-f38d3f45e484452ba99ef07b5348e2c479650d4a.zip tcl-f38d3f45e484452ba99ef07b5348e2c479650d4a.tar.gz tcl-f38d3f45e484452ba99ef07b5348e2c479650d4a.tar.bz2 |
* unix/tclUnixInit.c (TclpInitLibraryPath):
* win/tclWinInit.c (TclpInitLibraryPath): Fix for [Bug 832657]
that should not run afoul of startup constraints.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | unix/tclUnixInit.c | 23 | ||||
-rw-r--r-- | win/tclWinInit.c | 25 |
3 files changed, 49 insertions, 5 deletions
@@ -1,3 +1,9 @@ +2003-11-10 Don Porter <dgp@users.sourceforge.net> + + * unix/tclUnixInit.c (TclpInitLibraryPath): + * win/tclWinInit.c (TclpInitLibraryPath): Fix for [Bug 832657] + that should not run afoul of startup constraints. + 2003-11-10 Donal K. Fellows <donal.k.fellows@man.ac.uk> * tests/cmdIL.test: Stopped cmdIL-5.5 from stomping over the test diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 53853df..ea9b95a 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -7,7 +7,7 @@ * Copyright (c) 1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclUnixInit.c,v 1.35 2003/05/13 08:40:31 das Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.36 2003/11/10 20:34:15 dgp Exp $ */ #if defined(HAVE_CFBUNDLE) @@ -338,7 +338,25 @@ CONST char *path; /* Path to the executable in native */ if (path != NULL) { - Tcl_SplitPath(path, &pathc, &pathv); + int i, origc; + CONST char **origv; + + Tcl_SplitPath(path, &origc, &origv); + pathc = 0; + pathv = (CONST char **) ckalloc((unsigned int)(origc * sizeof(char *))); + for (i=0; i< origc; i++) { + if (origv[i][0] == '.') { + if (strcmp(origv[i], ".") == 0) { + /* do nothing */ + } else if (strcmp(origv[i], "..") == 0) { + pathc--; + } else { + pathv[pathc++] = origv[i]; + } + } else { + pathv[pathc++] = origv[i]; + } + } if (pathc > 2) { str = pathv[pathc - 2]; pathv[pathc - 2] = installLib; @@ -393,6 +411,7 @@ CONST char *path; /* Path to the executable in native Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } + ckfree((char *) origv); ckfree((char *) pathv); } diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 65ca7d1..d84925b 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.42 2003/08/06 23:48:42 hobbs Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.43 2003/11/10 20:34:17 dgp Exp $ */ #include "tclWinInt.h" @@ -197,7 +197,7 @@ TclpInitLibraryPath(path) */ sprintf(installLib, "lib/tcl%s", TCL_VERSION); - sprintf(developLib, "../tcl%s/library", TCL_PATCH_LEVEL); + sprintf(developLib, "tcl%s/library", TCL_PATCH_LEVEL); /* * Look for the library relative to default encoding dir. @@ -252,7 +252,25 @@ TclpInitLibraryPath(path) */ if (path != NULL) { - Tcl_SplitPath(path, &pathc, &pathv); + int i, origc; + CONST char **origv; + + Tcl_SplitPath(path, &origc, &origv); + pathc = 0; + pathv = (CONST char **) ckalloc((unsigned int)(origc * sizeof(char *))); + for (i=0; i< origc; i++) { + if (origv[i][0] == '.') { + if (strcmp(origv[i], ".") == 0) { + /* do nothing */ + } else if (strcmp(origv[i], "..") == 0) { + pathc--; + } else { + pathv[pathc++] = origv[i]; + } + } else { + pathv[pathc++] = origv[i]; + } + } if (pathc > 2) { str = pathv[pathc - 2]; pathv[pathc - 2] = installLib; @@ -307,6 +325,7 @@ TclpInitLibraryPath(path) Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } + ckfree((char *) origv); ckfree((char *) pathv); } |