[hackers] [sbase] Refactor rmdir || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 10 Jun 2014 12:14:37 +0200

commit 8f7bc0db354a20061a409fc72bb1e6d2ff47fff3
Author: FRIGN <dev_AT_frign.de>
Date: Mon Jun 9 21:03:42 2014 +0200

    Refactor rmdir
    
    Use arg.h- and pointer-iterator-idioms.

diff --git a/rmdir.c b/rmdir.c
index 5fdaadc..ec0110c 100644
--- a/rmdir.c
+++ b/rmdir.c
_AT_@ -15,15 +15,18 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
- argv++;;
- if(!*argv)
+ ARGBEGIN {
+ default:
                 usage();
+ } ARGEND;
 
- while(*argv) {
- if(rmdir(*argv++) == -1)
+ if (argc < 1)
+ usage();
+
+ for(; argc > 0; argc--, argv++)
+ if(rmdir(argv[0]) == -1)
                         fprintf(stderr, "rmdir: '%s': %s
",
- argv[-1], strerror(errno));
- }
+ argv[0], strerror(errno));
 
         return EXIT_SUCCESS;
 }
Received on Tue Jun 10 2014 - 12:14:37 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 10 2014 - 12:24:09 CEST