]> granicus.if.org Git - mutt/commitdiff
Remove the $locale configuration variable.
authorKevin McCarthy <kevin@8t8.us>
Tue, 23 Aug 2016 03:04:52 +0000 (20:04 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 23 Aug 2016 03:04:52 +0000 (20:04 -0700)
$locale was only used to set the LC_TIME locale.  Unfortunately, Mutt
previously defaulted to using "C".  This overrode the user's locale
setting and forced them to re-specify their locale inside their
.muttrc.

Remove $locale and instead use the locale specified by the
environment.  Mutt still allows "C locale" dates by using a leading
"!" in $date_format, ${}, etc.

Another use of $locale was to customize attribution dates using hooks.
The next commit will introduce $attribution_locale, which can be used
for this instead.

Thanks to Derek Martin for the original patch!

browser.c
crypt-gpgme.c
crypt.c
globals.h
hdrline.c
init.h
main.c
pgpkey.c

index 15eccc553d9c4d0ef16c09c0d6521873d925e443..8c2d335921da04feeead7882f598b12bb2712070 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -176,11 +176,12 @@ folder_format_str (char *dest, size_t destlen, size_t col, int cols, char op, co
          tnow = time (NULL);
          t_fmt = tnow - folder->ff->mtime < 31536000 ? "%b %d %H:%M" : "%b %d  %Y";
        }
-       if (do_locales)
-         setlocale(LC_TIME, NONULL (Locale)); /* use environment if $locale is not set */
-       else
-         setlocale(LC_TIME, "C");
-       strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
+
+        if (!do_locales)
+          setlocale (LC_TIME, "C");
+        strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
+        if (!do_locales)
+          setlocale (LC_TIME, "");
 
        mutt_format_s (dest, destlen, fmt, date);
       }
index ff74d6888a33fc9039e20e724f2e1a52c3c6f71d..8b701efd2e17908fb1170cf4577d2b081fe550a6 100644 (file)
@@ -869,13 +869,11 @@ static void print_time(time_t t, STATE *s)
 {
   char p[STRING];
 
-  setlocale (LC_TIME, "");
 #ifdef HAVE_LANGINFO_D_T_FMT
   strftime (p, sizeof (p), nl_langinfo (D_T_FMT), localtime (&t));
 #else
   strftime (p, sizeof (p), "%c", localtime (&t));
 #endif
-  setlocale (LC_TIME, "C");
   state_attach_puts (p, s);
 }
 
@@ -2815,9 +2813,6 @@ static const char *crypt_entry_fmt (char *dest,
        }
        *p = 0;
 
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
-        
         {
          time_t tt = 0;
 
@@ -2826,11 +2821,13 @@ static const char *crypt_entry_fmt (char *dest,
 
           tm = localtime (&tt);
         }
-       strftime (buf2, sizeof (buf2), dest, tm);
 
-       if (do_locales)
-         setlocale (LC_TIME, "C");
-        
+        if (!do_locales)
+          setlocale (LC_TIME, "C");
+        strftime (buf2, sizeof (buf2), dest, tm);
+        if (!do_locales)
+          setlocale (LC_TIME, "");
+
        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
        snprintf (dest, destlen, fmt, buf2);
        if (len > 0)
@@ -3371,9 +3368,6 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
   int i;
   gpgme_user_id_t uid = NULL;
 
-  if (Locale)
-    setlocale (LC_TIME, Locale);
-
   is_pgp = key->protocol == GPGME_PROTOCOL_OpenPGP;
 
   for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
@@ -3613,9 +3607,6 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
           putc ('\n', fp);
         }
     }
-
-  if (Locale)
-    setlocale (LC_TIME, "C");
 }
 
 
diff --git a/crypt.c b/crypt.c
index 7659fdc581cfeaea517125e8a53ef750f3aa00be..c852a31453134af26fe9153623bce93ac23cb3cb 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -64,9 +64,7 @@ void crypt_current_time(STATE *s, char *app_name)
   if (option (OPTCRYPTTIMESTAMP))
   {
     t = time(NULL);
-    setlocale (LC_TIME, "");
     strftime (p, sizeof (p), _(" (current time: %c)"), localtime (&t));
-    setlocale (LC_TIME, "C");
   }
   else
     *p = '\0';
index 95a6869baa03b4a01336947a34a64df1cb773807..27caae74d5c47d76f414b4c63b7f5d616c378dc7 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -66,7 +66,6 @@ WHERE char *ImapUser INITVAL (NULL);
 #endif
 WHERE char *Inbox;
 WHERE char *Ispell;
-WHERE char *Locale;
 WHERE char *MailcapPath;
 WHERE char *Maildir;
 #if defined(USE_IMAP) || defined(USE_POP)
index eef19e6c552cc2c6fad82e09e6e8b7d59ac8fa19..2d44de346d79b5dc14e0a877935178ecb56724ca 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -383,9 +383,6 @@ hdr_format_str (char *dest,
        }
        *p = 0;
 
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
-
        if (op == '[' || op == 'D')
          tm = localtime (&hdr->date_sent);
        else if (op == '(')
@@ -406,10 +403,11 @@ hdr_format_str (char *dest,
          tm = gmtime (&T);
        }
 
-       strftime (buf2, sizeof (buf2), dest, tm);
-
-       if (do_locales)
-         setlocale (LC_TIME, "C");
+        if (!do_locales)
+          setlocale (LC_TIME, "C");
+        strftime (buf2, sizeof (buf2), dest, tm);
+        if (!do_locales)
+          setlocale (LC_TIME, "");
 
        mutt_format_s (dest, destlen, prefix, buf2);
        if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
diff --git a/init.h b/init.h
index 3f3f96d9dd57e3d12e609bd9e3c01f8cc3fd7d93..c0159772ebd58caada57ea7e0df0120c7da98e8c 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1395,12 +1395,6 @@ struct option_t MuttVars[] = {
   ** from your spool mailbox to your $$mbox mailbox, or as a result of
   ** a ``$mbox-hook'' command.
   */
-  { "locale",          DT_STR,  R_BOTH, UL &Locale, UL "C" },
-  /*
-  ** .pp
-  ** The locale used by \fCstrftime(3)\fP to format dates. Legal values are
-  ** the strings your system accepts for the locale environment variable \fC$$$LC_TIME\fP.
-  */
   { "mail_check",      DT_NUM,  R_NONE, UL &BuffyTimeout, 5 },
   /*
   ** .pp
diff --git a/main.c b/main.c
index b6541697f4c9a7a3c14d6862393197798bd82318..68a3601834af737e4f08378a28c816a6e27efab4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -597,15 +597,14 @@ int main (int argc, char **argv)
     exit(1);
   }
 
+  setlocale (LC_ALL, "");
+
 #ifdef ENABLE_NLS
   /* FIXME what about init.c:1439 ? */
-  setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, MUTTLOCALEDIR);
   textdomain (PACKAGE);
 #endif
 
-  setlocale (LC_CTYPE, "");
-
   mutt_error = mutt_nocurses_error;
   mutt_message = mutt_nocurses_error;
   SRAND (time (NULL));
index 46661b7a065d04d2e03e04bdeef2312c2cac2440..36a92ae2c738bb28b65df7f9ccf3f62150f99035 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -195,15 +195,14 @@ static const char *pgp_entry_fmt (char *dest,
        }
        *p = 0;
 
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
 
        tm = localtime (&key->gen_time);
 
-       strftime (buf2, sizeof (buf2), dest, tm);
-
-       if (do_locales)
-         setlocale (LC_TIME, "C");
+        if (!do_locales)
+          setlocale (LC_TIME, "C");
+        strftime (buf2, sizeof (buf2), dest, tm);
+        if (!do_locales)
+          setlocale (LC_TIME, "");
 
        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
        snprintf (dest, destlen, fmt, buf2);