From c6d6aaedd512a1c4951be9af24d0a7951c932f35 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 20 Feb 2013 13:32:04 +0400 Subject: [PATCH] Drop limit of edited file size. Signed-off-by: Andrew Borodin --- src/editor/edit.c | 13 ++++--------- src/editor/editbuffer.c | 20 ++++++++++++++++++-- src/editor/editbuffer.h | 27 --------------------------- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/editor/edit.c b/src/editor/edit.c index 89e172812..f873e8d45 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -294,8 +294,10 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat if (st->st_size > 0) edit->delete_file = 0; - if (st->st_size >= SIZE_LIMIT) - errmsg = g_strdup_printf (_("File \"%s\" is too large"), vfs_path_as_str (filename_vpath)); + /* TODO: + * Add ini option of file size alarm threshold. + * Add here the query dialog "The file is too large. Open it anyway?". + */ cleanup: (void) mc_close (file); @@ -2413,10 +2415,6 @@ edit_push_redo_action (WEdit * edit, long c) void edit_insert (WEdit * edit, int c) { - /* check if file has grown to large */ - if (edit->last_byte >= SIZE_LIMIT) - return; - /* first we must update the position of the display window */ if (edit->buffer.curs1 < edit->start_display) { @@ -2461,9 +2459,6 @@ edit_insert (WEdit * edit, int c) void edit_insert_ahead (WEdit * edit, int c) { - if (edit->last_byte >= SIZE_LIMIT) - return; - if (edit->buffer.curs1 < edit->start_display) { edit->start_display++; diff --git a/src/editor/editbuffer.c b/src/editor/editbuffer.c index f05d74fd9..d7e599ab2 100644 --- a/src/editor/editbuffer.c +++ b/src/editor/editbuffer.c @@ -79,6 +79,22 @@ /*** file scope macro definitions ****************************************************************/ +/* + * The editor keeps data in two arrays of buffers. + * All buffers have the same size, which must be a power of 2. + */ + +/* Configurable: log2 of the buffer size in bytes */ +#ifndef S_EDIT_BUF_SIZE +#define S_EDIT_BUF_SIZE 16 +#endif + +/* Size of the buffer */ +#define EDIT_BUF_SIZE (((off_t) 1) << S_EDIT_BUF_SIZE) + +/* Buffer mask (used to find cursor position relative to the buffer) */ +#define M_EDIT_BUF_SIZE (EDIT_BUF_SIZE - 1) + /*** file scope type declarations ****************************************************************/ /*** file scope variables ************************************************************************/ @@ -127,8 +143,8 @@ edit_buffer_get_byte_ptr (const edit_buffer_t * buf, off_t byte_index) void edit_buffer_init (edit_buffer_t * buf, off_t size) { - buf->b1 = g_ptr_array_sized_new (MAXBUFF + 1); - buf->b2 = g_ptr_array_sized_new (MAXBUFF + 1); + buf->b1 = g_ptr_array_sized_new (32); + buf->b2 = g_ptr_array_sized_new (32); buf->curs1 = 0; buf->curs2 = 0; diff --git a/src/editor/editbuffer.h b/src/editor/editbuffer.h index d6a3c9e7c..06caf1db5 100644 --- a/src/editor/editbuffer.h +++ b/src/editor/editbuffer.h @@ -7,33 +7,6 @@ /*** typedefs(not structures) and defined constants **********************************************/ -/* - * The editor keeps data in two arrays of buffers. - * All buffers have the same size, which must be a power of 2. - */ - -/* Configurable: log2 of the buffer size in bytes */ -#ifndef S_EDIT_BUF_SIZE -#define S_EDIT_BUF_SIZE 16 -#endif - -/* Size of the buffer */ -#define EDIT_BUF_SIZE (((off_t) 1) << S_EDIT_BUF_SIZE) - -/* Buffer mask (used to find cursor position relative to the buffer) */ -#define M_EDIT_BUF_SIZE (EDIT_BUF_SIZE - 1) - -/* - * Configurable: Maximal allowed number of buffers in each buffer array. - * This number can be increased for systems with enough physical memory. - */ -#ifndef MAXBUFF -#define MAXBUFF 1024 -#endif - -/* Maximal length of file that can be opened */ -#define SIZE_LIMIT (EDIT_BUF_SIZE * (MAXBUFF - 2)) - /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/