From: Kevin McCarthy Date: Tue, 23 Aug 2016 03:04:52 +0000 (-0700) Subject: Remove the $locale configuration variable. X-Git-Tag: neomutt-20170225~32^2~133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2d2aadbf0f13a76cef3dee517a84ba6cf2fed0b;p=neomutt Remove the $locale configuration variable. $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! --- diff --git a/browser.c b/browser.c index 15eccc553..8c2d33592 100644 --- 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); } diff --git a/crypt-gpgme.c b/crypt-gpgme.c index ff74d6888..8b701efd2 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -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 7659fdc58..c852a3145 100644 --- 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'; diff --git a/globals.h b/globals.h index 95a6869ba..27caae74d 100644 --- 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) diff --git a/hdrline.c b/hdrline.c index eef19e6c5..2d44de346 100644 --- 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 3f3f96d9d..c0159772e 100644 --- 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 b6541697f..68a360183 100644 --- 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)); diff --git a/pgpkey.c b/pgpkey.c index 46661b7a0..36a92ae2c 100644 --- 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);