From e82f581055af6eadcf3e99ff7aa3f5f3479c7c22 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= 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 fail=1 fi +# 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 -- 1.5.6.1.156.ge903b