diff options
author | Denis Vlasenko | 2006-12-13 00:35:21 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-12-13 00:35:21 +0000 |
commit | 35a4bbe74f87900dc6014a1871e207709fe40de8 (patch) | |
tree | 1a2cd4ff4124efd3b617a72b0d22e9b4ffdf2331 | |
parent | 5e2db5e8ee527ef35f3654fdeaac9a9efe7b9eb9 (diff) | |
download | busybox-35a4bbe74f87900dc6014a1871e207709fe40de8.zip busybox-35a4bbe74f87900dc6014a1871e207709fe40de8.tar.gz |
date: -R shouldn't use locale
-rw-r--r-- | coreutils/date.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index 74e9966..37ccfd5 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -32,12 +32,18 @@ #define DATE_OPT_TIMESPEC 0x20 #define DATE_OPT_HINT 0x40 -static void maybe_set_utc(int opt) +static void xputenv(char *s) { - if ((opt & DATE_OPT_UTC) && putenv("TZ=UTC0") != 0) + if (putenv(s) != 0) bb_error_msg_and_die(bb_msg_memory_exhausted); } +static void maybe_set_utc(int opt) +{ + if (opt & DATE_OPT_UTC) + xputenv("TZ=UTC0"); +} + int date_main(int argc, char **argv) { time_t tm; @@ -53,9 +59,9 @@ int date_main(int argc, char **argv) opt_complementary = "?:d--s:s--d" USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); opt = getopt32(argc, argv, "Rs:ud:r:" - USE_FEATURE_DATE_ISOFMT("I::D:"), - &date_str, &date_str, &filename - USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); + USE_FEATURE_DATE_ISOFMT("I::D:"), + &date_str, &date_str, &filename + USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); maybe_set_utc(opt); if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) { @@ -205,6 +211,8 @@ format_utc: date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; } } else if (opt & DATE_OPT_RFC2822) { + /* Undo busybox.c for date -R */ + setlocale(LC_TIME, "C"); strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); i = 22; goto format_utc; |