mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
* edit-widget.h: Eliminate ERROR_FILE.
* edit.c: Remove all references to ERROR_FILE. * editcmd.c (edit_block_process_cmd): Revert to using catstrs(), those strings are freed now. Use system(), not execute() to execute commands. Use open_error_pipe() and close_error_pipe() to keep track of errors.
This commit is contained in:
parent
6f0a3ef49f
commit
221c35266c
@ -1,3 +1,12 @@
|
||||
2002-08-24 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* edit-widget.h: Eliminate ERROR_FILE.
|
||||
* edit.c: Remove all references to ERROR_FILE.
|
||||
* editcmd.c (edit_block_process_cmd): Revert to using catstrs(),
|
||||
those strings are freed now. Use system(), not execute() to
|
||||
execute commands. Use open_error_pipe() and close_error_pipe()
|
||||
to keep track of errors.
|
||||
|
||||
2002-08-22 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* editcmd.c: Clean up global variables in the completion code.
|
||||
|
@ -126,7 +126,6 @@ typedef struct editor_widget WEdit;
|
||||
#define CLIP_FILE EDIT_DIR PATH_SEP_STR "cooledit.clip"
|
||||
#define MACRO_FILE EDIT_DIR PATH_SEP_STR "cooledit.macros"
|
||||
#define BLOCK_FILE EDIT_DIR PATH_SEP_STR "cooledit.block"
|
||||
#define ERROR_FILE EDIT_DIR PATH_SEP_STR "cooledit.error"
|
||||
#define TEMP_FILE EDIT_DIR PATH_SEP_STR "cooledit.temp"
|
||||
|
||||
#endif /* !__EDIT_WIDGET_H */
|
||||
|
15
edit/edit.c
15
edit/edit.c
@ -2682,14 +2682,14 @@ void edit_execute_macro (WEdit * edit, struct macro macro[], int n)
|
||||
}
|
||||
|
||||
/* User edit menu, like user menu (F2) but only in editor. */
|
||||
void user_menu (WEdit *edit)
|
||||
void
|
||||
user_menu (WEdit * edit)
|
||||
{
|
||||
FILE *fd;
|
||||
int nomark;
|
||||
struct stat status;
|
||||
long start_mark, end_mark;
|
||||
char *block_file = catstrs (home_dir, BLOCK_FILE, 0);
|
||||
char *error_file = catstrs (home_dir, ERROR_FILE, 0);
|
||||
int rc = 0;
|
||||
|
||||
nomark = eval_marks (edit, &start_mark, &end_mark);
|
||||
@ -2699,8 +2699,6 @@ void user_menu (WEdit *edit)
|
||||
/* run shell scripts from menu */
|
||||
user_menu_cmd (edit);
|
||||
|
||||
if (mc_stat (error_file, &status) != 0 || !status.st_size) {
|
||||
/* no error messages */
|
||||
if (mc_stat (block_file, &status) != 0 || !status.st_size) {
|
||||
/* no block messages */
|
||||
return;
|
||||
@ -2714,15 +2712,6 @@ void user_menu (WEdit *edit)
|
||||
if (!rc) {
|
||||
edit_insert_file (edit, block_file);
|
||||
}
|
||||
} else {
|
||||
/* error file exists and is not empty */
|
||||
edit_cursor_to_bol (edit);
|
||||
edit_insert_file (edit, error_file);
|
||||
|
||||
/* truncate error file */
|
||||
if ((fd = fopen (error_file, "w")))
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
/* truncate block file */
|
||||
if ((fd = fopen (block_file, "w"))) {
|
||||
|
@ -2186,7 +2186,6 @@ void
|
||||
edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
{
|
||||
long start_mark, end_mark;
|
||||
struct stat s;
|
||||
char buf[BUFSIZ];
|
||||
FILE *script_home = NULL;
|
||||
FILE *script_src = NULL;
|
||||
@ -2194,49 +2193,50 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
char *o = NULL;
|
||||
char *h = NULL;
|
||||
char *b = NULL;
|
||||
char *e = NULL;
|
||||
|
||||
o = g_strconcat (mc_home, shell_cmd, 0); /* original source script */
|
||||
h = g_strconcat (home_dir, EDIT_DIR, shell_cmd, 0); /* home script */
|
||||
b = g_strconcat (home_dir, BLOCK_FILE, 0); /* block file */
|
||||
e = g_strconcat (home_dir, ERROR_FILE, 0); /* error file */
|
||||
o = catstrs (mc_home, shell_cmd, 0); /* original source script */
|
||||
h = catstrs (home_dir, EDIT_DIR, shell_cmd, 0); /* home script */
|
||||
b = catstrs (home_dir, BLOCK_FILE, 0); /* block file */
|
||||
|
||||
if (!(script_home = fopen (h, "r"))) {
|
||||
if (!(script_home = fopen (h, "w"))) {
|
||||
edit_error_dialog ("", get_sys_error (g_strconcat
|
||||
edit_error_dialog ("", get_sys_error (catstrs
|
||||
(_
|
||||
("Error create script:"),
|
||||
h, 0)));
|
||||
goto err;
|
||||
return;
|
||||
}
|
||||
if (!(script_src = fopen (o, "r"))) {
|
||||
fclose (script_home);
|
||||
unlink (h);
|
||||
edit_error_dialog ("", get_sys_error (g_strconcat
|
||||
edit_error_dialog ("", get_sys_error (catstrs
|
||||
(_("Error read script:"),
|
||||
o, 0)));
|
||||
goto err;
|
||||
return;
|
||||
}
|
||||
while (fgets (buf, sizeof (buf), script_src))
|
||||
fputs (buf, script_home);
|
||||
if (fclose (script_home)) {
|
||||
edit_error_dialog ("", get_sys_error (g_strconcat
|
||||
edit_error_dialog ("", get_sys_error (catstrs
|
||||
(_
|
||||
("Error close script:"),
|
||||
h, 0)));
|
||||
goto err;
|
||||
return;
|
||||
}
|
||||
chmod (h, 0700);
|
||||
edit_error_dialog ("", get_sys_error (g_strconcat
|
||||
edit_error_dialog ("", get_sys_error (catstrs
|
||||
(_("Script created:"), h,
|
||||
0)));
|
||||
}
|
||||
|
||||
open_error_pipe ();
|
||||
|
||||
if (block) { /* for marked block run indent formatter */
|
||||
if (eval_marks (edit, &start_mark, &end_mark)) {
|
||||
edit_error_dialog (_("Process block"),
|
||||
_
|
||||
(" You must first highlight a block of text. "));
|
||||
goto err;
|
||||
return;
|
||||
}
|
||||
edit_save_block (edit, b, start_mark, end_mark);
|
||||
|
||||
@ -2248,9 +2248,8 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
* $2 - file containing the current block.
|
||||
* $3 - file where error messages should be put.
|
||||
*/
|
||||
execute (g_strconcat (" ", home_dir, EDIT_DIR, shell_cmd, " ",
|
||||
edit->filename, " ", home_dir, BLOCK_FILE,
|
||||
" ", home_dir, ERROR_FILE, NULL));
|
||||
system (catstrs (" ", home_dir, EDIT_DIR, shell_cmd, " ",
|
||||
edit->filename, " ", home_dir, BLOCK_FILE, NULL));
|
||||
|
||||
} else {
|
||||
/*
|
||||
@ -2258,42 +2257,25 @@ edit_block_process_cmd (WEdit * edit, const char *shell_cmd, int block)
|
||||
* Arguments:
|
||||
* $1 - name of the edited file.
|
||||
*/
|
||||
execute (g_strconcat (" ", home_dir, EDIT_DIR, shell_cmd, " ",
|
||||
system (catstrs (" ", home_dir, EDIT_DIR, shell_cmd, " ",
|
||||
edit->filename, NULL));
|
||||
}
|
||||
|
||||
close_error_pipe (0, 0);
|
||||
|
||||
edit_refresh_cmd (edit);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
/* insert result block */
|
||||
if (block) {
|
||||
if (mc_stat (e, &s) == 0) {
|
||||
if (!s.st_size) { /* no error messages */
|
||||
if (edit_block_delete_cmd (edit))
|
||||
goto err;
|
||||
return;
|
||||
edit_insert_file (edit, b);
|
||||
} else {
|
||||
edit_insert_file (edit, e);
|
||||
}
|
||||
} else {
|
||||
edit_error_dialog ("",
|
||||
get_sys_error (g_strconcat
|
||||
(_
|
||||
("Error trying to stat file:"),
|
||||
e, 0)));
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
}
|
||||
if ((block_file = fopen (b, "w")))
|
||||
fclose (block_file);
|
||||
goto err;
|
||||
return;
|
||||
}
|
||||
|
||||
err:
|
||||
g_free (o);
|
||||
g_free (h);
|
||||
g_free (b);
|
||||
g_free (e);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user