/[dtapublic]/projs/trunk/shared_source/c_tcl_base_7_5_w_mods/tclinitscript.h
ViewVC logotype

Diff of /projs/trunk/shared_source/c_tcl_base_7_5_w_mods/tclinitscript.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 64 by dashley, Sun Oct 30 04:21:11 2016 UTC revision 71 by dashley, Sat Nov 5 11:07:06 2016 UTC
# Line 1  Line 1 
1  /* $Header$ */  /* $Header$ */
2  /*  /*
3   * tclInitScript.h --   * tclInitScript.h --
4   *   *
5   *      This file contains Unix & Windows common init script   *      This file contains Unix & Windows common init script
6   *      It is not used on the Mac. (the mac init script is in tclMacInit.c)   *      It is not used on the Mac. (the mac init script is in tclMacInit.c)
7   *   *
8   * Copyright (c) 1998 Sun Microsystems, Inc.   * Copyright (c) 1998 Sun Microsystems, Inc.
9   * Copyright (c) 1999 by Scriptics Corporation.   * Copyright (c) 1999 by Scriptics Corporation.
10   * All rights reserved.   * All rights reserved.
11   *   *
12   * RCS: @(#) $Id: tclinitscript.h,v 1.1.1.1 2001/06/13 04:39:33 dtashley Exp $   * RCS: @(#) $Id: tclinitscript.h,v 1.1.1.1 2001/06/13 04:39:33 dtashley Exp $
13   */   */
14    
15  /*  /*
16   * In order to find init.tcl during initialization, the following script   * In order to find init.tcl during initialization, the following script
17   * is invoked by Tcl_Init().  It looks in several different directories:   * is invoked by Tcl_Init().  It looks in several different directories:
18   *   *
19   *      $tcl_library            - can specify a primary location, if set   *      $tcl_library            - can specify a primary location, if set
20   *                                no other locations will be checked   *                                no other locations will be checked
21   *   *
22   *      $env(TCL_LIBRARY)       - highest priority so user can always override   *      $env(TCL_LIBRARY)       - highest priority so user can always override
23   *                                the search path unless the application has   *                                the search path unless the application has
24   *                                specified an exact directory above   *                                specified an exact directory above
25   *   *
26   *      $tclDefaultLibrary      - this value is initialized by TclPlatformInit   *      $tclDefaultLibrary      - this value is initialized by TclPlatformInit
27   *                                from a static C variable that was set at   *                                from a static C variable that was set at
28   *                                compile time   *                                compile time
29   *   *
30   *      $tcl_libPath            - this value is initialized by a call to   *      $tcl_libPath            - this value is initialized by a call to
31   *                                TclGetLibraryPath called from Tcl_Init.   *                                TclGetLibraryPath called from Tcl_Init.
32   *   *
33   * The first directory on this path that contains a valid init.tcl script   * The first directory on this path that contains a valid init.tcl script
34   * will be set as the value of tcl_library.   * will be set as the value of tcl_library.
35   *   *
36   * Note that this entire search mechanism can be bypassed by defining an   * Note that this entire search mechanism can be bypassed by defining an
37   * alternate tclInit procedure before calling Tcl_Init().   * alternate tclInit procedure before calling Tcl_Init().
38   */   */
39    
40  static char initScript[] = "if {[info proc tclInit]==\"\"} {\n\  static char initScript[] = "if {[info proc tclInit]==\"\"} {\n\
41    proc tclInit {} {\n\    proc tclInit {} {\n\
42      global tcl_libPath tcl_library errorInfo\n\      global tcl_libPath tcl_library errorInfo\n\
43      global env tclDefaultLibrary\n\      global env tclDefaultLibrary\n\
44      rename tclInit {}\n\      rename tclInit {}\n\
45      set errors {}\n\      set errors {}\n\
46      set dirs {}\n\      set dirs {}\n\
47      if {[info exists tcl_library]} {\n\      if {[info exists tcl_library]} {\n\
48          lappend dirs $tcl_library\n\          lappend dirs $tcl_library\n\
49      } else {\n\      } else {\n\
50          if {[info exists env(TCL_LIBRARY)]} {\n\          if {[info exists env(TCL_LIBRARY)]} {\n\
51              lappend dirs $env(TCL_LIBRARY)\n\              lappend dirs $env(TCL_LIBRARY)\n\
52          }\n\          }\n\
53          lappend dirs $tclDefaultLibrary\n\          lappend dirs $tclDefaultLibrary\n\
54          unset tclDefaultLibrary\n\          unset tclDefaultLibrary\n\
55          set dirs [concat $dirs $tcl_libPath]\n\          set dirs [concat $dirs $tcl_libPath]\n\
56      }\n\      }\n\
57      foreach i $dirs {\n\      foreach i $dirs {\n\
58          set tcl_library $i\n\          set tcl_library $i\n\
59          set tclfile [file join $i init.tcl]\n\          set tclfile [file join $i init.tcl]\n\
60          if {[file exists $tclfile]} {\n\          if {[file exists $tclfile]} {\n\
61              if {![catch {uplevel #0 [list source $tclfile]} msg]} {\n\              if {![catch {uplevel #0 [list source $tclfile]} msg]} {\n\
62                  return\n\                  return\n\
63              } else {\n\              } else {\n\
64                  append errors \"$tclfile: $msg\n$errorInfo\n\"\n\                  append errors \"$tclfile: $msg\n$errorInfo\n\"\n\
65              }\n\              }\n\
66          }\n\          }\n\
67      }\n\      }\n\
68      set msg \"Can't find a usable init.tcl in the following directories: \n\"\n\      set msg \"Can't find a usable init.tcl in the following directories: \n\"\n\
69      append msg \"    $dirs\n\n\"\n\      append msg \"    $dirs\n\n\"\n\
70      append msg \"$errors\n\n\"\n\      append msg \"$errors\n\n\"\n\
71      append msg \"This probably means that Tcl wasn't installed properly.\n\"\n\      append msg \"This probably means that Tcl wasn't installed properly.\n\"\n\
72      error $msg\n\      error $msg\n\
73    }\n\    }\n\
74  }\n\  }\n\
75  tclInit";  tclInit";
76    
77    
78  /*  /*
79   * A pointer to a string that holds an initialization script that if non-NULL   * A pointer to a string that holds an initialization script that if non-NULL
80   * is evaluated in Tcl_Init() prior to the the built-in initialization script   * is evaluated in Tcl_Init() prior to the the built-in initialization script
81   * above.  This variable can be modified by the procedure below.   * above.  This variable can be modified by the procedure below.
82   */   */
83    
84  static char *          tclPreInitScript = NULL;  static char *          tclPreInitScript = NULL;
85    
86    
87  /*  /*
88   *----------------------------------------------------------------------   *----------------------------------------------------------------------
89   *   *
90   * TclSetPreInitScript --   * TclSetPreInitScript --
91   *   *
92   *      This routine is used to change the value of the internal   *      This routine is used to change the value of the internal
93   *      variable, tclPreInitScript.   *      variable, tclPreInitScript.
94   *   *
95   * Results:   * Results:
96   *      Returns the current value of tclPreInitScript.   *      Returns the current value of tclPreInitScript.
97   *   *
98   * Side effects:   * Side effects:
99   *      Changes the way Tcl_Init() routine behaves.   *      Changes the way Tcl_Init() routine behaves.
100   *   *
101   *----------------------------------------------------------------------   *----------------------------------------------------------------------
102   */   */
103    
104  char *  char *
105  TclSetPreInitScript (string)  TclSetPreInitScript (string)
106      char *string;               /* Pointer to a script. */      char *string;               /* Pointer to a script. */
107  {  {
108      char *prevString = tclPreInitScript;      char *prevString = tclPreInitScript;
109      tclPreInitScript = string;      tclPreInitScript = string;
110      return(prevString);      return(prevString);
111  }  }
112    
113  /* End of tclinitscript.h */  /* End of tclinitscript.h */

Legend:
Removed from v.64  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25