From d239d2fffcee499da5f3c5b4ddacc9caa258f3b0 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Sun, 6 Apr 2008 11:47:28 -0400 Subject: [PATCH] Use default English time-formats for `en_*' locales src/ls.c: (decode_switches) only goto case_long_iso_time_style from `locale' time-format setting when the untranslated locale is not an `en_*' locale. Signed-off-by: Bo Borgerson --- src/ls.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ls.c b/src/ls.c index e029fe0..e5fbd0d 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1924,16 +1924,30 @@ decode_switches (int argc, char **argv) if (hard_locale (LC_TIME)) { /* Ensure that the locale has translations for both - formats. If not, fall back on long-iso format. */ + formats. If not, fall back on either the default + format for en_* locales or on long-iso format for + non-en_* locales. */ int i; + char *full_cutover[2] = {NULL, NULL}; + char const *lc_time = setlocale (LC_TIME, NULL); + char const *lc_en_prefix = "en_"; + for (i = 0; i < 2; i++) { char const *locale_format = dcgettext (NULL, long_time_format[i], LC_TIME); if (locale_format == long_time_format[i]) - goto case_long_iso_time_style; - long_time_format[i] = locale_format; + break; + full_cutover[i] = (char *) locale_format; + } + if (full_cutover[0] && full_cutover[1]) + { + long_time_format[0] = full_cutover[0]; + long_time_format[1] = full_cutover[1]; } + else if (strncmp (lc_time, lc_en_prefix, + strlen (lc_en_prefix))) + goto case_long_iso_time_style; } } } -- 1.5.2.5