as reported in https://bugzilla.redhat.com/show_bug.cgi?id=525134 by
Daniel Qarras, ls -l shows iso long format for en_* locales. This is
caused by
. After that commit ls in locale time style checks if the translation
differs from defaults. If not, it fallbacks to long iso time style
format. However - for english locales is this default time style format
(same as C) expected, so the check for missing translation is wrong. 

Attached patch should fix this, allowing the default timestyle for en_*
locales. However - I guess it would be maybe better to remove the check
for possibly messed translation completely - as the default time-style
(the same as C style) could be in use in more LC_TIME styles and
fallback to C style for locales with missing translation is not that bad
behaviour (imho better than long iso style).

         Ondřej Vašík
From e82f581055af6eadcf3e99ff7aa3f5f3479c7c22 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <ova...@redhat.com>
Date: Fri, 25 Sep 2009 15:20:47 +0200
Subject: [PATCH] ls: do not show long iso time format for en_* locales

* src/ls.c (decode_switches): Do not fallback to long iso time format for
  en_* locales.
  Introduced by commit 6837183d, 11-08-2005 and reported
  in https://bugzilla.redhat.com/show_bug.cgi?id=525134 by Daniel Qarras.
* tests/misc/ls-time: test it
* NEWS: mention it
 NEWS               |    3 +++
 src/ls.c           |    8 ++++++--
 tests/misc/ls-time |    7 +++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 1571c9c..502355a 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   when the color of a more specific type is disabled.
   [bug introduced in coreutils-5.90]
+  ls -l now correctly show locale timestamp of files instead of long iso format
+  [bug introduced in coreutils-6.0]
 ** Portability
   On Solaris 9, many commands would mistakenly treat file/ the same as
diff --git a/src/ls.c b/src/ls.c
index 1bb6873..3a1d2d1 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2027,13 +2027,17 @@ 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 (translation differs from default).  If not,
+                   fall back on long-iso format, unless unchanged
+                   format is expected (for english locales).  */
                 int i;
+                const char *lc_time = setlocale (LC_TIME, NULL);
                 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])
+                    if (lc_time && strncmp(lc_time, "en_", 3) &&
+                        locale_format == long_time_format[i])
                       goto case_long_iso_time_style;
                     long_time_format[i] = locale_format;
diff --git a/tests/misc/ls-time b/tests/misc/ls-time
index abdd429..86868a7 100755
--- a/tests/misc/ls-time
+++ b/tests/misc/ls-time
@@ -123,4 +123,11 @@ EOF
+# The output for english locale should differ from long iso format
+# This failed between 6.0 and 7.7
+LC_ALL=en_US ls -l c >en_output
+ls -l --time-style=long-iso c >liso_output
+compare en_output liso_output && { fail=1;
+ echo "Long format timestamp for en_US locale is same as for long iso." 1>&2; }
 Exit $fail

Attachment: signature.asc
Description: Toto je digitálně podepsaná část zprávy

Reply via email to