[PATCH] Refactor rmdir

From: FRIGN <dev_AT_frign.de>
Date: Mon, 9 Jun 2014 21:03:42 +0200

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..4578787 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\n",
-					argv[-1], strerror(errno));
-	}
+					argv[0], strerror(errno));
 
 	return EXIT_SUCCESS;
 }
-- 
1.8.5.5
--Multipart=_Mon__9_Jun_2014_21_09_07_+0200_eP+o+dM6=38V/aH4--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 11 2014 - 01:24:03 CEST