From 1247e7630960b0ed9658d606b4a11e5855bf5298 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 18 Jun 2004 20:38:00 +0000 Subject: * generic/tclEncoding.c: Static TclFindEncodings -> FindEncodings. * generic/tclInt.h: Updated TclpFindExecutable() so that failed * generic/tclUtil.c: attempts to find the executable are saved * unix/tclUnixFile.c: just as successful finds are. [Patch 966053] * unix/tclUnixTest.c: --- ChangeLog | 8 ++++++++ generic/tclEncoding.c | 28 +++++++++++++++------------- generic/tclInt.h | 3 ++- generic/tclUtil.c | 3 ++- unix/tclUnixFile.c | 5 +++-- unix/tclUnixTest.c | 10 +++++++--- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index feebc45..529168a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-06-18 Don Porter + + * generic/tclEncoding.c: Static TclFindEncodings -> FindEncodings. + * generic/tclInt.h: Updated TclpFindExecutable() so that failed + * generic/tclUtil.c: attempts to find the executable are saved + * unix/tclUnixFile.c: just as successful finds are. [Patch 966053] + * unix/tclUnixTest.c: + 2004-06-18 Kevin B. Kenny * tests/winFCmd.test (winFCmd-16.12): Changed test to diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 7552eb4..558487e 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEncoding.c,v 1.22 2004/05/07 20:01:23 rmax Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.23 2004/06/18 20:38:01 dgp Exp $ */ #include "tclInt.h" @@ -236,7 +236,7 @@ static int UtfExtToUtfIntProc _ANSI_ARGS_((ClientData clientData, Tcl_EncodingState *statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr)); -static int TclFindEncodings _ANSI_ARGS_((CONST char *argv0)); +static int FindEncodings(); /* @@ -1142,7 +1142,7 @@ Tcl_FindExecutable(argv0) /* * The value returned from TclpNameOfExecutable is a UTF string that * is possibly dirty depending on when it was initialized. - * TclFindEncodings will indicate whether we must "clean" the UTF (as + * FindEncodings will indicate whether we must "clean" the UTF (as * reported by the underlying system). To assure that the UTF string * is a properly encoded native string for this system, convert the * UTF string to the default native encoding before the default @@ -1151,7 +1151,7 @@ Tcl_FindExecutable(argv0) */ Tcl_UtfToExternalDString(NULL, name, -1, &buffer); - mustCleanUtf = TclFindEncodings(argv0); + mustCleanUtf = FindEncodings(); /* * Now it is OK to convert the native string back to UTF and set @@ -1174,7 +1174,7 @@ Tcl_FindExecutable(argv0) return; done: - (void) TclFindEncodings(argv0); + (void) FindEncodings(); } /* @@ -2942,7 +2942,7 @@ unilen(src) /* *------------------------------------------------------------------------- * - * TclFindEncodings -- + * FindEncodings -- * * Find and load the encoding file for this operating system. * Before this is called, Tcl makes assumptions about the @@ -2959,10 +2959,8 @@ unilen(src) *------------------------------------------------------------------------- */ -int -TclFindEncodings(argv0) - CONST char *argv0; /* Name of executable from argv[0] to main() - * in native multi-byte encoding. */ +static int +FindEncodings() { int mustCleanUtf = 0; @@ -2974,7 +2972,6 @@ TclFindEncodings(argv0) TclpInitLock(); if (encodingsInitialized == 0) { - char *native; Tcl_Obj *pathPtr; Tcl_DString libPath, buffer; @@ -2985,8 +2982,13 @@ TclFindEncodings(argv0) encodingsInitialized = 1; - native = TclpFindExecutable(argv0); - mustCleanUtf = TclpInitLibraryPath(native); + /* + * NOTE: we can safely make direct use of tclNativeExecutableName + * because we know all our callers ( Tcl_FindExecutable() is the + * only one) have already called TclpFindExecutable(). + */ + + mustCleanUtf = TclpInitLibraryPath(tclNativeExecutableName); /* * The library path was set in the TclpInitLibraryPath routine. diff --git a/generic/tclInt.h b/generic/tclInt.h index e96b5a8..6723f03 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.164 2004/06/18 15:12:39 dkf Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.165 2004/06/18 20:38:01 dgp Exp $ */ #ifndef _TCLINT @@ -1641,6 +1641,7 @@ typedef Tcl_ObjCmdProc *TclObjCmdProcType; extern char * tclExecutableName; extern char * tclNativeExecutableName; +extern int tclFindExecutableSearchDone; extern char * tclDefaultEncodingDir; extern char * tclMemDumpFileName; extern TclPlatformType tclPlatform; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 6acc643..41a4f0c 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUtil.c,v 1.44 2004/04/06 22:25:55 dgp Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.45 2004/06/18 20:38:01 dgp Exp $ */ #include "tclInt.h" @@ -25,6 +25,7 @@ char *tclExecutableName = NULL; char *tclNativeExecutableName = NULL; +int tclFindExecutableSearchDone = 0; /* * The following values are used in the flags returned by Tcl_ScanElement diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index db8e5b6..e0f5cf5 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixFile.c,v 1.39 2004/04/06 22:25:57 dgp Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.40 2004/06/18 20:38:02 dgp Exp $ */ #include "tclInt.h" @@ -54,9 +54,10 @@ TclpFindExecutable(argv0) if (argv0 == NULL) { return NULL; } - if (tclNativeExecutableName != NULL) { + if (tclFindExecutableSearchDone) { return tclNativeExecutableName; } + tclFindExecutableSearchDone = 1; Tcl_DStringInit(&buffer); diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c index f3414f5..955f719 100644 --- a/unix/tclUnixTest.c +++ b/unix/tclUnixTest.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixTest.c,v 1.17 2004/05/27 13:18:55 dkf Exp $ + * RCS: @(#) $Id: tclUnixTest.c,v 1.18 2004/06/18 20:38:02 dgp Exp $ */ #include "tclInt.h" @@ -446,6 +446,7 @@ TestfindexecutableCmd(clientData, interp, argc, argv) { char *oldName; char *oldNativeName; + int oldDone; if (argc != 2) { Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0], @@ -455,9 +456,11 @@ TestfindexecutableCmd(clientData, interp, argc, argv) oldName = tclExecutableName; oldNativeName = tclNativeExecutableName; + oldDone = tclFindExecutableSearchDone; tclExecutableName = NULL; tclNativeExecutableName = NULL; + tclFindExecutableSearchDone = 0; Tcl_FindExecutable(argv[1]); if (tclExecutableName != NULL) { @@ -468,8 +471,9 @@ TestfindexecutableCmd(clientData, interp, argc, argv) ckfree(tclNativeExecutableName); } - tclExecutableName = oldName; - tclNativeExecutableName = oldNativeName; + tclExecutableName = oldName; + tclNativeExecutableName = oldNativeName; + tclFindExecutableSearchDone = oldDone; return TCL_OK; } -- cgit v0.12