diff options
Diffstat (limited to 'ar.c')
-rw-r--r-- | ar.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -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)); |