<<< Date Index >>>     <<< Thread Index >>>

minor bug in buffy.c [fix attached]



Hi all.

[please cc me on any replies; I'm currently not subscribed to mutt-dev.]

I've been using the "change_folder_next" patch that Simon Burge
posted in August 2002:
        http://marc.theaimsgroup.com/?l=mutt-dev&m=102819789426654&w=2

With that patch applied and the option enabled, pressing `c' to
change folder selects the next folder (relative to the current
folder) with unread messages, rather than scanning from the start
of the list of `mailboxes'.

For example, given:
        mailboxes =inbox =b =bsrc =board =root
and I'm currently in =bsrc, if there's new mail in =inbox
and =board, with this option `c' will select =board and not
=inbox.

As I have ~ 35 mailboxes I monitor, this patch enhances my
mail reading ability.

However, due to a bug in buffy.c, this patch doesn't work correctly
when there's no unread mail.  Instead of printing
        Open mailbox ('?' for list):
it prints
        Open mailbox ('?' for list): /home/lukem/Mail/bsrc

Code inspection of buffy.c::mutt_buffy() reveals the bug is
that function; instead of changing the first byte of the
buffer pointed to by `char *s' to NUL (\0), it sets the pointer
itself to \0, which is then ignored by the rest of the function.
A fix is attached.

Cheers,
Luke.

PS: it would be excellent if Simon's patch could be applied to the
mutt sources; I have described its functionality to a few mutt-using
collegues and they unanimously agree that the functionality is useful
and, in my opinion, is useful enough to make the default.
--- buffy.c.orig        2002-03-25 22:30:23.000000000 +1100
+++ buffy.c
@@ -440,7 +440,7 @@ void mutt_buffy (char *s, size_t slen)
   {
   case 0:
 
-    s = '\0';
+    *s = '\0';
     break;
 
   case 1:
@@ -449,7 +449,7 @@ void mutt_buffy (char *s, size_t slen)
       tmp = tmp->next;
     if (!tmp)
     {
-      s = '\0';
+      *s = '\0';
       mutt_buffy_check (1); /* buffy was wrong - resync things */
       break;
     }
@@ -475,7 +475,7 @@ void mutt_buffy (char *s, size_t slen)
     }
     if (count >= 3)
     {
-      s = '\0';
+      *s = '\0';
       mutt_buffy_check (1); /* buffy was wrong - resync things */
       break;
     }

Attachment: pgpJvuCFgz6OC.pgp
Description: PGP signature