head	1.41;
access;
symbols
	core-8-5-9:1.26.2.1
	core-8-5-8:1.26
	macosx-cocoa-merge:1.27
	macosx-cocoa-premerge:1.27
	macosx-carbon-freeze:1.27
	core-8-5-7:1.26
	core-8-5-6:1.26
	core-8-6-b1:1.27
	core-8-6-a3:1.27
	core-8-5-5:1.26
	core-8-6-a2:1.27
	core-8-5-4:1.26
	core-8-5-3:1.26
	core-8-6-a1:1.27
	core-8-4-19:1.15.2.2
	core-8-5-branch:1.26.0.2
	core-8-5-2:1.26
	core-8-4-18:1.15.2.2
	core-8-5-1:1.26
	core-8-4-17:1.15.2.2
	core-8-5-0:1.26
	core-8-5-b3:1.25
	core-8-5-b2:1.25
	core-8-4-16:1.15.2.2
	core-8-5-b1:1.24
	core-stablilizer-merge:1.23
	core-stabilizer-branch:1.23.0.2
	core-stabilizer-merge:1.26
	core-8-4-15:1.15.2.2
	core-8-5-a6:1.23
	core-8-5-a5:1.23
	core-8-4-14:1.15.2.2
	core-8-5-a4:1.23
	core-8-4-13:1.15.2.2
	core-8-4-12:1.15.2.2
	core-8-4-11:1.15.2.2
	core-8-5-a3:1.21
	core-8-4-10:1.15.2.2
	core-8-4-9-branch:1.15.2.2.0.2
	core-8-5-a2:1.21
	core-8-4-9:1.15.2.2
	core-8-4-8:1.15.2.2
	core-8-4-7:1.15.2.2
	core-8-5-a1:1.21
	core-8-4-6:1.15.2.2
	core-8-4-5:1.15
	mistachkin-dev-branch:1.15.0.4
	core-8-4-4:1.15
	core-8-4-3:1.15
	core-8-4-branch:1.15.0.2
	core-8-4-2:1.15
	core-8-4-1:1.14
	core-8-3-5:1.10.2.1
	core-8-4-0:1.12
	macosx-8-4-merge-2002-08-31-trunk:1.12
	macosx-8-4-premerge-2002-08-31-branch:1.11.2.1
	macosx-8-4-premerge-2002-08-31-trunk:1.12
	macosx-8-4-merge-2002-08-30-branch:1.11.2.1
	macosx-8-4-merge-2002-08-30-trunk:1.12
	macosx-8-4-merge-2002-08-20-branch:1.11
	macosx-8-4-merge-2002-08-20-trunk:1.11
	core-8-4-b2:1.11
	core-8-4-b1:1.11
	macosx-premerge-6-9-02:1.11
	core-8-4-a4:1.11
	core-8-3-4:1.10
	macosx-8-4-branch:1.11.0.2
	macosx-8-4-branchpoint:1.11
	core-8-4-a3:1.11
	core-8-3-3:1.10
	dgp-privates-into-namespace:1.10.0.6
	tclpro-1-5-0:1.10
	core-8-4-win-speedup:1.10.0.4
	core-8-4-a2:1.10
	tclpro-1-4-1:1.10
	tclpro-1-4-0:1.10
	core-8-3-2:1.10
	ajuba-ajuba2-2-1-base:1.10
	ajuba-ajuba2-2-0:1.10
	core-8-4-a1:1.10
	core-8-3-1-branch:1.10.0.2
	core-8-3-1:1.10
	scriptics-sc-2-0-b5:1.9
	scriptics-sc-2-0-fixed:1.9
	scriptics-sc-2-0-b2:1.9
	scriptics-sc-2-0-b1:1.9
	core-8-3-0:1.9
	core-8-3-b2:1.9
	core-8-3-b1:1.9
	scriptics-sc-1-1:1.7.6.1
	scriptics-sc-1-1-b1:1.7.6.1
	core-8-2-3:1.7.6.1
	scriptics-sc-1-1-branch:1.7.6.1.0.4
	scriptics-sc-1-1-base:1.7.6.1
	scriptics-sc-1-0:1.7.6.1
	scriptics-sc-1-0-branch:1.7.6.1.0.2
	scriptics-sc-1-0-base:1.7.6.1
	core-8-2-2:1.7.6.1
	core-8-2-1:1.7
	scriptics-bc-1-0-b1:1.7
	core-8-2-1-branch:1.7.0.6
	scriptics-tclpro-1-3-0:1.7
	core-8-2-0:1.7
	core-8-2-b3-branch:1.7.0.4
	core-8-2-b3-base:1.7
	scriptics-tclpro-1-3-b4:1.7
	core-8-2-b2:1.7
	scriptics-tclpro-1-3-b3:1.7
	core-8-2-b1:1.7
	scriptics-tclpro-1-3-b2:1.7
	merge-to-mainline-5/21/99:1.7
	scriptics-tclpro-1-3-b2-branch:1.7.0.2
	core-8-1-1:1.7
	scriptics-tclpro-1-3-b1:1.7
	core-8-1-1-base:1.7
	core-8-1-0:1.6
	merge-to-mainline-4-29-99:1.6
	merge-to-mainline-4-23-99:1.6
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.5.0.2
	core-8-0-6-base:1.5
	core-8-0-5:1.4
	core-8-1-b3:1.1.4.5
	core-8-1-b2:1.1.4.5
	dev-8-1-stubs-branch:1.1.4.4.0.2
	dev-stubs-branch:1.4.0.4
	scriptics-tclpro-1-2:1.4
	scriptics-tclpro-1-2-b2:1.4
	core-8-1-merge-2/10/99:1.4
	core-8-0-5-branch:1.4.0.2
	core-8-0-5-base:1.4
	scriptics-tclpro-1-2-b1:1.3
	scriptics-tclpro-1-2-a1:1.3
	core-8-1-b1:1.1.4.2
	core-8-0-4:1.3
	core-8-1-a2:1.1.4.1
	core-8-0-2:1.1
	core-8-0-3:1.3;
locks; strict;
comment	@ * @;


1.41
date	2010.12.16.09.03.07;	author nijtmans;	state Exp;
branches;
next	1.40;

1.40
date	2010.11.24.12.57.54;	author nijtmans;	state Exp;
branches;
next	1.39;

1.39
date	2010.11.24.10.34.18;	author nijtmans;	state Exp;
branches;
next	1.38;

1.38
date	2010.11.18.15.54.20;	author nijtmans;	state Exp;
branches;
next	1.37;

1.37
date	2010.11.17.14.31.40;	author nijtmans;	state Exp;
branches;
next	1.36;

1.36
date	2010.11.17.10.37.45;	author nijtmans;	state Exp;
branches;
next	1.35;

1.35
date	2010.11.16.14.05.36;	author nijtmans;	state Exp;
branches;
next	1.34;

1.34
date	2010.10.11.21.50.46;	author nijtmans;	state Exp;
branches;
next	1.33;

1.33
date	2010.09.23.21.45.14;	author nijtmans;	state Exp;
branches;
next	1.32;

1.32
date	2010.09.23.20.59.00;	author nijtmans;	state Exp;
branches;
next	1.31;

1.31
date	2010.09.23.10.01.57;	author nijtmans;	state Exp;
branches;
next	1.30;

1.30
date	2010.09.10.08.59.24;	author nijtmans;	state Exp;
branches;
next	1.29;

1.29
date	2010.01.22.14.17.53;	author nijtmans;	state Exp;
branches;
next	1.28;

1.28
date	2009.10.21.20.28.52;	author nijtmans;	state Exp;
branches;
next	1.27;

1.27
date	2008.04.27.22.39.17;	author dkf;	state Exp;
branches;
next	1.26;

1.26
date	2007.12.13.15.28.56;	author dgp;	state Exp;
branches
	1.26.2.1;
next	1.25;

1.25
date	2007.10.12.01.39.15;	author davygrvy;	state Exp;
branches;
next	1.24;

1.24
date	2007.09.07.00.34.58;	author dgp;	state Exp;
branches;
next	1.23;

1.23
date	2005.12.02.00.19.04;	author dkf;	state Exp;
branches
	1.23.2.1;
next	1.22;

1.22
date	2005.09.13.21.25.21;	author dgp;	state Exp;
branches;
next	1.21;

1.21
date	2004.02.02.08.12.58;	author davygrvy;	state Exp;
branches;
next	1.20;

1.20
date	2004.02.01.10.44.54;	author davygrvy;	state Exp;
branches;
next	1.19;

1.19
date	2003.12.21.23.50.13;	author davygrvy;	state Exp;
branches;
next	1.18;

1.18
date	2003.12.12.00.45.33;	author davygrvy;	state Exp;
branches;
next	1.17;

1.17
date	2003.12.12.00.34.06;	author davygrvy;	state Exp;
branches;
next	1.16;

1.16
date	2003.10.14.15.35.52;	author patthoyts;	state Exp;
branches;
next	1.15;

1.15
date	2002.11.04.07.49.43;	author davygrvy;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	2002.10.19.02.10.07;	author hobbs;	state Exp;
branches;
next	1.13;

1.13
date	2002.09.27.00.48.06;	author hobbs;	state Exp;
branches;
next	1.12;

1.12
date	2002.08.26.14.32.18;	author dgp;	state Exp;
branches;
next	1.11;

1.11
date	2001.08.04.00.29.43;	author hobbs;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2000.04.19.23.12.56;	author hobbs;	state Exp;
branches
	1.10.2.1
	1.10.4.1;
next	1.9;

1.9
date	99.12.02.02.05.46;	author redman;	state Exp;
branches;
next	1.8;

1.8
date	99.11.10.02.56.42;	author hobbs;	state Exp;
branches;
next	1.7;

1.7
date	99.04.28.18.18.07;	author redman;	state Exp;
branches
	1.7.6.1;
next	1.6;

1.6
date	99.04.16.01.51.55;	author stanton;	state Exp;
branches;
next	1.5;

1.5
date	99.03.10.07.04.46;	author stanton;	state Exp;
branches;
next	1.4;

1.4
date	99.02.04.20.57.18;	author stanton;	state Exp;
branches
	1.4.4.1;
next	1.3;

1.3
date	98.09.14.18.24.02;	author stanton;	state Exp;
branches;
next	1.2;

1.2
date	98.07.24.15.11.23;	author welch;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.10.00.33;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.29.00.26.11;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.09.30.02.19.41;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	99.02.11.04.13.52;	author stanton;	state Exp;
branches;
next	1.1.4.4;

1.1.4.4
date	99.02.26.02.24.46;	author redman;	state Exp;
branches
	1.1.4.4.2.1;
next	1.1.4.5;

1.1.4.5
date	99.03.10.07.13.52;	author stanton;	state Exp;
branches;
next	;

1.1.4.4.2.1
date	99.03.09.17.50.39;	author redman;	state Exp;
branches;
next	;

1.4.4.1
date	99.03.06.23.18.05;	author stanton;	state Exp;
branches;
next	1.4.4.2;

1.4.4.2
date	99.03.07.00.15.47;	author redman;	state Exp;
branches;
next	;

1.7.6.1
date	99.11.03.00.43.09;	author hobbs;	state Exp;
branches;
next	;

1.10.2.1
date	2002.10.18.19.32.07;	author hobbs;	state Exp;
branches;
next	;

1.10.4.1
date	2000.11.03.22.49.30;	author hobbs;	state Exp;
branches;
next	1.10.4.2;

1.10.4.2
date	2002.04.02.21.17.05;	author hobbs;	state Exp;
branches;
next	;

1.11.2.1
date	2002.08.30.15.36.13;	author das;	state Exp;
branches;
next	;

1.15.2.1
date	2003.12.11.03.32.05;	author davygrvy;	state Exp;
branches;
next	1.15.2.2;

1.15.2.2
date	2003.12.12.00.42.10;	author davygrvy;	state Exp;
branches;
next	;

1.23.2.1
date	2007.09.07.01.25.41;	author dgp;	state Exp;
branches;
next	1.23.2.2;

1.23.2.2
date	2007.10.15.18.38.41;	author dgp;	state Exp;
branches;
next	;

1.26.2.1
date	2010.05.31.13.47.33;	author nijtmans;	state Exp;
branches;
next	1.26.2.2;

1.26.2.2
date	2010.11.24.15.15.25;	author nijtmans;	state Exp;
branches;
next	;


desc
@@


1.41
log
@[Patch 3124554]: Move WishPanic from Tk to Tcl
Remove special MessageBox'es here, since every panic-related thing is now handled correctly by Tcl
@
text
@/*
 * winMain.c --
 *
 *	Provides a default version of the main program and Tcl_AppInit
 *	procedure for wish and other Tk-based applications.
 *
 * Copyright (c) 1993 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id: winMain.c,v 1.40 2010/11/24 12:57:54 nijtmans Exp $
 */

#include "tk.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <locale.h>
#include <stdlib.h>
#include <tchar.h>

#ifdef TK_TEST
extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */

#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
extern Tcl_PackageInitProc Registry_Init;
extern Tcl_PackageInitProc Dde_Init;
extern Tcl_PackageInitProc Dde_SafeInit;
#endif

#ifdef TCL_BROKEN_MAINARGS
static void setargv(int *argcPtr, TCHAR ***argvPtr);
#endif

/*
 * Forward declarations for procedures defined later in this file:
 */

static BOOL consoleRequired = TRUE;

/*
 * The following #if block allows you to change the AppInit function by using
 * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
 * #if checks for that #define and uses Tcl_AppInit if it doesn't exist.
 */

#ifndef TK_LOCAL_APPINIT
#define TK_LOCAL_APPINIT Tcl_AppInit
#endif
extern int TK_LOCAL_APPINIT(Tcl_Interp *interp);

/*
 * The following #if block allows you to change how Tcl finds the startup
 * script, prime the library or encoding paths, fiddle with the argv, etc.,
 * without needing to rewrite Tk_Main()
 */

#ifdef TK_LOCAL_MAIN_HOOK
extern int TK_LOCAL_MAIN_HOOK(int *argc, TCHAR ***argv);
#endif

/*
 *----------------------------------------------------------------------
 *
 * _tWinMain --
 *
 *	Main entry point from Windows.
 *
 * Results:
 *	Returns false if initialization fails, otherwise it never returns.
 *
 * Side effects:
 *	Just about anything, since from here we call arbitrary Tcl code.
 *
 *----------------------------------------------------------------------
 */

int APIENTRY
#ifdef TCL_BROKEN_MAINARGS
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpszCmdLine,
    int nCmdShow)
#else
_tWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpszCmdLine,
    int nCmdShow)
#endif
{
    TCHAR **argv;
    int argc;
    TCHAR *p;

    /*
     * Create the console channels and install them as the standard channels.
     * All I/O will be discarded until Tk_CreateConsoleWindow is called to
     * attach the console to a text widget.
     */

    consoleRequired = TRUE;

    /*
     * Set up the default locale to be standard "C" locale so parsing is
     * performed correctly.
     */

    setlocale(LC_ALL, "C");

    /*
     * Get our args from the c-runtime. Ignore lpszCmdLine.
     */

#if defined(TCL_BROKEN_MAINARGS)
    setargv(&argc, &argv);
#else
    argc = __argc;
    argv = __targv;
#endif

    /*
     * Forward slashes substituted for backslashes.
     */

    for (p = argv[0]; *p != TEXT('\0'); p++) {
	if (*p == TEXT('\\')) {
	    *p = TEXT('/');
	}
    }

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif

    Tk_Main(argc, argv, TK_LOCAL_APPINIT);
    return 0;			/* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --
 *
 *	This procedure performs application-specific initialization. Most
 *	applications, especially those that incorporate additional packages,
 *	will have their own version of this procedure.
 *
 * Results:
 *	Returns a standard Tcl completion code, and leaves an error message in
 *	the interp's result if an error occurs.
 *
 * Side effects:
 *	Depends on the startup script.
 *
 *----------------------------------------------------------------------
 */

int
Tcl_AppInit(
    Tcl_Interp *interp)		/* Interpreter for application. */
{
    if ((Tcl_Init)(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    if (Tk_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);

    /*
     * Initialize the console only if we are running as an interactive
     * application.
     */

    if (consoleRequired) {
	if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
	    return TCL_ERROR;
	}
    }
#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
    if (Registry_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "registry", Registry_Init, 0);

    if (Dde_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "dde", Dde_Init, Dde_SafeInit);
#endif

#ifdef TK_TEST
    if (Tktest_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tktest", Tktest_Init, 0);
#endif /* TK_TEST */

    /*
     * Call the init procedures for included packages. Each call should look
     * like this:
     *
     * if (Mod_Init(interp) == TCL_ERROR) {
     *     return TCL_ERROR;
     * }
     *
     * where "Mod" is the name of the module. (Dynamically-loadable packages
     * should have the same entry-point name.)
     */

    /*
     * Call Tcl_CreateCommand for application-specific commands, if they
     * weren't already created by the init procedures called above.
     */

    /*
     * Specify a user-specific startup file to invoke if the application is
     * run interactively. Typically the startup file is "~/.apprc" where "app"
     * is the name of the application. If this line is deleted then no user-
     * specific startup file will be run under any conditions.
     */

    (Tcl_SetVar)(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
    return TCL_OK;
}

#if defined(__CYGWIN__) || defined(TK_TEST)
/*
 *----------------------------------------------------------------------
 *
 * _tmain --
 *
 *	Main entry point from the console.
 *
 * Results:
 *	None: Tk_Main never returns here, so this procedure never returns
 *	either.
 *
 * Side effects:
 *	Whatever the applications does.
 *
 *----------------------------------------------------------------------
 */

#ifdef TCL_BROKEN_MAINARGS
int
main(
    int argc,
    char **dummy)
{
    TCHAR **argv;
#else
int
_tmain(
    int argc,
    TCHAR **argv)
{
#endif
    /*
     * Set up the default locale to be standard "C" locale so parsing is
     * performed correctly.
     */

    setlocale(LC_ALL, "C");

#ifdef TCL_BROKEN_MAINARGS
    /*
     * Get our args from the c-runtime. Ignore argc/argv.
     */

    setargv(&argc, &argv);
#endif
    /*
     * Console emulation widget not required as this entry is from the
     * console subsystem, thus stdin,out,err already have end-points.
     */

    consoleRequired = FALSE;

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif

    Tk_Main(argc, argv, Tcl_AppInit);
    return 0;
}
#endif /* !__GNUC__ || TK_TEST */


/*
 *-------------------------------------------------------------------------
 *
 * setargv --
 *
 *	Parse the Windows command line string into argc/argv. Done here
 *	because we don't trust the builtin argument parser in crt0. Windows
 *	applications are responsible for breaking their command line into
 *	arguments.
 *
 *	2N backslashes + quote -> N backslashes + begin quoted string
 *	2N + 1 backslashes + quote -> literal
 *	N backslashes + non-quote -> literal
 *	quote + quote in a quoted string -> single quote
 *	quote + quote not in quoted string -> empty string
 *	quote -> begin quoted string
 *
 * Results:
 *	Fills argcPtr with the number of arguments and argvPtr with the array
 *	of arguments.
 *
 * Side effects:
 *	Memory allocated.
 *
 *--------------------------------------------------------------------------
 */

#ifdef TCL_BROKEN_MAINARGS
static void
setargv(
    int *argcPtr,		/* Filled with number of argument strings. */
    TCHAR ***argvPtr)		/* Filled with argument strings (malloc'd). */
{
    TCHAR *cmdLine, *p, *arg, *argSpace;
    TCHAR **argv;
    int argc, size, inquote, copy, slashes;

    cmdLine = GetCommandLine();

    /*
     * Precompute an overly pessimistic guess at the number of arguments in
     * the command line by counting non-space spans.
     */

    size = 2;
    for (p = cmdLine; *p != TEXT('\0'); p++) {
	if ((*p == TEXT(' ')) || (*p == TEXT('\t'))) {	/* INTL: ISO space. */
	    size++;
	    while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
		p++;
	    }
	    if (*p == TEXT('\0')) {
		break;
	    }
	}
    }

    /* Make sure we don't call ckalloc through the (not yet initialized) stub table */
    #undef Tcl_Alloc
    #undef Tcl_DbCkalloc

    argSpace = (TCHAR *) ckalloc(
	    (unsigned) (size * sizeof(char *) + (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR)));
    argv = (TCHAR **) argSpace;
    argSpace += size * (sizeof(char *)/sizeof(TCHAR));
    size--;

    p = cmdLine;
    for (argc = 0; argc < size; argc++) {
	argv[argc] = arg = argSpace;
	while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) {	/* INTL: ISO space. */
	    p++;
	}
	if (*p == TEXT('\0')) {
	    break;
	}

	inquote = 0;
	slashes = 0;
	while (1) {
	    copy = 1;
	    while (*p == TEXT('\\')) {
		slashes++;
		p++;
	    }
	    if (*p == TEXT('"')) {
		if ((slashes & 1) == 0) {
		    copy = 0;
		    if ((inquote) && (p[1] == TEXT('"'))) {
			p++;
			copy = 1;
		    } else {
			inquote = !inquote;
		    }
		}
		slashes >>= 1;
	    }

	    while (slashes) {
		*arg = TEXT('\\');
		arg++;
		slashes--;
	    }

	    if ((*p == TEXT('\0')) || (!inquote &&
		    ((*p == TEXT(' ')) || (*p == TEXT('\t'))))) {	/* INTL: ISO space. */
		break;
	    }
	    if (copy != 0) {
		*arg = *p;
		arg++;
	    }
	    p++;
	}
	*arg = '\0';
	argSpace = arg + 1;
    }
    argv[argc] = 0;

    *argcPtr = argc;
    *argvPtr = argv;
}
#endif /* TCL_BROKEN_MAINARGS */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
@


1.40
log
@use TkpDisplayWarning as panic proc on Windows, but restore panic
dialog title to exactly what it was in Tk 8.5 ("Fatal Error in Wish")
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.39 2010/11/24 10:34:18 nijtmans Exp $
a37 1
extern void TkpDisplayWarning(const char *, const char *);
a42 1
static void WishPanic(const char *format, ...);
a81 8
#ifdef UNICODE
/* workaround for bug in some versions of mingw32-w64 */
#   undef _tWinMain
#   define _tWinMain wWinMain
#   undef __targv
#   define __targv __wargv
#endif

a100 2
    (Tcl_SetPanicProc)(WishPanic);

d169 1
a169 1
	goto error;
d172 1
a172 1
	goto error;
d183 1
a183 1
	    goto error;
d188 1
a188 1
	goto error;
d193 1
a193 1
	goto error;
d200 1
a200 1
	goto error;
a230 14

error:
    MessageBeep(MB_ICONEXCLAMATION);
    TkpDisplayWarning((Tcl_GetStringResult)(interp), "Error in Wish");
#ifdef _MSC_VER
    DebugBreak();
#endif
    ExitProcess(1);

    /*
     * We won't reach this, but we need the return.
     */

    return TCL_ERROR;
d233 1
a233 34
/*
 *----------------------------------------------------------------------
 *
 * WishPanic --
 *
 *	Display a message and exit.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Exits the program.
 *
 *----------------------------------------------------------------------
 */

void
WishPanic(
    const char *format, ...)
{
    va_list argList;
    char buf[1024];

    MessageBeep(MB_ICONEXCLAMATION);
    va_start(argList, format);
    vsprintf(buf, format, argList);
	TkpDisplayWarning(buf, "Fatal Error in Wish");
#ifdef _MSC_VER
    DebugBreak();
#endif
    ExitProcess(1);
}

#if !defined(TCL_BROKEN_MAINARGS) || defined(TK_TEST)
a264 2
    (Tcl_SetPanicProc)(WishPanic);

@


1.39
log
@re-write TkpDisplayWarning not to use any Tcl functions any more. This allows TkpDisplayWarning to be used as panic proc on Windows
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.38 2010/11/18 15:54:20 nijtmans Exp $
d202 1
a202 1
    Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);
d245 6
a250 1
    WishPanic("%s", (Tcl_GetStringResult)(interp));
a274 4
/* Make sure we don't call those through the stub table */
#undef Tcl_WinUtfToTChar
#undef Tcl_DStringFree

d285 1
a285 1
	TkpDisplayWarning(buf, "Error in Wish");
d474 1
a474 1
    argv[argc] = NULL;
@


1.38
log
@[FRQ 491789]: "setargv() doesn't support a unicode cmdline"
now implemented for cygwin and mingw32 too.
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.37 2010/11/17 14:31:40 nijtmans Exp $
d38 1
a44 1

a279 1
    Tcl_DString ds;
d284 1
a284 4
    Tcl_WinUtfToTChar(buf, -1, &ds);
    MessageBox(NULL, (TCHAR *)Tcl_DStringValue(&ds), TEXT("Error in Wish"),
	    MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
    Tcl_DStringFree(&ds);
@


1.37
log
@Workaround for bug in some versions of mingw-w64
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.36 2010/11/17 10:37:45 nijtmans Exp $
a16 12
#ifdef TCL_BROKEN_MAINARGS
/* On mingw32 and cygwin this doesn't work */
#   undef UNICODE
#   undef _UNICODE
#elif defined(UNICODE)
/* workaround for bug in some versions of mingw32-w64 */
#   undef _tWinMain
#   define _tWinMain wWinMain
#   undef __targv
#   define __targv __wargv
#endif

d29 8
a36 2
#if defined(__CYGWIN__)
static void setargv(int *argcPtr, char ***argvPtr);
d71 1
a71 1
 * WinMain --
d84 8
d93 7
d105 1
d132 1
a132 1
#if defined(__CYGWIN__)
d199 4
a202 4
    {
	extern Tcl_PackageInitProc Registry_Init;
	extern Tcl_PackageInitProc Dde_Init;
	extern Tcl_PackageInitProc Dde_SafeInit;
d204 4
a207 10
	if (Registry_Init(interp) == TCL_ERROR) {
	    goto error;
	}
	Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);

	if (Dde_Init(interp) == TCL_ERROR) {
	    goto error;
	}
	Tcl_StaticPackage(interp, "dde", Dde_Init, Dde_SafeInit);
   }
d245 1
a245 4
    MessageBeep(MB_ICONEXCLAMATION);
    MessageBoxA(NULL, (Tcl_GetStringResult)(interp), "Error in Wish",
	    MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
    ExitProcess(1);
d270 4
d280 1
d282 1
d285 2
a286 3

    MessageBeep(MB_ICONEXCLAMATION);
    MessageBoxA(NULL, buf, "Fatal Error in Wish",
d288 1
d299 1
a299 1
 * main --
d313 8
d326 1
d336 7
d387 1
a387 1
#if defined(__CYGWIN__)
d391 1
a391 1
    char ***argvPtr)		/* Filled with argument strings (malloc'd). */
d393 2
a394 2
    char *cmdLine, *p, *arg, *argSpace;
    char **argv;
d405 2
a406 2
    for (p = cmdLine; *p != '\0'; p++) {
	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d408 1
a408 1
	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
d411 1
a411 1
	    if (*p == '\0') {
d416 9
a424 4
    argSpace = (char *) ckalloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
    argv = (char **) argSpace;
    argSpace += size * sizeof(char *);
d430 1
a430 1
	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d433 1
a433 1
	if (*p == '\0') {
d441 1
a441 1
	    while (*p == '\\') {
d445 1
a445 1
	    if (*p == '"') {
d448 1
a448 1
		    if ((inquote) && (p[1] == '"')) {
d459 1
a459 1
		*arg = '\\';
d464 2
a465 2
	    if ((*p == '\0') || (!inquote &&
		    ((*p == ' ') || (*p == '\t')))) {	/* INTL: ISO space. */
d482 1
a482 1
#endif /* __CYGWIN__ */
@


1.36
log
@Bring compilation under mingw-w64 a bit closer to reality (but don't break mingw32 build!)
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.35 2010/11/16 14:05:36 nijtmans Exp $
d21 6
d94 1
a94 1
    LPWSTR lpszCmdLine,
@


1.35
log
@Bring compilation under mingw-w64 a bit closer to reality
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.34 2010/10/11 21:50:46 nijtmans Exp $
d388 1
a388 1
	    (unsigned) (size * sizeof(char *) + (strlen(cmdLine)) + 1));
d390 1
a390 1
    argSpace += size;
@


1.34
log
@[FRQ 491789]: "setargv() doesn't support a unicode
cmdline" implemented for Tk on MSVC++
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.33 2010/09/23 21:45:14 nijtmans Exp $
d17 2
a18 2
#ifndef _MSC_VER
/* On mingw and cygwin this doesn't work yet */
d36 2
a37 2
static void setargv(int *argcPtr, TCHAR ***argvPtr);
#endif /* __CYGWIN__ */
d88 1
a88 1
    LPTSTR lpszCmdLine,
d282 1
a282 1
#if !defined(__GNUC__) || defined(TK_TEST)
d362 1
a362 1
    TCHAR ***argvPtr)		/* Filled with argument strings (malloc'd). */
d364 2
a365 2
    TCHAR *cmdLine, *p, *arg, *argSpace;
    TCHAR **argv;
d376 2
a377 2
    for (p = cmdLine; *p != TEXT('\0'); p++) {
	if ((*p == TEXT(' ')) || (*p == TEXT('\t'))) {	/* INTL: ISO space. */
d379 1
a379 1
	    while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
d382 1
a382 1
	    if (*p == TEXT('\0')) {
d387 4
a390 4
    argSpace = (TCHAR *) ckalloc(
	    (unsigned) (size * sizeof(TCHAR *) + (_tcslen(cmdLine) * sizeof(TCHAR)) + 1));
    argv = (TCHAR **) argSpace;
    argSpace += size * sizeof(TCHAR *);
d396 1
a396 1
	while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) {	/* INTL: ISO space. */
d399 1
a399 1
	if (*p == TEXT('\0')) {
d407 1
a407 1
	    while (*p == TEXT('\\')) {
d411 1
a411 1
	    if (*p == TEXT('"')) {
d414 1
a414 1
		    if ((inquote) && (p[1] == TEXT('"'))) {
d425 1
a425 1
		*arg = TEXT('\\');
d430 2
a431 2
	    if ((*p == TEXT('\0')) || (!inquote &&
		    ((*p == TEXT(' ')) || (*p == TEXT('\t'))))) {	/* INTL: ISO space. */
d440 1
a440 1
	*arg = TEXT('\0');
@


1.33
log
@Make Tcl_SetPanicProc and Tcl_GetStringResult  callable without stubs, just as Tcl_SetVar.
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.32 2010/09/23 20:59:00 nijtmans Exp $
d17 5
a21 5
/* TODO: This file does not compile in UNICODE mode.
 * See [Freq 2965056]: Windows build with -DUNICODE
 */
#undef UNICODE
#undef _UNICODE
@


1.32
log
@winMain should never be called with stubs
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.31 2010/09/23 10:01:57 nijtmans Exp $
a22 3
/* Make sure this file is never compiled with Stubs! */
#undef USE_TCL_STUBS
#undef USE_TK_STUBS
d95 1
a95 1
    Tcl_SetPanicProc(WishPanic);
d164 1
a164 1
    if (Tcl_Init(interp) == TCL_ERROR) {
d236 1
a236 1
    MessageBoxA(NULL, Tcl_GetStringResult(interp), "Error in Wish",
d305 1
a305 1
    Tcl_SetPanicProc(WishPanic);
@


1.31
log
@Add -Wdeclaration-after-statement
tkWinX.c,winMain.c: Make compilable with -DUNICODE
tkAppInit.c,winMain.c: Many clean-ups in comments, so all (tcl|tk)AppInit.c variants use the same style.
@
text
@d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.30 2010/09/10 08:59:24 nijtmans Exp $
d23 3
@


1.30
log
@Make compilable with -DUNICODE, or mark files with a TODO which are not done yet.
tkWinPort.h:  mingw/cygwin fixes: <tchar.h> should always be included here.
@
text
@d4 2
a5 1
 *	Main entry point for wish and other Tk-based applications.
d7 3
a9 2
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
d14 1
a14 1
 * RCS: @@(#) $Id: winMain.c,v 1.29 2010/01/22 14:17:53 nijtmans Exp $
d23 1
a23 4
/* Make sure this file is never compiled with Stubs! */
#undef USE_TCL_STUBS
#undef USE_TK_STUBS
#include "tkInt.h"
d28 2
d31 3
d35 3
a37 4
/*
 * The following declarations refer to internal Tk routines. These interfaces
 * are available for use, but are not supported.
 */
d43 1
a43 8
static void		WishPanic(const char *format, ...);
#ifdef TK_TEST
extern int		Tktest_Init(Tcl_Interp *interp);
#endif /* TK_TEST */

#if defined(__CYGWIN__)
static void		setargv(int *argcPtr, char ***argvPtr);
#endif /* __CYGWIN__ */
d65 1
a65 1
extern int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
d85 1
a85 1
WinMain(
d88 1
a88 1
    LPSTR lpszCmdLine,
d91 1
a91 1
    char **argv;
d93 1
a93 1
    char *p;
d120 1
a120 1
    argv = __argv;
d127 3
a129 3
    for (p = argv[0]; *p != '\0'; p++) {
	if (*p == '\\') {
	    *p = '/';
d138 1
a138 1
    return 1;
d186 1
d189 1
a189 1
	    return TCL_ERROR;
d194 1
a194 1
	    return TCL_ERROR;
d196 1
a196 1
	Tcl_StaticPackage(interp, "dde", Dde_Init, NULL);
d204 1
a204 1
    Tcl_StaticPackage(interp, "Tktest", Tktest_Init, NULL);
d207 25
a231 1
    Tcl_SetVar(interp, "tcl_rcFileName", "~/wishrc.tcl", TCL_GLOBAL_ONLY);
d236 1
a236 1
    MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish",
d274 1
a274 1
    MessageBox(NULL, buf, "Fatal Error in Wish",
d301 1
a301 1
main(
d303 1
a303 1
    char **argv)
d321 4
d362 1
a362 1
    char ***argvPtr)		/* Filled with argument strings (malloc'd). */
d364 2
a365 2
    char *cmdLine, *p, *arg, *argSpace;
    char **argv;
d368 1
a368 1
    cmdLine = GetCommandLine();	/* INTL: BUG */
d376 2
a377 2
    for (p = cmdLine; *p != '\0'; p++) {
	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d379 1
a379 1
	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
d382 1
a382 1
	    if (*p == '\0') {
d387 4
a390 4
    argSpace = (char *) ckalloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
    argv = (char **) argSpace;
    argSpace += size * sizeof(char *);
d396 1
a396 1
	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d399 1
a399 1
	if (*p == '\0') {
d407 1
a407 1
	    while (*p == '\\') {
d411 1
a411 1
	    if (*p == '"') {
d414 1
a414 1
		    if ((inquote) && (p[1] == '"')) {
d425 1
a425 1
		*arg = '\\';
d430 2
a431 2
	    if ((*p == '\0') || (!inquote &&
		    ((*p == ' ') || (*p == '\t')))) {	/* INTL: ISO space. */
d440 1
a440 1
	*arg = '\0';
a448 8

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
@


1.29
log
@fix more gcc warnings: missing initializer
Eliminate use of __argc and __argv for CYGWIN
Make cygwin configuration error into
 a warning: CYGWIN compilation works
although there still are test failures.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.28 2009/10/21 20:28:52 nijtmans Exp $
d15 6
@


1.28
log
@Bug fix for #2875562
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.27 2008/04/27 22:39:17 dkf Exp $
d39 4
d114 3
d119 1
d298 128
@


1.27
log
@Get rid of pre-C89-isms (esp. CONST vs const).
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.26 2007/12/13 15:28:56 dgp Exp $
d15 3
@


1.26
log
@merge stable branch onto HEAD
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.23.2.2 2007/10/15 18:38:41 dgp Exp $
d31 1
a31 1
static void		WishPanic(CONST char *format, ...);
d227 1
a227 1
    CONST char *format, ...)
@


1.26.2.1
log
@Add command line processing for CYGWIN, backported from trunk.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.26 2007/12/13 15:28:56 dgp Exp $
a35 4
#if defined(__CYGWIN__)
static void		setargv(int *argcPtr, char ***argvPtr);
#endif /* __CYGWIN__ */

a106 3
#if defined(__CYGWIN__)
    setargv(&argc, &argv);
#else
a108 1
#endif
d287 1
a287 121


/*
 *-------------------------------------------------------------------------
 *
 * setargv --
 *
 *	Parse the Windows command line string into argc/argv. Done here
 *	because we don't trust the builtin argument parser in crt0. Windows
 *	applications are responsible for breaking their command line into
 *	arguments.
 *
 *	2N backslashes + quote -> N backslashes + begin quoted string
 *	2N + 1 backslashes + quote -> literal
 *	N backslashes + non-quote -> literal
 *	quote + quote in a quoted string -> single quote
 *	quote + quote not in quoted string -> empty string
 *	quote -> begin quoted string
 *
 * Results:
 *	Fills argcPtr with the number of arguments and argvPtr with the array
 *	of arguments.
 *
 * Side effects:
 *	Memory allocated.
 *
 *--------------------------------------------------------------------------
 */

#if defined(__CYGWIN__)
static void
setargv(
    int *argcPtr,		/* Filled with number of argument strings. */
    char ***argvPtr)		/* Filled with argument strings (malloc'd). */
{
    char *cmdLine, *p, *arg, *argSpace;
    char **argv;
    int argc, size, inquote, copy, slashes;

    cmdLine = GetCommandLine();	/* INTL: BUG */

    /*
     * Precompute an overly pessimistic guess at the number of arguments in
     * the command line by counting non-space spans.
     */

    size = 2;
    for (p = cmdLine; *p != '\0'; p++) {
	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
	    size++;
	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
		p++;
	    }
	    if (*p == '\0') {
		break;
	    }
	}
    }
    argSpace = (char *) ckalloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
    argv = (char **) argSpace;
    argSpace += size * sizeof(char *);
    size--;

    p = cmdLine;
    for (argc = 0; argc < size; argc++) {
	argv[argc] = arg = argSpace;
	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
	    p++;
	}
	if (*p == '\0') {
	    break;
	}

	inquote = 0;
	slashes = 0;
	while (1) {
	    copy = 1;
	    while (*p == '\\') {
		slashes++;
		p++;
	    }
	    if (*p == '"') {
		if ((slashes & 1) == 0) {
		    copy = 0;
		    if ((inquote) && (p[1] == '"')) {
			p++;
			copy = 1;
		    } else {
			inquote = !inquote;
		    }
		}
		slashes >>= 1;
	    }

	    while (slashes) {
		*arg = '\\';
		arg++;
		slashes--;
	    }

	    if ((*p == '\0') || (!inquote &&
		    ((*p == ' ') || (*p == '\t')))) {	/* INTL: ISO space. */
		break;
	    }
	    if (copy != 0) {
		*arg = *p;
		arg++;
	    }
	    p++;
	}
	*arg = '\0';
	argSpace = arg + 1;
    }
    argv[argc] = NULL;

    *argcPtr = argc;
    *argvPtr = argv;
}
#endif /* __CYGWIN__ */

@


1.26.2.2
log
@re-wrote TkpDisplayWarning such that it does not use an Tcl API calls any more, so it works even with an ill-initialized Tcl
Teach WishPanic how to thread UTF-8 in it's messagebox.
Both of those changes backported from Tcl 8.6. No change in functionality.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.26.2.1 2010/05/31 13:47:33 nijtmans Exp $
a25 9
#ifdef TK_TEST
extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */

#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
extern Tcl_PackageInitProc Registry_Init;
extern Tcl_PackageInitProc Dde_Init;
extern Tcl_PackageInitProc Dde_SafeInit;
#endif
d32 3
a158 3
#define TK_MAX_WARN_LEN 1024
    WCHAR msgString[TK_MAX_WARN_LEN + 5];

d178 8
a185 4
    if (Registry_Init(interp) == TCL_ERROR) {
	goto error;
    }
    Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);
d187 5
a191 4
    if (Dde_Init(interp) == TCL_ERROR) {
	goto error;
    }
    Tcl_StaticPackage(interp, "dde", Dde_Init, NULL);
a200 24
    /*
     * Call the init procedures for included packages. Each call should look
     * like this:
     *
     * if (Mod_Init(interp) == TCL_ERROR) {
     *     return TCL_ERROR;
     * }
     *
     * where "Mod" is the name of the module. (Dynamically-loadable packages
     * should have the same entry-point name.)
     */

    /*
     * Call Tcl_CreateCommand for application-specific commands, if they
     * weren't already created by the init procedures called above.
     */

    /*
     * Specify a user-specific startup file to invoke if the application is
     * run interactively. Typically the startup file is "~/.apprc" where "app"
     * is the name of the application. If this line is deleted then no user-
     * specific startup file will be run under any conditions.
     */

a204 7
    MultiByteToWideChar(CP_UTF8, 0, Tcl_GetStringResult(interp), -1,
	    msgString, TK_MAX_WARN_LEN);
    /*
     * Truncate MessageBox string if it is too long to not overflow the screen
     * and cause possible oversized window error.
     */
	memcpy(msgString + TK_MAX_WARN_LEN, L" ...", 5 * sizeof(WCHAR));
d206 1
a206 1
    MessageBoxW(NULL, msgString, L"Error in Wish",
d238 1
a238 2
    char buf[TK_MAX_WARN_LEN];
    WCHAR msgString[TK_MAX_WARN_LEN + 5];
a242 6
    MultiByteToWideChar(CP_UTF8, 0, buf, -1, msgString, TK_MAX_WARN_LEN);
    /*
     * Truncate MessageBox string if it is too long to not overflow the screen
     * and cause possible oversized window error.
     */
	memcpy(msgString + TK_MAX_WARN_LEN, L" ...", 5 * sizeof(WCHAR));
d244 1
a244 1
    MessageBoxW(NULL, msgString, L"Fatal Error in Wish",
@


1.25
log
@* win/winMain.c:  Replaced incorrect comments in main() to descibe
why the console widget does not need to be created for this
application entry point (if used).  Must have been a bad copy/paste
of WinMain() from 10 years back.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.24 2007/09/07 00:34:58 dgp Exp $
@


1.24
log
@header cleanup
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.23 2005/12/02 00:19:04 dkf Exp $
d277 2
a278 3
     * Create the console channels and install them as the standard channels.
     * All I/O will be discarded until Tk_CreateConsoleWindow is called to
     * attach the console to a text widget.
@


1.23
log
@ANSIfication
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.22 2005/09/13 21:25:21 dgp Exp $
d15 1
a15 1
#include <tk.h>
a20 1
#include "tkInt.h"
@


1.23.2.1
log
@merge updates from HEAD
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.23 2005/12/02 00:19:04 dkf Exp $
d15 1
a15 1
#include "tkInt.h"
d21 1
@


1.23.2.2
log
@merge updates from HEAD
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.23.2.1 2007/09/07 01:25:41 dgp Exp $
d277 3
a279 2
     * Console emulation widget not required as this entry is from the
     * console subsystem, thus stdin,out,err already have end-points.
@


1.22
log
@        * win/winMain.c (WishPanic):    Replaced TCL_VARARGS* macros with
        direct use of stdarg.h conventions.
@
text
@d1 1
a1 1
/* 
d9 2
a10 2
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.21 2004/02/02 08:12:58 davygrvy Exp $
d24 2
a25 2
 * The following declarations refer to internal Tk routines.  These
 * interfaces are available for use, but are not supported.
a27 1

d32 1
a32 1
static void		WishPanic _ANSI_ARGS_((CONST char *format, ...));
d40 3
a42 4
 * The following #if block allows you to change the AppInit
 * function by using a #define of TCL_LOCAL_APPINIT instead
 * of rewriting this entire file.  The #if checks for that
 * #define and uses Tcl_AppInit if it doesn't exist.
d44 1
a44 1
    
d46 1
a46 1
#define TK_LOCAL_APPINIT Tcl_AppInit    
d48 2
a49 2
extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
    
d52 2
a53 2
 * script, prime the library or encoding paths, fiddle with the argv,
 * etc., without needing to rewrite Tk_Main()
d57 1
a57 1
extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
a58 1

d68 1
a68 2
 *	Returns false if initialization fails, otherwise it never
 *	returns. 
d77 5
a81 5
WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
    HINSTANCE hInstance;
    HINSTANCE hPrevInstance;
    LPSTR lpszCmdLine;
    int nCmdShow;
d90 3
a92 3
     * Create the console channels and install them as the standard
     * channels.  All I/O will be discarded until Tk_CreateConsoleWindow is
     * called to attach the console to a text widget.
d98 2
a99 2
     * Set up the default locale to be standard "C" locale so parsing
     * is performed correctly.
d105 1
a105 1
     *  Get our args from the c-runtime.  Ignore lpszCmdLine.
a127 1

d134 3
a136 3
 *	This procedure performs application-specific initialization.
 *	Most applications, especially those that incorporate additional
 *	packages, will have their own version of this procedure.
d139 2
a140 2
 *	Returns a standard Tcl completion code, and leaves an error
 *	message in the interp's result if an error occurs.
d149 2
a150 2
Tcl_AppInit(interp)
    Tcl_Interp *interp;		/* Interpreter for application. */
d191 1
a191 2
    Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
            (Tcl_PackageInitProc *) NULL);
d202 5
a206 1
    /* we won't reach this, but we need the return */
d227 2
a228 1
WishPanic(CONST char *format, ...)
d232 1
a232 1
    
d254 2
a255 2
 *	None: Tk_Main never returns here, so this procedure never
 *      returns either.
d263 4
a266 1
int main(int argc, char **argv)
d271 2
a272 2
     * Set up the default locale to be standard "C" locale so parsing
     * is performed correctly.
d278 3
a280 3
     * Create the console channels and install them as the standard
     * channels.  All I/O will be discarded until Tk_CreateConsoleWindow is
     * called to attach the console to a text widget.
d289 8
@


1.21
log
@#include <malloc.h> has no purpose.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.20 2004/02/01 10:44:54 davygrvy Exp $
d33 1
a33 1
static void		WishPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,format));
d229 1
a229 1
WishPanic TCL_VARARGS_DEF(CONST char *,arg1)
a232 1
    CONST char *format;
d234 1
a234 1
    format = TCL_VARARGS_START(CONST char *,arg1,argList);
@


1.20
log
@* win/winMain.c: Removed our custom setargv() in favor of
the exported __argc and __argv exported by the c-runtime.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.19 2003/12/21 23:50:13 davygrvy Exp $
a18 1
#include <malloc.h>
@


1.19
log
@	* generic/tkEvent.c:  Added three new functions: TkCreateExitHandler,
	* generic/tkInt.h:    TkDeleteExitHandler, and TkFinalize.  This adds
	* generic/tkMenu.c:   an insertion point so Tk's exit handlers can be
	* generic/tkWindow.c: called on their own from tk85.dll's DllMain
	* mac/tkMacButton.c:  for DLL_PROCESS_DETACH.  These are private to
	* unix/tkUnixEvent.c: the binary and not exported.  It is possible
	* win/tkWin32Dll.c:   the Windows OS can unload Tk _prior_ to Tcl
	* win/tkWinEmbed.c:   under some conditions such as ExitProcess().
	* win/tkWinMenu.c:    This avoids a dangling pointer problem when Tcl
	* win/tkWinX.c:	      does Tcl_Finalize after Tk has been unloaded.
	* win/winMain.c:      DllMain's DLL_PROCESS_DETACH now protected with
			      SEH as DeleteWindowsExitProc is causing an
			      exception of its own under some teardown
			      conditions.  AT&T assembly syntax has not been
			      added for MinGW yet.  [Tcl Patch 858493]
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.18 2003/12/12 00:45:33 davygrvy Exp $
a33 1
static void		setargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr));
a34 2
static void		AppInitExitHandler(ClientData clientData);

a39 1
static char **argvSave = NULL;
a89 1
    char buffer[MAX_PATH+1];
a107 1
    setargv(&argc, &argv);
d110 1
a110 1
     * Save this for later, so we can free it.
d112 3
a114 1
    argvSave = argv;
d117 1
a117 2
     * Replace argv[0] with full pathname of executable, and forward
     * slashes substituted for backslashes.
d120 1
a120 3
    GetModuleFileName(NULL, buffer, sizeof(buffer));
    argv[0] = buffer;
    for (p = buffer; *p != '\0'; p++) {
a166 6
     * This exit handler will be used to free the
     * resources allocated in this file.
     */
    TkCreateExitHandler(AppInitExitHandler, NULL);

    /*
d176 1
a176 1
#if defined(STATIC_BUILD) && defined(TCL_USE_STATIC_PACKAGES)
a247 144
/*
 *----------------------------------------------------------------------
 *
 * AppInitExitHandler --
 *
 *	This function is called to cleanup the app init resources before
 *	Tcl is unloaded.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Frees the saved argv and deletes the async exit handler.
 *
 *----------------------------------------------------------------------
 */

static void
AppInitExitHandler(
    ClientData clientData)
{
    if (argvSave != NULL) {
        ckfree((char *)argvSave);
        argvSave = NULL;
    }
}

/*
 *-------------------------------------------------------------------------
 *
 * setargv --
 *
 *	Parse the Windows command line string into argc/argv.  Done here
 *	because we don't trust the builtin argument parser in crt0.  
 *	Windows applications are responsible for breaking their command
 *	line into arguments.
 *
 *	2N backslashes + quote -> N backslashes + begin quoted string
 *	2N + 1 backslashes + quote -> literal
 *	N backslashes + non-quote -> literal
 *	quote + quote in a quoted string -> single quote
 *	quote + quote not in quoted string -> empty string
 *	quote -> begin quoted string
 *
 * Results:
 *	Fills argcPtr with the number of arguments and argvPtr with the
 *	array of arguments.
 *
 * Side effects:
 *	Memory allocated.
 *
 *--------------------------------------------------------------------------
 */

static void
setargv(argcPtr, argvPtr)
    int *argcPtr;		/* Filled with number of argument strings. */
    char ***argvPtr;		/* Filled with argument strings (malloc'd). */
{
    char *cmdLine, *p, *arg, *argSpace;
    char **argv;
    int argc, size, inquote, copy, slashes;
    
    cmdLine = GetCommandLine();	/* INTL: BUG */

    /*
     * Precompute an overly pessimistic guess at the number of arguments
     * in the command line by counting non-space spans.
     */

    size = 2;
    for (p = cmdLine; *p != '\0'; p++) {
	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
	    size++;
	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
		p++;
	    }
	    if (*p == '\0') {
		break;
	    }
	}
    }
    argSpace = (char *) ckalloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
    argv = (char **) argSpace;
    argSpace += size * sizeof(char *);
    size--;

    p = cmdLine;
    for (argc = 0; argc < size; argc++) {
	argv[argc] = arg = argSpace;
	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
	    p++;
	}
	if (*p == '\0') {
	    break;
	}

	inquote = 0;
	slashes = 0;
	while (1) {
	    copy = 1;
	    while (*p == '\\') {
		slashes++;
		p++;
	    }
	    if (*p == '"') {
		if ((slashes & 1) == 0) {
		    copy = 0;
		    if ((inquote) && (p[1] == '"')) {
			p++;
			copy = 1;
		    } else {
			inquote = !inquote;
		    }
                }
                slashes >>= 1;
            }

            while (slashes) {
		*arg = '\\';
		arg++;
		slashes--;
	    }

	    if ((*p == '\0')
		    || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */
		break;
	    }
	    if (copy != 0) {
		*arg = *p;
		arg++;
	    }
	    p++;
        }
	*arg = '\0';
	argSpace = arg + 1;
    }
    argv[argc] = NULL;

    *argcPtr = argc;
    *argvPtr = argv;
}

@


1.18
log
@fixed bad commit from before.  my mistake.  This is 1.16 now.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.16 2003/10/14 15:35:52 patthoyts Exp $
d177 1
a177 1
    Tcl_CreateExitHandler(AppInitExitHandler, NULL);
@


1.17
log
@Reverted to 1.15 for two reasons.  1) problem is best addressed in Tcl's
DllMain() and 2) needs a MinGW custom assembly  implimentation as
it doesn't understand SEH syntax.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.15 2002/11/04 07:49:43 davygrvy Exp $
d35 2
a36 1
static Tcl_PanicProc	WishPanic;
d43 1
d116 5
d174 6
d258 28
a285 1
    ExitProcess(EXIT_FAILURE);
d287 1
d343 1
a343 1
    argSpace = (char *) Tcl_Alloc(
@


1.16
log
@	* win/makefile.vc:  Applied patches from tcl bug #801467 from
	* win/winMain.c:    Joe Mistachkin
@
text
@d35 1
a35 2
static void		WishPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,format));
static void		AppInitExitHandler(ClientData clientData);
a41 1
static char **argvSave = NULL;
a113 5
     * Save this for later, so we can free it.
     */
    argvSave = argv;

    /*
a166 6
     * This exit handler will be used to free the
     * resources allocated in this file.
     */
    Tcl_CreateExitHandler(AppInitExitHandler, NULL);

    /*
d245 1
a245 28
    ExitProcess(1);
}

/*
 *----------------------------------------------------------------------
 *
 * AppInitExitHandler --
 *
 *	This function is called to cleanup the app init resources before
 *	Tcl is unloaded.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Frees the saved argv and deletes the async exit handler.
 *
 *----------------------------------------------------------------------
 */

static void
AppInitExitHandler(
    ClientData clientData)
{
    if (argvSave != NULL) {
        ckfree((char *)argvSave);
        argvSave = NULL;
    }
a246 1

d302 1
a302 1
    argSpace = (char *) ckalloc(
@


1.15
log
@	* win/winMain.c (Tcl_AppInit): Calls Registry_Init() and
	Dde_Init() when STATIC_BUILD and TCL_USE_STATIC_PACKAGES macros
	are set.

	* win/makefile.vc:  linkexten option now sets the
	TCL_USE_STATIC_PACKAGES	macro which also adds the registry and
	dde static lib files to the link of the shell. [Patch 479697]

	* win/rules.vc: Matches the one from Tcl.

	* win/buildall.vc.bat: More useful commentary.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.14 2002/10/19 02:10:07 hobbs Exp $
d36 1
d43 1
d116 5
d174 6
d260 28
d343 1
a343 1
    argSpace = (char *) Tcl_Alloc(
@


1.15.2.1
log
@(WishPanic) : placed ExitProcess() in a __try block (SEH) to catch any
exceptions that might happen.  As Tcl will call Tcl_Finalize from its DllMain
due to the unload from ExitProcess() unloading Tcl, and if Tcl_Panic had
gotten called in an __except block, this avoid the possibility of not being
able to exit.  Falls to TerminateProcess() in the __except case.

Removed the #ifdef _MSC_VER around DebugBreak as that function
exists in kernel32.dll and is not compiler dependent.  I'd prefer to use
if (IsDebuggerPresent()) DebugBreak(); but IsDebuggerPresent() isn't
available in all kernel32.dll modules for all versions of windows.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.15 2002/11/04 07:49:43 davygrvy Exp $
d242 1
d244 2
a245 5
    __try {
	ExitProcess(EXIT_FAILURE);
    } __except (EXCEPTION_EXECUTE_HANDLER) {
	TerminateProcess(GetCurrentProcess(), EXIT_FAILURE);
    }
@


1.15.2.2
log
@Reverted to 1.15 for two reasons.  1) problem is best addressed in Tcl's
DllMain() and 2) needs a MinGW custom assembly  implimentation as
it doesn't understand SEH syntax.
@
text
@d35 1
a35 1
static Tcl_PanicProc	WishPanic;
a241 1
#ifdef _MSC_VER
d243 5
a247 2
#endif
    ExitProcess(1);
@


1.14
log
@	* win/winMain.c (WinMain, main): remove obsolete SetMessageQueue call
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.13 2002/09/27 00:48:06 hobbs Exp $
d176 16
@


1.13
log
@2002-09-18  Mumit Khan  <khan@@nanotech.wisc.edu>

	Added basic Cygwin support.

	* win/tcl.m4 (SC_PATH_TCLCONFIG): Support one-tree build.
	(SC_PATH_TKCONFIG): Likewise.
	(SC_PROG_TCLSH): Likewise.
	(SC_CONFIG_CFLAGS): Assume real Cygwin port and remove -mno-cygwin
	flags.  Add -mwin32 to extra_cflags and extra_ldflags.
	Remove ``-e _WinMain@@16'' from LDFLAGS_WINDOW.
	* win/configure: Regenerate.

	* win/tkWinPort.h (tchar.h): Do not include on Cygwin.
	(_T): Define for Cygwin.
	* win/winMain.c (main): Conditionally define.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.12 2002/08/26 14:32:18 dgp Exp $
a97 10
     * Increase the application queue size from default value of 8.
     * At the default value, cross application SendMessage of WM_KILLFOCUS
     * will fail because the handler will not be able to do a PostMessage!
     * This is only needed for Windows 3.x, since NT dynamically expands
     * the queue.
     */

    SetMessageQueue(64);

    /*
a375 9
    /*
     * Increase the application queue size from default value of 8.
     * At the default value, cross application SendMessage of WM_KILLFOCUS
     * will fail because the handler will not be able to do a PostMessage!
     * This is only needed for Windows 3.x, since NT dynamically expands
     * the queue.
     */

    SetMessageQueue(64);
a388 1

@


1.12
log
@        * win/Makefile.in:      Removed dependence on the (parts of) the
        * win/winMain.c:        tcltest executable on Windows.  It was not
        used, and the dependency complicated the Makefile.  [Bug 592638].
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.11 2001/08/04 00:29:43 hobbs Exp $
a356 1

d358 1
d407 1
@


1.11
log
@	* win/winMain.c (WishPanic): fixed CONST changes to go with
	CONST-ification in Tcl.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.10 2000/04/19 23:12:56 hobbs Exp $
a40 5
#ifdef TCL_TEST
extern int		TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
extern int		Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TCL_TEST */

a185 11

#ifdef TCL_TEST
    if (Tcltest_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
            (Tcl_PackageInitProc *) NULL);
    if (TclObjTest_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
#endif /* TCL_TEST */
@


1.11.2.1
log
@merged with trunk at tag macosx-8-4-merge-2002-08-30-trunk
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.11 2001/08/04 00:29:43 hobbs Exp $
d41 5
d191 11
@


1.10
log
@	* library/choosedir.tcl (::tk::dialog::file::chooseDir::Config):
	* library/tkfbox.tcl (::tk::dialog::file::Config): removed the
	extraneous glob on -initialdir after file isdir already returned 1
	and moved cd trick into this case as the else already uses [pwd].
	[Bug: 5181]

	* win/winMain.c: moved extern call out of WinMain func
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.9 1999/12/02 02:05:46 redman Exp $
d35 1
a35 1
static void		WishPanic _ANSI_ARGS_(TCL_VARARGS(char *,format));
d240 1
a240 1
WishPanic TCL_VARARGS_DEF(char *,arg1)
d244 1
a244 1
    char *format;
d246 1
a246 1
    format = TCL_VARARGS_START(char *,arg1,argList);
@


1.10.2.1
log
@	* win/tkWinPort.h (tchar.h): Do not include on Cygwin.
	(_T): Define for Cygwin.
	(OPEN_MAX): only define if currently undefined.
	* win/winMain.c (main): Conditionally define. [Patch #625283] (khan)

	* win/configure: Regen.
	* win/configure.in: Set CFLAGS to "" if the user did not set
	CFLAGS in the env. This keeps AC_PROG_CC from adding "-g -O2" to
	the CFLAGS by default. (dejong)
	* win/tcl.m4 (SC_CONFIG_CFLAGS): Check for bug in Cygwin version
	of windres and work around that case by passing a POSIX path
	instead of a Windows native path. One can't always pass a POSIX
	path because the mingw native toolchain accepts only Windows
	native paths. [Patch #625283] (dejong)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.10 2000/04/19 23:12:56 hobbs Exp $
d373 1
a374 1
#if !defined(__GNUC__) || defined(TK_TEST)
d423 1
a423 1
#endif /* !__GNUC__ || TK_TEST */
@


1.10.4.1
log
@	* generic/tk.decls:
	* generic/tkInt.decls:
	* generic/tkIntPlatDecls.h:
	* generic/tkPlatDecls.h:
	* generic/tkStubInit.c:
	* win/Makefile.in:
	* win/makefile.vc:
	* win/tkWin3d.c:
	* win/tkWinButton.c:
	* win/tkWinColor.c:
	* win/tkWinDraw.c:
	* win/tkWinFont.c:
	* win/tkWinGdi.c (new):
	* win/tkWinGdi.h (new):
	* win/tkWinImage.c:
	* win/tkWinInt.h:
	* win/tkWinMenu.c:
	* win/tkWinPixmap.c:
	* win/tkWinUtil.c (new):
	* win/tkWinWindow.c:
	* win/tkWinWm.c:
	* win/tkWinX.c:
	* win/winMain.c:
	* xlib/xgc.c:
	* xlib/X11/Xlib.h: first cut at Windows speedup improvements by
	Leo Schubert.  Needs to be streamlined, but the code is correct
	and passes all tests.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.10 2000/04/19 23:12:56 hobbs Exp $
a21 1
#include <tkPlatDecls.h>
a39 10
#ifdef STATIC_LIB
#include <tkWinInt.h>
#include <stdlib.h>
BOOL APIENTRY DllMain(HINSTANCE hInstance,DWORD reason,LPVOID reserved);
void static_exit(void){
 HINSTANCE hInstance=Tk_GetHINSTANCE();
// DllMain(hInstance,DLL_PROCESS_DETACH,NULL);
 TkWinXCleanup(hInstance);
}
#endif
a177 3
    }
    if (TkWin_Init(interp) == TCL_ERROR) {
        goto error;
@


1.10.4.2
log
@sync with head
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.11 2001/08/04 00:29:43 hobbs Exp $
d36 1
a36 1
static void		WishPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,format));
d254 1
a254 1
WishPanic TCL_VARARGS_DEF(CONST char *,arg1)
d258 1
a258 1
    CONST char *format;
d260 1
a260 1
    format = TCL_VARARGS_START(CONST char *,arg1,argList);
@


1.9
log
@
	* generic/tkMain.c :
	* unix/tkAppInit.c:
	* win/winMain.c: Added added hooks into the main() code for
	supporting TclPro and other "big" shells more easily without
	requiring a copy of the main() code.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.8 1999/11/10 02:56:42 hobbs Exp $
d48 22
a98 22
    
    /*
     * The following #if block allows you to change the AppInit
     * function by using a #define of TCL_LOCAL_APPINIT instead
     * of rewriting this entire file.  The #if checks for that
     * #define and uses Tcl_AppInit if it doesn't exist.
     */
    
#ifndef TK_LOCAL_APPINIT
#define TK_LOCAL_APPINIT Tcl_AppInit    
#endif
    extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
    
    /*
     * The following #if block allows you to change how Tcl finds the startup
     * script, prime the library or encoding paths, fiddle with the argv,
     * etc., without needing to rewrite Tk_Main()
     */
    
#ifdef TK_LOCAL_MAIN_HOOK
    extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
#endif
@


1.8
log
@	* win/winMain.c: corrected winMain to not do a DebugBreak when
	returning an error message from the top level
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.7 1999/04/28 18:18:07 redman Exp $
d75 15
a89 3

    Tcl_SetPanicProc(WishPanic);

d91 3
a93 2
     * Set up the default locale to be standard "C" locale so parsing
     * is performed correctly.
d95 4
d100 1
a100 2
    setlocale(LC_ALL, "C");
    setargv(&argc, &argv);
d120 26
a145 1
    Tk_Main(argc, argv, Tcl_AppInit);
@


1.7
log
@Rename TkConsoleCreate_() to Tk_InitConsoleChannels() and make the
function public.  Add an interp argument and init the Tcl stubs.
Rename TkConsoleInit() to Tk_CreateConsoleWindow()
Remove TkConsoleCreate() (no underbar)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.6 1999/04/16 01:51:55 stanton Exp $
d174 5
a178 1
    WishPanic(Tcl_GetStringResult(interp));
@


1.7.6.1
log
@	* win/winMain.c: changed Tcl_AppInit to not cause a DebugBreak
	on simple startup errors (like bad options to wish)
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.7 1999/04/28 18:18:07 redman Exp $
d174 1
a174 5
    MessageBeep(MB_ICONEXCLAMATION);
    MessageBox(NULL, Tcl_GetStringResult(interp), "Error in Wish",
	    MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
    ExitProcess(1);
    /* we won't reach this, but we need the return */
a211 1

d328 1
@


1.6
log
@* Merged 8.1 branch into the main trunk
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id$
d98 1
a98 1
     * channels.  All I/O will be discarded until TkConsoleInit is
d146 1
a146 1
	if (TkConsoleInit(interp) == TCL_ERROR) {
d369 1
a369 1
     * channels.  All I/O will be discarded until TkConsoleInit is
@


1.5
log
@integrated stubs into 8.0 main branch
@
text
@d6 2
a7 1
 * Copyright (c) 1995 Sun Microsystems, Inc.
d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.4.4.2 1999/03/07 00:15:47 redman Exp $
a15 1
#include "tkInt.h"
d22 2
d29 1
d41 7
d73 1
a73 1
    char **argv, *p;
a74 1
    char buffer[MAX_PATH];
d84 1
a84 1

d93 1
a95 2
    setargv(&argc, &argv);

d97 3
a99 2
     * Replace argv[0] with full pathname of executable, and forward
     * slashes substituted for backslashes.
d102 1
a102 7
    GetModuleFileName(NULL, buffer, sizeof(buffer));
    argv[0] = buffer;
    for (p = buffer; *p != '\0'; p++) {
	if (*p == '\\') {
	    *p = '/';
	}
    }
d120 1
a120 1
 *	message in interp->result if an error occurs.
a137 1

d145 14
a158 2
    if (TkConsoleInit(interp) == TCL_ERROR) {
	goto error;
d160 1
d174 1
a174 1
    WishPanic(interp->result);
d248 1
a248 1
    cmdLine = GetCommandLine();
d257 1
a257 1
	if (isspace(*p)) {
d259 1
a259 1
	    while (isspace(*p)) {
d267 2
a268 2
    argSpace = (char *) ckalloc((unsigned) (size * sizeof(char *) 
	    + strlen(cmdLine) + 1));
d276 1
a276 1
	while (isspace(*p)) {
d310 2
a311 1
	    if ((*p == '\0') || (!inquote && isspace(*p))) {
d327 50
@


1.4
log
@* mac/tkMacAppInit.c:
* generic/tkTest.c:
* generic/tkAppInit.c:
* win/winMain.c: Changed some EXTERN declarations to extern
since they are not defining exported interfaces.  This avoids
generating useless declspec() attributes and makes the windows
makefile simpler.
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: winMain.c,v 1.3 1998/09/14 18:24:02 stanton Exp $
d15 1
a26 3
EXTERN void		TkConsoleCreate(void);
EXTERN int		TkConsoleInit(Tcl_Interp *interp);

a85 8
    /*
     * Create the console channels and install them as the standard
     * channels.  All I/O will be discarded until TkConsoleInit is
     * called to attach the console to a text widget.
     */

    TkConsoleCreate();

d135 1
@


1.4.4.1
log
@stubbed out TkConsoleCreate and added a call to TkConsoleCreate_
in Tk_Main() so that Tk can be dynamically loaded
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: winMain.c,v 1.4 1999/02/04 20:57:18 stanton Exp $
d26 1
d87 8
@


1.4.4.2
log
@Stubs changes, now wish works on Windows.
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: winMain.c,v 1.4.4.1 1999/03/06 23:18:05 stanton Exp $
a14 1
#include "tkInt.h"
d26 2
a135 1

@


1.3
log
@Replaced SCCS strings, fixed binary files
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id$
d37 1
a37 1
EXTERN int		Tktest_Init(Tcl_Interp *interp);
@


1.2
log
@Removed assembly code
@
text
@d11 1
a11 1
 * SCCS: @@(#) winMain.c 1.33 96/12/17 12:56:14
@


1.1
log
@Initial revision
@
text
@d202 1
a202 3
    _asm {
        int 3
    }
@


1.1.4.1
log
@initial tk8.1a2 version
@
text
@d6 1
a6 1
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
d11 1
a11 1
 * SCCS: @@(#) winMain.c 1.37 98/01/20 22:47:06
a39 5
#ifdef TCL_TEST
EXTERN int		TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int		Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TCL_TEST */

d65 1
a65 1
    char **argv;
d67 1
d77 1
a77 1
    setargv(&argc, &argv);
a85 1

d96 15
d127 1
a127 1
 *	message in the interp's result if an error occurs.
a155 11
#ifdef TCL_TEST
    if (Tcltest_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
            (Tcl_PackageInitProc *) NULL);
    if (TclObjTest_Init(interp) == TCL_ERROR) {
	return TCL_ERROR;
    }
#endif /* TCL_TEST */

d168 1
a168 1
    WishPanic(Tcl_GetStringResult(interp));
d244 1
a244 1
    cmdLine = GetCommandLine();	/* INTL: BUG */
d253 1
a253 1
	if ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d255 1
a255 1
	    while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
d263 2
a264 2
    argSpace = (char *) Tcl_Alloc(
	    (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
d272 1
a272 1
	while ((*p == ' ') || (*p == '\t')) {	/* INTL: ISO space. */
d306 1
a306 2
	    if ((*p == '\0')
		    || (!inquote && ((*p == ' ') || (*p == '\t')))) { /* INTL: ISO space. */
d323 1
@


1.1.4.2
log
@Merged 8.0.3 changes into 8.1
@
text
@d11 1
a11 1
 * RCS: @@(#) $Id: winMain.c,v 1.3 1998/09/14 18:24:02 stanton Exp $
d203 3
a205 1
    DebugBreak();
@


1.1.4.3
log
@* Various cleanup related to the Tcl_Eval and Tcl_ObjSetVar
changes in Tcl.

* Integrated patches from 8.0.5b2
@
text
@a6 1
 * Copyright (c) 1998-1999 by Scriptics Corporation.
d11 1
a11 1
 * RCS: @@(#) $Id$
d37 1
a37 1
extern int		Tktest_Init(Tcl_Interp *interp);
d41 2
a42 2
extern int		TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
extern int		Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
@


1.1.4.4
log
@Add wishc81.exe and wishc81d.exe, console-based wish executables (console
subsystem instead of windows subsystem).  This required adding a main() function
and adding code to disable calling Tk_ConsoleInit().

Add code to hook windows-based wish81.exe and wish81d.exe to stdin/stdout/stderr
if they are actually there (usually this happens if it's a pipe, file, lpt or com
port).

Modified makefile to be able to run tests from the makefile.  Added cat32.exe
for this purpose.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.1.4.3 1999/02/11 04:13:52 stanton Exp $
a45 2
static BOOL consoleRequired = TRUE;

a99 1
    consoleRequired = TRUE;
d143 2
a144 4
    if (consoleRequired) {
	if (TkConsoleInit(interp) == TCL_ERROR) {
	    goto error;
	}
a323 51


/*
 *----------------------------------------------------------------------
 *
 * main --
 *
 *	Main entry point from the console.
 *
 * Results:
 *	None: Tk_Main never returns here, so this procedure never
 *      returns either.
 *
 * Side effects:
 *	Whatever the applications does.
 *
 *----------------------------------------------------------------------
 */

int main(int argc, char **argv)
{
    Tcl_SetPanicProc(WishPanic);

    /*
     * Set up the default locale to be standard "C" locale so parsing
     * is performed correctly.
     */

    setlocale(LC_ALL, "C");
    /*
     * Increase the application queue size from default value of 8.
     * At the default value, cross application SendMessage of WM_KILLFOCUS
     * will fail because the handler will not be able to do a PostMessage!
     * This is only needed for Windows 3.x, since NT dynamically expands
     * the queue.
     */

    SetMessageQueue(64);

    /*
     * Create the console channels and install them as the standard
     * channels.  All I/O will be discarded until TkConsoleInit is
     * called to attach the console to a text widget.
     */

    consoleRequired = FALSE;

    Tk_Main(argc, argv, Tcl_AppInit);
    return 0;
}

@


1.1.4.5
log
@integrated stubs from development branch
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.1.4.4 1999/02/26 02:24:46 redman Exp $
a21 2
#include "tkInt.h"

d27 2
d103 1
@


1.1.4.4.2.1
log
@Changes to support stubs in 8.1. Merged from 8.0.6 code base.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: winMain.c,v 1.1.4.4 1999/02/26 02:24:46 redman Exp $
a21 2
#include "tkInt.h"

d27 2
d103 1
@


