aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-14 18:39:08 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-07-14 18:39:08 +0000
commitfbcc2c5f075a88eb4c0c305b577220a1e1f8ff4d (patch)
tree2ccbcd48f335161c647be3f2c296cae06aceb671 /coreutils
parent223879b57be61bfb6142e42b6b8da8b334cdb479 (diff)
downloadbusybox-w32-fbcc2c5f075a88eb4c0c305b577220a1e1f8ff4d.tar.gz
busybox-w32-fbcc2c5f075a88eb4c0c305b577220a1e1f8ff4d.tar.bz2
busybox-w32-fbcc2c5f075a88eb4c0c305b577220a1e1f8ff4d.zip
Getopt'ed by Marc Nijdam <marc_nijdam@hp.com>
-Erik git-svn-id: svn://busybox.net/trunk/busybox@860 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/date.c70
-rw-r--r--coreutils/echo.c25
2 files changed, 43 insertions, 52 deletions
diff --git a/coreutils/date.c b/coreutils/date.c
index bc6d13137..3ede1237c 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -159,7 +159,7 @@ int date_main(int argc, char **argv)
159 char *date_str = NULL; 159 char *date_str = NULL;
160 char *date_fmt = NULL; 160 char *date_fmt = NULL;
161 char *t_buff; 161 char *t_buff;
162 int i; 162 char c;
163 int set_time = 0; 163 int set_time = 0;
164 int rfc822 = 0; 164 int rfc822 = 0;
165 int utc = 0; 165 int utc = 0;
@@ -168,49 +168,39 @@ int date_main(int argc, char **argv)
168 struct tm tm_time; 168 struct tm tm_time;
169 169
170 /* Interpret command line args */ 170 /* Interpret command line args */
171 i = --argc; 171 while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
172 argv++; 172 switch (c) {
173 while (i > 0 && **argv) { 173 case 'R':
174 if (**argv == '-') { 174 rfc822 = 1;
175 while (i > 0 && *++(*argv)) 175 break;
176 switch (**argv) { 176 case 's':
177 case 'R': 177 set_time = 1;
178 rfc822 = 1; 178 if ((date_str != NULL) || ((date_str = optarg) == NULL))
179 break;
180 case 's':
181 set_time = 1;
182 if (date_str != NULL)
183 usage(date_usage);
184 date_str = *argv;
185 break;
186 case 'u':
187 utc = 1;
188 if (putenv("TZ=UTC0") != 0)
189 fatalError(memory_exhausted);
190 break;
191 case 'd':
192 use_arg = 1;
193 if (date_str != NULL)
194 usage(date_usage);
195 date_str = *argv;
196 break;
197 case '-':
198 usage(date_usage);
199 }
200 } else {
201 if ((date_fmt == NULL) && (**argv == '+'))
202 date_fmt = *argv + 1; /* Skip over the '+' */
203 else if (date_str == NULL) {
204 set_time = 1;
205 date_str = *argv;
206 } else {
207 usage(date_usage); 179 usage(date_usage);
208 } 180 break;
181 case 'u':
182 utc = 1;
183 if (putenv("TZ=UTC0") != 0)
184 fatalError(memory_exhausted);
185 break;
186 case 'd':
187 use_arg = 1;
188 if ((date_str != NULL) || ((date_str = optarg) == NULL))
189 usage(date_usage);
190 break;
191 default:
192 usage(date_usage);
209 } 193 }
210 i--;
211 argv++;
212 } 194 }
213 195
196 if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
197 date_fmt = &argv[optind][1]; /* Skip over the '+' */
198 else if (date_str == NULL) {
199 set_time = 1;
200 date_str = argv[optind];
201 } else {
202 usage(date_usage);
203 }
214 204
215 /* Now we have parsed all the information except the date format 205 /* Now we have parsed all the information except the date format
216 which depends on whether the clock is being set or read */ 206 which depends on whether the clock is being set or read */
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 6e279d1c6..387ea3fef 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -45,23 +45,24 @@ echo_main(int argc, char** argv)
45 int nflag = 0; 45 int nflag = 0;
46 int eflag = 0; 46 int eflag = 0;
47 47
48 ap = argv; 48
49 if (argc) 49 while ((c = getopt(argc, argv, "neE")) != EOF) {
50 ap++; 50 switch (c) {
51 while ((p = *ap) != NULL && *p == '-') { 51 case 'n':
52 if (strcmp(p, "-n")==0) {
53 nflag = 1; 52 nflag = 1;
54 } else if (strcmp(p, "-e")==0) { 53 break;
54 case 'e':
55 eflag = 1; 55 eflag = 1;
56 } else if (strcmp(p, "-E")==0) { 56 break;
57 case 'E':
57 eflag = 0; 58 eflag = 0;
59 break;
60 default:
61 usage(uname_usage);
58 } 62 }
59 else if (strncmp(p, "--", 2)==0) {
60 usage( uname_usage);
61 }
62 else break;
63 ap++;
64 } 63 }
64
65 ap = &argv[optind];
65 while ((p = *ap++) != NULL) { 66 while ((p = *ap++) != NULL) {
66 while ((c = *p++) != '\0') { 67 while ((c = *p++) != '\0') {
67 if (c == '\\' && eflag) { 68 if (c == '\\' && eflag) {