mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-23 11:42:09 +03:00
Merge branch '2710_mcedit_fix'
* 2710_mcedit_fix: (edit_insert_file_cmd): sync with new edit_insert_file() Ticket #2710 (can't open an edit zero-length file from VFS in mcedit)
This commit is contained in:
commit
be6590a4a8
@ -241,7 +241,7 @@ void edit_complete_word_cmd (WEdit * edit);
|
||||
void edit_get_match_keyword_cmd (WEdit * edit);
|
||||
int edit_save_block (WEdit * edit, const char *filename, long start, long finish);
|
||||
int edit_save_block_cmd (WEdit * edit);
|
||||
int edit_insert_file_cmd (WEdit * edit);
|
||||
gboolean edit_insert_file_cmd (WEdit * edit);
|
||||
void edit_insert_over (WEdit * edit);
|
||||
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
|
||||
long *start_pos, long *end_pos, int *col1, int *col2);
|
||||
|
@ -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)
|
||||
|
@ -2778,43 +2778,33 @@ edit_save_block_cmd (WEdit * edit)
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** returns 1 on success */
|
||||
/** returns TRUE on success */
|
||||
|
||||
int
|
||||
gboolean
|
||||
edit_insert_file_cmd (WEdit * edit)
|
||||
{
|
||||
gchar *tmp;
|
||||
char *exp;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
|
||||
exp = input_expand_dialog (_("Insert file"), _("Enter file name:"),
|
||||
MC_HISTORY_EDIT_INSERT_FILE, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
|
||||
if (exp)
|
||||
|
||||
if (exp != NULL && *exp != '\0')
|
||||
{
|
||||
if (!*exp)
|
||||
{
|
||||
g_free (exp);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (edit_insert_file (edit, exp) != 0)
|
||||
{
|
||||
g_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (exp);
|
||||
edit_error_dialog (_("Insert file"), get_sys_error (_("Cannot insert file")));
|
||||
}
|
||||
}
|
||||
ret = (edit_insert_file (edit, exp) >= 0);
|
||||
if (!ret)
|
||||
edit_error_dialog (_("Insert file"), get_sys_error (_("Cannot insert file")));
|
||||
}
|
||||
|
||||
g_free (exp);
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user