diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-08 20:59:49 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-08 20:59:49 +0000 |
commit | 6837183d42a0ccdf7b7106794ea693c5b609aea5 (patch) | |
tree | 91d8527c5506aa7089d2077d5646e23999e8da33 /src/ls.c | |
parent | 9391b55213e39616ca5366b0b99c02393c73c9b5 (diff) | |
download | coreutils-6837183d42a0ccdf7b7106794ea693c5b609aea5.tar.xz |
(decode_switches): ls now defaults to --time-style='locale', which in
turn acts like --time-style='posix-long-iso' if the locale settings
are messed up.
Diffstat (limited to 'src/ls.c')
-rw-r--r-- | src/ls.c | 40 |
1 files changed, 24 insertions, 16 deletions
@@ -676,20 +676,20 @@ enum { TIME_STAMP_LEN_MAXIMUM = MAX (1000, INT_STRLEN_BOUND (time_t)) }; static char const *long_time_format[2] = { /* strftime format for non-recent files (older than 6 months), in - -l output when --time-style=locale is specified. This should - contain the year, month and day (at least), in an order that is - understood by people in your locale's territory. - Please try to keep the number of used screen columns small, - because many people work in windows with only 80 columns. But - make this as wide as the other string below, for recent files. */ + -l output. This should contain the year, month and day (at + least), in an order that is understood by people in your + locale's territory. Please try to keep the number of used + screen columns small, because many people work in windows with + only 80 columns. But make this as wide as the other string + below, for recent files. */ N_("%b %e %Y"), - /* strftime format for recent files (younger than 6 months), in - -l output when --time-style=locale is specified. This should - contain the month, day and time (at least), in an order that is - understood by people in your locale's territory. - Please try to keep the number of used screen columns small, - because many people work in windows with only 80 columns. But - make this as wide as the other string above, for non-recent files. */ + /* strftime format for recent files (younger than 6 months), in -l + output. This should contain the month, day and time (at + least), in an order that is understood by people in your + locale's territory. Please try to keep the number of used + screen columns small, because many people work in windows with + only 80 columns. But make this as wide as the other string + above, for non-recent files. */ N_("%b %e %H:%M") }; @@ -1831,7 +1831,7 @@ decode_switches (int argc, char **argv) if (! style) if (! (style = getenv ("TIME_STYLE"))) - style = "posix-long-iso"; + style = "locale"; while (strncmp (style, posix_prefix, sizeof posix_prefix - 1) == 0) { @@ -1867,6 +1867,7 @@ 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; @@ -1878,10 +1879,17 @@ 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++) - long_time_format[i] = - dcgettext (NULL, long_time_format[i], LC_TIME); + { + 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; + } } } } |