1
1

Drop limit of edited file size.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2013-02-20 13:32:04 +04:00
родитель ccf82ada12
Коммит c6d6aaedd5
3 изменённых файлов: 22 добавлений и 38 удалений

Просмотреть файл

@ -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++;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)*****************************************/