From 2047e4c5cc55721087c285cdb180ff39a8b6a77b Mon Sep 17 00:00:00 2001
From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com>
Date: Mon, 9 Apr 2007 18:12:44 -0500
Subject: [PATCH] Open files in binary mode, to avoid problems with line
endings on win32
---
makewin | 1 -
moo.mprj | 2 +-
moo/mooedit/mooeditfileops.c | 8 ++++++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/makewin b/makewin
index cd7a8fe9..81a62887 100755
--- a/makewin
+++ b/makewin
@@ -125,7 +125,6 @@ def copy_files():
else:
do_cmd("%s %s/lib/moo/plugins/*/*.dll" % (strip, moo_windir))
do_cmd("%s %s/lib/moo/plugins/*/*.pyd" % (strip, moo_windir))
- do_cmd("%s %s/bin/medit.exe %s/bin/libmoo.dll" % (strip, moo_windir, moo_windir))
do_cmd("%s %s/bin/medit.exe %s/bin/libmoo.dll" % (strip, moo_windir, moo_windir))
def build():
diff --git a/moo.mprj b/moo.mprj
index 275a2f12..85703fdb 100644
--- a/moo.mprj
+++ b/moo.mprj
@@ -34,7 +34,7 @@
- /home/muntyan/projects/moo/moo/mooedit/
+ /home/muntyan/projects/moo/build/debug/moo/mooedit/
--g-fatal-warnings --new-app
medit/medit
diff --git a/moo/mooedit/mooeditfileops.c b/moo/mooedit/mooeditfileops.c
index e8140363..d45c81a7 100644
--- a/moo/mooedit/mooeditfileops.c
+++ b/moo/mooedit/mooeditfileops.c
@@ -44,6 +44,10 @@
#define DEFAULT_ENCODING_LIST ""
#define ENCODING_LOCALE "LOCALE"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
static GSList *UNTITLED = NULL;
static GHashTable *UNTITLED_NO = NULL;
@@ -469,7 +473,7 @@ do_load (MooEdit *edit,
}
}
- file = g_io_channel_new_file (filename, "r", error);
+ file = g_io_channel_new_file (filename, "rb", error);
if (!file)
return ERROR_FILE;
@@ -835,7 +839,7 @@ do_write (MooEdit *edit,
#endif
errno = 0;
- fd = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC, mode);
+ fd = g_open (filename, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, mode);
if (fd == -1)
{