summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker <voelker@cs.washington.edu>1996-03-17 00:06:39 +0000
committerGeoff Voelker <voelker@cs.washington.edu>1996-03-17 00:06:39 +0000
commit81da5517f2f4938a06c29f418962f9c2932fee97 (patch)
tree9f0ca956b01fb865a3adf138b2ffe74b44be2169 /src
parent946c0775c63fd2f7edf4b85f1e08c47f6a820fc7 (diff)
downloademacs-81da5517f2f4938a06c29f418962f9c2932fee97.tar.gz
(WinMain): Allocate a console for stdout
and stderr if necessary.
Diffstat (limited to 'src')
-rw-r--r--src/unexw32.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/unexw32.c b/src/unexw32.c
index 67555b2ad36..e00662a0fea 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -75,6 +75,9 @@ WinMain (_hinst, _hPrevInst, _lpCmdLine, _nCmdShow)
LPSTR _lpCmdLine;
int _nCmdShow;
{
+ int i, j, new_argc;
+ char **new_argv;
+
/* Need to parse command line */
hinst = _hinst;
@@ -82,7 +85,26 @@ WinMain (_hinst, _hPrevInst, _lpCmdLine, _nCmdShow)
lpCmdLine = _lpCmdLine;
nCmdShow = _nCmdShow;
- return (main (__argc,__argv,_environ));
+ new_argc = __argc;
+ new_argv = (char **) xmalloc (sizeof (char *) * new_argc);
+ if (!new_argv)
+ return main (__argc, __argv, _environ);
+
+ for (i = j = 0; i < __argc; i++)
+ {
+ /* Allocate a console window for stdout and stderr if requested.
+ We want to allocate as soon as we possibly can to catch
+ debugging output. */
+ if (!strcmp ("-output_console", __argv[i]))
+ {
+ AllocConsole ();
+ new_argc--;
+ continue;
+ }
+ new_argv[j++] = __argv[i];
+ }
+
+ return main (new_argc, new_argv, _environ);
}
#endif /* HAVE_NTGUI */