Artifact 8522030c25c01bf87d9c52cc1af503b4083486c5:
- File generic/tclInitScript.h — part of check-in [f989579c4c] at 1999-03-12 23:29:11 on branch core-8-1-branch-old — Summary ------- 1) Broke the initialization of memory and finding the encodings file into seprarate routines. 2) Added wrapper hooks for locating files and initialization. 3) Modified the library path lookup algorithm. What I Changed -------------- 1) Modified generic/tclInt.h a) Added cache of the tclNativeExecutable name so the variable does not have be recomputed on subsequent calls to TclpFindExecutable. a) Added variable tclDefaultEncoding dir to store the path to the encoding files. b) Added prototype for TclpFindExecutable & TclpFindEncodings. 2) Modified generic/tclInitScript.h a) Added the TclSetPreInitScript proc and pointer to the script. 3) Modified generic/tclUtil.c a) Added initialization of the tclNativeExecutableName. 4) Modified generic/tclEvent.c a) Added boolean that indicates if the encodings have been initialized. b) Modified TclInitSubsystems so it only initializes "in-memory" subsystems, and not the encoding sub system. c) Added TclFindEncodigs procedure to initialize the encoding subsystem. d) Tcl_Finallize cleans up memory allocated for tclNativeExecutableName and tclDefaultEncodingDir. 5) Modified generic/tclEncoding.c a) Added intialization of the tclDefaultEncodingDir variable. b) Added two accessor functions, Tcl_GetDefaultEncodingDir and Tcl_SetDefaultEncodingDir. c) Made Tcl_FindExecutable platform independent, and moved to this file. 6) Modified unix/tclUnixFile.c and win/tclWinFile.c a) Added TclpFindExecutable(argv0) to compute a native string. c) Tcl_FindExecutable calls TclpFindExecutable to get the native string. d) Modified the TclpInitLibraryPath lookup algorithm (see below) 7) Modified unix/tclUnixInit.c and win/tclWinInit.c a) Added the call evaluate to the pre-init script b) Modified TclpInitLibraryPath to take a native path to the executable so it does not have to call Tcl_FindExecutable. c) On windows, the AppendRegistry routine was removed. 8) Modified unix/tclUnixTest.c a) Modified TestfindexecutableCmd to reset the cached value of tclNativeExecutable name. (user: surles, size: 2351) [annotate] [blame] [check-ins using]
/* * tclInitScript.h -- * * This file contains Unix & Windows common init script * It is not used on the Mac. (the mac init script is in tclMacInit.c) * * Copyright (c) 1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclInitScript.h,v 1.1.2.3 1999/03/12 23:29:14 surles Exp $ */ /* * The following string is the startup script executed in new * interpreters. It looks on disk in several different directories * for a script "init.tcl" that is compatible with this version * of Tcl. The init.tcl script does all of the real work of * initialization. */ static char initScript[] = "if {[info proc tclInit]==\"\"} {\n\ proc tclInit {} {\n\ global tcl_libPath tcl_library errorInfo\n\ rename tclInit {}\n\ set errors {}\n\ foreach i $tcl_libPath {\n\ set tcl_library $i\n\ set tclfile [file join $i init.tcl]\n\ if {[file exists $tclfile]} {\n\ if {[catch {uplevel #0 [list source $tclfile]} msg] != 1} {\n\ return\n\ } else {\n\ append errors \"$tclfile: $msg\n$errorInfo\n\"\n\ }\n\ }\n\ }\n\ set msg \"Can't find a usable init.tcl in the following directories: \n\"\n\ append msg \" $tcl_libPath\n\n\"\n\ append msg \"$errors\n\n\"\n\ append msg \"This probably means that Tcl wasn't installed properly.\n\"\n\ error $msg\n\ }\n\ }\n\ tclInit"; /* * A pointer to a string that holds an initialization script that if non-NULL * is evaluated in Tcl_Init() prior to the the built-in initialization script * above. This variable can be modified by the procedure below. */ static char * tclPreInitScript = NULL; /* *---------------------------------------------------------------------- * * TclSetPreInitScript -- * * This routine is used to change the value of the internal * variable, tclPreInitScript. * * Results: * Returns the current value of tclPreInitScript. * * Side effects: * Changes the way Tcl_Init() routine behaves. * *---------------------------------------------------------------------- */ char * TclSetPreInitScript (string) char *string; /* Pointer to a script. */ { char *prevString = tclPreInitScript; tclPreInitScript = string; return(prevString); }