diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-13 00:35:21 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-13 00:35:21 +0000 |
| commit | 35a4bbe74f87900dc6014a1871e207709fe40de8 (patch) | |
| tree | 1a2cd4ff4124efd3b617a72b0d22e9b4ffdf2331 /coreutils | |
| parent | 5e2db5e8ee527ef35f3654fdeaac9a9efe7b9eb9 (diff) | |
| download | busybox-w32-35a4bbe74f87900dc6014a1871e207709fe40de8.tar.gz busybox-w32-35a4bbe74f87900dc6014a1871e207709fe40de8.tar.bz2 busybox-w32-35a4bbe74f87900dc6014a1871e207709fe40de8.zip | |
date: -R shouldn't use locale
Diffstat (limited to 'coreutils')
| -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 74e99665d..37ccfd5ba 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
| @@ -32,12 +32,18 @@ | |||
| 32 | #define DATE_OPT_TIMESPEC 0x20 | 32 | #define DATE_OPT_TIMESPEC 0x20 |
| 33 | #define DATE_OPT_HINT 0x40 | 33 | #define DATE_OPT_HINT 0x40 |
| 34 | 34 | ||
| 35 | static void maybe_set_utc(int opt) | 35 | static void xputenv(char *s) |
| 36 | { | 36 | { |
| 37 | if ((opt & DATE_OPT_UTC) && putenv("TZ=UTC0") != 0) | 37 | if (putenv(s) != 0) |
| 38 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 38 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | static void maybe_set_utc(int opt) | ||
| 42 | { | ||
| 43 | if (opt & DATE_OPT_UTC) | ||
| 44 | xputenv("TZ=UTC0"); | ||
| 45 | } | ||
| 46 | |||
| 41 | int date_main(int argc, char **argv) | 47 | int date_main(int argc, char **argv) |
| 42 | { | 48 | { |
| 43 | time_t tm; | 49 | time_t tm; |
| @@ -53,9 +59,9 @@ int date_main(int argc, char **argv) | |||
| 53 | opt_complementary = "?:d--s:s--d" | 59 | opt_complementary = "?:d--s:s--d" |
| 54 | USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); | 60 | USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); |
| 55 | opt = getopt32(argc, argv, "Rs:ud:r:" | 61 | opt = getopt32(argc, argv, "Rs:ud:r:" |
| 56 | USE_FEATURE_DATE_ISOFMT("I::D:"), | 62 | USE_FEATURE_DATE_ISOFMT("I::D:"), |
| 57 | &date_str, &date_str, &filename | 63 | &date_str, &date_str, &filename |
| 58 | USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); | 64 | USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); |
| 59 | maybe_set_utc(opt); | 65 | maybe_set_utc(opt); |
| 60 | 66 | ||
| 61 | if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) { | 67 | if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) { |
| @@ -205,6 +211,8 @@ format_utc: | |||
| 205 | date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; | 211 | date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z'; |
| 206 | } | 212 | } |
| 207 | } else if (opt & DATE_OPT_RFC2822) { | 213 | } else if (opt & DATE_OPT_RFC2822) { |
| 214 | /* Undo busybox.c for date -R */ | ||
| 215 | setlocale(LC_TIME, "C"); | ||
| 208 | strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); | 216 | strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); |
| 209 | i = 22; | 217 | i = 22; |
| 210 | goto format_utc; | 218 | goto format_utc; |
