Artifact 943ad6fb254744914ca192163ca8dd6dfa5cd6bb:
- File
kitsh/buildsrc/kitsh-0.0/kitInit.c
— part of check-in
[636da30116]
at
2010-09-26 04:39:19
on branch trunk
— Corrected check for mk4tcl to actually be functional
Removed support of "config.h" and started passing all defines on the command line (user: rkeene, size: 6095) [annotate] [blame] [check-ins using]
0000: 2f 2a 20 0a 20 2a 20 74 63 6c 41 70 70 49 6e 69 /* . * tclAppIni 0010: 74 2e 63 20 2d 2d 0a 20 2a 0a 20 2a 20 20 50 72 t.c --. *. * Pr 0020: 6f 76 69 64 65 73 20 61 20 64 65 66 61 75 6c 74 ovides a default 0030: 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 version of the 0040: 6d 61 69 6e 20 70 72 6f 67 72 61 6d 20 61 6e 64 main program and 0050: 20 54 63 6c 5f 41 70 70 49 6e 69 74 0a 20 2a 20 Tcl_AppInit. * 0060: 20 70 72 6f 63 65 64 75 72 65 20 66 6f 72 20 54 procedure for T 0070: 63 6c 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 cl applications 0080: 28 77 69 74 68 6f 75 74 20 54 6b 29 2e 20 20 4e (without Tk). N 0090: 6f 74 65 20 74 68 61 74 20 74 68 69 73 0a 20 2a ote that this. * 00a0: 20 20 70 72 6f 67 72 61 6d 20 6d 75 73 74 20 62 program must b 00b0: 65 20 62 75 69 6c 74 20 69 6e 20 57 69 6e 33 32 e built in Win32 00c0: 20 63 6f 6e 73 6f 6c 65 20 6d 6f 64 65 20 74 6f console mode to 00d0: 20 77 6f 72 6b 20 70 72 6f 70 65 72 6c 79 2e 0a work properly.. 00e0: 20 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 *. * Copyright 00f0: 28 63 29 20 31 39 39 36 2d 31 39 39 37 20 62 79 (c) 1996-1997 by 0100: 20 53 75 6e 20 4d 69 63 72 6f 73 79 73 74 65 6d Sun Microsystem 0110: 73 2c 20 49 6e 63 2e 0a 20 2a 20 43 6f 70 79 72 s, Inc.. * Copyr 0120: 69 67 68 74 20 28 63 29 20 31 39 39 38 2d 31 39 ight (c) 1998-19 0130: 39 39 20 62 79 20 53 63 72 69 70 74 69 63 73 20 99 by Scriptics 0140: 43 6f 72 70 6f 72 61 74 69 6f 6e 2e 0a 20 2a 20 Corporation.. * 0150: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30 Copyright (c) 20 0160: 30 30 2d 32 30 30 32 20 4a 65 61 6e 2d 43 6c 61 00-2002 Jean-Cla 0170: 75 64 65 20 57 69 70 70 6c 65 72 20 3c 6a 63 77 ude Wippler <jcw 0180: 40 65 71 75 69 34 2e 63 6f 6d 3e 0a 20 2a 0a 20 @equi4.com>. *. 0190: 2a 20 53 65 65 20 74 68 65 20 66 69 6c 65 20 22 * See the file " 01a0: 6c 69 63 65 6e 73 65 2e 74 65 72 6d 73 22 20 66 license.terms" f 01b0: 6f 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 6f or information o 01c0: 6e 20 75 73 61 67 65 20 61 6e 64 20 72 65 64 69 n usage and redi 01d0: 73 74 72 69 62 75 74 69 6f 6e 0a 20 2a 20 6f 66 stribution. * of 01e0: 20 74 68 69 73 20 66 69 6c 65 2c 20 61 6e 64 20 this file, and 01f0: 66 6f 72 20 61 20 44 49 53 43 4c 41 49 4d 45 52 for a DISCLAIMER 0200: 20 4f 46 20 41 4c 4c 20 57 41 52 52 41 4e 54 49 OF ALL WARRANTI 0210: 45 53 2e 0a 20 2a 0a 20 2a 20 52 43 53 3a 20 40 ES.. *. * RCS: @ 0220: 28 23 29 20 24 49 64 24 0a 20 2a 2f 0a 0a 23 69 (#) $Id$. */..#i 0230: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE 0240: 53 5f 54 4b 0a 23 69 6e 63 6c 75 64 65 20 3c 74 S_TK.#include <t 0250: 6b 2e 68 3e 0a 23 65 6c 73 65 0a 23 69 6e 63 6c k.h>.#else.#incl 0260: 75 64 65 20 3c 74 63 6c 2e 68 3e 0a 23 65 6e 64 ude <tcl.h>.#end 0270: 69 66 0a 0a 23 69 66 64 65 66 20 5f 57 49 4e 33 if..#ifdef _WIN3 0280: 32 0a 23 64 65 66 69 6e 65 20 57 49 4e 33 32 5f 2.#define WIN32_ 0290: 4c 45 41 4e 5f 41 4e 44 5f 4d 45 41 4e 0a 23 69 LEAN_AND_MEAN.#i 02a0: 6e 63 6c 75 64 65 20 3c 77 69 6e 64 6f 77 73 2e nclude <windows. 02b0: 68 3e 0a 23 75 6e 64 65 66 20 57 49 4e 33 32 5f h>.#undef WIN32_ 02c0: 4c 45 41 4e 5f 41 4e 44 5f 4d 45 41 4e 0a 23 65 LEAN_AND_MEAN.#e 02d0: 6e 64 69 66 0a 0a 23 69 66 6e 64 65 66 20 4d 42 ndif..#ifndef MB 02e0: 5f 54 41 53 4b 4d 4f 44 41 4c 0a 23 64 65 66 69 _TASKMODAL.#defi 02f0: 6e 65 20 4d 42 5f 54 41 53 4b 4d 4f 44 41 4c 20 ne MB_TASKMODAL 0300: 30 0a 23 65 6e 64 69 66 0a 0a 23 69 6e 63 6c 75 0.#endif..#inclu 0310: 64 65 20 22 74 63 6c 49 6e 74 2e 68 22 0a 0a 23 de "tclInt.h"..# 0320: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD 0330: 45 53 5f 49 54 43 4c 0a 54 63 6c 5f 41 70 70 49 ES_ITCL.Tcl_AppI 0340: 6e 69 74 50 72 6f 63 09 49 74 63 6c 5f 49 6e 69 nitProc.Itcl_Ini 0350: 74 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 t;.#endif.#ifdef 0360: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 4d 4b KIT_INCLUDES_MK 0370: 34 54 43 4c 0a 54 63 6c 5f 41 70 70 49 6e 69 74 4TCL.Tcl_AppInit 0380: 50 72 6f 63 09 4d 6b 34 74 63 6c 5f 49 6e 69 74 Proc.Mk4tcl_Init 0390: 3b 0a 23 65 6e 64 69 66 0a 54 63 6c 5f 41 70 70 ;.#endif.Tcl_App 03a0: 49 6e 69 74 50 72 6f 63 20 56 66 73 5f 49 6e 69 InitProc Vfs_Ini 03b0: 74 2c 20 52 65 63 68 61 6e 5f 49 6e 69 74 2c 20 t, Rechan_Init, 03c0: 5a 6c 69 62 5f 49 6e 69 74 3b 0a 23 69 66 20 31 Zlib_Init;.#if 1 03d0: 30 20 2a 20 54 43 4c 5f 4d 41 4a 4f 52 5f 56 45 0 * TCL_MAJOR_VE 03e0: 52 53 49 4f 4e 20 2b 20 54 43 4c 5f 4d 49 4e 4f RSION + TCL_MINO 03f0: 52 5f 56 45 52 53 49 4f 4e 20 3c 20 38 35 0a 54 R_VERSION < 85.T 0400: 63 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 09 50 cl_AppInitProc.P 0410: 77 62 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a wb_Init;.#endif. 0420: 23 69 66 64 65 66 20 54 43 4c 5f 54 48 52 45 41 #ifdef TCL_THREA 0430: 44 53 0a 54 63 6c 5f 41 70 70 49 6e 69 74 50 72 DS.Tcl_AppInitPr 0440: 6f 63 09 54 68 72 65 61 64 5f 49 6e 69 74 3b 0a oc.Thread_Init;. 0450: 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f 57 #endif.#ifdef _W 0460: 49 4e 33 32 0a 54 63 6c 5f 41 70 70 49 6e 69 74 IN32.Tcl_AppInit 0470: 50 72 6f 63 09 44 64 65 5f 49 6e 69 74 2c 20 52 Proc.Dde_Init, R 0480: 65 67 69 73 74 72 79 5f 49 6e 69 74 3b 0a 23 65 egistry_Init;.#e 0490: 6e 64 69 66 0a 0a 63 68 61 72 20 2a 74 63 6c 45 ndif..char *tclE 04a0: 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 3b 0a 0a xecutableName;.. 04b0: 20 20 20 20 2f 2a 0a 20 20 20 20 20 2a 20 20 41 /*. * A 04c0: 74 74 65 6d 70 74 20 74 6f 20 6c 6f 61 64 20 61 ttempt to load a 04d0: 20 22 62 6f 6f 74 2e 74 63 6c 22 20 65 6e 74 72 "boot.tcl" entr 04e0: 79 20 66 72 6f 6d 20 74 68 65 20 65 6d 62 65 64 y from the embed 04f0: 64 65 64 20 4d 65 74 61 4b 69 74 20 66 69 6c 65 ded MetaKit file 0500: 2e 0a 20 20 20 20 20 2a 20 20 49 66 20 74 68 65 .. * If the 0510: 72 65 20 69 73 6e 27 74 20 6f 6e 65 2c 20 74 72 re isn't one, tr 0520: 79 20 74 6f 20 6f 70 65 6e 20 61 20 72 65 67 75 y to open a regu 0530: 6c 61 72 20 22 73 65 74 75 70 2e 74 63 6c 22 20 lar "setup.tcl" 0540: 66 69 6c 65 20 69 6e 73 74 65 61 64 2e 0a 20 20 file instead.. 0550: 20 20 20 2a 20 20 49 66 20 74 68 61 74 20 66 61 * If that fa 0560: 69 6c 73 2c 20 74 68 69 73 20 63 6f 64 65 20 77 ils, this code w 0570: 69 6c 6c 20 74 68 72 6f 77 20 61 6e 20 65 72 72 ill throw an err 0580: 6f 72 2c 20 75 73 69 6e 67 20 61 20 6d 65 73 73 or, using a mess 0590: 61 67 65 20 62 6f 78 2e 0a 20 20 20 20 20 2a 2f age box.. */ 05a0: 0a 0a 73 74 61 74 69 63 20 63 68 61 72 20 2a 70 ..static char *p 05b0: 72 65 49 6e 69 74 43 6d 64 20 3d 20 0a 23 69 66 reInitCmd = .#if 05c0: 64 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 2f def _WIN32_WCE./ 05d0: 2a 20 73 69 6c 6c 79 20 68 61 63 6b 20 74 6f 20 * silly hack to 05e0: 67 65 74 20 77 69 6e 63 65 20 70 6f 72 74 20 74 get wince port t 05f0: 6f 20 6c 61 75 6e 63 68 2c 20 73 6f 6d 65 20 73 o launch, some s 0600: 6f 72 74 20 6f 66 20 73 74 64 7b 69 6e 2c 6f 75 ort of std{in,ou 0610: 74 2c 65 72 72 7d 20 70 72 6f 62 6c 65 6d 20 2a t,err} problem * 0620: 2f 0a 22 6f 70 65 6e 20 2f 6b 69 74 6f 75 74 2e /."open /kitout. 0630: 74 78 74 20 61 3b 20 6f 70 65 6e 20 2f 6b 69 74 txt a; open /kit 0640: 6f 75 74 2e 74 78 74 20 61 3b 20 6f 70 65 6e 20 out.txt a; open 0650: 2f 6b 69 74 6f 75 74 2e 74 78 74 20 61 5c 6e 22 /kitout.txt a\n" 0660: 0a 2f 2a 20 74 68 69 73 20 74 6f 6f 20 73 65 65 ./* this too see 0670: 6d 73 20 74 6f 20 62 65 20 6e 65 65 64 65 64 20 ms to be needed 0680: 6f 6e 20 77 69 6e 63 65 20 2d 20 69 74 20 61 70 on wince - it ap 0690: 70 65 61 72 73 20 74 6f 20 62 65 20 72 65 6c 61 pears to be rela 06a0: 74 65 64 20 74 6f 20 74 68 65 20 61 62 6f 76 65 ted to the above 06b0: 20 2a 2f 0a 22 63 61 74 63 68 20 7b 72 65 6e 61 */."catch {rena 06c0: 6d 65 20 73 6f 75 72 63 65 20 3a 3a 74 63 6c 3a me source ::tcl: 06d0: 3a 73 6f 75 72 63 65 7d 5c 6e 22 0a 22 70 72 6f :source}\n"."pro 06e0: 63 20 73 6f 75 72 63 65 20 66 69 6c 65 20 7b 5c c source file {\ 06f0: 6e 22 0a 20 20 20 20 22 73 65 74 20 6f 6c 64 20 n". "set old 0700: 5b 69 6e 66 6f 20 73 63 72 69 70 74 5d 5c 6e 22 [info script]\n" 0710: 0a 20 20 20 20 22 69 6e 66 6f 20 73 63 72 69 70 . "info scrip 0720: 74 20 24 66 69 6c 65 5c 6e 22 0a 20 20 20 20 22 t $file\n". " 0730: 73 65 74 20 66 69 64 20 5b 6f 70 65 6e 20 24 66 set fid [open $f 0740: 69 6c 65 5d 5c 6e 22 0a 20 20 20 20 22 73 65 74 ile]\n". "set 0750: 20 64 61 74 61 20 5b 72 65 61 64 20 24 66 69 64 data [read $fid 0760: 5d 5c 6e 22 0a 20 20 20 20 22 63 6c 6f 73 65 20 ]\n". "close 0770: 24 66 69 64 5c 6e 22 0a 20 20 20 20 22 73 65 74 $fid\n". "set 0780: 20 63 6f 64 65 20 5b 63 61 74 63 68 20 7b 75 70 code [catch {up 0790: 6c 65 76 65 6c 20 31 20 24 64 61 74 61 7d 20 72 level 1 $data} r 07a0: 65 73 5d 5c 6e 22 0a 20 20 20 20 22 69 6e 66 6f es]\n". "info 07b0: 20 73 63 72 69 70 74 20 24 6f 6c 64 5c 6e 22 0a script $old\n". 07c0: 20 20 20 20 22 69 66 20 7b 24 63 6f 64 65 20 3d "if {$code = 07d0: 3d 20 32 7d 20 7b 20 73 65 74 20 63 6f 64 65 20 = 2} { set code 07e0: 30 20 7d 5c 6e 22 0a 20 20 20 20 22 72 65 74 75 0 }\n". "retu 07f0: 72 6e 20 2d 63 6f 64 65 20 24 63 6f 64 65 20 24 rn -code $code $ 0800: 72 65 73 5c 6e 22 0a 22 7d 5c 6e 22 0a 23 65 6e res\n"."}\n".#en 0810: 64 69 66 0a 22 70 72 6f 63 20 74 63 6c 4b 69 74 dif."proc tclKit 0820: 49 6e 69 74 20 7b 7d 20 7b 5c 6e 22 0a 20 20 20 Init {} {\n". 0830: 20 22 72 65 6e 61 6d 65 20 74 63 6c 4b 69 74 49 "rename tclKitI 0840: 6e 69 74 20 7b 7d 5c 6e 22 0a 20 20 20 20 22 63 nit {}\n". "c 0850: 61 74 63 68 20 7b 20 6c 6f 61 64 20 7b 7d 20 4d atch { load {} M 0860: 6b 34 74 63 6c 20 7d 5c 6e 22 0a 20 20 20 20 22 k4tcl }\n". " 0870: 6d 6b 3a 3a 66 69 6c 65 20 6f 70 65 6e 20 65 78 mk::file open ex 0880: 65 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 e [info nameofex 0890: 65 63 75 74 61 62 6c 65 5d 20 2d 72 65 61 64 6f ecutable] -reado 08a0: 6e 6c 79 5c 6e 22 0a 20 20 20 20 22 73 65 74 20 nly\n". "set 08b0: 6e 20 5b 6d 6b 3a 3a 73 65 6c 65 63 74 20 65 78 n [mk::select ex 08c0: 65 2e 64 69 72 73 21 30 2e 66 69 6c 65 73 20 6e e.dirs!0.files n 08d0: 61 6d 65 20 62 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 ame boot.tcl]\n" 08e0: 0a 20 20 20 20 22 69 66 20 7b 24 6e 20 21 3d 20 . "if {$n != 08f0: 5c 22 5c 22 7d 20 7b 5c 6e 22 0a 20 20 20 20 20 \"\"} {\n". 0900: 20 20 20 22 73 65 74 20 73 20 5b 6d 6b 3a 3a 67 "set s [mk::g 0910: 65 74 20 65 78 65 2e 64 69 72 73 21 30 2e 66 69 et exe.dirs!0.fi 0920: 6c 65 73 21 24 6e 20 63 6f 6e 74 65 6e 74 73 5d les!$n contents] 0930: 5c 6e 22 0a 09 22 69 66 20 7b 21 5b 73 74 72 69 \n".."if {![stri 0940: 6e 67 20 6c 65 6e 67 74 68 20 24 73 5d 7d 20 7b ng length $s]} { 0950: 20 65 72 72 6f 72 20 5c 22 65 6d 70 74 79 20 62 error \"empty b 0960: 6f 6f 74 2e 74 63 6c 5c 22 20 7d 5c 6e 22 0a 20 oot.tcl\" }\n". 0970: 20 20 20 20 20 20 20 22 63 61 74 63 68 20 7b 6c "catch {l 0980: 6f 61 64 20 7b 7d 20 7a 6c 69 62 7d 5c 6e 22 0a oad {} zlib}\n". 0990: 20 20 20 20 20 20 20 20 22 69 66 20 7b 5b 6d 6b "if {[mk 09a0: 3a 3a 67 65 74 20 65 78 65 2e 64 69 72 73 21 30 ::get exe.dirs!0 09b0: 2e 66 69 6c 65 73 21 24 6e 20 73 69 7a 65 5d 20 .files!$n size] 09c0: 21 3d 20 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 != [string lengt 09d0: 68 20 24 73 5d 7d 20 7b 5c 6e 22 0a 09 20 20 20 h $s]} {\n".. 09e0: 20 22 73 65 74 20 73 20 5b 7a 6c 69 62 20 64 65 "set s [zlib de 09f0: 63 6f 6d 70 72 65 73 73 20 24 73 5d 5c 6e 22 0a compress $s]\n". 0a00: 09 22 7d 5c 6e 22 0a 20 20 20 20 22 7d 20 65 6c ."}\n". "} el 0a10: 73 65 20 7b 5c 6e 22 0a 20 20 20 20 20 20 20 20 se {\n". 0a20: 22 73 65 74 20 66 20 5b 6f 70 65 6e 20 73 65 74 "set f [open set 0a30: 75 70 2e 74 63 6c 5d 5c 6e 22 0a 20 20 20 20 20 up.tcl]\n". 0a40: 20 20 20 22 73 65 74 20 73 20 5b 72 65 61 64 20 "set s [read 0a50: 24 66 5d 5c 6e 22 0a 20 20 20 20 20 20 20 20 22 $f]\n". " 0a60: 63 6c 6f 73 65 20 24 66 5c 6e 22 0a 20 20 20 20 close $f\n". 0a70: 22 7d 5c 6e 22 0a 20 20 20 20 22 75 70 6c 65 76 "}\n". "uplev 0a80: 65 6c 20 23 30 20 24 73 5c 6e 22 0a 23 69 66 64 el #0 $s\n".#ifd 0a90: 65 66 20 5f 57 49 4e 33 32 0a 20 20 20 20 22 70 ef _WIN32. "p 0aa0: 61 63 6b 61 67 65 20 69 66 6e 65 65 64 65 64 20 ackage ifneeded 0ab0: 64 64 65 20 31 2e 33 2e 31 20 7b 6c 6f 61 64 20 dde 1.3.1 {load 0ac0: 7b 7d 20 64 64 65 7d 5c 6e 22 0a 20 20 20 20 22 {} dde}\n". " 0ad0: 70 61 63 6b 61 67 65 20 69 66 6e 65 65 64 65 64 package ifneeded 0ae0: 20 72 65 67 69 73 74 72 79 20 31 2e 31 2e 35 20 registry 1.1.5 0af0: 7b 6c 6f 61 64 20 7b 7d 20 72 65 67 69 73 74 72 {load {} registr 0b00: 79 7d 5c 6e 22 0a 23 65 6e 64 69 66 0a 22 7d 5c y}\n".#endif."}\ 0b10: 6e 22 0a 22 74 63 6c 4b 69 74 49 6e 69 74 22 0a n"."tclKitInit". 0b20: 3b 0a 0a 73 74 61 74 69 63 20 63 6f 6e 73 74 20 ;..static const 0b30: 63 68 61 72 20 69 6e 69 74 53 63 72 69 70 74 5b char initScript[ 0b40: 5d 20 3d 0a 22 69 66 20 7b 5b 66 69 6c 65 20 69 ] =."if {[file i 0b50: 73 66 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 6e sfile [file join 0b60: 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 [info nameofexe 0b70: 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5d 7d 20 7b 5c ] main.tcl]]} {\ 0b80: 6e 22 0a 20 20 20 20 22 69 66 20 7b 5b 69 6e 66 n". "if {[inf 0b90: 6f 20 63 6f 6d 6d 61 6e 64 73 20 63 6f 6e 73 6f o commands conso 0ba0: 6c 65 5d 20 21 3d 20 7b 7d 7d 20 7b 20 63 6f 6e le] != {}} { con 0bb0: 73 6f 6c 65 20 68 69 64 65 20 7d 5c 6e 22 0a 20 sole hide }\n". 0bc0: 20 20 20 22 73 65 74 20 74 63 6c 5f 69 6e 74 65 "set tcl_inte 0bd0: 72 61 63 74 69 76 65 20 30 5c 6e 22 0a 20 20 20 ractive 0\n". 0be0: 20 22 69 6e 63 72 20 61 72 67 63 5c 6e 22 0a 20 "incr argc\n". 0bf0: 20 20 20 22 73 65 74 20 61 72 67 76 20 5b 6c 69 "set argv [li 0c00: 6e 73 65 72 74 20 24 61 72 67 76 20 30 20 24 61 nsert $argv 0 $a 0c10: 72 67 76 30 5d 5c 6e 22 0a 20 20 20 20 22 73 65 rgv0]\n". "se 0c20: 74 20 61 72 67 76 30 20 5b 66 69 6c 65 20 6a 6f t argv0 [file jo 0c30: 69 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 in [info nameofe 0c40: 78 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5c 6e 22 xe] main.tcl]\n" 0c50: 0a 22 7d 20 65 6c 73 65 20 63 6f 6e 74 69 6e 75 ."} else continu 0c60: 65 5c 6e 22 0a 3b 0a 0a 2f 2a 20 53 65 74 45 78 e\n".;../* SetEx 0c70: 65 63 4e 61 6d 65 20 2d 2d 0a 0a 20 20 20 48 61 ecName --.. Ha 0c80: 63 6b 20 74 6f 20 67 65 74 20 61 72 6f 75 6e 64 ck to get around 0c90: 20 54 63 6c 20 62 75 67 20 31 32 32 34 38 38 38 Tcl bug 1224888 0ca0: 2e 0a 2a 2f 0a 0a 76 6f 69 64 20 53 65 74 45 78 ..*/..void SetEx 0cb0: 65 63 4e 61 6d 65 28 54 63 6c 5f 49 6e 74 65 72 ecName(Tcl_Inter 0cc0: 70 20 2a 69 6e 74 65 72 70 29 20 7b 0a 20 20 20 p *interp) {. 0cd0: 20 69 66 20 28 74 63 6c 45 78 65 63 75 74 61 62 if (tclExecutab 0ce0: 6c 65 4e 61 6d 65 20 3d 3d 20 4e 55 4c 4c 29 20 leName == NULL) 0cf0: 7b 0a 09 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0a {..int len = 0;. 0d00: 09 54 63 6c 5f 4f 62 6a 20 2a 65 78 65 63 4e 61 .Tcl_Obj *execNa 0d10: 6d 65 4f 62 6a 3b 0a 09 54 63 6c 5f 4f 62 6a 20 meObj;..Tcl_Obj 0d20: 2a 6c 6f 62 6a 76 5b 31 5d 3b 0a 0a 09 6c 6f 62 *lobjv[1];...lob 0d30: 6a 76 5b 30 5d 20 3d 20 54 63 6c 5f 47 65 74 56 jv[0] = Tcl_GetV 0d40: 61 72 32 45 78 28 69 6e 74 65 72 70 2c 20 22 61 ar2Ex(interp, "a 0d50: 72 67 76 30 22 2c 20 4e 55 4c 4c 2c 20 54 43 4c rgv0", NULL, TCL 0d60: 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 09 _GLOBAL_ONLY);.. 0d70: 65 78 65 63 4e 61 6d 65 4f 62 6a 20 3d 20 54 63 execNameObj = Tc 0d80: 6c 5f 46 53 4a 6f 69 6e 54 6f 50 61 74 68 28 54 l_FSJoinToPath(T 0d90: 63 6c 5f 46 53 47 65 74 43 77 64 28 69 6e 74 65 cl_FSGetCwd(inte 0da0: 72 70 29 2c 20 31 2c 20 6c 6f 62 6a 76 29 3b 0a rp), 1, lobjv);. 0db0: 0a 09 74 63 6c 45 78 65 63 75 74 61 62 6c 65 4e ..tclExecutableN 0dc0: 61 6d 65 20 3d 20 73 74 72 64 75 70 28 54 63 6c ame = strdup(Tcl 0dd0: 5f 47 65 74 53 74 72 69 6e 67 46 72 6f 6d 4f 62 _GetStringFromOb 0de0: 6a 28 65 78 65 63 4e 61 6d 65 4f 62 6a 2c 20 26 j(execNameObj, & 0df0: 6c 65 6e 29 29 3b 0a 20 20 20 20 7d 0a 7d 0a 0a len));. }.}.. 0e00: 69 6e 74 20 0a 54 63 6c 4b 69 74 5f 41 70 70 49 int .TclKit_AppI 0e10: 6e 69 74 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a nit(Tcl_Interp * 0e20: 69 6e 74 65 72 70 29 0a 7b 0a 23 69 66 64 65 66 interp).{.#ifdef 0e30: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 49 54 KIT_INCLUDES_IT 0e40: 43 4c 0a 20 20 20 20 54 63 6c 5f 53 74 61 74 69 CL. Tcl_Stati 0e50: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 49 74 63 cPackage(0, "Itc 0e60: 6c 22 2c 20 49 74 63 6c 5f 49 6e 69 74 2c 20 4e l", Itcl_Init, N 0e70: 55 4c 4c 29 3b 0a 23 65 6e 64 69 66 20 0a 23 69 ULL);.#endif .#i 0e80: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE 0e90: 53 5f 4d 4b 34 54 43 4c 0a 20 20 20 20 54 63 6c S_MK4TCL. Tcl 0ea0: 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 _StaticPackage(0 0eb0: 2c 20 22 4d 6b 34 74 63 6c 22 2c 20 4d 6b 34 74 , "Mk4tcl", Mk4t 0ec0: 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a cl_Init, NULL);. 0ed0: 23 65 6e 64 69 66 0a 23 69 66 20 31 30 20 2a 20 #endif.#if 10 * 0ee0: 54 43 4c 5f 4d 41 4a 4f 52 5f 56 45 52 53 49 4f TCL_MAJOR_VERSIO 0ef0: 4e 20 2b 20 54 43 4c 5f 4d 49 4e 4f 52 5f 56 45 N + TCL_MINOR_VE 0f00: 52 53 49 4f 4e 20 3c 20 38 35 0a 20 20 20 20 54 RSION < 85. T 0f10: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage 0f20: 28 30 2c 20 22 70 77 62 22 2c 20 50 77 62 5f 49 (0, "pwb", Pwb_I 0f30: 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 nit, NULL);.#end 0f40: 69 66 20 0a 20 20 20 20 54 63 6c 5f 53 74 61 74 if . Tcl_Stat 0f50: 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 72 65 icPackage(0, "re 0f60: 63 68 61 6e 22 2c 20 52 65 63 68 61 6e 5f 49 6e chan", Rechan_In 0f70: 69 74 2c 20 4e 55 4c 4c 29 3b 0a 20 20 20 20 54 it, NULL);. T 0f80: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage 0f90: 28 30 2c 20 22 76 66 73 22 2c 20 56 66 73 5f 49 (0, "vfs", Vfs_I 0fa0: 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 20 20 20 20 nit, NULL);. 0fb0: 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 Tcl_StaticPackag 0fc0: 65 28 30 2c 20 22 7a 6c 69 62 22 2c 20 5a 6c 69 e(0, "zlib", Zli 0fd0: 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 b_Init, NULL);.# 0fe0: 69 66 64 65 66 20 54 43 4c 5f 54 48 52 45 41 44 ifdef TCL_THREAD 0ff0: 53 0a 20 20 20 20 54 63 6c 5f 53 74 61 74 69 63 S. Tcl_Static 1000: 50 61 63 6b 61 67 65 28 30 2c 20 22 54 68 72 65 Package(0, "Thre 1010: 61 64 22 2c 20 54 68 72 65 61 64 5f 49 6e 69 74 ad", Thread_Init 1020: 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 69 66 0a , NULL);.#endif. 1030: 23 69 66 64 65 66 20 5f 57 49 4e 33 32 0a 20 20 #ifdef _WIN32. 1040: 20 20 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b Tcl_StaticPack 1050: 61 67 65 28 30 2c 20 22 64 64 65 22 2c 20 44 64 age(0, "dde", Dd 1060: 65 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 20 e_Init, NULL);. 1070: 20 20 20 54 63 6c 5f 53 74 61 74 69 63 50 61 63 Tcl_StaticPac 1080: 6b 61 67 65 28 30 2c 20 22 72 65 67 69 73 74 72 kage(0, "registr 1090: 79 22 2c 20 52 65 67 69 73 74 72 79 5f 49 6e 69 y", Registry_Ini 10a0: 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 69 66 t, NULL);.#endif 10b0: 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c .#ifdef KIT_INCL 10c0: 55 44 45 53 5f 54 4b 0a 20 20 20 20 54 63 6c 5f UDES_TK. Tcl_ 10d0: 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c StaticPackage(0, 10e0: 20 22 54 6b 22 2c 20 54 6b 5f 49 6e 69 74 2c 20 "Tk", Tk_Init, 10f0: 54 6b 5f 53 61 66 65 49 6e 69 74 29 3b 0a 23 65 Tk_SafeInit);.#e 1100: 6e 64 69 66 0a 0a 20 20 20 20 2f 2a 20 74 68 65 ndif.. /* the 1110: 20 74 63 6c 5f 72 63 46 69 6c 65 4e 61 6d 65 20 tcl_rcFileName 1120: 76 61 72 69 61 62 6c 65 20 6f 6e 6c 79 20 65 78 variable only ex 1130: 69 73 74 73 20 69 6e 20 74 68 65 20 69 6e 69 74 ists in the init 1140: 69 61 6c 20 69 6e 74 65 72 70 72 65 74 65 72 20 ial interpreter 1150: 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 4e 33 32 */.#ifdef _WIN32 1160: 0a 20 20 20 20 54 63 6c 5f 53 65 74 56 61 72 28 . Tcl_SetVar( 1170: 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 interp, "tcl_rcF 1180: 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 74 63 6c ileName", "~/tcl 1190: 6b 69 74 72 63 2e 74 63 6c 22 2c 20 54 43 4c 5f kitrc.tcl", TCL_ 11a0: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 65 GLOBAL_ONLY);.#e 11b0: 6c 73 65 0a 20 20 20 20 54 63 6c 5f 53 65 74 56 lse. Tcl_SetV 11c0: 61 72 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f ar(interp, "tcl_ 11d0: 72 63 46 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f rcFileName", "~/ 11e0: 2e 74 63 6c 6b 69 74 72 63 22 2c 20 54 43 4c 5f .tclkitrc", TCL_ 11f0: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 65 GLOBAL_ONLY);.#e 1200: 6e 64 69 66 0a 0a 20 20 20 20 2f 2a 20 48 61 63 ndif.. /* Hac 1210: 6b 20 74 6f 20 67 65 74 20 61 72 6f 75 6e 64 20 k to get around 1220: 54 63 6c 20 62 75 67 20 31 32 32 34 38 38 38 2e Tcl bug 1224888. 1230: 20 20 54 68 69 73 20 6d 75 73 74 20 62 65 20 72 This must be r 1240: 75 6e 20 68 65 72 65 20 61 6e 64 0a 20 20 20 20 un here and. 1250: 20 2a 20 69 6e 20 4c 69 62 72 61 72 79 50 61 74 * in LibraryPat 1260: 68 4f 62 6a 43 6d 64 20 62 65 63 61 75 73 65 20 hObjCmd because 1270: 74 68 69 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e this information 1280: 20 69 73 20 6e 65 65 64 65 64 20 62 6f 74 68 0a is needed both. 1290: 20 20 20 20 20 2a 20 62 65 66 6f 72 65 20 61 6e * before an 12a0: 64 20 61 66 74 65 72 20 74 68 61 74 20 63 6f 6d d after that com 12b0: 6d 61 6e 64 20 69 73 20 72 75 6e 2e 20 2a 2f 0a mand is run. */. 12c0: 20 20 20 20 53 65 74 45 78 65 63 4e 61 6d 65 28 SetExecName( 12d0: 69 6e 74 65 72 70 29 3b 0a 0a 20 20 20 20 54 63 interp);.. Tc 12e0: 6c 53 65 74 50 72 65 49 6e 69 74 53 63 72 69 70 lSetPreInitScrip 12f0: 74 28 70 72 65 49 6e 69 74 43 6d 64 29 3b 0a 20 t(preInitCmd);. 1300: 20 20 20 69 66 20 28 54 63 6c 5f 49 6e 69 74 28 if (Tcl_Init( 1310: 69 6e 74 65 72 70 29 20 3d 3d 20 54 43 4c 5f 45 interp) == TCL_E 1320: 52 52 4f 52 29 0a 20 20 20 20 20 20 20 20 67 6f RROR). go 1330: 74 6f 20 65 72 72 6f 72 3b 0a 0a 23 69 66 64 65 to error;..#ifde 1340: 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 f KIT_INCLUDES_T 1350: 4b 0a 23 69 66 64 65 66 20 5f 57 49 4e 33 32 0a K.#ifdef _WIN32. 1360: 20 20 20 20 69 66 20 28 54 6b 5f 49 6e 69 74 28 if (Tk_Init( 1370: 69 6e 74 65 72 70 29 20 3d 3d 20 54 43 4c 5f 45 interp) == TCL_E 1380: 52 52 4f 52 29 0a 20 20 20 20 20 20 20 20 67 6f RROR). go 1390: 74 6f 20 65 72 72 6f 72 3b 0a 20 20 20 20 69 66 to error;. if 13a0: 20 28 54 6b 5f 43 72 65 61 74 65 43 6f 6e 73 6f (Tk_CreateConso 13b0: 6c 65 57 69 6e 64 6f 77 28 69 6e 74 65 72 70 29 leWindow(interp) 13c0: 20 3d 3d 20 54 43 4c 5f 45 52 52 4f 52 29 0a 20 == TCL_ERROR). 13d0: 20 20 20 20 20 20 20 67 6f 74 6f 20 65 72 72 6f goto erro 13e0: 72 3b 0a 23 65 6e 64 69 66 0a 23 65 6e 64 69 66 r;.#endif.#endif 13f0: 0a 0a 20 20 20 20 20 20 2f 2a 20 6d 65 73 73 79 .. /* messy 1400: 20 62 65 63 61 75 73 65 20 54 63 6c 53 65 74 53 because TclSetS 1410: 74 61 72 74 75 70 53 63 72 69 70 74 50 61 74 68 tartupScriptPath 1420: 20 69 73 20 63 61 6c 6c 65 64 20 73 6c 69 67 68 is called sligh 1430: 74 6c 79 20 74 6f 6f 20 6c 61 74 65 20 2a 2f 0a tly too late */. 1440: 20 20 20 20 69 66 20 28 54 63 6c 5f 45 76 61 6c if (Tcl_Eval 1450: 28 69 6e 74 65 72 70 2c 20 69 6e 69 74 53 63 72 (interp, initScr 1460: 69 70 74 29 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 ipt) == TCL_OK) 1470: 7b 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 4f 62 {. Tcl_Ob 1480: 6a 2a 20 70 61 74 68 3b 0a 23 69 66 64 65 66 20 j* path;.#ifdef 1490: 48 41 56 45 5f 54 43 4c 53 45 54 53 54 41 52 54 HAVE_TCLSETSTART 14a0: 55 50 53 43 52 49 50 54 50 41 54 48 0a 20 20 20 UPSCRIPTPATH. 14b0: 20 20 20 20 20 70 61 74 68 20 3d 20 54 63 6c 47 path = TclG 14c0: 65 74 53 74 61 72 74 75 70 53 63 72 69 70 74 50 etStartupScriptP 14d0: 61 74 68 28 29 3b 0a 09 54 63 6c 53 65 74 53 74 ath();..TclSetSt 14e0: 61 72 74 75 70 53 63 72 69 70 74 50 61 74 68 28 artupScriptPath( 14f0: 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 75 6c 74 Tcl_GetObjResult 1500: 28 69 6e 74 65 72 70 29 29 3b 0a 23 65 6c 73 65 (interp));.#else 1510: 0a 23 20 20 69 66 64 65 66 20 48 41 56 45 5f 54 .# ifdef HAVE_T 1520: 43 4c 5f 53 45 54 53 54 41 52 54 55 50 53 43 52 CL_SETSTARTUPSCR 1530: 49 50 54 0a 20 20 20 20 20 20 20 20 70 61 74 68 IPT. path 1540: 20 3d 20 54 63 6c 5f 47 65 74 53 74 61 72 74 75 = Tcl_GetStartu 1550: 70 53 63 72 69 70 74 28 4e 55 4c 4c 29 3b 0a 09 pScript(NULL);.. 1560: 54 63 6c 5f 53 65 74 53 74 61 72 74 75 70 53 63 Tcl_SetStartupSc 1570: 72 69 70 74 28 54 63 6c 5f 47 65 74 4f 62 6a 52 ript(Tcl_GetObjR 1580: 65 73 75 6c 74 28 69 6e 74 65 72 70 29 2c 20 4e esult(interp), N 1590: 55 4c 4c 29 3b 0a 23 20 20 65 6e 64 69 66 0a 23 ULL);.# endif.# 15a0: 65 6e 64 69 66 0a 09 69 66 20 28 70 61 74 68 20 endif..if (path 15b0: 3d 3d 20 4e 55 4c 4c 29 0a 09 20 20 54 63 6c 5f == NULL).. Tcl_ 15c0: 45 76 61 6c 28 69 6e 74 65 72 70 2c 20 22 69 6e Eval(interp, "in 15d0: 63 72 20 61 72 67 63 20 2d 31 3b 20 73 65 74 20 cr argc -1; set 15e0: 61 72 67 76 20 5b 6c 72 61 6e 67 65 20 24 61 72 argv [lrange $ar 15f0: 67 76 20 31 20 65 6e 64 5d 22 29 3b 0a 20 20 20 gv 1 end]");. 1600: 20 7d 0a 0a 20 20 20 20 54 63 6c 5f 53 65 74 56 }.. Tcl_SetV 1610: 61 72 28 69 6e 74 65 72 70 2c 20 22 65 72 72 6f ar(interp, "erro 1620: 72 49 6e 66 6f 22 2c 20 22 22 2c 20 54 43 4c 5f rInfo", "", TCL_ 1630: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 20 20 GLOBAL_ONLY);. 1640: 20 20 54 63 6c 5f 52 65 73 65 74 52 65 73 75 6c Tcl_ResetResul 1650: 74 28 69 6e 74 65 72 70 29 3b 0a 20 20 20 20 72 t(interp);. r 1660: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 0a 65 eturn TCL_OK;..e 1670: 72 72 6f 72 3a 0a 23 69 66 64 65 66 20 4b 49 54 rror:.#ifdef KIT 1680: 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 0a 23 69 66 _INCLUDES_TK.#if 1690: 64 65 66 20 5f 57 49 4e 33 32 0a 20 20 20 20 4d def _WIN32. M 16a0: 65 73 73 61 67 65 42 65 65 70 28 4d 42 5f 49 43 essageBeep(MB_IC 16b0: 4f 4e 45 58 43 4c 41 4d 41 54 49 4f 4e 29 3b 0a ONEXCLAMATION);. 16c0: 23 69 66 6e 64 65 66 20 5f 57 49 4e 33 32 5f 57 #ifndef _WIN32_W 16d0: 43 45 0a 20 20 20 20 4d 65 73 73 61 67 65 42 6f CE. MessageBo 16e0: 78 28 4e 55 4c 4c 2c 20 54 63 6c 5f 47 65 74 53 x(NULL, Tcl_GetS 16f0: 74 72 69 6e 67 52 65 73 75 6c 74 28 69 6e 74 65 tringResult(inte 1700: 72 70 29 2c 20 22 45 72 72 6f 72 20 69 6e 20 54 rp), "Error in T 1710: 63 6c 4b 69 74 22 2c 0a 20 20 20 20 20 20 20 20 clKit",. 1720: 4d 42 5f 49 43 4f 4e 53 54 4f 50 20 7c 20 4d 42 MB_ICONSTOP | MB 1730: 5f 4f 4b 20 7c 20 4d 42 5f 54 41 53 4b 4d 4f 44 _OK | MB_TASKMOD 1740: 41 4c 20 7c 20 4d 42 5f 53 45 54 46 4f 52 45 47 AL | MB_SETFOREG 1750: 52 4f 55 4e 44 29 3b 0a 20 20 20 20 45 78 69 74 ROUND);. Exit 1760: 50 72 6f 63 65 73 73 28 31 29 3b 0a 23 65 6e 64 Process(1);.#end 1770: 69 66 0a 20 20 20 20 2f 2a 20 77 65 20 77 6f 6e if. /* we won 1780: 27 74 20 72 65 61 63 68 20 74 68 69 73 2c 20 62 't reach this, b 1790: 75 74 20 77 65 20 6e 65 65 64 20 74 68 65 20 72 ut we need the r 17a0: 65 74 75 72 6e 20 2a 2f 0a 23 65 6e 64 69 66 0a eturn */.#endif. 17b0: 23 65 6e 64 69 66 0a 20 20 20 20 72 65 74 75 72 #endif. retur 17c0: 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 7d 0a n TCL_ERROR;.}.