do_cursorpos cleanups

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2000-12-27 04:47:28 +00:00
parent d55655f23a
commit 66795ecbe1
2 changed files with 7 additions and 11 deletions

View File

@ -5,6 +5,9 @@ CVS code -
main() main()
- Reorder the getopt options to be more or less alphabetical - Reorder the getopt options to be more or less alphabetical
(suggested by Sven Guckes). (suggested by Sven Guckes).
- winio.c:
do_cursorpos()
- Optimizations and cleanups by Rocco Corsi.
nano 0.9.24 - 12/18/2000 nano 0.9.24 - 12/18/2000
General General

15
winio.c
View File

@ -1132,33 +1132,26 @@ void previous_line(void)
int do_cursorpos(void) int do_cursorpos(void)
{ {
filestruct *fileptr; filestruct *fileptr;
float linepct, bytepct; float linepct = 0.0, bytepct = 0.0;
int i, tot = 0; int i = 0;
if (current == NULL || fileage == NULL) if (current == NULL || fileage == NULL)
return 0; return 0;
for (fileptr = fileage; fileptr != current && fileptr != NULL; for (fileptr = fileage; fileptr != current && fileptr != NULL;
fileptr = fileptr->next) fileptr = fileptr->next)
tot += strlen(fileptr->data) + 1; i += strlen(fileptr->data) + 1;
if (fileptr == NULL) if (fileptr == NULL)
return -1; return -1;
i = tot + current_x;; i += current_x;
for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next)
tot += strlen(fileptr->data) + 1;
if (totlines > 0) if (totlines > 0)
linepct = 100 * current->lineno / totlines; linepct = 100 * current->lineno / totlines;
else
linepct = 0;
if (totsize > 0) if (totsize > 0)
bytepct = 100 * i / totsize; bytepct = 100 * i / totsize;
else
bytepct = 0;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"), fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),