aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-02-11 10:57:11 +0000
committerRon Yorston <rmy@pobox.com>2020-02-11 12:03:49 +0000
commitbeba51059500737e6c004d7a8b0d196278115860 (patch)
tree7ebe34e7b41be2787ef8a98625168a1747e77f6b /coreutils
parent649eabaf4d9e7c733471351effce0b80b2ee76b1 (diff)
downloadbusybox-w32-beba51059500737e6c004d7a8b0d196278115860.tar.gz
busybox-w32-beba51059500737e6c004d7a8b0d196278115860.tar.bz2
busybox-w32-beba51059500737e6c004d7a8b0d196278115860.zip
date: code shrink
Since we don't have a working clock_settime(2) there's no point in claiming to support the '-s' option. Saves 96 bytes
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/date.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/coreutils/date.c b/coreutils/date.c
index b9b7fd2cb..37a47eb14 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -98,11 +98,15 @@
98//usage:#define date_full_usage "\n\n" 98//usage:#define date_full_usage "\n\n"
99//usage: "Display time (using +FMT), or set time\n" 99//usage: "Display time (using +FMT), or set time\n"
100//usage: IF_NOT_LONG_OPTS( 100//usage: IF_NOT_LONG_OPTS(
101//usage: IF_NOT_PLATFORM_MINGW32(
101//usage: "\n [-s] TIME Set time to TIME" 102//usage: "\n [-s] TIME Set time to TIME"
103//usage: )
102//usage: "\n -u Work in UTC (don't convert to local time)" 104//usage: "\n -u Work in UTC (don't convert to local time)"
103//usage: "\n -R Output RFC-2822 compliant date string" 105//usage: "\n -R Output RFC-2822 compliant date string"
104//usage: ) IF_LONG_OPTS( 106//usage: ) IF_LONG_OPTS(
107//usage: IF_NOT_PLATFORM_MINGW32(
105//usage: "\n [-s,--set] TIME Set time to TIME" 108//usage: "\n [-s,--set] TIME Set time to TIME"
109//usage: )
106//usage: "\n -u,--utc Work in UTC (don't convert to local time)" 110//usage: "\n -u,--utc Work in UTC (don't convert to local time)"
107//usage: "\n -R,--rfc-2822 Output RFC-2822 compliant date string" 111//usage: "\n -R,--rfc-2822 Output RFC-2822 compliant date string"
108//usage: ) 112//usage: )
@@ -144,19 +148,30 @@
144 148
145enum { 149enum {
146 OPT_RFC2822 = (1 << 0), /* R */ 150 OPT_RFC2822 = (1 << 0), /* R */
151#if !ENABLE_PLATFORM_MINGW32
147 OPT_SET = (1 << 1), /* s */ 152 OPT_SET = (1 << 1), /* s */
148 OPT_UTC = (1 << 2), /* u */ 153 OPT_UTC = (1 << 2), /* u */
149 OPT_DATE = (1 << 3), /* d */ 154 OPT_DATE = (1 << 3), /* d */
150 OPT_REFERENCE = (1 << 4), /* r */ 155 OPT_REFERENCE = (1 << 4), /* r */
151 OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */ 156 OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
152 OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */ 157 OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
158#else
159 OPT_SET = (0), /* s */
160 OPT_UTC = (1 << 1), /* u */
161 OPT_DATE = (1 << 2), /* d */
162 OPT_REFERENCE = (1 << 3), /* r */
163 OPT_TIMESPEC = (1 << 4) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
164 OPT_HINT = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
165#endif
153}; 166};
154 167
155#if ENABLE_LONG_OPTS 168#if ENABLE_LONG_OPTS
156static const char date_longopts[] ALIGN1 = 169static const char date_longopts[] ALIGN1 =
157 "rfc-822\0" No_argument "R" 170 "rfc-822\0" No_argument "R"
158 "rfc-2822\0" No_argument "R" 171 "rfc-2822\0" No_argument "R"
172#if !ENABLE_PLATFORM_MINGW32
159 "set\0" Required_argument "s" 173 "set\0" Required_argument "s"
174#endif
160 "utc\0" No_argument "u" 175 "utc\0" No_argument "u"
161 /* "universal\0" No_argument "u" */ 176 /* "universal\0" No_argument "u" */
162 "date\0" Required_argument "d" 177 "date\0" Required_argument "d"
@@ -192,13 +207,25 @@ int date_main(int argc UNUSED_PARAM, char **argv)
192 char *isofmt_arg = NULL; 207 char *isofmt_arg = NULL;
193 208
194 opt = getopt32long(argv, "^" 209 opt = getopt32long(argv, "^"
210#if !ENABLE_PLATFORM_MINGW32
195 "Rs:ud:r:" 211 "Rs:ud:r:"
212#else
213 "Rud:r:"
214#endif
196 IF_FEATURE_DATE_ISOFMT("I::D:") 215 IF_FEATURE_DATE_ISOFMT("I::D:")
216#if !ENABLE_PLATFORM_MINGW32
197 "\0" 217 "\0"
198 "d--s:s--d" 218 "d--s:s--d"
199 IF_FEATURE_DATE_ISOFMT(":R--I:I--R"), 219 IF_FEATURE_DATE_ISOFMT(":R--I:I--R"),
220#else
221 IF_FEATURE_DATE_ISOFMT("\0R--I:I--R"),
222#endif
200 date_longopts, 223 date_longopts,
224#if !ENABLE_PLATFORM_MINGW32
201 &date_str, &date_str, &filename 225 &date_str, &date_str, &filename
226#else
227 &date_str, &filename
228#endif
202 IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt) 229 IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt)
203 ); 230 );
204 argv += optind; 231 argv += optind;