From e49a220a306077d189c079e3cbae98a7d5714d20 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Mon, 23 Sep 2002 06:54:50 +0000 Subject: [PATCH] * edit.c: Use O_BINARY when opening files. * editcmd.c: Likewise. From Alexander Varakin --- edit/ChangeLog | 6 ++++++ edit/edit.c | 6 +++--- edit/editcmd.c | 14 +++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/edit/ChangeLog b/edit/ChangeLog index 432ae381d..4842c8ad4 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,3 +1,9 @@ +2002-09-23 Pavel Roskin + + * edit.c: Use O_BINARY when opening files. + * editcmd.c: Likewise. + From Alexander Varakin + 2002-09-20 Pavel Roskin * editwidget.c (edit_event): Add support for mouse wheel events. diff --git a/edit/edit.c b/edit/edit.c index 77f2540ba..fed6cecde 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -170,7 +170,7 @@ int init_dynamic_edit_buffers (WEdit * edit, const char *filename, const char *t } if (filename) - if ((file = mc_open (filename, O_RDONLY)) == -1) { + if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) { /* The file-name is printed after the ':' */ edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0))); return 1; @@ -369,7 +369,7 @@ int edit_insert_file (WEdit * edit, const char *filename) int i, file, blocklen; long current = edit->curs1; unsigned char *buf; - if ((file = mc_open (filename, O_RDONLY)) == -1) + if ((file = mc_open (filename, O_RDONLY | O_BINARY )) == -1) return 0; buf = malloc (TEMP_BUF_LEN); while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0) { @@ -404,7 +404,7 @@ static int check_file_access (WEdit *edit, const char *filename, struct stat *st } /* Open the file, create it if needed */ - if ((file = mc_open (filename, O_RDONLY | O_CREAT, 0666)) < 0) { + if ((file = mc_open (filename, O_RDONLY | O_CREAT | O_BINARY, 0666)) < 0) { edit_error_dialog (_ (" Error "), get_sys_error (catstrs (_ (" Failed trying to open file for reading: "), filename, " ", 0))); return 1; } diff --git a/edit/editcmd.c b/edit/editcmd.c index f3c10dc4d..d1f2fb7b8 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -200,7 +200,7 @@ int edit_save_file (WEdit * edit, const char *filename) if (!*filename) return 0; - if ((fd = mc_open (filename, O_WRONLY)) == -1) { + if ((fd = mc_open (filename, O_WRONLY | O_BINARY)) == -1) { /* * The file does not exists yet, so no safe save or * backup are necessary. @@ -237,7 +237,7 @@ int edit_save_file (WEdit * edit, const char *filename) mc_chmod (savename, edit->stat1.st_mode); mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid); - if ((fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | MY_O_TEXT, + if ((fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY , edit->stat1.st_mode)) == -1) goto error_save; @@ -428,7 +428,7 @@ int edit_save_as_cmd (WEdit * edit) if (strcmp(catstrs (edit->dir, edit->filename, 0), exp)) { int file; different_filename = 1; - if ((file = mc_open ((char *) exp, O_RDONLY)) != -1) { /* the file exists */ + if ((file = mc_open ((char *) exp, O_RDONLY | O_BINARY)) != -1) { /* the file exists */ mc_close (file); if (edit_query_dialog2 (_(" Warning "), _(" A file already exists with this name. "), @@ -1974,11 +1974,15 @@ unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l) } /* save block, returns 1 on success */ -int edit_save_block (WEdit * edit, const char *filename, long start, long finish) +int +edit_save_block (WEdit * edit, const char *filename, long start, + long finish) { int len, file; - if ((file = mc_open ((char *) filename, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) + if ((file = + mc_open ((char *) filename, O_CREAT | O_WRONLY | O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY)) == -1) return 0; if (column_highlighting) {