aboutsummaryrefslogtreecommitdiff
path: root/archival/ar.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2000-09-09 13:38:26 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2000-09-09 13:38:26 +0000
commit437bf72785cdd8c9d689c241a94c79f1f71a2354 (patch)
treec9551952cd7d6fe255a6e7f93c3107843eda1130 /archival/ar.c
parent6fb88e73f792ad6dfb1c2c08600972988f223012 (diff)
downloadbusybox-w32-437bf72785cdd8c9d689c241a94c79f1f71a2354.tar.gz
busybox-w32-437bf72785cdd8c9d689c241a94c79f1f71a2354.tar.bz2
busybox-w32-437bf72785cdd8c9d689c241a94c79f1f71a2354.zip
Changed getopt so that options can be grouped together, the source
archive is now assumed to be the first non parameter. This is how GNU ar behaves.
Diffstat (limited to 'archival/ar.c')
-rw-r--r--archival/ar.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/archival/ar.c b/archival/ar.c
index eaa15a516..41750ac7c 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -239,7 +239,7 @@ extern int ar_main(int argc, char **argv)
239 int srcFd=0, dstFd=0; 239 int srcFd=0, dstFd=0;
240 headerL_t *header, *entry, *extractList; 240 headerL_t *header, *entry, *extractList;
241 241
242 while ((opt = getopt(argc, argv, "ovt:p:x:")) != -1) { 242 while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
243 switch (opt) { 243 switch (opt) {
244 case 'o': 244 case 'o':
245 funct = funct | PRESERVE_DATE; 245 funct = funct | PRESERVE_DATE;
@@ -249,31 +249,29 @@ extern int ar_main(int argc, char **argv)
249 break; 249 break;
250 case 't': 250 case 't':
251 funct = funct | DISPLAY; 251 funct = funct | DISPLAY;
252 break;
252 case 'x': 253 case 'x':
253 if (opt=='x') { 254 funct = funct | EXT_TO_FILE;
254 funct = funct | EXT_TO_FILE; 255 break;
255 }
256 case 'p': 256 case 'p':
257 if (opt=='p') { 257 funct = funct | EXT_TO_STDOUT;
258 funct = funct | EXT_TO_STDOUT;
259 }
260 /* following is common to 't','x' and 'p' */
261 if ( (srcFd = open(optarg, O_RDONLY)) < 0) {
262 errorMsg("Cannot read %s\n", optarg);
263 return (FALSE);
264 }
265 break; 258 break;
266 default: 259 default:
267 usage(ar_usage); 260 usage(ar_usage);
268 } 261 }
269 } 262 }
270 263
271 /* check options not just preserve_dates and/or verbose */ 264 /* check the src filename was specified */
272 if (funct < 4) { 265 if (optind == argc) {
273 usage(ar_usage); 266 usage(ar_usage);
274 return(FALSE); 267 return(FALSE);
275 } 268 }
276 269
270 if ( (srcFd = open(argv[optind], O_RDONLY)) < 0) {
271 errorMsg("Cannot read %s\n", optarg);
272 return (FALSE);
273 }
274 optind++;
277 entry = (headerL_t *) malloc(sizeof(headerL_t)); 275 entry = (headerL_t *) malloc(sizeof(headerL_t));
278 header = (headerL_t *) malloc(sizeof(headerL_t)); 276 header = (headerL_t *) malloc(sizeof(headerL_t));
279 extractList = (headerL_t *) malloc(sizeof(headerL_t)); 277 extractList = (headerL_t *) malloc(sizeof(headerL_t));