]> granicus.if.org Git - mutt/commitdiff
Make BUFFY_SIZE a runtime switch ($check_mbox_size)
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 20 Mar 2007 20:39:29 +0000 (13:39 -0700)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 20 Mar 2007 20:39:29 +0000 (13:39 -0700)
ChangeLog
UPDATING
buffy.c
buffy.h
commands.c
configure.ac
init.h
main.c
mutt.h
mx.c

index 9c9eb47071524a9f0b994830ae1f83ec59efa810..96db3dd13d8033ead7fef019a872b214cdaff6cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-03-20 13:17 -0700  Rocco Rutte  <pdmef@gmx.net>  (2fbc65f3feb6)
+
+       * addrbook.c, browser.c, compose.c, crypt-gpgme.c, curs_main.c,
+       mutt_ssl.c, mutt_ssl_gnutls.c, pgpkey.c, postpone.c, query.c,
+       recvattach.c, remailer.c: Enlarge help string buffers Even on 80x25
+       terminals, SHORT_STRING (128 byte) may not be enough so use
+       LONG_STRING (1k) as STRING (256 byte) may well be too short for
+       wider terminals. Closes debian #4152777.
+
+2007-03-20 09:45 -0700  Antoine Reilles  <tonio@NetBSD.org>  (f0461517fc93)
+
+       * muttlib.c: Remove trailing slash from $folder in
+       mutt_expand_path.
+
 2007-03-20 08:20 -0700  Rocco Rutte  <pdmef@gmx.net>  (3122a4a338b1)
 
        * rfc3676.c: Make f=f handler behave like old f=f handler for quoted
@@ -22,7 +36,7 @@
 
 2007-03-15 16:29 -0700  Brendan Cully  <brendan@kublai.com>  (4ade0c9660d5)
 
-       * ChangeLog, Makefile.am: Add reldate.h to BUILT_SOURCES
+       * Makefile.am: Add reldate.h to BUILT_SOURCES
 
 2007-03-15 16:10 +0100  Christoph Berg  <cb@df7cb.de>  (ed804d94676a)
 
index c0daa39ecd2825040caad4ff6d342c4d8cb3b2a7..60c1800490d9ff7c7a1b2c2d2280f5208e670d2f 100644 (file)
--- a/UPDATING
+++ b/UPDATING
@@ -4,6 +4,7 @@ mutt. Please read this file carefully when upgrading your installation.
 The keys used are:
   !: modified feature, -: deleted feature, +: new feature
 
+  + $check_mbox_size (use size change instead of atime for new mail)
   ! improved f=f support wraps lines at $wrap if $wrap is not 0
   + $wrap (>0 wraps at $wrap, <0 = $wrapmargin)
   + $assumed_charset, $attach_charset, $ignore_linear_white_space
diff --git a/buffy.c b/buffy.c
index b1513f5bb15e42070ca67f604211eaa2c2116ef9..d0998ff255c1b944a26f0e85a7d2ac984db7ef8c 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -45,8 +45,6 @@ time_t BuffyDoneTime = 0;     /* last time we knew for sure how much mail there was.
 static short BuffyCount = 0;   /* how many boxes with new mail */
 static short BuffyNotify = 0;  /* # of unnotified new boxes */
 
-#ifdef BUFFY_SIZE
-
 /* Find the last message in the file. 
  * upon success return 0. If no message found - return -1 */
 
@@ -167,15 +165,12 @@ void mutt_update_mailbox (BUFFY * b)
     b->size = 0;
   return;
 }
-#endif
 
 int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err)
 {
   BUFFY **tmp,*tmp1;
   char buf[_POSIX_PATH_MAX];
-#ifdef BUFFY_SIZE
   struct stat sb;
-#endif /* BUFFY_SIZE */
 
   while (MoreArgs (s))
   {
@@ -232,31 +227,28 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
     (*tmp)->notified = 1;
     (*tmp)->newly_created = 0;
 
-#ifdef BUFFY_SIZE
-    /* for buffy_size, it is important that if the folder is new (tested by
+    /* for check_mbox_size, it is important that if the folder is new (tested by
      * reading it), the size is set to 0 so that later when we check we see
-     * that it increased .  without buffy_size we probably don't care.
+     * that it increased .  without check_mbox_size we probably don't care.
      */
-    if (stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path))
+    if (option(OPTCHECKMBOXSIZE) &&
+       stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path))
     {
       /* some systems out there don't have an off_t type */
       (*tmp)->size = (long) sb.st_size;
     }
     else
       (*tmp)->size = 0;
-#endif /* BUFFY_SIZE */
   }
   return 0;
 }
 
-#ifdef BUFFY_SIZE
-/* people use buffy_size on systems where modified time attributes are BADLY
- * broken. Ignore them.
+/* people use check_mbox_size on systems where modified time attributes are 
+ * BADLY broken. Ignore them.
  */
-#define STAT_CHECK (sb.st_size > tmp->size)
-#else
-#define STAT_CHECK (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
-#endif /* BUFFY_SIZE */
+#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
+#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
+#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
 
 int mutt_buffy_check (int force)
 {
@@ -323,9 +315,7 @@ int mutt_buffy_check (int force)
        * be ready for when it does. */
       tmp->newly_created = 1;
       tmp->magic = 0;
-#ifdef BUFFY_SIZE
       tmp->size = 0;
-#endif
       continue;
     }
 #ifdef USE_IMAP
@@ -365,13 +355,11 @@ int mutt_buffy_check (int force)
          BuffyCount++;
          tmp->new = 1;
        }
-#ifdef BUFFY_SIZE
-       else
+       else if (option(OPTCHECKMBOXSIZE))
        {
          /* some other program has deleted mail from the folder */
          tmp->size = (long) sb.st_size;
        }
-#endif
        if (tmp->newly_created &&
            (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
          tmp->newly_created = 0;
@@ -407,10 +395,8 @@ int mutt_buffy_check (int force)
        break;
       }
     }
-#ifdef BUFFY_SIZE
-    else if (Context && Context->path)
+    else if (option(OPTCHECKMBOXSIZE) && Context && Context->path)
       tmp->size = (long) sb.st_size;   /* update the size */
-#endif
 
     if (!tmp->new)
       tmp->notified = 0;
diff --git a/buffy.h b/buffy.h
index cecff7c2a561da49b7a2e8342c59ef9a9dc51f82..b86d1aa419e5d3306e96671e7bb25000505c53ee 100644 (file)
--- a/buffy.h
+++ b/buffy.h
@@ -23,9 +23,7 @@
 typedef struct buffy_t
 {
   char *path;
-#ifdef BUFFY_SIZE
   long size;
-#endif                         /* BUFFY_SIZE */
   struct buffy_t *next;
   short new;                   /* mailbox has new mail */
   short notified;              /* user has been notified */
@@ -39,7 +37,5 @@ WHERE short BuffyTimeout INITVAL (3);
 
 extern time_t BuffyDoneTime;   /* last time we knew for sure how much mail there was */
 
-#ifdef BUFFY_SIZE
 BUFFY *mutt_find_mailbox (const char *path);
 void mutt_update_mailbox (BUFFY * b);
-#endif
index 6f99cbc93f52e74cb6d0369d4250ec921d157248..2fdcb7ffae394885e925ee7326422dbfc1daaae9 100644 (file)
@@ -40,9 +40,7 @@
 #include "imap.h"
 #endif
 
-#ifdef BUFFY_SIZE
 #include "buffy.h"
-#endif
 
 #include <errno.h>
 #include <unistd.h>
@@ -703,11 +701,8 @@ int mutt_save_message (HEADER *h, int delete,
   char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
   CONTEXT ctx;
   struct stat st;
-#ifdef BUFFY_SIZE
   BUFFY *tmp = NULL;
-#else
   struct utimbuf ut;
-#endif
 
   *redraw = 0;
 
@@ -842,21 +837,24 @@ int mutt_save_message (HEADER *h, int delete,
 
     if (need_buffy_cleanup)
     {
-#ifdef BUFFY_SIZE
-      tmp = mutt_find_mailbox (buf);
-      if (tmp && !tmp->new)
-       mutt_update_mailbox (tmp);
-#else
-      /* fix up the times so buffy won't get confused */
-      if (st.st_mtime > st.st_atime)
+      if (option(OPTCHECKMBOXSIZE))
       {
-       ut.actime = st.st_atime;
-       ut.modtime = time (NULL);
-       utime (buf, &ut); 
+       tmp = mutt_find_mailbox (buf);
+       if (tmp && !tmp->new)
+         mutt_update_mailbox (tmp);
       }
       else
-       utime (buf, NULL);
-#endif
+      {
+       /* fix up the times so buffy won't get confused */
+       if (st.st_mtime > st.st_atime)
+       {
+         ut.actime = st.st_atime;
+         ut.modtime = time (NULL);
+         utime (buf, &ut); 
+       }
+       else
+         utime (buf, NULL);
+      }
     }
 
     mutt_clear_error ();
index 2cd6b00ec2f5b196a07e63d92a6752192873d5b6..90aa4b6713fc057266c9f77fe3fd25979e99a0bd 100644 (file)
@@ -792,11 +792,6 @@ AC_ARG_ENABLE(nfs-fix, AC_HELP_STRING([--enable-nfs-fix], [Work around an NFS wi
                    incorrectly cache the attributes of small files.])
         fi])
 
-AC_ARG_ENABLE(buffy-size, AC_HELP_STRING([--enable-buffy-size], [Use file size attribute instead of access time]),
-        [if test x$enableval = xyes; then
-                AC_DEFINE(BUFFY_SIZE,1,[ Define to enable the "buffy_size" feature. ])
-        fi])
-
 AC_ARG_ENABLE(mailtool, AC_HELP_STRING([--enable-mailtool], [Enable Sun mailtool attachments support]),
         [if test x$enableval = xyes; then
                 AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
diff --git a/init.h b/init.h
index 3ef28e0e6e21997b772201b2937d82ef39b1afbe..86b0072dfd1685ff9ee1752f708c26d266ef9bcc 100644 (file)
--- a/init.h
+++ b/init.h
@@ -351,6 +351,12 @@ struct option_t MuttVars[] = {
   ** follow these menus.  The option is disabled by default because many 
   ** visual terminals don't permit making the cursor invisible.
   */
+  { "check_mbox_size", DT_BOOL, R_NONE, OPTCHECKMBOXSIZE, 0 },
+  /*
+  ** .pp
+  ** When this variable is set, mutt will use file size attribute instead of
+  ** access time when checking for new mail.
+  */
   { "charset",         DT_STR,  R_NONE, UL &Charset, UL 0 },
   /*
   ** .pp
diff --git a/main.c b/main.c
index 546748311ab558b8668daca99bf1e9498d1cc7fa..bcca8002d173f3f20eb1e185eba2785c37761f1c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -375,11 +375,6 @@ static void show_version (void)
         );
   
   puts (
-#ifdef BUFFY_SIZE
-       "+BUFFY_SIZE "
-#else
-       "-BUFFY_SIZE "
-#endif
 #ifdef EXACT_ADDRESS
        "+EXACT_ADDRESS  "
 #else
diff --git a/mutt.h b/mutt.h
index 05fffa4246c09a19215efe15bc1f5700c0103afb..02df3c485f9a75cfa22ef43d61d8d9b401faa465 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -339,6 +339,7 @@ enum
   OPTBEEPNEW,
   OPTBOUNCEDELIVERED,
   OPTBRAILLEFRIENDLY,
+  OPTCHECKMBOXSIZE,
   OPTCHECKNEW,
   OPTCOLLAPSEUNREAD,
   OPTCONFIRMAPPEND,
diff --git a/mx.c b/mx.c
index 7e8c7a2387d3198daa3ebf0786cb4fdbea95fec9..2c16196f365f4f42f409ff2c8b072160ef128fdc 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -38,9 +38,7 @@
 #include "pop.h"
 #endif
 
-#ifdef BUFFY_SIZE
 #include "buffy.h"
-#endif
 
 #ifdef USE_DOTLOCK
 #include "dotlock.h"
@@ -57,9 +55,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#ifndef BUFFY_SIZE
 #include <utime.h>
-#endif
 
 
 #define mutt_is_spool(s)  (mutt_strcmp (Spoolfile, s) == 0)
@@ -426,9 +422,7 @@ int mx_get_magic (const char *path)
   }
   else if ((f = fopen (path, "r")) != NULL)
   {
-#ifndef BUFFY_SIZE
     struct utimbuf times;
-#endif
 
     fgets (tmp, sizeof (tmp), f);
     if (mutt_strncmp ("From ", tmp, 5) == 0)
@@ -436,15 +430,17 @@ int mx_get_magic (const char *path)
     else if (mutt_strcmp (MMDF_SEP, tmp) == 0)
       magic = M_MMDF;
     safe_fclose (&f);
-#ifndef BUFFY_SIZE
-    /* need to restore the times here, the file was not really accessed,
-     * only the type was accessed.  This is important, because detection
-     * of "new mail" depends on those times set correctly.
-     */
-    times.actime = st.st_atime;
-    times.modtime = st.st_mtime;
-    utime (path, &times);
-#endif
+
+    if (!option(OPTCHECKMBOXSIZE))
+    {
+      /* need to restore the times here, the file was not really accessed,
+       * only the type was accessed.  This is important, because detection
+       * of "new mail" depends on those times set correctly.
+       */
+      times.actime = st.st_atime;
+      times.modtime = st.st_mtime;
+      utime (path, &times);
+    }
   }
   else
   {
@@ -781,9 +777,7 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
 /* save changes to disk */
 static int sync_mailbox (CONTEXT *ctx, int *index_hint)
 {
-#ifdef BUFFY_SIZE
   BUFFY *tmp = NULL;
-#endif
   int rc = -1;
 
   if (!ctx->quiet)
@@ -794,9 +788,8 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint)
     case M_MBOX:
     case M_MMDF:
       rc = mbox_sync_mailbox (ctx, index_hint);
-#ifdef BUFFY_SIZE
-      tmp = mutt_find_mailbox (ctx->path);
-#endif
+      if (option(OPTCHECKMBOXSIZE))
+       tmp = mutt_find_mailbox (ctx->path);
       break;
       
     case M_MH:
@@ -823,10 +816,8 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint)
     mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path);
 #endif
   
-#ifdef BUFFY_SIZE
   if (tmp && tmp->new == 0)
     mutt_update_mailbox (tmp);
-#endif
   return rc;
 }