Kevin, I have a patch that I believe does what's needed. It passed all my testing, including running with my default config, setting locale, unsetting locale, adding or removing a ! to the date format in index_format.
Note that: - The default locale is now "" allowing it to be set from OS settings - I removed setlocale() calls from some places it seemed superfluous - Wherever the "!" is relevant, I set locale to C immediately before, and reset it to Locale immediately after. - I ADDED a call to setlocale() before the index is redrawn - I suggested in the manual to not set locale. :) The last I did so that if the user changes locale in the running mutt, the index will be redrawn and "notice" the change. Patch attached. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
diff -ur mutt-1.7.0/browser.c mutt-1.7.0.locale_patch/browser.c
--- mutt-1.7.0/browser.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/browser.c 2016-08-19 15:37:37.136603655 -0400
@@ -176,12 +176,16 @@
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");
+ /* if user doesn't want locales on dates, temporarily disable */
+ if (!do_locales)
+ setlocale(LC_TIME, "C");
+
strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
+ /* Reset locale to whatever user configured, via $locale or the OS */
+ if (!do_locales)
+ setlocale(LC_TIME, NONULL(Locale));
+
mutt_format_s (dest, destlen, fmt, date);
}
else
diff -ur mutt-1.7.0/crypt-gpgme.c mutt-1.7.0.locale_patch/crypt-gpgme.c
--- mutt-1.7.0/crypt-gpgme.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/crypt-gpgme.c 2016-08-19 16:00:42.971473117
-0400
@@ -869,13 +869,11 @@
{
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 @@
}
*p = 0;
- if (do_locales && Locale)
- setlocale (LC_TIME, Locale);
-
{
time_t tt = 0;
@@ -2826,10 +2821,13 @@
tm = localtime (&tt);
}
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+
strftime (buf2, sizeof (buf2), dest, tm);
- if (do_locales)
- setlocale (LC_TIME, "C");
+ if (!do_locales)
+ setlocale (LC_TIME, NONULL(Locale));
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
snprintf (dest, destlen, fmt, buf2);
@@ -3371,9 +3369,6 @@
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 +3608,6 @@
putc ('\n', fp);
}
}
-
- if (Locale)
- setlocale (LC_TIME, "C");
}
diff -ur mutt-1.7.0/crypt.c mutt-1.7.0.locale_patch/crypt.c
--- mutt-1.7.0/crypt.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/crypt.c 2016-08-19 16:02:45.171730698 -0400
@@ -64,9 +64,7 @@
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 -ur mutt-1.7.0/hdrline.c mutt-1.7.0.locale_patch/hdrline.c
--- mutt-1.7.0/hdrline.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/hdrline.c 2016-08-19 16:03:34.923835398 -0400
@@ -383,9 +383,6 @@
}
*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,13 @@
tm = gmtime (&T);
}
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+
strftime (buf2, sizeof (buf2), dest, tm);
- if (do_locales)
- setlocale (LC_TIME, "C");
+ if (!do_locales)
+ setlocale (LC_TIME, Locale);
mutt_format_s (dest, destlen, prefix, buf2);
if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
diff -ur mutt-1.7.0/init.h mutt-1.7.0.locale_patch/init.h
--- mutt-1.7.0/init.h 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/init.h 2016-08-19 16:11:20.928811531 -0400
@@ -1395,11 +1395,13 @@
** 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" },
+ { "locale", DT_STR, R_BOTH, UL &Locale, UL "" },
/*
** .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.
+ ** the strings your system accepts for the locale environment variable
\fC$$$LC_TIME\fP.
+ ** In general, avoid setting this; just set LC_TIME directly in your
+ ** environment instead.
*/
{ "mail_check", DT_NUM, R_NONE, UL &BuffyTimeout, 5 },
/*
diff -ur mutt-1.7.0/main.c mutt-1.7.0.locale_patch/main.c
--- mutt-1.7.0/main.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/main.c 2016-08-19 15:12:53.133585104 -0400
@@ -597,15 +597,14 @@
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 -ur mutt-1.7.0/pgpkey.c mutt-1.7.0.locale_patch/pgpkey.c
--- mutt-1.7.0/pgpkey.c 2016-08-10 21:47:00.000000000 -0400
+++ mutt-1.7.0.locale_patch/pgpkey.c 2016-08-19 16:04:29.731950626 -0400
@@ -195,15 +195,16 @@
}
*p = 0;
- if (do_locales && Locale)
- setlocale (LC_TIME, Locale);
tm = localtime (&key->gen_time);
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+
strftime (buf2, sizeof (buf2), dest, tm);
- if (do_locales)
- setlocale (LC_TIME, "C");
+ if (!do_locales)
+ setlocale (LC_TIME, NONULL(Locale));
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
snprintf (dest, destlen, fmt, buf2);
pgp7vLAhitiST.pgp
Description: PGP signature
