Fix corrupted .sav files on w32 builds
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 20 Mar 2009 01:27:46 +0000 (10:27 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 20 Mar 2009 01:27:46 +0000 (10:27 +0900)
Added the O_BINARY flag to the mode of files
created with open, so that lines aren't appended
with extraneous characters, thus corrupting .sav
files.

Smake
src/data/make-file.c

diff --git a/Smake b/Smake
index a466423753fca2ef07bf4a6950fc3beca8835adf..5a76b3c1635f657c1440b7827b303b70ecf2fc5f 100644 (file)
--- a/Smake
+++ b/Smake
@@ -15,6 +15,7 @@ GNULIB_MODULES = \
        environ \
        exit \
        fatal-signal \
+       fcntl \
        fpieee \
        fprintf-posix \
        full-read \
index 807adc50d9d112de7b47459f0a06a98a4786651f..2162741a78e416324d07578f49e5d75f5da4a95e 100644 (file)
@@ -185,7 +185,7 @@ replace_file_start (const char *file_name, const char *mode,
         }
 
       /* Create file by that name. */
-      fd = open (rf->tmp_name, O_WRONLY | O_CREAT | O_EXCL, permissions);
+      fd = open (rf->tmp_name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, permissions);
       if (fd >= 0)
         break;
       if (errno != EEXIST)