]> git.wh0rd.org Git - nano.git/commitdiff
simplify do_cursorpos(), and remove an unneeded assert from it
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Sun, 31 Jul 2005 18:51:51 +0000 (18:51 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Sun, 31 Jul 2005 18:51:51 +0000 (18:51 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2953 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/winio.c

index d41657eeaa2e58e2b46d1f72f35b85cc6a5ee045..3f10da681b6ddefb4bf2779d702751f902f7a331 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -273,6 +273,8 @@ CVS code -
          that there's more room for other things, and to not display
          the status when we're in the file browser, since Pico doesn't.
          (DLR)
+  do_cursorpos()
+       - Simplify, and remove unneeded assert. (DLR)
 - configure.ac:
        - Since we only use vsnprintf() now, remove the tests for
          snprintf(). (DLR)
index 66e65f2008e3d20e42c5a6dd8dc6cb833f44829f..58b027df3a25a9611b4073598cd7c09b794298fa 100644 (file)
@@ -3823,25 +3823,19 @@ void display_main_list(void)
  * display the current cursor position next time. */
 void do_cursorpos(bool constant)
 {
-    char c;
-    filestruct *f;
-    size_t i, cur_xpt = xplustabs() + 1;
+    size_t i = 0, cur_xpt = xplustabs() + 1;
     size_t cur_lenpt = strlenpt(openfile->current->data) + 1;
     int linepct, colpct, charpct;
 
-    assert(openfile->current != NULL && openfile->fileage != NULL);
+    assert(openfile->fileage != NULL && openfile->current != NULL);
 
-    c = openfile->current->data[openfile->current_x];
-    f = openfile->current->next;
-    openfile->current->data[openfile->current_x] = '\0';
-    openfile->current->next = NULL;
-    i = get_totsize(openfile->fileage, openfile->current);
-    openfile->current->data[openfile->current_x] = c;
-    openfile->current->next = f;
+    if (openfile->current->prev != NULL)
+       i += get_totsize(openfile->fileage, openfile->current->prev);
+    i += mbstrnlen(openfile->current->data, openfile->current_x);
 
     /* Check whether totsize is correct.  If it isn't, there is a bug
      * somewhere. */
-    assert(openfile->current != openfile->filebot || i == openfile->totsize);
+    assert(i == openfile->totsize);
 
     if (constant && disable_cursorpos) {
        disable_cursorpos = FALSE;