diff options
author | Jim Meyering <jim@meyering.net> | 2001-08-18 15:43:28 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-08-18 15:43:28 +0000 |
commit | 6eb493e1db3cf188bbea0f42f6b75129c7d06e22 (patch) | |
tree | 4429ae6c7567aad50eccce6ce1ab6388fc6342b3 /src | |
parent | 50f3294545af8652fbc018d519465068de5c1f50 (diff) | |
download | coreutils-6eb493e1db3cf188bbea0f42f6b75129c7d06e22.tar.xz |
Revert part of last change and solve the problem a better way.
(show_date) [--rfc-822]: Set LC_ALL=C just before
calling strftime and restore it just afterwards.
Suggestion from Ulrich Drepper.
Diffstat (limited to 'src')
-rw-r--r-- | src/date.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/date.c b/src/date.c index 3e75899d1..380c749fa 100644 --- a/src/date.c +++ b/src/date.c @@ -488,11 +488,9 @@ show_date (const char *format, time_t when) return; } - if (rfc_format) - setlocale (LC_TIME, "C"); - - do + while (1) { + int done; out_length += 200; out = (char *) xrealloc (out, out_length); @@ -501,8 +499,18 @@ show_date (const char *format, time_t when) would not terminate when date was invoked like this `LANG=de date +%p' on a system with good language support. */ out[0] = '\1'; + + if (rfc_format) + setlocale (LC_ALL, "C"); + + done = (strftime (out, out_length, format, tm) || out[0] == '\0'); + + if (rfc_format) + setlocale (LC_ALL, ""); + + if (done) + break; } - while (strftime (out, out_length, format, tm) == 0 && out[0] != '\0'); printf ("%s\n", out); free (out); |