Patch: Console redirection under WinCE

After downloading the latest win32 SDL_main.c from CVS, I was distressed
to see that SDL still doesn’t support console redirection under
WinCE. CE is the one platform where file redirection is absolutely
necessary, because it lacks a console output… My previous patch for
this admittedly modified a lot of code; hopefully this one will be more
acceptable.

Instead of adding tons’n’tons of #ifdef _WIN32_WCE blocks, I have one
#ifdef block that contains a bunch of defines; a small amount of the
current code was modified to use these, but on the whole the code’s
nearly exactly the same(except Unicoded under CE.) Also thought it best
to typedef the lone “/” to a “\” for CE, because the M$ file-handling
routines are, in some places, so badly designed that a forward-slash
causes them to crash.

Additionally, since WinCE has no concept of a ‘current working
directory’, and hence no _getcwd function, I replaced it with

define DIR_SEPERATOR TEXT("\")

define _getcwd(str,len) wcscpy(str,DIR_SEPERATOR);

Also, the path buffers needed to be #ifdef’ed to allow the use of
unicode characters, like this:

#ifndef NO_STDIO_REDIRECT

ifdef _WIN32_WCE

static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];

else

static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];

endif

#endif

Additionally, I had to put #ifdef _WIN32_WCE around some NT-specific
code that the CE compiler threw up on.

Lastly, for plain-vanillia Win32, io.h is the wrong include file to have
_getcwd defined; use direct.h instead.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_main.c
Type: application/x-unknown-content-type-cfile
Size: 8203 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030105/f36a07cc/attachment.bin

GNU diff is your friend (and our friend)…

If not that, windiff, if it can save its output in something resembling a
context or unified diff format.

I followed the message, but I could have gotten it a lot faster had you
used a diff format to explain the changes. I advise keeping this in mind
because Sam’s a hell of a lot busier than I am. A little time spent
downloading and figuring out how to use a good diff tool will save you
time in the future. More importantly, it will save the users of your
patches time.

Just a suggestion from the peanut gallery.On Sun, Jan 05, 2003 at 02:07:42PM -0600, Corona688 wrote:

After downloading the latest win32 SDL_main.c from CVS, I was distressed
to see that SDL still doesn’t support console redirection under
WinCE. CE is the one platform where file redirection is absolutely
necessary, because it lacks a console output… My previous patch for
this admittedly modified a lot of code; hopefully this one will be more
acceptable.

Instead of adding tons’n’tons of #ifdef _WIN32_WCE blocks, I have one
#ifdef block that contains a bunch of defines; a small amount of the
current code was modified to use these, but on the whole the code’s
nearly exactly the same(except Unicoded under CE.) Also thought it best
to typedef the lone “/” to a “\” for CE, because the M$ file-handling
routines are, in some places, so badly designed that a forward-slash
causes them to crash.

Additionally, since WinCE has no concept of a ‘current working
directory’, and hence no _getcwd function, I replaced it with

define DIR_SEPERATOR TEXT("\")

define _getcwd(str,len) wcscpy(str,DIR_SEPERATOR);

Also, the path buffers needed to be #ifdef’ed to allow the use of
unicode characters, like this:

#ifndef NO_STDIO_REDIRECT

ifdef _WIN32_WCE

static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];

else

static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];

endif

#endif

Additionally, I had to put #ifdef _WIN32_WCE around some NT-specific
code that the CE compiler threw up on.

Lastly, for plain-vanillia Win32, io.h is the wrong include file to have
_getcwd defined; use direct.h instead.


Joseph Carter <@Joseph_Carter> <-- That boy needs therapy

knghtbrd: evidence exists that X is only the 2nd worst windowing
system :wink:

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030105/75e69166/attachment.pgp

I’ve added your patch to CVS.

Thanks!
-Sam Lantinga, Software Engineer, Blizzard Entertainment