Browse Source

* 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.

Pavel Roskin 22 years ago
parent
commit
221c35266c
4 changed files with 50 additions and 71 deletions
  1. 9 0
      edit/ChangeLog
  2. 0 1
      edit/edit-widget.h
  3. 16 27
      edit/edit.c
  4. 25 43
      edit/editcmd.c

+ 9 - 0
edit/ChangeLog

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

+ 0 - 1
edit/edit-widget.h

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

+ 16 - 27
edit/edit.c

@@ -2682,51 +2682,40 @@ 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); 
-    if (! nomark) /* remember marked or not */
+    nomark = eval_marks (edit, &start_mark, &end_mark);
+    if (!nomark)		/* remember marked or not */
 	edit_save_block (edit, block_file, start_mark, end_mark);
 
-    /* run shell scripts from menu */     
+    /* 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;
-	}
 
-	if (! nomark) {
-	    /* i.e. we have marked block */
-	    rc = edit_block_delete_cmd(edit);
-	}
+    if (mc_stat (block_file, &status) != 0 || !status.st_size) {
+	/* no block messages */
+	return;
+    }
 
-	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);
+    if (!nomark) {
+	/* i.e. we have marked block */
+	rc = edit_block_delete_cmd (edit);
+    }
 
-	/* truncate error file */
-	if ((fd = fopen (error_file, "w")))
-	    fclose(fd);
+    if (!rc) {
+	edit_insert_file (edit, block_file);
     }
 
     /* truncate block file */
     if ((fd = fopen (block_file, "w"))) {
-	fclose(fd);
+	fclose (fd);
     }
 
     edit_refresh_cmd (edit);

+ 25 - 43
edit/editcmd.c

@@ -2182,11 +2182,10 @@ int edit_sort_cmd (WEdit * edit)
 /* if block is 1, a block must be highlighted and the shell command
    processes it. If block is 0 the shell command is a straight system
    command, that just produces some output which is to be inserted */
-void 
+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, " ",
-			      edit->filename, NULL));
+	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;
-		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 (edit_block_delete_cmd (edit))
+	    return;
+	edit_insert_file (edit, b);
 	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;
 }