From 8aa15b2be2bd2ab4b76d197a279abf8b9091680a Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Mon, 28 Sep 2009 17:32:15 +0100 Subject: [PATCH] ls: use the POSIX date style when the locale does not specify one Previously we defaulted to "long-iso" format in locales without specific format translations, like the en_* locales for example. This reverts part of commit 6837183d, 08-11-2005, "ls ... acts like --time-style='posix-long-iso' if the locale settings are messed up" * src/ls.c (decode_switches): Only use the ISO format when specified. * NEWS: Mention the change in behavior. Reported by Daniel Qarras at http://bugzilla.redhat.com/525134 --- NEWS | 9 +++++++++ doc/coreutils.texi | 9 ++++----- src/ls.c | 12 ++---------- tests/misc/ls-time | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 3e170c5..2bacb7f 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,15 @@ GNU coreutils NEWS -*- outline -*- ** Changes in behavior + ls -l now uses the traditional three field time style rather than + the wider two field numeric ISO style, in locales where a style has + not been specified. The new approach has nicer behavior in some + locales, including English, which was judged to outweigh the disadvantage + of generating less-predictable and often worse output in poorly-configured + locales where there is an onus to specify appropriate non-default styles. + [The old behavior was introduced in coreutils-6.0 and had been removed + for English only using a different method since coreutils-8.1] + sort -g now uses long doubles for greater range and precision. stat no longer accepts the --context (-Z) option. Initially it was diff --git a/doc/coreutils.texi b/doc/coreutils.texi index f103bd8..5c2bd1a 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -6927,11 +6927,10 @@ is 80. @node Formatting file timestamps @subsection Formatting file timestamps -By default, file timestamps are listed in abbreviated form. Most -locales use a timestamp like @samp{2002-03-30 23:45}. However, the -default @acronym{POSIX} locale uses a date like @samp{Mar 30@ @ 2002} -for non-recent timestamps, and a date-without-year and time like -@samp{Mar 30 23:45} for recent timestamps. +By default, file timestamps are listed in abbreviated form, using +a date like @samp{Mar 30@ @ 2002} for non-recent timestamps, and a +date-without-year and time like @samp{Mar 30 23:45} for recent timestamps. +This format can change depending on the current locale as detailed below. A timestamp is considered to be @dfn{recent} if it is less than six months old, and is not dated in the future. If a timestamp dated diff --git a/src/ls.c b/src/ls.c index ff0ad21..6e3e836 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2032,7 +2032,6 @@ decode_switches (int argc, char **argv) break; case long_iso_time_style: - case_long_iso_time_style: long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; break; @@ -2044,17 +2043,10 @@ decode_switches (int argc, char **argv) case locale_time_style: if (hard_locale (LC_TIME)) { - /* Ensure that the locale has translations for both - formats. If not, fall back on long-iso format. */ int i; 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; - } + long_time_format[i] = + dcgettext (NULL, long_time_format[i], LC_TIME); } } /* Note we leave %5b etc. alone so user widths/flags are honored. */ diff --git a/tests/misc/ls-time b/tests/misc/ls-time index 1d10abb..beea159 100755 --- a/tests/misc/ls-time +++ b/tests/misc/ls-time @@ -122,4 +122,24 @@ EOF fail=1 fi +# This check is ineffective if: +# en_US locale is not on the system. +# The system en_US message catalog has a specific TIME_FMT translation, +# which was inadvertently the case between coreutils 8.1 and 8.5 inclusive. + +if gettext --version >/dev/null 2>&1; then + + default_tf1='%b %e %Y' + en_tf1=$(LC_ALL=en_US gettext coreutils "$default_tf1") + + if test "$default_tf1" = "$en_tf1"; then + LC_ALL=en_US ls -l c >en_output + ls -l --time-style=long-iso c >liso_output + if compare en_output liso_output; then + fail=1 + echo "Long ISO TIME_FMT being used for en_US locale." >&2 + fi + fi +fi + Exit $fail -- 2.7.4