From 20b83508f4bbd83f3fb7a8c26e0141372ba1e21c Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 26 Aug 2004 18:07:58 +0000
Subject: [PATCH] simplify edit_update() so as not to require the fileptr
 parameter anymore, since it's set to current in all calls

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1915 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    |  3 +++
 src/move.c   |  4 ++--
 src/proto.h  |  2 +-
 src/search.c |  2 +-
 src/winio.c  | 18 ++++++++++--------
 5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7c1428a3..da283fe1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,9 @@ CVS code -
 	- If there are more than MAIN_VISIBLE shortcuts available, only
 	  register clicks on the first MAIN_VISIBLE shortcuts, since
 	  bottombars() only shows that many shortcuts. (DLR)
+  edit_update()
+	- Simplify so as not to require the fileptr parameter anymore,
+	  since it's set to current in all calls. (DLR)
   do_yesno()
 	- Don't bother assigning the value of get_mouseinput() to
 	  anything.  Since allow_shortcuts is FALSE, its return value
diff --git a/src/move.c b/src/move.c
index 84b907fa..7e22d338 100644
--- a/src/move.c
+++ b/src/move.c
@@ -35,7 +35,7 @@ void do_first_line(void)
     placewewant = 0;
     current_x = 0;
     if (edittop != fileage || need_vertical_update(old_pww))
-	edit_update(current, TOP);
+	edit_update(TOP);
 }
 
 void do_last_line(void)
@@ -46,7 +46,7 @@ void do_last_line(void)
     current_x = 0;
     if (edittop->lineno + (editwinrows / 2) != filebot->lineno ||
 	need_vertical_update(old_pww))
-	edit_update(current, CENTER);
+	edit_update(CENTER);
 }
 
 void do_home(void)
diff --git a/src/proto.h b/src/proto.h
index 5ea8c11b..a975326b 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -565,7 +565,7 @@ int need_vertical_update(size_t old_pww);
 void edit_scroll(updown direction, int nlines);
 void edit_redraw(const filestruct *old_current, size_t old_pww);
 void edit_refresh(void);
-void edit_update(filestruct *fileptr, topmidnone location);
+void edit_update(topmidnone location);
 int statusq(int allowtabs, const shortcut *s, const char *def,
 #ifndef NANO_SMALL
 		historyheadtype *history_list,
diff --git a/src/search.c b/src/search.c
index 63596897..79e36239 100644
--- a/src/search.c
+++ b/src/search.c
@@ -877,7 +877,7 @@ void do_gotoline(int line, bool save_pos)
 
     /* If save_pos is TRUE, don't change the cursor position when
      * updating the edit window. */
-    edit_update(current, save_pos ? NONE : CENTER);
+    edit_update(save_pos ? NONE : CENTER);
 
     placewewant = 0;
     display_main_list();
diff --git a/src/winio.c b/src/winio.c
index 4e155e37..a4a3a0b1 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2897,7 +2897,7 @@ void edit_refresh(void)
 	 * current->lineno = edittop->lineno + editwinrows / 2.  Thus
 	 * when it then calls edit_refresh(), there is no danger of
 	 * getting an infinite loop. */
-	edit_update(current, CENTER);
+	edit_update(CENTER);
     else {
 	int nlines = 0;
 	const filestruct *foo = edittop;
@@ -2922,20 +2922,22 @@ void edit_refresh(void)
     }
 }
 
-/* Nice generic routine to update the edit buffer, given a pointer to the
- * file struct =) */
-void edit_update(filestruct *fileptr, topmidnone location)
+/* A nice generic routine to update the edit buffer. */
+void edit_update(topmidnone location)
 {
-    if (fileptr == NULL)
+    filestruct *foo = current;
+
+    /* We shouldn't need this check.  Yuck. */
+    if (current == NULL)
 	return;
 
     if (location != TOP) {
 	int goal = (location == NONE) ? current_y : editwinrows / 2;
 
-	for (; goal > 0 && fileptr->prev != NULL; goal--)
-	    fileptr = fileptr->prev;
+	for (; goal > 0 && foo->prev != NULL; goal--)
+	    foo = foo->prev;
     }
-    edittop = fileptr;
+    edittop = foo;
     edit_refresh();
 }
 
-- 
GitLab