From 8f7bc0db354a20061a409fc72bb1e6d2ff47fff3 Mon Sep 17 00:00:00 2001 From: FRIGN Date: Mon, 9 Jun 2014 21:03:42 +0200 Subject: [PATCH] Refactor rmdir Use arg.h- and pointer-iterator-idioms. --- rmdir.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rmdir.c b/rmdir.c index 5fdaadc..ec0110c 100644 --- a/rmdir.c +++ b/rmdir.c @@ -15,15 +15,18 @@ usage(void) int main(int argc, char *argv[]) { - argv++;; - if(!*argv) + ARGBEGIN { + default: + usage(); + } ARGEND; + + if (argc < 1) usage(); - while(*argv) { - if(rmdir(*argv++) == -1) + for(; argc > 0; argc--, argv++) + if(rmdir(argv[0]) == -1) fprintf(stderr, "rmdir: '%s': %s\n", - argv[-1], strerror(errno)); - } + argv[0], strerror(errno)); return EXIT_SUCCESS; }