From 7e8fee64863faab685ab7200d03d12b857cb585d Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Wed, 4 Jan 2012 15:42:18 +0400 Subject: [PATCH] Ticket #2710 (can't open an edit zero-length file from VFS in mcedit) fixed problem with zero-length files from VFS in mcedit. steps to reproduce the problem: 1. touch test.txt 2. tar cf test.tar test.txt 3. place cursor on test.tar and press Enter to enter to the archive. 4. place cursor on test.txt and press F4 to open file in editor. Result: file not opened. (cherry picked from commit 88b3f840a72b89fa46536ff7e366044aa9bc551d) Signed-off-by: Ilia Maslakov --- src/editor/edit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/editor/edit.c b/src/editor/edit.c index f95bb00ff..c6918c0ea 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -482,7 +482,7 @@ edit_load_file (WEdit * edit) if (*edit->filename) { edit->undo_stack_disable = 1; - if (edit_insert_file (edit, edit->filename) == 0) + if (edit_insert_file (edit, edit->filename) < 0) { edit_clean (edit); return 1; @@ -2094,7 +2094,7 @@ edit_insert_file (WEdit * edit, const char *filename) edit_error_dialog (_("Error"), errmsg); g_free (errmsg); g_free (p); - return 0; + return -1; } } else @@ -2104,7 +2104,7 @@ edit_insert_file (WEdit * edit, const char *filename) edit_error_dialog (_("Error"), errmsg); g_free (errmsg); g_free (p); - return 0; + return -1; } g_free (p); } @@ -2116,7 +2116,7 @@ edit_insert_file (WEdit * edit, const char *filename) char *buf; file = mc_open (filename, O_RDONLY | O_BINARY); if (file == -1) - return 0; + return -1; buf = g_malloc0 (TEMP_BUF_LEN); blocklen = mc_read (file, buf, sizeof (VERTICAL_MAGIC)); if (blocklen > 0)