From 9d41ddcc1ab9ccdfc4c679ceff988cdd1c37a102 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Wed, 13 Sep 2006 03:40:52 +0000 Subject: [PATCH] Don't write in text mode (uio/Win32 conflict; Bug #912) - Michael git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2437 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/libs/input/sdl/input.c | 2 +- sc2/src/sc2code/libs/input/sdl/vcontrol.c | 8 +++++--- sc2/src/sc2code/libs/reslib.h | 1 + sc2/src/sc2code/libs/resource/alist.c | 2 +- sc2/src/sc2code/libs/resource/filecntl.c | 12 ++++++++++++ sc2/src/sc2code/libs/resource/mapres.c | 2 +- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index ff12c8095..e04461217 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.6: +- All output done in binary mode, due to uio/Win32 conflicts (#912) - Michael - Online key configuration menu actually functional now - Michael - Tweak to Lander UI - Special Weapon is now explicitly Lander Escape, just as Warp Escape is - Michael diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index 2a5814e18..af066ed43 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -454,7 +454,7 @@ SaveKeyConfiguration (uio_DirHandle *path, const char *fname) { uio_Stream *f; - f = res_OpenResFile (path, fname, "wt"); + f = res_OpenResFile (path, fname, "wb"); if (f) { VControl_Dump (f); diff --git a/sc2/src/sc2code/libs/input/sdl/vcontrol.c b/sc2/src/sc2code/libs/input/sdl/vcontrol.c index ba7438703..e3bd5240f 100644 --- a/sc2/src/sc2code/libs/input/sdl/vcontrol.c +++ b/sc2/src/sc2code/libs/input/sdl/vcontrol.c @@ -964,7 +964,7 @@ dump_keybindings (uio_Stream *out, keybinding *kb, char *name) PutResFileChar (':', out); PutResFileChar (' ', out); WriteResFile (name, 1, strlen (name), out); - PutResFileChar ('\n', out); + PutResFileNewline (out); kb = kb->next; } @@ -976,8 +976,9 @@ VControl_Dump (uio_Stream *out) int i; char namebuffer[64]; - sprintf (namebuffer, "version %d\n", version); + sprintf (namebuffer, "version %d", version); WriteResFile (namebuffer, 1, strlen (namebuffer), out); + PutResFileNewline (out); /* Print out keyboard bindings */ for (i = 0; i < SDLK_LAST; i++) @@ -998,8 +999,9 @@ VControl_Dump (uio_Stream *out) { int j; - sprintf (namebuffer, "joystick %d threshold %d\n", i, joysticks[i].threshold); + sprintf (namebuffer, "joystick %d threshold %d", i, joysticks[i].threshold); WriteResFile (namebuffer, 1, strlen (namebuffer), out); + PutResFileNewline (out); for (j = 0; j < joysticks[i].numaxes; j++) { diff --git a/sc2/src/sc2code/libs/reslib.h b/sc2/src/sc2code/libs/reslib.h index 97b71a8b8..a33166e7f 100644 --- a/sc2/src/sc2code/libs/reslib.h +++ b/sc2/src/sc2code/libs/reslib.h @@ -60,6 +60,7 @@ extern int WriteResFile (PCVOID lpBuf, COUNT size, COUNT count, uio_Stream *fp); extern int GetResFileChar (uio_Stream *fp); extern int PutResFileChar (char ch, uio_Stream *fp); +extern int PutResFileNewline (uio_Stream *fp); extern long SeekResFile (uio_Stream *fp, long offset, int whence); extern long TellResFile (uio_Stream *fp); extern long LengthResFile (uio_Stream *fp); diff --git a/sc2/src/sc2code/libs/resource/alist.c b/sc2/src/sc2code/libs/resource/alist.c index 04505be2c..0614a52ca 100644 --- a/sc2/src/sc2code/libs/resource/alist.c +++ b/sc2/src/sc2code/libs/resource/alist.c @@ -222,7 +222,7 @@ Alist_Dump (alist *m, uio_Stream *s, const char *prefix) PutResFileChar('=', s); PutResFileChar(' ', s); WriteResFile (e->value, 1, strlen (e->value), s); - PutResFileChar('\n', s); + PutResFileNewline(s); } e = e->next; } diff --git a/sc2/src/sc2code/libs/resource/filecntl.c b/sc2/src/sc2code/libs/resource/filecntl.c index 7453b0d07..fe88a984e 100644 --- a/sc2/src/sc2code/libs/resource/filecntl.c +++ b/sc2/src/sc2code/libs/resource/filecntl.c @@ -99,6 +99,18 @@ PutResFileChar (char ch, uio_Stream *fp) return (retval); } +int +PutResFileNewline (uio_Stream *fp) +{ + int retval; + +#ifdef WIN32 + PutResFileChar ('\r', fp); +#endif + retval = PutResFileChar ('\n', fp); + return (retval); +} + long SeekResFile (uio_Stream *fp, long offset, int whence) { diff --git a/sc2/src/sc2code/libs/resource/mapres.c b/sc2/src/sc2code/libs/resource/mapres.c index 688dd7c29..bf07e4b49 100644 --- a/sc2/src/sc2code/libs/resource/mapres.c +++ b/sc2/src/sc2code/libs/resource/mapres.c @@ -109,7 +109,7 @@ res_SaveFilename (uio_DirHandle *path, const char *fname, const char *root) uio_Stream *f; check_map_init (); - f = res_OpenResFile (path, fname, "wt"); + f = res_OpenResFile (path, fname, "wb"); if (f) { res_SaveFile (f, root); res_CloseResFile (f);