From 66795ecbe18b85b92664503cb1bad917040f07d8 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Wed, 27 Dec 2000 04:47:28 +0000
Subject: [PATCH] do_cursorpos cleanups

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog |  3 +++
 winio.c   | 15 ++++-----------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b7b81bd1..e3bc0ddb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ CVS code -
   main()
 	- Reorder the getopt options to be more or less alphabetical
 	  (suggested by Sven Guckes).
+- winio.c:
+  do_cursorpos()
+	- Optimizations and cleanups by Rocco Corsi.
 
 nano 0.9.24 - 12/18/2000
 General
diff --git a/winio.c b/winio.c
index 4597d3fb..71fe081d 100644
--- a/winio.c
+++ b/winio.c
@@ -1132,33 +1132,26 @@ void previous_line(void)
 int do_cursorpos(void)
 {
     filestruct *fileptr;
-    float linepct, bytepct;
-    int i, tot = 0;
+    float linepct = 0.0, bytepct = 0.0;
+    int i = 0;
 
     if (current == NULL || fileage == NULL)
 	return 0;
 
     for (fileptr = fileage; fileptr != current && fileptr != NULL;
 	 fileptr = fileptr->next)
-	tot += strlen(fileptr->data) + 1;
+	i += strlen(fileptr->data) + 1;
 
     if (fileptr == NULL)
 	return -1;
 
-    i = tot + current_x;;
-
-    for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next)
-	tot += strlen(fileptr->data) + 1;
+    i += current_x;
 
     if (totlines > 0)
 	linepct = 100 * current->lineno / totlines;
-    else
-	linepct = 0;
 
     if (totsize > 0)
 	bytepct = 100 * i / totsize;
-    else
-	bytepct = 0;
 
 #ifdef DEBUG
     fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),
-- 
GitLab