coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-06 11:57:41
Commit82b2c724c61fe094bbdee4f977b7091e4c58c96b
Parent637e3a15065f82a9bab757cdf6b4fe3f061a89f8

unlink: Use libokv error reporting

Diffstat

M src/unlink.c | 19 ++++++++++---------

1 files changed, 10 insertions, 9 deletions

diff --git a/src/unlink.c b/src/unlink.c
index 8456102..1ba9f5d 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -1,4 +1,4 @@
-// unlink.c, version 1.0.0
+// unlink.c, version 1.0.1
 // OMKOV coreutils implementation of POSIX unlink
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,19 +33,20 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
 #include "optget.h"
 
+#include <error.h>
+
 #include <unistd.h>
 
-#include <errno.h>
 #include <stdio.h>
-#include <string.h>
+
+#define VERSION "1.0.1"
 
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) {
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -53,15 +54,15 @@ int main(int argc, char *argv[]) {
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; int o;
-	while ((o = optget(&opt, argv, 1)) != -1) switch (o) {
+	while ((o = optget(&opt, av, 1)) != -1) switch (o) {
 	case 256: { help(); return 0; }
 	case 257: { version(); return 0; }
 	default: { return 1; }
 	}
 
-	if (argc == 1) { error(1, "%s: missing operand", argv[0]); }
+	if (ac == 1) { error(1, "missing operand"); }
 
-	if (unlink(argv[1])) { error(1, "%s: %s", argv[0], serrno); }
+	if (unlink(av[1])) { error(1, "%s", serr()); }
 
 	return 0;
 }
@@ -76,7 +77,7 @@ static void help(void) {
 }
 
 static void version(void) {
-	puts("OMKOV coreutils unlink, version 1.0.0");
+	puts("OMKOV coreutils unlink, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");