Browse Source

* edit.h: Remove "dir" field in WEdit - it's always an empty
string. Adjust all dependencies.

Pavel Roskin 22 years ago
parent
commit
dd7f5798fa
6 changed files with 18 additions and 38 deletions
  1. 3 0
      edit/ChangeLog
  2. 0 1
      edit/edit-widget.h
  3. 7 26
      edit/edit.c
  4. 2 2
      edit/edit.h
  5. 5 8
      edit/editcmd.c
  6. 1 1
      edit/editwidget.c

+ 3 - 0
edit/ChangeLog

@@ -1,5 +1,8 @@
 2002-11-30  Pavel Roskin  <proski@gnu.org>
 
+	* edit.h: Remove "dir" field in WEdit - it's always an empty
+	string.  Adjust all dependencies.
+
 	* editcmd.c (edit_get_save_file): Remove first argument, it's
 	unused.
 	(edit_get_save_file): Likewise.

+ 0 - 1
edit/edit-widget.h

@@ -38,7 +38,6 @@ struct WEdit {
     int have_frame;
 
     char *filename;		/* Name of the file */
-    char *dir;			/* current directory */
 
 /* dynamic buffers and cursor position for editor: */
     long curs1;			/*position of the cursor from the beginning of the file. */

+ 7 - 26
edit/edit.c

@@ -388,9 +388,8 @@ edit_open_file (WEdit * edit, const char *filename, const char *text, unsigned l
 #define space_width 1
 
 /* fills in the edit struct. returns 0 on fail. Pass edit as NULL for this */
-WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, const char *text, const char *dir, unsigned long text_size)
+WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, const char *text, unsigned long text_size)
 {
-    const char *f;
     int to_free = 0;
     int use_filter = 0;
 
@@ -430,17 +429,11 @@ WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, co
     edit->stat1.st_uid = getuid ();
     edit->stat1.st_gid = getgid ();
     edit->bracket = -1;
-    if (!dir)
-	dir = "";
-    f = filename;
-    if (filename) {
-	f = catstrs (dir, filename, 0);
-    }
-    if (edit_find_filter (f) < 0) {
+    if (edit_find_filter (filename) < 0) {
 #ifdef CR_LF_TRANSLATION
 	use_filter = 1;
 #endif
-	if (edit_open_file (edit, f, text, text_size)) {
+	if (edit_open_file (edit, filename, text, text_size)) {
 /* edit_load_file already gives an error message */
 	    if (to_free)
 		g_free (edit);
@@ -456,11 +449,9 @@ WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, co
     }
     edit->force |= REDRAW_PAGE;
     if (filename) {
-	filename = catstrs (dir, filename, 0);
 	edit_split_filename (edit, filename);
     } else {
 	edit->filename = (char *) strdup ("");
-	edit->dir = (char *) strdup (dir);
     }
     edit->stack_size = START_STACK_SIZE;
     edit->stack_size_mask = START_STACK_SIZE - 1;
@@ -469,7 +460,7 @@ WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, co
     if (use_filter) {
 	push_action_disabled = 1;
 	if (check_file_access (edit, filename, &(edit->stat1))
-	    || !edit_insert_file (edit, f))
+	    || !edit_insert_file (edit, filename))
 	{
 	    edit_clean (edit);
 	    if (to_free)
@@ -506,8 +497,6 @@ int edit_clean (WEdit * edit)
 	    free (edit->undo_stack);
 	if (edit->filename)
 	    free (edit->filename);
-	if (edit->dir)
-	    free (edit->dir);
 /* we don't want to clear the widget */
 	memset (&(edit->from_here), 0, (unsigned long)&(edit->to_here) - (unsigned long)&(edit->from_here));
 
@@ -525,24 +514,16 @@ int edit_renew (WEdit * edit)
 {
     int lines = edit->num_widget_lines;
     int columns = edit->num_widget_columns;
-    char *dir;
     int retval = 1;
 
-    if (edit->dir)
-	dir = (char *) strdup (edit->dir);
-    else
-	dir = 0;
-
     edit_clean (edit);
-    if (!edit_init (edit, lines, columns, 0, "", dir, 0))
+    if (!edit_init (edit, lines, columns, 0, "", 0))
 	retval = 0;
-    if (dir)
-	free (dir);
     return retval;
 }
 
 /* returns 1 on success, if returns 0, the edit struct would have been free'd */
-int edit_reload (WEdit * edit, const char *filename, const char *text, const char *dir, unsigned long text_size)
+int edit_reload (WEdit * edit, const char *filename, const char *text, unsigned long text_size)
 {
     WEdit *e;
     int lines = edit->num_widget_lines;
@@ -551,7 +532,7 @@ int edit_reload (WEdit * edit, const char *filename, const char *text, const cha
     memset (e, 0, sizeof (WEdit));
     e->widget = edit->widget;
     e->macro_i = -1;
-    if (!edit_init (e, lines, columns, filename, text, dir, text_size)) {
+    if (!edit_init (e, lines, columns, filename, text, text_size)) {
 	g_free (e);
 	return 0;
     }

+ 2 - 2
edit/edit.h

@@ -184,11 +184,11 @@ char *edit_get_write_filter (char *writename, const char *filename);
 int edit_save_cmd (WEdit * edit);
 int edit_save_confirm_cmd (WEdit * edit);
 int edit_save_as_cmd (WEdit * edit);
-WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, const char *text, const char *dir, unsigned long text_size);
+WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, const char *text, unsigned long text_size);
 int edit_clean (WEdit * edit);
 int edit_renew (WEdit * edit);
 int edit_new_cmd (WEdit * edit);
-int edit_reload (WEdit * edit, const char *filename, const char *text, const char *dir, unsigned long text_size);
+int edit_reload (WEdit * edit, const char *filename, const char *text, unsigned long text_size);
 int edit_load_cmd (WEdit * edit);
 void edit_mark_cmd (WEdit * edit, int unmark);
 void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);

+ 5 - 8
edit/editcmd.c

@@ -402,9 +402,6 @@ void edit_split_filename (WEdit * edit, const char *f)
     if (edit->filename)
 	free (edit->filename);
     edit->filename = (char *) strdup (f);
-    if (edit->dir)
-	free (edit->dir);
-    edit->dir = (char *) strdup ("");
 }
 
 /* Here we want to warn the users of overwriting an existing file,
@@ -426,7 +423,7 @@ edit_save_as_cmd (WEdit *edit)
 	    edit->force |= REDRAW_COMPLETELY;
 	    return 0;
 	} else {
-	    if (strcmp (catstrs (edit->dir, edit->filename, 0), exp)) {
+	    if (strcmp (edit->filename, exp)) {
 		int file;
 		different_filename = 1;
 		if ((file = mc_open (exp, O_RDONLY | O_BINARY)) != -1) {
@@ -707,7 +704,7 @@ int edit_save_confirm_cmd (WEdit * edit)
 /* returns 1 on success */
 int edit_save_cmd (WEdit * edit)
 {
-    if (!edit_save_file (edit, catstrs (edit->dir, edit->filename, 0)))
+    if (!edit_save_file (edit, edit->filename))
 	return edit_save_as_cmd (edit);
     edit->force |= REDRAW_COMPLETELY;
     edit->modified = 0;
@@ -735,7 +732,7 @@ int edit_new_cmd (WEdit * edit)
 static int
 edit_load_file_from_filename (WEdit * edit, char *exp)
 {
-    if (!edit_reload (edit, exp, 0, "", 0))
+    if (!edit_reload (edit, exp, 0, 0))
 	return 1;
     edit_split_filename (edit, exp);
     edit->modified = 0;
@@ -1975,7 +1972,7 @@ void edit_quit_cmd (WEdit * edit)
 	    break;
 	case 2:
 	    if (edit->delete_file)
-		unlink (catstrs (edit->dir, edit->filename, 0));
+		unlink (edit->filename);
 	    break;
 	case 0:
 	case -1:
@@ -1983,7 +1980,7 @@ void edit_quit_cmd (WEdit * edit)
 	}
     }
     else if (edit->delete_file)
-	unlink (catstrs (edit->dir, edit->filename, 0));
+	unlink (edit->filename);
     dlg_stop (edit->widget.parent);
 }
 

+ 1 - 1
edit/editwidget.c

@@ -178,7 +178,7 @@ edit (const char *_file, int line)
     } else
 	text = "";
 
-    if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, text, "", 0))) {
+    if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, text, 0))) {
 	return 0;
     }
     wedit->macro_i = -1;