mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Changes into src/editor directory:
* edit/editcmd.c: * ignore fscanf() result in edit_delete_macro() * ignore fscanf() result in edit_load_macro_cmd() * ignoring mc_chown() errors in edit_save_file() * handling system() call errors in edit_block_process_cmd() * edit/edit.c: handling read errors in edit_load_file_fast() Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
35dae723ee
commit
5d79a90737
@ -328,6 +328,7 @@ edit_load_file_fast (WEdit * edit, const char *filename)
|
||||
{
|
||||
long buf, buf2;
|
||||
int file = -1;
|
||||
int ret=1;
|
||||
edit->curs2 = edit->last_byte;
|
||||
buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
|
||||
edit->utf8 = 0;
|
||||
@ -343,20 +344,31 @@ edit_load_file_fast (WEdit * edit, const char *filename)
|
||||
if (!edit->buffers2[buf2])
|
||||
edit->buffers2[buf2] = g_malloc0 (EDIT_BUF_SIZE);
|
||||
|
||||
mc_read (file,
|
||||
do
|
||||
{
|
||||
if (mc_read (file,
|
||||
(char *) edit->buffers2[buf2] + EDIT_BUF_SIZE -
|
||||
(edit->curs2 & M_EDIT_BUF_SIZE), edit->curs2 & M_EDIT_BUF_SIZE);
|
||||
(edit->curs2 & M_EDIT_BUF_SIZE), edit->curs2 & M_EDIT_BUF_SIZE) < 0)
|
||||
break;
|
||||
|
||||
for (buf = buf2 - 1; buf >= 0; buf--)
|
||||
{
|
||||
/* edit->buffers2[0] is already allocated */
|
||||
if (!edit->buffers2[buf])
|
||||
edit->buffers2[buf] = g_malloc0 (EDIT_BUF_SIZE);
|
||||
mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE);
|
||||
if (mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE) < 0)
|
||||
break;
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
while (0);
|
||||
if (ret) {
|
||||
char *err_str = g_strdup_printf(_(" Error reading %s "), filename);
|
||||
edit_error_dialog (_("Error"), err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
|
||||
mc_close (file);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* detecting an error on save is easy: just check if every byte has been written. */
|
||||
|
@ -273,9 +273,11 @@ edit_save_file (WEdit * edit, const char *filename)
|
||||
}
|
||||
else
|
||||
savename = g_strdup (real_filename);
|
||||
|
||||
mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
|
||||
mc_chmod (savename, edit->stat1.st_mode);
|
||||
{
|
||||
int ret;
|
||||
ret = mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
|
||||
ret = mc_chmod (savename, edit->stat1.st_mode);
|
||||
}
|
||||
|
||||
if ((fd =
|
||||
mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, edit->stat1.st_mode)) == -1)
|
||||
@ -757,7 +759,10 @@ edit_delete_macro (WEdit * edit, int k)
|
||||
n = 0;
|
||||
while (fscanf (f, "%lu %d, ", ¯o[n].command, ¯o[n].ch))
|
||||
n++;
|
||||
fscanf (f, ";\n");
|
||||
{
|
||||
int ret;
|
||||
ret = fscanf (f, ";\n");
|
||||
}
|
||||
if (s != k)
|
||||
{
|
||||
fprintf (g, ("key '%d 0': "), s);
|
||||
@ -866,7 +871,10 @@ edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k)
|
||||
{
|
||||
while (2 == fscanf (f, "%lu %d, ", &dummy.command, &dummy.ch));
|
||||
}
|
||||
fscanf (f, ";\n");
|
||||
{
|
||||
int ret;
|
||||
ret = fscanf (f, ";\n");
|
||||
}
|
||||
if (s == k)
|
||||
found = 1;
|
||||
}
|
||||
@ -2503,8 +2511,6 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
*/
|
||||
tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", quoted_name,
|
||||
" ", home_dir, PATH_SEP_STR EDIT_BLOCK_FILE " /dev/null", (char *) NULL);
|
||||
system (tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2515,9 +2521,15 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
*/
|
||||
tmp = g_strconcat (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ",
|
||||
quoted_name, (char *) NULL);
|
||||
system (tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
if (system (tmp) == -1)
|
||||
{
|
||||
edit_error_dialog (_("Process block"),_("Error calling program"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
g_free (quoted_name);
|
||||
close_error_pipe (D_NORMAL, NULL);
|
||||
|
||||
@ -2532,6 +2544,8 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
if (block_file != NULL)
|
||||
fclose (block_file);
|
||||
}
|
||||
}
|
||||
g_free (tmp);
|
||||
|
||||
edit_block_process_cmd__EXIT:
|
||||
g_free (b);
|
||||
|
Loading…
Reference in New Issue
Block a user