Check-in [f644c21488]
Overview
Comment:Updated kitsh to support Windows

Removed executable bit from boot.tcl

Updated licensing

Added documentation regarding statically linking to Tk

Updated win32 build test to pass in path to zlib

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f644c21488947ebd6f993e159a25c8583c98ef24
User & Date: rkeene on 2010-09-26 04:40:28
Other Links: manifest | tags
Context
2010-09-26
04:40
Fixed issue with Tcl 8.5 and up cross-compile installation

Fixed check for no Tk libs to exclude stubs in the check, but include it in the linking check-in: b84f59e5de user: rkeene tags: trunk

04:40
Updated kitsh to support Windows

Removed executable bit from boot.tcl

Updated licensing

Added documentation regarding statically linking to Tk

Updated win32 build test to pass in path to zlib check-in: f644c21488 user: rkeene tags: trunk

04:40
Updated to support Win32 compilation of TclVFS check-in: 2bcd1b2d5e user: rkeene tags: trunk
Changes

Modified LICENSE from [abcc194246] to [5d2145a262].

     1      1   The MIT License is applied to all files in this distribution, except:
     2      2   	kitsh/buildsrc/kitsh-0.0/boot.tcl
     3      3   	kitsh/buildsrc/kitsh-0.0/kitInit.c
     4      4   	kitsh/buildsrc/kitsh-0.0/license.terms
     5      5   	kitsh/buildsrc/kitsh-0.0/pwb.c
     6      6   	kitsh/buildsrc/kitsh-0.0/rechan.c
     7      7   	kitsh/buildsrc/kitsh-0.0/zlib.c
            8  +	kitsh/buildsrc/kitsh-0.0/winMain.c
     8      9   
     9     10   Please see "kitsh/buildsrc/kitsh-0.0/license.terms" for licensing information
    10     11   regarding these files.
    11     12   
    12     13   All others are licensed under the terms of the MIT License, below:
    13     14   The MIT License
    14     15   

Modified README from [f4f19cabd3] to [ed546801c6].

    63     63   		GNU Patch. 
    64     64   
    65     65   	3. TCLKIT
    66     66   		Specify the path to a Tclkit that is runnable on the current
    67     67   		system.  The default is "tclkit".  A working tclkit is required
    68     68   		for cross-compiling Tclkits.
    69     69   
           70  +	4. STATICTK
           71  +		Specify this as "1" to statically link to Tk.  The default
           72  +		action on most platforms is to dynamically link to Tk.
           73  +
    70     74   
    71     75   
    72     76   -------------------
    73     77   Method of Operation
    74     78   -------------------
    75     79   Summary:
    76     80   	1. "kitcreator" calls */build.sh

Modified build/make-kit-win32 from [9863dce36d] to [d9637ee9cf].

     1      1   #! /bin/sh
     2      2   
     3      3   AR=i586-mingw32msvc-ar
     4         -CC='i586-mingw32msvc-gcc -I/home/rkeene/root/windows-i386/include -L/home/rkeene/root/windows-i386/lib'
     5         -CXX='i586-mingw32msvc-g++ -I/home/rkeene/root/windows-i386/include -L/home/rkeene/root/windows-i386/lib'
            4  +CC=i586-mingw32msvc-gcc
            5  +CXX=i586-mingw32msvc-g++
     6      6   RANLIB=i586-mingw32msvc-ranlib
     7      7   RC=i586-mingw32msvc-windres
     8      8   export AR CC CXX RANLIB RC
     9      9   
    10         -./kitcreator --host=i586-mingw32msvc
           10  +./kitcreator "$@" --host=i586-mingw32msvc --with-zlib=/home/rkeene/root/windows-i386

Modified kitsh/buildsrc/kitsh-0.0/Makefile.in from [43b96c5515] to [81946681c5].

     1      1   CC = @CC@
     2         -CFLAGS = @CFLAGS@ @DEFS@ -DSTDC_HEADERS=1
     3         -CPPFLAGS = @CPPFLAGS@ @DEFS@ -DSTDC_HEADERS=1
            2  +CFLAGS = @CFLAGS@ @DEFS@ -DSTDC_HEADERS=1 -DTK_LOCAL_APPINIT=TclKit_AppInit
            3  +CPPFLAGS = @CPPFLAGS@ @DEFS@ -DSTDC_HEADERS=1 -DTK_LOCAL_APPINIT=TclKit_AppInit
     4      4   LDFLAGS = @LDFLAGS@
     5      5   LIBS = @LIBS@
     6      6   ARCHS = @ARCHS@
     7         -OBJS = kitInit.o main.o pwb.o rechan.o zlib.o
            7  +OBJS = kitInit.o main.o pwb.o rechan.o zlib.o winMain.o
     8      8   
     9      9   all: kit
    10     10   
    11     11   kit: $(OBJS) $(ARCHS)
    12     12   	$(CC) $(CPPFLAGS) $(CFLAGS) -o kit $(OBJS) $(ARCHS) $(LDFLAGS) $(LIBS)
    13     13   
    14     14   clean:

Modified kitsh/buildsrc/kitsh-0.0/aclocal.m4 from [c33a095bf7] to [274d569e46].

     2      2   	AC_MSG_CHECKING([path to tcl])
     3      3   	AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl], [directory containing tcl configuration (tclConfig.sh)]), [], [
     4      4   		with_tcl="auto"
     5      5   	])
     6      6   
     7      7   	if test "${with_tcl}" = "auto"; then
     8      8   		for dir in `echo "${PATH}" | sed 's@:@ @g'`; do
            9  +			if test -f "${dir}/tclConfig.sh"; then
           10  +				tclconfigshdir="${dir}"
           11  +				tclconfigsh="${tclconfigshdir}/tclConfig.sh"
           12  +				break
           13  +			fi
     9     14   			if test -f "${dir}/../lib/tclConfig.sh"; then
    10         -				tclconfigsh="${dir}/../lib/tclConfig.sh"
           15  +				tclconfigshdir="${dir}/../lib"
           16  +				tclconfigsh="${tclconfigshdir}/tclConfig.sh"
    11     17   				break
    12     18   			fi
    13     19   			if test -f "${dir}/../lib64/tclConfig.sh"; then
    14         -				tclconfigsh="${dir}/../lib64/tclConfig.sh"
           20  +				tclconfigshdir="${dir}/../lib64"
           21  +				tclconfigsh="${tclconfigshdir}/tclConfig.sh"
    15     22   				break
    16     23   			fi
    17     24   		done
    18     25   
    19     26   		if test -z "${tclconfigsh}"; then
    20     27   			AC_MSG_ERROR([Unable to find tclConfig.sh])
    21     28   		fi
    22     29   	else
    23         -		tclconfigsh="${with_tcl}/tclConfig.sh"
           30  +		tclconfigshdir="${with_tcl}"
           31  +		tclconfigsh="${tclconfigshdir}/tclConfig.sh"
    24     32   	fi
    25     33   
    26     34   	if test -f "${tclconfigsh}"; then
    27     35   		source "${tclconfigsh}"
    28     36   
    29         -		CFLAGS="${CFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${TCL_SRC_DIR}/unix"
    30         -		CPPFLAGS="${CPPFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${TCL_SRC_DIR}/unix"
           37  +		CFLAGS="${CFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${tclconfigshdir}"
           38  +		CPPFLAGS="${CPPFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${tclconfigshdir}"
    31     39   		LDFLAGS="${LDFLAGS}"
    32     40   		LIBS="${LIBS} ${TCL_LIBS}"
    33     41   	fi
    34     42   
    35     43   	AC_SUBST(CFLAGS)
    36     44   	AC_SUBST(CPPFLAGS)
    37     45   	AC_SUBST(LDFLAGS)
    38     46   	AC_SUBST(LIBS)
    39     47   
    40     48   	AC_MSG_RESULT([$tclconfigsh])
    41     49   ])
           50  +
           51  +AC_DEFUN(DC_DO_TK, [
           52  +	AC_MSG_CHECKING([path to tk])
           53  +	AC_ARG_WITH(tk, AC_HELP_STRING([--with-tk], [directory containing tk configuration (tkConfig.sh)]), [], [
           54  +		with_tk="auto"
           55  +	])
           56  +
           57  +	if test "${with_tk}" = "auto"; then
           58  +		for dir in ../../../tk/build/tk*/*/ `echo "${PATH}" | sed 's@:@ @g'`; do
           59  +			if test -f "${dir}/tkConfig.sh"; then
           60  +				tkconfigshdir="${dir}"
           61  +				tkconfigsh="${tkconfigshdir}/tkConfig.sh"
           62  +				break
           63  +			fi
           64  +			if test -f "${dir}/../lib/tkConfig.sh"; then
           65  +				tkconfigshdir="${dir}/../lib"
           66  +				tkconfigsh="${tkconfigshdir}/tkConfig.sh"
           67  +				break
           68  +			fi
           69  +			if test -f "${dir}/../lib64/tkConfig.sh"; then
           70  +				tkconfigshdir="${dir}/../lib64"
           71  +				tkconfigsh="${tkconfigshdir}/tkConfig.sh"
           72  +				break
           73  +			fi
           74  +		done
           75  +
           76  +		if test -z "${tkconfigsh}"; then
           77  +			AC_MSG_ERROR([Unable to find tkConfig.sh])
           78  +		fi
           79  +	else
           80  +		tkconfigshdir="${with_tk}"
           81  +		tkconfigsh="${tkconfigshdir}/tkConfig.sh"
           82  +	fi
           83  +
           84  +	if test -f "${tkconfigsh}"; then
           85  +		source "${tkconfigsh}"
           86  +
           87  +		CFLAGS="${CFLAGS} ${TK_INCLUDE_SPEC} -I${TK_SRC_DIR}/generic -I${tkconfigshdir}"
           88  +		CPPFLAGS="${CPPFLAGS} ${TK_INCLUDE_SPEC} -I${TK_SRC_DIR}/generic -I${tkconfigshdir}"
           89  +		LDFLAGS="${LDFLAGS}"
           90  +		LIBS="${LIBS} ${TK_LIBS}"
           91  +	fi
           92  +
           93  +	AC_SUBST(CFLAGS)
           94  +	AC_SUBST(CPPFLAGS)
           95  +	AC_SUBST(LDFLAGS)
           96  +	AC_SUBST(LIBS)
           97  +
           98  +	AC_MSG_RESULT([$tkconfigsh])
           99  +])
    42    100   
    43    101   AC_DEFUN(DC_DO_STATIC_LINK_LIBCXX, [
    44    102   	AC_MSG_CHECKING([for how to statically link to libstdc++])
    45    103   
    46    104   	SAVELIBS="${LIBS}"
    47    105   	staticlibcxx=""
    48    106   	for trylink in "-Wl,-Bstatic -lCstd -lCrun -Wl,-Bdynamic" "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic" "-lCstd -lCrun" "-lstdc++"; do
................................................................................
    58    116   
    59    117   	AC_MSG_RESULT([${staticlibcxx}])
    60    118   
    61    119   	AC_SUBST(LIBS)
    62    120   ])
    63    121   
    64    122   AC_DEFUN(DC_FIND_TCLKIT_LIBS, [
          123  +	DC_SETUP_TCL_PLAT_DEFS
    65    124   
    66         -	for proj in mk4tcl tcl tclvfs; do
          125  +	for proj in mk4tcl tcl tclvfs tk; do
    67    126   		AC_MSG_CHECKING([for libraries required for ${proj}])
    68    127   
    69    128   		libdir="../../../${proj}/inst"
    70         -		libfiles="`find "${libdir}" -name '*.a' | tr "\n" ' '`"
          129  +		libfiles="`find "${libdir}" -name '*.a' | grep -v 'stub' | tr "\n" ' '`"
    71    130   
    72    131   		ARCHS="${ARCHS} ${libfiles}"
    73    132   
    74    133   		AC_MSG_RESULT([${libfiles}])
    75    134   
    76    135   		if test "${libfiles}" != ""; then
    77    136   			if test "${proj}" = "mk4tcl"; then
    78    137   				AC_DEFINE(KIT_INCLUDES_MK4TCL, [1], [Specify this if you link against mkt4tcl])
    79    138   				DC_DO_STATIC_LINK_LIBCXX
          139  +			fi
          140  +			if test "${proj}" = "tk"; then
          141  +				DC_DO_TK
          142  +				AC_DEFINE(KIT_INCLUDES_TK, [1], [Specify this if we link statically to Tk])
          143  +
          144  +				if test "$host_os" = "mingw32msvc"; then
          145  +					AC_DEFINE(KITSH_NEED_WINMAIN, [1], [Define if you need WinMain (Windows)])
          146  +					CFLAGS="${CFLAGS} -mwindows"
          147  +				fi
    80    148   			fi
    81    149   		fi
    82    150   	done
    83    151   
    84    152   	AC_SUBST(ARCHS)
    85    153   ])
    86    154   
................................................................................
    94    162   		mingw32msvc*)
    95    163   			CFLAGS="${CFLAGS} -mno-cygwin -mms-bitfields"
    96    164   
    97    165   			dnl If we are building for Win32, we need to define "BUILD_tcl" so that
    98    166   			dnl TCL_STORAGE_CLASS gets defined as DLLEXPORT, to make static linking
    99    167   			dnl work
   100    168   			AC_DEFINE(BUILD_tcl, [1], [Define if you need to pretend to be building Tcl (Windows)])
          169  +			AC_DEFINE(BUILD_tk, [1], [Define if you need to pretend to be building Tk (Windows)])
   101    170   			;;
   102    171   		cygwin*)
   103    172   			CFLAGS="${CFLAGS} -mms-bitfields"
   104    173   			;;
   105    174   	esac
   106         -])          
          175  +])

kitsh/buildsrc/kitsh-0.0/boot.tcl became a regular file with contents [22b7e78c5d].


Modified kitsh/buildsrc/kitsh-0.0/configure.ac from [2cb258376d] to [1011f72d15].

     5      5   AC_PROG_CC
     6      6   AC_PROG_MAKE_SET
     7      7   AC_PROG_INSTALL
     8      8   AC_AIX
     9      9   AC_GNU_SOURCE
    10     10   
    11     11   dnl Find the appropriate libraries to link to
    12         -AC_SEARCH_LIBS(inflate, z zlib,, [ AC_MSG_WARN([Couldn't find inflate (normally in zlib)!]) ])
    13     12   AC_SEARCH_LIBS(acos, m,, [ AC_MSG_WARN([Couldn't find acos (normally in libm)!]) ])
    14     13   AC_SEARCH_LIBS(dlsym, dl,, [ AC_MSG_WARN([Couldn't find dlsym (normally in libdl)!]) ])
    15     14   
    16     15   dnl Find the appropriate Tcl headers and libraries
    17     16   DC_DO_TCL
    18     17   
    19     18   dnl Find archives we need to link to
    20     19   DC_FIND_TCLKIT_LIBS
    21     20   
    22         -dnl Find any platform specific defines that we need to make
    23         -DC_SETUP_TCL_PLAT_DEFS
    24         -
    25     21   dnl Determine if we have "Tcl_SetStartupScript" (8.6.x) or "TclSetStartupScriptPath" (8.4.x)
    26     22   SAVE_LIBS="${LIBS}"
    27     23   LIBS="${ARCHS} ${LIBS}"
    28     24   AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath)
    29     25   LIBS="${SAVE_LIBS}"
    30     26   
           27  +dnl Find zlib
           28  +AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib], [directory containing zlib]), [
           29  +	CFLAGS="${CFLAGS} -I${with_zlib}/include -I${with_zlib}"
           30  +	LDFLAGS="${CFLAGS} -L${with_zlib}/lib -L${with_zlib}"
           31  +])
           32  +AC_SEARCH_LIBS(inflate, z zlib,, [ AC_MSG_WARN([Couldn't find inflate (normally in zlib)!]) ])
           33  +
    31     34   dnl Produce output
    32     35   AC_OUTPUT(Makefile)

Modified kitsh/buildsrc/kitsh-0.0/main.c from [adc8789527] to [f0d4d5a170].

            1  +#ifndef KITSH_NEED_WINMAIN
     1      2   #include <tcl.h>
     2      3   
     3      4   int TclKit_AppInit(Tcl_Interp *interp);
     4      5   
     5      6   int main(int argc, char **argv) {
     6      7   	Tcl_Interp *x;
     7      8   
     8      9   	x = Tcl_CreateInterp();
     9     10   
    10     11   	Tcl_Main(argc, argv, TclKit_AppInit);
    11     12   
    12     13   	return(0);
    13     14   }
           15  +#endif

Added kitsh/buildsrc/kitsh-0.0/winMain.c version [7676f90af4].

            1  +#ifdef KITSH_NEED_WINMAIN
            2  +/* 
            3  + * winMain.c --
            4  + *
            5  + *	Main entry point for wish and other Tk-based applications.
            6  + *
            7  + * Copyright (c) 1995-1997 Sun Microsystems, Inc.
            8  + * Copyright (c) 1998-1999 by Scriptics Corporation.
            9  + *
           10  + * See the file "license.terms" for information on usage and redistribution
           11  + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
           12  + *
           13  + * RCS: @(#) $Id: winMain.c 1629 2007-06-09 13:59:31Z jcw $
           14  + */
           15  +
           16  +#include <tk.h>
           17  +#define WIN32_LEAN_AND_MEAN
           18  +#include <windows.h>
           19  +#undef WIN32_LEAN_AND_MEAN
           20  +#include <malloc.h>
           21  +
           22  +#ifndef UNDER_CE
           23  +#include <locale.h>
           24  +#endif
           25  +
           26  +/*
           27  + * The following declarations refer to internal Tk routines.  These
           28  + * interfaces are available for use, but are not supported.
           29  + */
           30  +
           31  +
           32  +/*
           33  + * Forward declarations for procedures defined later in this file:
           34  + */
           35  +
           36  +static void		setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr));
           37  +static Tcl_PanicProc	WishPanic;
           38  +
           39  +#ifdef TK_TEST
           40  +extern int		Tktest_Init(Tcl_Interp *interp);
           41  +#endif /* TK_TEST */
           42  +
           43  +static BOOL consoleRequired = TRUE;
           44  +
           45  +/*
           46  + * The following #if block allows you to change the AppInit
           47  + * function by using a #define of TCL_LOCAL_APPINIT instead
           48  + * of rewriting this entire file.  The #if checks for that
           49  + * #define and uses Tcl_AppInit if it doesn't exist.
           50  + */
           51  +    
           52  +#ifndef TK_LOCAL_APPINIT
           53  +#define TK_LOCAL_APPINIT Tcl_AppInit    
           54  +#endif
           55  +extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
           56  +    
           57  +/*
           58  + * The following #if block allows you to change how Tcl finds the startup
           59  + * script, prime the library or encoding paths, fiddle with the argv,
           60  + * etc., without needing to rewrite Tk_Main()
           61  + */
           62  +
           63  +#ifdef TK_LOCAL_MAIN_HOOK
           64  +extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
           65  +#endif
           66  +
           67  +
           68  +/*
           69  + *----------------------------------------------------------------------
           70  + *
           71  + * WinMain --
           72  + *
           73  + *	Main entry point from Windows.
           74  + *
           75  + * Results:
           76  + *	Returns false if initialization fails, otherwise it never
           77  + *	returns. 
           78  + *
           79  + * Side effects:
           80  + *	Just about anything, since from here we call arbitrary Tcl code.
           81  + *
           82  + *----------------------------------------------------------------------
           83  + */
           84  +
           85  +int APIENTRY
           86  +#ifdef UNDER_CE
           87  +wWinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
           88  +#else
           89  +WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
           90  +#endif
           91  +    HINSTANCE hInstance;
           92  +    HINSTANCE hPrevInstance;
           93  +    LPSTR lpszCmdLine;
           94  +    int nCmdShow;
           95  +{
           96  +    char **argv;
           97  +    int argc;
           98  +#ifndef UNDER_CE
           99  +    char buffer[MAX_PATH+1];
          100  +    char *p;
          101  +#endif
          102  +
          103  +#ifdef UNDER_CE
          104  +    nCmdShow = SW_SHOWNORMAL;
          105  +
          106  +    XCEShowWaitCursor();
          107  +
          108  +    xceinit(lpszCmdLine);
          109  +    argc = __xceargc;
          110  +    argv = __xceargv;
          111  +#endif
          112  +
          113  +    Tcl_SetPanicProc(WishPanic);
          114  +
          115  +    /*
          116  +     * Create the console channels and install them as the standard
          117  +     * channels.  All I/O will be discarded until Tk_CreateConsoleWindow is
          118  +     * called to attach the console to a text widget.
          119  +     */
          120  +
          121  +    consoleRequired = TRUE;
          122  +
          123  +    /*
          124  +     * Set up the default locale to be standard "C" locale so parsing
          125  +     * is performed correctly.
          126  +     */
          127  +
          128  +#ifndef UNDER_CE
          129  +    setlocale(LC_ALL, "C");
          130  +    setargv(&argc, &argv);
          131  +
          132  +    /*
          133  +     * Replace argv[0] with full pathname of executable, and forward
          134  +     * slashes substituted for backslashes.
          135  +     */
          136  +
          137  +    GetModuleFileName(NULL, buffer, sizeof(buffer));
          138  +    argv[0] = buffer;
          139  +    for (p = buffer; *p != '\0'; p++) {
          140  +	if (*p == '\\') {
          141  +	    *p = '/';
          142  +	}
          143  +    }
          144  +#endif
          145  +
          146  +#ifdef TK_LOCAL_MAIN_HOOK
          147  +    TK_LOCAL_MAIN_HOOK(&argc, &argv);
          148  +#endif
          149  +
          150  +    Tk_Main(argc, argv, TK_LOCAL_APPINIT);
          151  +    return 1;
          152  +}
          153  +
          154  +
          155  +/*
          156  + *----------------------------------------------------------------------
          157  + *
          158  + * Tcl_AppInit --
          159  + *
          160  + *	This procedure performs application-specific initialization.
          161  + *	Most applications, especially those that incorporate additional
          162  + *	packages, will have their own version of this procedure.
          163  + *
          164  + * Results:
          165  + *	Returns a standard Tcl completion code, and leaves an error
          166  + *	message in the interp's result if an error occurs.
          167  + *
          168  + * Side effects:
          169  + *	Depends on the startup script.
          170  + *
          171  + *----------------------------------------------------------------------
          172  + */
          173  +
          174  +int
          175  +Tcl_AppInit(interp)
          176  +    Tcl_Interp *interp;		/* Interpreter for application. */
          177  +{
          178  +    if (Tcl_Init(interp) == TCL_ERROR) {
          179  +	goto error;
          180  +    }
          181  +    if (Tk_Init(interp) == TCL_ERROR) {
          182  +	goto error;
          183  +    }
          184  +    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
          185  +
          186  +    /*
          187  +     * Initialize the console only if we are running as an interactive
          188  +     * application.
          189  +     */
          190  +
          191  +#ifdef UNDER_CE
          192  +    consoleRequired = FALSE;
          193  +#endif
          194  +
          195  +    if (consoleRequired) {
          196  +	if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
          197  +	    goto error;
          198  +	}
          199  +    }
          200  +#if defined(STATIC_BUILD) && defined(TCL_USE_STATIC_PACKAGES)
          201  +    {
          202  +	extern Tcl_PackageInitProc Registry_Init;
          203  +	extern Tcl_PackageInitProc Dde_Init;
          204  +
          205  +	if (Registry_Init(interp) == TCL_ERROR) {
          206  +	    return TCL_ERROR;
          207  +	}
          208  +	Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);
          209  +
          210  +	if (Dde_Init(interp) == TCL_ERROR) {
          211  +	    return TCL_ERROR;
          212  +	}
          213  +	Tcl_StaticPackage(interp, "dde", Dde_Init, NULL);
          214  +   }
          215  +#endif
          216  +
          217  +#ifdef TK_TEST
          218  +    if (Tktest_Init(interp) == TCL_ERROR) {
          219  +	goto error;
          220  +    }
          221  +    Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
          222  +            (Tcl_PackageInitProc *) NULL);
          223  +#endif /* TK_TEST */
          224  +
          225  +    Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
          226  +    return TCL_OK;
          227  +
          228  +error:
          229  +    MessageBeep(MB_ICONEXCLAMATION);
          230  +    MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish",
          231  +	    MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
          232  +    ExitProcess(1);
          233  +    /* we won't reach this, but we need the return */
          234  +    return TCL_ERROR;
          235  +}
          236  +
          237  +/*
          238  + *----------------------------------------------------------------------
          239  + *
          240  + * WishPanic --
          241  + *
          242  + *	Display a message and exit.
          243  + *
          244  + * Results:
          245  + *	None.
          246  + *
          247  + * Side effects:
          248  + *	Exits the program.
          249  + *
          250  + *----------------------------------------------------------------------
          251  + */
          252  +
          253  +void
          254  +WishPanic TCL_VARARGS_DEF(CONST char *,arg1)
          255  +{
          256  +    va_list argList;
          257  +    char buf[1024];
          258  +    CONST char *format;
          259  +    
          260  +    format = TCL_VARARGS_START(CONST char *,arg1,argList);
          261  +    vsprintf(buf, format, argList);
          262  +
          263  +    MessageBeep(MB_ICONEXCLAMATION);
          264  +    MessageBox(NULL, buf, "Fatal Error in Wish",
          265  +	    MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
          266  +#ifdef _MSC_VER
          267  +    DebugBreak();
          268  +#endif
          269  +    ExitProcess(1);
          270  +}
          271  +/*
          272  + *-------------------------------------------------------------------------
          273  + *
          274  + * setargv --
          275  + *
          276  + *	Parse the Windows command line string into argc/argv.  Done here
          277  + *	because we don't trust the builtin argument parser in crt0.  
          278  + *	Windows applications are responsible for breaking their command
          279  + *	line into arguments.
          280  + *
          281  + *	2N backslashes + quote -> N backslashes + begin quoted string
          282  + *	2N + 1 backslashes + quote -> literal
          283  + *	N backslashes + non-quote -> literal
          284  + *	quote + quote in a quoted string -> single quote
          285  + *	quote + quote not in quoted string -> empty string
          286  + *	quote -> begin quoted string
          287  + *
          288  + * Results:
          289  + *	Fills argcPtr with the number of arguments and argvPtr with the
          290  + *	array of arguments.
          291  + *
          292  + * Side effects:
          293  + *	Memory allocated.
          294  + *
          295  + *--------------------------------------------------------------------------
          296  + */
          297  +
          298  +static void
          299  +setargv(argcPtr, argvPtr)
          300  +    int *argcPtr;		/* Filled with number of argument strings. */
          301  +    char ***argvPtr;		/* Filled with argument strings (malloc'd). */
          302  +{
          303  +    char *cmdLine, *p, *arg, *argSpace;
          304  +    char **argv;
          305  +    int argc, size, inquote, copy, slashes;
          306  +    
          307  +    cmdLine = GetCommandLine();	/* INTL: BUG */
          308  +
          309  +    /*
          310  +     * Precompute an overly pessimistic guess at the number of arguments
          311  +     * in the command line by counting non-space spans.
          312  +     */
          313  +
          314  +    size = 2;
          315  +    for (p = cmdLine; *p != '\0'; p++) {
          316  +	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
          317  +	    size++;
          318  +	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
          319  +		p++;
          320  +	    }
          321  +	    if (*p == '\0') {
          322  +		break;
          323  +	    }
          324  +	}
          325  +    }
          326  +    argSpace = (char *) Tcl_Alloc(
          327  +	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
          328  +    argv = (char **) argSpace;
          329  +    argSpace += size * sizeof(char *);
          330  +    size--;
          331  +
          332  +    p = cmdLine;
          333  +    for (argc = 0; argc < size; argc++) {
          334  +	argv[argc] = arg = argSpace;
          335  +	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
          336  +	    p++;
          337  +	}
          338  +	if (*p == '\0') {
          339  +	    break;
          340  +	}
          341  +
          342  +	inquote = 0;
          343  +	slashes = 0;
          344  +	while (1) {
          345  +	    copy = 1;
          346  +	    while (*p == '\\') {
          347  +		slashes++;
          348  +		p++;
          349  +	    }
          350  +	    if (*p == '"') {
          351  +		if ((slashes & 1) == 0) {
          352  +		    copy = 0;
          353  +		    if ((inquote) && (p[1] == '"')) {
          354  +			p++;
          355  +			copy = 1;
          356  +		    } else {
          357  +			inquote = !inquote;
          358  +		    }
          359  +                }
          360  +                slashes >>= 1;
          361  +            }
          362  +
          363  +            while (slashes) {
          364  +		*arg = '\\';
          365  +		arg++;
          366  +		slashes--;
          367  +	    }
          368  +
          369  +	    if ((*p == '\0')
          370  +		    || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */
          371  +		break;
          372  +	    }
          373  +	    if (copy != 0) {
          374  +		*arg = *p;
          375  +		arg++;
          376  +	    }
          377  +	    p++;
          378  +        }
          379  +	*arg = '\0';
          380  +	argSpace = arg + 1;
          381  +    }
          382  +    argv[argc] = NULL;
          383  +
          384  +    *argcPtr = argc;
          385  +    *argvPtr = argv;
          386  +}
          387  +
          388  +#if !defined(__GNUC__) || defined(TK_TEST)
          389  +/*
          390  + *----------------------------------------------------------------------
          391  + *
          392  + * main --
          393  + *
          394  + *	Main entry point from the console.
          395  + *
          396  + * Results:
          397  + *	None: Tk_Main never returns here, so this procedure never
          398  + *      returns either.
          399  + *
          400  + * Side effects:
          401  + *	Whatever the applications does.
          402  + *
          403  + *----------------------------------------------------------------------
          404  + */
          405  +
          406  +int main(int argc, char **argv)
          407  +{
          408  +    Tcl_SetPanicProc(WishPanic);
          409  +
          410  +    /*
          411  +     * Set up the default locale to be standard "C" locale so parsing
          412  +     * is performed correctly.
          413  +     */
          414  +#ifndef UNDER_CE
          415  +    setlocale(LC_ALL, "C");
          416  +#endif
          417  +
          418  +    /*
          419  +     * Create the console channels and install them as the standard
          420  +     * channels.  All I/O will be discarded until Tk_CreateConsoleWindow is
          421  +     * called to attach the console to a text widget.
          422  +     */
          423  +
          424  +    consoleRequired = FALSE;
          425  +
          426  +    Tk_Main(argc, argv, Tcl_AppInit);
          427  +    return 0;
          428  +}
          429  +#endif /* !__GNUC__ || TK_TEST */
          430  +#endif