Browse Source

* edit.c (edit_open_file): Remove "text" and "text_size"
arguments. Adjust all callers.

Pavel Roskin 22 years ago
parent
commit
581cf41929
5 changed files with 18 additions and 24 deletions
  1. 3 0
      edit/ChangeLog
  2. 11 11
      edit/edit.c
  3. 2 3
      edit/edit.h
  4. 1 1
      edit/editcmd.c
  5. 1 9
      edit/editwidget.c

+ 3 - 0
edit/ChangeLog

@@ -1,5 +1,8 @@
 2002-12-08  Pavel Roskin  <proski@gnu.org>
 
+	* edit.c (edit_open_file): Remove "text" and "text_size"
+	arguments.  Adjust all callers.
+
 	* edit.c (edit_move_to_column): Remove, use
 	edit_move_to_prev_col() instead.
 

+ 11 - 11
edit/edit.c

@@ -382,11 +382,11 @@ check_file_access (WEdit *edit, const char *filename, struct stat *st)
 
 /* returns 1 on error */
 static int
-edit_open_file (WEdit * edit, const char *filename, const char *text, unsigned long text_size)
+edit_open_file (WEdit *edit, const char *filename)
 {
     struct stat st;
-    if (text) {
-	edit->last_byte = text_size;
+    if (!filename || !*filename) {
+	edit->last_byte = 0;
 	filename = 0;
     } else {
 	int r;
@@ -400,10 +400,9 @@ edit_open_file (WEdit * edit, const char *filename, const char *text, unsigned l
 /* going to read the file into the buffer later byte by byte */
 	edit->last_byte = 0;
 	filename = 0;
-	text = "";
 #endif
     }
-    return init_dynamic_edit_buffers (edit, filename, text);
+    return init_dynamic_edit_buffers (edit, filename, "");
 }
 
 /* Restore saved cursor position in the file */
@@ -461,7 +460,7 @@ edit_purge_widget (WEdit *edit)
  */
 WEdit *
 edit_init (WEdit *edit, int lines, int columns, const char *filename,
-	   const char *text, unsigned long text_size, long line)
+	   long line)
 {
     int to_free = 0;
     int use_filter = 0;
@@ -507,7 +506,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
 #ifdef CR_LF_TRANSLATION
 	use_filter = 1;
 #endif
-	if (edit_open_file (edit, filename, text, text_size)) {
+	if (edit_open_file (edit, filename)) {
 /* edit_load_file already gives an error message */
 	    if (to_free)
 		g_free (edit);
@@ -515,7 +514,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
 	}
     } else {
 	use_filter = 1;
-	if (edit_open_file (edit, 0, "", 0)) {
+	if (edit_open_file (edit, 0)) {
 	    if (to_free)
 		g_free (edit);
 	    return 0;
@@ -607,13 +606,14 @@ int edit_renew (WEdit * edit)
     int retval = 1;
 
     edit_clean (edit);
-    if (!edit_init (edit, lines, columns, 0, "", 0, 0))
+    if (!edit_init (edit, lines, columns, "", 0))
 	retval = 0;
     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, unsigned long text_size)
+int
+edit_reload (WEdit *edit, const char *filename)
 {
     WEdit *e;
     int lines = edit->num_widget_lines;
@@ -622,7 +622,7 @@ int edit_reload (WEdit * edit, const char *filename, const char *text, unsigned
     memset (e, 0, sizeof (WEdit));
     e->widget = edit->widget;
     e->macro_i = -1;
-    if (!edit_init (e, lines, columns, filename, text, text_size, 0)) {
+    if (!edit_init (e, lines, columns, filename, 0)) {
 	g_free (e);
 	return 0;
     }

+ 2 - 3
edit/edit.h

@@ -183,12 +183,11 @@ 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,
-		  unsigned long text_size, long line);
+		  const char *filename, long line);
 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, unsigned long text_size);
+int edit_reload (WEdit *edit, const char *filename);
 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);

+ 1 - 1
edit/editcmd.c

@@ -733,7 +733,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))
 	return 1;
     edit_split_filename (edit, exp);
     edit->modified = 0;

+ 1 - 9
edit/editwidget.c

@@ -156,7 +156,6 @@ edit (const char *_file, int line)
 {
     static int made_directory = 0;
     int framed = 0;
-    char *text = 0;
     Dlg_head *edit_dlg;
     WButtonBar *edit_bar;
 
@@ -170,15 +169,8 @@ edit (const char *_file, int line)
 	mkdir (catstrs (home_dir, EDIT_DIR, 0), 0700);
 	made_directory = 1;
     }
-    if (_file) {
-	if (!(*_file)) {
-	    _file = 0;
-	    text = "";
-	}
-    } else
-	text = "";
 
-    if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, text, 0, line))) {
+    if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) {
 	return 0;
     }
     wedit->macro_i = -1;